Camera debugging

This page describes the debugging tools in the camera service for viewing changes in capture request and result values that are sent to and from the camera HAL. The camera service includes the watch and the dumpsys commands. Available on devices running Android 13 or higher, the watch command allows control over when tags are monitored and accessed, live previewing of tag monitoring dumps from open clients, and viewing of cached dumps from closed clients. The dumpsys command allows for accessing debugging information but doesn't provide tag monitoring dumps from closed clients.

watch command

This section describes how to use the watch command and provides examples.

Start monitoring tags

To start monitoring tags, use:

adb shell cmd media.camera watch start -m <tags> [-c <clients>]

Example:

adb shell cmd media.camera watch start \
-m android.control.effectMode,android.control.aeMode \
-c com.google.android.GoogleCamera,com.android.chrome

Arguments:

  • 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).
  • 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.

This command starts tag monitoring in open clients and in any clients that are subsequently opened (until stop is called). After start is called, The camera service caches tag monitoring dumps from clients when the clients close.

Unless start is called, the camera service doesn't monitor tags for any clients, and doesn't cache tag monitoring dumps. If all is passed in the clients parameter, the camera service monitors tags and caches monitoring dumps from all clients.

Dump tag monitoring information

To dump tag monitoring information, use:

adb shell cmd media.camera watch dump

This command dumps the tag monitoring information to standard output and then exits. It prints the cached tag monitoring dumps from clients that have closed since start (or last clear) and the latest tag monitoring dump from open clients.

Sample output:

$ 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
...

Preview tag monitoring information in real time

To preview tag monitoring information in real time, use:

adb shell cmd media.camera watch live [-n refresh_interval_ms]

Example:

adb shell cmd media.camera watch live -n 250

Arguments:

  • refresh_interval_ms: Optional argument. Interval in milliseconds to refresh the information at. Defaults to 1000 if no value is passed.

This command prints tag monitoring information in real time. To exit, press return/enter.

Sample output:

$ 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]

Clear cached dumps

To clear all cached tag monitoring dumps, use:

adb shell cmd media.camera watch clear

This command doesn't stop tag monitoring.

Stop monitoring tags

To stop monitoring tags in all clients and clear all buffers held for caching tag monitoring dumps, use:

adb shell cmd media.camera watch stop

dumpsys command

The dumpsys command provides a host of debugging information from the camera service. The following command captures the entire debugging dump from the camera service:

adb shell dumpsys media.camera

The dumpsys command also allows capturing tag monitoring dumps from open clients. However, dumpsys doesn't provide tag monitoring dumps from closed clients. The following are examples of using dumpsys for tag monitoring:

  • Capture tag monitoring dumps from all open clients:

    adb shell dumpsys media.camera -m 3a | grep -A50 Monitored
    
  • Get live preview of tag monitoring information using the Linux watch command:

    watch -n 1 -c 'adb shell dumpsys media.camera -m 3a | grep -A50 Monitored'