背景:
有学员朋友在群里询问WMShell相关的Proto日志该如何打印相关疑问,这里其实在aosp13时候是有分享过的
https://blog.csdn.net/learnframework/article/details/129474650
aosp13时候:
test@test:~/aosp/frameworks$ adb shell wm logging enable-text WM_SHELL_STARTING_WINDOW
Loaded 705 log definitions from /system/etc/protolog.conf.json.gz
No IProtoLogGroup named WM_SHELL_STARTING_WINDOW
Not handled, calling status bar with args: [enable-text, WM_SHELL_STARTING_WINDOW]
Starting logging on groups: [WM_SHELL_STARTING_WINDOW]
那时候直接调用wm即wms的下面的proto开启方式,虽然提示Not handled, calling status bar with args,但是依旧wms会跨进程调用到了systemui进程帮我们把proto打开。
但是在aosp14版本上一样方式执行显示如下:
test@test:~/disk2/aosp14/frameworks/base$ adb shell wm logging enable-text WM_SHELL_STARTING_WINDOW
Loaded 753 log definitions from /system/etc/protolog.conf.json.gz
No IProtoLogGroup named WM_SHELL_STARTING_WINDOW
Not handled, please use `adb shell dumpsys activity service SystemUIService WMShell` if you are looking for ProtoLog in WMShell
这里明显看到没有帮我们开启相关的proto,让用adb shell dumpsys activity service SystemUIService WMShell命令去开启。
aosp14代码:
frameworks/base/services/core/java/com/android/server/wm/WindowManagerShellCommand.java
可以看出来,这里wms没有帮我们跨进程让systemui干了,只是用了一下相关的提示命令。
具体实战验证剖析
这里可以先使用一下WMShell的help命令
test@test:~/disk2/aosp14/frameworks/base$ adb shell dumpsys activity service SystemUIService WMShell help
SERVICE com.android.systemui/.SystemUIService b7c03e4 pid=2600 user=0
Client:
Dump starting: 07-02 11:06:20.225
com.android.systemui.wmshell.WMShell:
----------------------------------------------------------------------------
Window Manager Shell commands:
compatui
restartDialogEnabled [0|false|1|true]
Enable/Disable the restart education dialog for Size Compat Mode
reachabilityEducationEnabled [0|false|1|true]
Enable/Disable the restart education dialog for letterbox reachability
Disable the restart education dialog for letterbox reachability
protolog
status
Get current ProtoLog status.
start
Start proto logging.
stop
Stop proto logging and flush to file.
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.
save-for-bugreport
Flush proto logging to file, only if it's enabled.
splitscreen
moveToSideStage <taskId> <SideStagePosition>
Move a task with given id in split-screen mode.
removeFromSideStage <taskId>
Remove a task with given id in split-screen mode.
setSideStagePosition <SideStagePosition>
Sets the position of the side-stage.
transitions
tracing
start
Start tracing the transitions.
stop
Stop tracing the transitions.
save-for-bugreport
Flush in memory transition trace to file.
help
Print this help text.
<no arguments provided>
Dump all Window Manager Shell internal state
NORMAL dump took 0ms -- com.android.systemui.wmshell.WMShell
Dump took 1ms
这里重点关注protolog相关的输出,发现也是和wm的proto没有区别。
看看分屏相关的Proto日志:
体验一下开启:
adb shell dumpsys activity service SystemUIService WMShell protolog enable-text WM_SHELL_SPLIT_SCREEN
然后操作进入投屏再看看日志:
test@test:~/disk2/aosp14/frameworks/base$ adb logcat -c;adb logcat -s ShellSplitScreen
07-02 11:35:00.137 2600 2636 D ShellSplitScreen: Request to show divider bar from com.android.wm.shell.splitscreen.SplitScreenController.onKeyguardVisibilityChanged:15.
07-02 11:35:01.440 2600 2636 D ShellSplitScreen: Set divider bar non-interactive from onSplitResizeStart
07-02 11:35:01.735 2600 2636 D ShellSplitScreen: Set divider bar interactive from onSplitResizeFinish
可以看到有相关ShellSplitScreen的打印,注意这里的ShellSplitScreen是源码中看出来的,每个可能不一样
代码路径:
frameworks/base/libs/WindowManager/Shell/src/com/android/wm/shell/protolog/ShellProtoLogGroup.java
可以去这个代码里面查验自己的TAG,这里是Consts.TAG_WM_SPLIT_SCREEN
所以tag就是ShellSplitScreen。
总结
针对WMShell包下面的Proto日志,在高版本aosp14统一只能使用
adb shell dumpsys activity service SystemUIService WMShell protolog enable-text XXXX
方式来开启,而且相关logcat过滤的TAG需要去看看
frameworks/base/libs/WindowManager/Shell/src/com/android/wm/shell/protolog/ShellProtoLogGroup.java
具体对应TAG是啥。
本文章更多详细代码和资料需要购买课程获取
hal+perfetto+surfaceflinger
https://mp.weixin.qq.com/s/LbVLnu1udqExHVKxd74ILg
其他课程七件套专题:
点击这里
https://mp.weixin.qq.com/s/Qv8zjgQ0CkalKmvi8tMGaw