aosp中关于winscope记录

文章目录

winscope在机器中的路径为/data/misc/wmtrace,关于截图如下所示

这里重点关注下wm_trace.winscope和layers_trace.winscope。
针对生成的文件的加载需要使用源码路径为

bash 复制代码
prebuilts/misc/common/winscope/winscope.html

wm_trace.winscope

抓取的是window信息

java 复制代码
		private IWindowManager mWindowManager;
		mWindowManager = WindowManagerGlobal.getWindowManagerService();
		// 调用方法 isEnabled true->startWindowTrace,false->stopWindowTrace
        private void setWindowTraceEnabled(boolean isEnabled) {
            try {
                if (isEnabled) {
                    mWindowManager.startWindowTrace();
                } else {
                    mWindowManager.stopWindowTrace();
                }
            } catch (RemoteException e) {
                Log.e(TAG, "Could not set window trace status." + e.toString());
            }
        }

layers_trace.winscope

抓取的是SurfaceFlinger信息

java 复制代码
        @VisibleForTesting
        static final int SURFACE_FLINGER_LAYER_TRACE_CONTROL_CODE = 1025;
        private IBinder mSurfaceFlinger;
        private void setLayerTraceEnabled(boolean isEnabled) {
            Parcel data = null;
            try {
                if (mSurfaceFlinger != null) {
                    data = Parcel.obtain();
                    data.writeInterfaceToken("android.ui.ISurfaceComposer");
                    data.writeInt(isEnabled ? 1 : 0);
                    mSurfaceFlinger.transact(SURFACE_FLINGER_LAYER_TRACE_CONTROL_CODE,
                            data, null, 0 /* flags */);
                }
            } catch (RemoteException e) {
                Log.e(TAG, "Could not set layer tracing." + e.toString());
            } finally {
                if (data != null) {
                    data.recycle();
                }
            }
        }

adb 命令抓取

bash 复制代码
# 开始抓取
adb shell su root service call SurfaceFlinger 1025 i32 1
# 结束抓取
adb shell su root service call SurfaceFlinger 1025 i32 0
相关推荐
千里马学框架5 个月前
google官方文档:深入剖析ProtoLog原理及Winscope的查看方式
android·车载系统·framework·perfetto·系统开发·winscope
千里马学框架7 个月前
windows系统上aosp15上winscope离线html如何使用?
android·windows·html·framework·安卓窗口系统·winscope