Android S:cmd window logging 和 dumpsys window logging 调试WMS功能
$ cmd window logging
Unknown command
Window manager logging options:
start: Start proto logging
stop: Stop proto logging
enable [group...]: Enable proto logging for given groups
disable [group...]: Disable proto logging for given groups
enable-text [group...]: Enable logcat logging for given groups
disable-text [group...]: Disable logcat logging for given groups
Not handled, calling status bar with args: []
$ dumpsys window logging
WINDOW MANAGER LOGGING (dumpsys window logging)
ProtoLog status: Disabled
Enabled log groups:
Proto: TEST_GROUP WM_DEBUG_ADD_REMOVE WM_DEBUG_APP_TRANSITIONS WM_DEBUG_APP_TRANSITIONS_ANIM WM_DEBUG_BOOT WM_DEBUG_CONFIGURATION WM_DEBUG_CONTAINERS WM_DEBUG_DRAW WM_DEBUG_FOCUS WM_DEBUG_FOCUS_LIGHT WM_DEBUG_IME WM_DEBUG_IMMERSIVE WM_DEBUG_KEEP_SCREEN_ON WM_DEBUG_LOCKTASK WM_DEBUG_ORIENTATION WM_DEBUG_RECENTS_ANIMATIONS WM_DEBUG_REMOTE_ANIMATIONS WM_DEBUG_RESIZE WM_DEBUG_SCREEN_ON WM_DEBUG_STARTING_WINDOW WM_DEBUG_STATES WM_DEBUG_SWITCH WM_DEBUG_SYNC_ENGINE WM_DEBUG_TASKS WM_DEBUG_WINDOW_MOVEMENT WM_DEBUG_WINDOW_ORGANIZER WM_DEBUG_WINDOW_TRANSITIONS WM_ERROR WM_SHOW_SURFACE_ALLOC WM_SHOW_TRANSACTIONS
Logcat: WM_DEBUG_FOCUS_LIGHT WM_DEBUG_WINDOW_TRANSITIONS WM_ERROR
Logging definitions loaded: 604
例如:
$ logcat | grep findFocusedWindow // 抓取findFocusedWindow相关的log
在DisplayContent.java中,有如下代码:
ProtoLog.v(WM_DEBUG_FOCUS_LIGHT, "findFocusedWindow: Found new focus @ %s", w);
正常情况下,logcat中不会输出上面的log。
但通过如下命令打开调试log后,在logcat中就会输出上面的log:
$ cmd window logging enable-text WM_DEBUG_FOCUS_LIGHT