adb shell 中的 dumpsys 命令调用过程 探究 (16/04/05)

本文探讨了Android中adb shell dumpsys gfxinfo命令的调用过程,从源码层面解析了如何获取和输出应用程序的显示列表操作和缓存信息。通过ActivityManagerService、ApplicationThread和WindowManagerImpl等组件的交互,详细阐述了命令执行的各个环节。
摘要由CSDN通过智能技术生成

《代码里的世界》原理篇

用文字札记描绘自己 android学习之路

转载请保留出处 by Qiao
http://blog.csdn.net/qiaoidea/article/details/72943797

  之前在研究png 和svg在绘制过程中的内存占用和绘制效率对比问题的时候,使用了比较便捷的adb shell 命令 adb shell dumpsys gfxinfo来查看具体数据。由于使用需要,就稍微跟进了一下代码,这里记录下命令行调用输出的详细过程。
  

1.场景举例

  以com.xxx.demo举例,在terminal终端调用 adb shell dumpsys gfxinfo com.xxx.demo,得到的信息大概有两部分:
- Recent DisplayList operations
- Caches
详细日志如下:

•   >adb shell dumpsys com.xxx.demo
•   Applications Graphics Acceleration Info:
•   Uptime: 24363222 Realtime: 26646172
•   
•   ** Graphics info for pid 30503 [com.xxx.demo] **
•   
•   Recent DisplayList operations
•   Save
•   DrawRenderNode
•     DrawRenderNode
•       DrawRect
•     DrawRenderNode
•       Save
•       ClipRect
•       DrawRenderNode
•         DrawRenderNode
•           Save
•           ClipRect
•           DrawPath
•           DrawPath
•           RestoreToCount
•           DrawBitmapRect
•       RestoreToCount
•     DrawRenderNode
•       DrawRenderNode
•         DrawRect
•   RestoreToCount
•   
•   Caches:
•   Current memory usage / total memory usage (bytes):
•     TextureCache            65536 / 50331648
•     LayerCache                  0 / 33554432 (numLayers = 0)
•     Layers total          0 (numLayers = 0)
•     RenderBufferCache           0 /  8388608
•     GradientCache               0 /  3145728
•     PathCache               14850 / 33554432
•     TessellationCache           0 /  1048576
•     TextDropShadowCache         0 /  6291456
•     PatchCache                  0 /   131072
•     FontRenderer 0 A8           0 /        0
•     FontRenderer 0 RGBA         0 /        0
•     FontRenderer 0 total        0 /        0
•   Other:
•     FboCache                    0 /       25
•   Total memory usage:
•     80386 bytes, 0.08 MB
•   
•   Profile data in ms:
•   
•           com.xxx.demo/com.xxx.demo.MainActivity/android.view.ViewRootImpl@3719de6c (visibility=0)
View hierarchy:

  这里从android-4.0.1_r1源码跟进一下dumpsys gfxinfo 的调用过程。
  

源码探究

  首先从入口 \cmds\dumpsys\dumpsys.cpp文件入手。
通过遍历ServiceManager来获取对应参数的Service,并且调用其dump(FileDescriptor fd, PrintWriter pw, String[] args)方法.

int main(int argc, char* const argv[])
{
    //...

     const size_t N = services.size();

        if (N > 1) {
            // first print a list of the current services
            aout << "Currently running services:" << endl;

            for (size_t i=0; i<N; i++) {
                sp<IBinder> service = sm->checkService(services[i]);
                if (service != NULL) {
                    aout << <
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值