小驰私房菜 | Dump Camera framework层jpeg

文摘   2024-11-12 07:31   广东  

对于dumpsys media.camera 这个命令,我们估计会比较熟悉也用的比较多。今天来看下同样是和media.camera相关的,adb shell cmd media.camera

这个命令的实现是在framework层CameraService.cpp里面实现的。利用这个命令,比较实用的一点就是,可以在framework层dump到拍照生成的jpeg文件。当然,还有其它一些功能。

一、使用:adb shell cmd media.camera

//查看命令帮助adb shell cmd media.camera help
//dump 拍照jpeg,同时需要setenforce 0,jpeg文件保存在/data/misc/cameraserver 下。adb shell cmd media.camera set-image-dump-mask 1

二、对应的代码逻辑

----- CameraService.cpp
status_t CameraService::printHelp(int out) { return dprintf(out, "Camera service commands:\n" " get-uid-state <PACKAGE> [--user USER_ID] gets the uid state\n" " set-uid-state <PACKAGE> <active|idle> [--user USER_ID] overrides the uid state\n" " reset-uid-state <PACKAGE> [--user USER_ID] clears the uid state override\n" " set-rotate-and-crop <ROTATION> overrides the rotate-and-crop value for AUTO backcompat\n" " Valid values 0=0 deg, 1=90 deg, 2=180 deg, 3=270 deg, 4=No override\n" " get-rotate-and-crop returns the current override rotate-and-crop value\n" " set-image-dump-mask <MASK> specifies the formats to be saved to disk\n" " Valid values 0=OFF, 1=ON for JPEG\n" " get-image-dump-mask returns the current image-dump-mask value\n" " set-camera-mute <0/1> enable or disable camera muting\n" " help print this message\n");}

status_t CameraService::shellCommand(int in, int out, int err, const Vector<String16>& args) {    if (!checkCallingPermission(sManageCameraPermission, nullptr, nullptr)) {        return PERMISSION_DENIED;    }    if (in == BAD_TYPE || out == BAD_TYPE || err == BAD_TYPE) {        return BAD_VALUE;    }    if (args.size() >= 3 && args[0] == String16("set-uid-state")) {        return handleSetUidState(args, err);    } else if (args.size() >= 2 && args[0] == String16("reset-uid-state")) {        return handleResetUidState(args, err);    } else if (args.size() >= 2 && args[0] == String16("get-uid-state")) {        return handleGetUidState(args, out, err);    } else if (args.size() >= 2 && args[0] == String16("set-rotate-and-crop")) {        return handleSetRotateAndCrop(args);    } else if (args.size() >= 1 && args[0] == String16("get-rotate-and-crop")) {        return handleGetRotateAndCrop(out);    } else if (args.size() >= 2 && args[0] == String16("set-image-dump-mask")) {        return handleSetImageDumpMask(args);    } else if (args.size() >= 1 && args[0] == String16("get-image-dump-mask")) {        return handleGetImageDumpMask(out);    } else if (args.size() >= 2 && args[0] == String16("set-camera-mute")) {        return handleSetCameraMute(args);    } else if (args.size() == 1 && args[0] == String16("help")) {        printHelp(out);        return NO_ERROR;    }



《Android Camera开发入门》、《Camx初认识》已经上架,可以点击了解 -> 小驰成长圈 |期待见证彼此的成长 



觉得不错,点个赞呗 

小驰行动派
前世界500强软件开发工程师,记录分享工作和生活的思考。感谢关注,期待见证彼此的成长~
 最新文章