自 2025 年 3 月 27 日起,我们建议您使用 android-latest-release
而非 aosp-main
构建 AOSP 并为其做出贡献。如需了解详情,请参阅 AOSP 的变更。
相机调试
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
本页介绍相机服务中的调试工具,用于查看发送到和发送自相机 HAL 的拍摄请求和结果值的变化。相机服务包含 watch
和 dumpsys
命令。watch
命令适用于搭载 Android 13 或更高版本的设备,可让您控制何时监控和访问代码,实时预览来自打开的客户端的代码监控转储以及查看来自关闭的客户端的缓存转储。dumpsys
命令允许访问调试信息,但不提供来自关闭的客户端的代码监控转储。
watch 命令
本部分介绍如何使用 watch
命令并提供了示例。
开始监控代码
如需开始监控代码,请使用以下命令:
adb shell cmd media.camera watch start -m <tags> [-c <clients>]
示例:
adb shell cmd media.camera watch start \
-m android.control.effectMode,android.control.aeMode \
-c com.google.android.GoogleCamera,com.android.chrome
参数:
tags
:要监控的代码的逗号分隔列表。也接受简写形式 3a
,其中 3a
是指与 AF、AE 和 AWB 相关的所有 android.control.*
代码的集合(有关代码的完整列表,请参阅 TagMonitor.cpp
)。
clients
:可选参数。代码受监控的客户端软件包名称的逗号分隔列表。如果未传递任何客户端参数,或客户端列表中出现 all
,则监视所有客户端。
此命令会在打开的客户端中以及随后打开的任何客户端中开始监控代码(直到 stop
被调用为止)。start
被调用后,相机服务会在客户端关闭时缓存来自客户端的代码监控转储。
除非 start
被调用,否则相机服务不会监控任何客户端的代码,也不会缓存代码监控转储。如果在 clients
参数中传递 all
,相机服务会监控所有客户端的代码并缓存监控转储。
转储代码监控信息
如需转储代码监控信息,请使用以下命令:
adb shell cmd media.camera watch dump
此命令会将代码监控信息转储为标准输出,然后退出。它会输出自 start
(或上次 clear
)起关闭的客户端的缓存代码监控转储,以及来自打开的客户端的最新代码监控转储。
示例输出:
$ adb shell cmd media.camera watch dump
Client: com.android.chrome (active)
1:com.android.chrome f0:532642803202286ns: REQ:android.control.aeMode: [ON] output stream ids: 0
1:com.android.chrome f0:532642803202286ns: REQ:android.control.afMode: [CONTINUOUS_PICTURE] output stream ids: 0
..
Client: com.google.android.GoogleCamera (cached)
0:com.google.android.GoogleCamera f0:532601698728552ns: REQ:android.control.aeMode: [ON] output stream ids: 0 3 1 2
0:com.google.android.GoogleCamera f0:532601698728552ns: REQ:android.control.afMode: [CONTINUOUS_PICTURE] output stream ids: 2 1 3 0
0:com.google.android.GoogleCamera f0:532601698728552ns: REQ:android.control.awbMode: [AUTO] output stream ids: 0 3 1 2
...
实时预览代码监控信息
如需实时预览代码监控信息,请使用以下命令:
adb shell cmd media.camera watch live [-n refresh_interval_ms]
示例:
adb shell cmd media.camera watch live -n 250
参数:
refresh_interval_ms
:可选参数。刷新信息的时间间隔(以毫秒为单位)。如果未传递任何值,则默认为 1000。
此命令会实时输出代码监控信息。如需退出,请按回车键/Enter 键。
示例输出:
$ adb shell cmd media.camera watch live
Press return to exit...
0:com.google.android.GoogleCamera f0:533016991302201ns: REQ:android.control.aeMode: [ON] output stream ids: 1 3 0 2
0:com.google.android.GoogleCamera f0:533016991302201ns: REQ:android.control.afMode: [CONTINUOUS_PICTURE] output stream ids: 2 0 3 1
...
0:com.google.android.GoogleCamera f0:533017066793915ns: RES:android.control.aeState: [SEARCHING]
0:com.google.android.GoogleCamera f0:533017066793915ns: 3 RES:android.control.aeState: [SEARCHING]
0:com.google.android.GoogleCamera f0:533017066793915ns: 2 RES:android.control.aeState: [SEARCHING]
0:com.google.android.GoogleCamera f0:533017066793915ns: RES:android.control.afState: [PASSIVE_SCAN]
清除缓存的转储
如需清除所有缓存的代码监控转储,请使用以下命令:
adb shell cmd media.camera watch clear
此命令不会停止代码监控。
如需停止监控所有客户端中的代码并清除为缓存代码监控转储而保留的所有缓冲区,请使用以下命令:
adb shell cmd media.camera watch stop
dumpsys 命令
dumpsys
命令提供相机服务的一系列调试信息。以下命令可通过相机服务捕获整个调试转储:
adb shell dumpsys media.camera
dumpsys
命令还允许从打开的客户端捕获代码监控转储。但是,dumpsys
不提供来自关闭的客户端的代码监控转储。以下是使用 dumpsys
进行代码监控的示例:
本页面上的内容和代码示例受内容许可部分所述许可的限制。Java 和 OpenJDK 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-03-26。
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["没有我需要的信息","missingTheInformationINeed","thumb-down"],["太复杂/步骤太多","tooComplicatedTooManySteps","thumb-down"],["内容需要更新","outOfDate","thumb-down"],["翻译问题","translationIssue","thumb-down"],["示例/代码问题","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-03-26。"],[],[],null,["# Camera debugging\n\nThis page describes the debugging tools in the camera service for viewing\nchanges in capture request and result values that are sent to and from the\ncamera HAL. The camera service includes the `watch` and the `dumpsys` commands.\nAvailable on devices running Android 13 or higher, the\n`watch` command allows control over when tags are monitored and accessed, live\npreviewing of tag monitoring dumps from open clients, and viewing of cached\ndumps from closed clients. The `dumpsys` command allows for accessing debugging\ninformation but doesn't provide tag monitoring dumps from closed clients.\n\nwatch command\n-------------\n\nThis section describes how to use the `watch` command and provides examples.\n\n### Start monitoring tags\n\nTo start monitoring tags, use: \n\n adb shell cmd media.camera watch start -m \u003ctags\u003e [-c \u003cclients\u003e]\n\nExample: \n\n adb shell cmd media.camera watch start \\\n -m android.control.effectMode,android.control.aeMode \\\n -c com.google.android.GoogleCamera,com.android.chrome\n\nArguments:\n\n- `tags`: Comma-separated list of tags to be monitored. Also accepts the shorthand `3a`, where `3a` refers to the set of all `android.control.*` tags related to AF, AE, and AWB (for the full list of tags, see [`TagMonitor.cpp`](https://cs.android.com/android/platform/superproject/+/android-latest-release:frameworks/av/services/camera/libcameraservice/utils/TagMonitor.cpp?q=%22const%20char*%20TagMonitor::k3aTags%22)).\n- `clients`: Optional argument. Comma-separated list of client package names for which tags are monitored. Watches all clients if no client argument is passed, or if `all` is present in the list of clients.\n\nThis command starts tag monitoring in open clients and in any clients\nthat are subsequently opened (until `stop` is called). After `start` is called,\nThe camera service caches tag monitoring dumps from clients when the clients\nclose.\n\nUnless `start` is called, the camera service doesn't monitor tags for any\nclients, and doesn't cache tag monitoring dumps. If `all` is passed in the\n`clients` parameter, the camera service monitors tags and caches monitoring\ndumps from all clients.\n\n### Dump tag monitoring information\n\nTo dump tag monitoring information, use: \n\n adb shell cmd media.camera watch dump\n\nThis command dumps the tag monitoring information to standard output and then\nexits. It prints the cached tag monitoring dumps from clients that have closed\nsince `start` (or last `clear`) and the latest tag monitoring dump from open\nclients.\n\nSample output: \n\n $ adb shell cmd media.camera watch dump\n Client: com.android.chrome (active)\n 1:com.android.chrome f0:532642803202286ns: REQ:android.control.aeMode: [ON] output stream ids: 0\n 1:com.android.chrome f0:532642803202286ns: REQ:android.control.afMode: [CONTINUOUS_PICTURE] output stream ids: 0\n ..\n Client: com.google.android.GoogleCamera (cached)\n 0:com.google.android.GoogleCamera f0:532601698728552ns: REQ:android.control.aeMode: [ON] output stream ids: 0 3 1 2\n 0:com.google.android.GoogleCamera f0:532601698728552ns: REQ:android.control.afMode: [CONTINUOUS_PICTURE] output stream ids: 2 1 3 0\n 0:com.google.android.GoogleCamera f0:532601698728552ns: REQ:android.control.awbMode: [AUTO] output stream ids: 0 3 1 2\n ...\n\n### Preview tag monitoring information in real time\n\nTo preview tag monitoring information in real time, use: \n\n adb shell cmd media.camera watch live [-n refresh_interval_ms]\n\nExample: \n\n adb shell cmd media.camera watch live -n 250\n\nArguments:\n\n- `refresh_interval_ms`: Optional argument. Interval in milliseconds to refresh the information at. Defaults to 1000 if no value is passed.\n\nThis command prints tag monitoring information in real time. To exit, press\n*return* /*enter*.\n\nSample output: \n\n $ adb shell cmd media.camera watch live\n Press return to exit...\n\n 0:com.google.android.GoogleCamera f0:533016991302201ns: REQ:android.control.aeMode: [ON] output stream ids: 1 3 0 2\n 0:com.google.android.GoogleCamera f0:533016991302201ns: REQ:android.control.afMode: [CONTINUOUS_PICTURE] output stream ids: 2 0 3 1\n ...\n 0:com.google.android.GoogleCamera f0:533017066793915ns: RES:android.control.aeState: [SEARCHING]\n 0:com.google.android.GoogleCamera f0:533017066793915ns: 3 RES:android.control.aeState: [SEARCHING]\n 0:com.google.android.GoogleCamera f0:533017066793915ns: 2 RES:android.control.aeState: [SEARCHING]\n 0:com.google.android.GoogleCamera f0:533017066793915ns: RES:android.control.afState: [PASSIVE_SCAN]\n\n### Clear cached dumps\n\nTo clear all cached tag monitoring dumps, use: \n\n adb shell cmd media.camera watch clear\n\nThis command doesn't stop tag monitoring.\n\n### Stop monitoring tags\n\nTo stop monitoring tags in all clients and clear all buffers held for caching\ntag monitoring dumps, use: \n\n adb shell cmd media.camera watch stop\n\ndumpsys command\n---------------\n\nThe `dumpsys` command provides a host of debugging information from the camera\nservice. The following command captures the entire debugging dump from the\ncamera service: \n\n adb shell dumpsys media.camera\n\nThe `dumpsys` command also allows capturing tag monitoring dumps from open\nclients. However, `dumpsys` doesn't provide tag monitoring dumps from closed\nclients. The following are examples of using `dumpsys` for tag monitoring:\n\n- Capture tag monitoring dumps from all open clients:\n\n adb shell dumpsys media.camera -m 3a | grep -A50 Monitored\n\n- Get live preview of tag monitoring information using the Linux\n `watch` command:\n\n watch -n 1 -c 'adb shell dumpsys media.camera -m 3a | grep -A50 Monitored'"]]