dumpsys的使用

前端之家收集整理的这篇文章主要介绍了dumpsys的使用前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

转自:http://blog.csdn.net/androiddevelop/article/details/37689339

Android提供的dumpsys工具可以用于查看感兴趣的系统服务信息与状态,手机连接电脑后可以直接命令行执行adb shell dumpsys 查看所有支持的Service但是这样输出的太多,可以通过dumpsys | grep "DUMP OF SERVICE" 仅显示主要的Service的信息

一、列出dumpsys所有支持命令

  1. >adbshell
  2. $dumpsys|grep"DUMPOFSERVICE"

以下是在我个人三星S3手机上的输出信息

copy
C:\Windows\System32>adbshell
  • shell@m:/$dumpsys|grep"DUMPOFSERVICE"
  • dumpsys|grep"DUMPOFSERVICE"
  • DUMPOFSERVICEAtCmdFwd:
  • DUMPOFSERVICECustomFrequencyManagerService:
  • DUMPOFSERVICEDirEncryptService:
  • DUMPOFSERVICEExynos.HWCService:
  • DUMPOFSERVICEExynos.IPService:
  • DUMPOFSERVICEFMPlayer:
  • DUMPOFSERVICELEDService:
  • DUMPOFSERVICESecTVOutService:
  • DUMPOFSERVICESurfaceFlinger:
  • DUMPOFSERVICETvoutService_C:
  • DUMPOFSERVICEaccessibility:
  • DUMPOFSERVICEaccount:
  • DUMPOFSERVICEactivity:
  • DUMPOFSERVICEalarm:
  • DUMPOFSERVICEandroid.security.keystore:
  • DUMPOFSERVICEapplication_policy:
  • DUMPOFSERVICEappops:
  • DUMPOFSERVICEappwidget:
  • DUMPOFSERVICEaudio:
  • DUMPOFSERVICEbackup:
  • DUMPOFSERVICEbattery:
  • DUMPOFSERVICEbatteryinfo:
  • DUMPOFSERVICEbluetooth_manager:
  • DUMPOFSERVICEbluetooth_secure_mode_manager:
  • DUMPOFSERVICEclipboard:
  • DUMPOFSERVICEclipboardEx:
  • DUMPOFSERVICEcommontime_management:
  • DUMPOFSERVICEconnectivity:
  • DUMPOFSERVICEcontainer_service:
  • DUMPOFSERVICEcontent:
  • DUMPOFSERVICEcountry_detector:
  • DUMPOFSERVICEcpuinfo:
  • DUMPOFSERVICEdbinfo:
  • DUMPOFSERVICEdevice_policy:
  • DUMPOFSERVICEdevicestoragemonitor:
  • DUMPOFSERVICEdiskstats:
  • DUMPOFSERVICEdisplay:
  • DUMPOFSERVICEdreams:
  • DUMPOFSERVICEdrm.drmManager:
  • DUMPOFSERVICEdropbox:
  • DUMPOFSERVICEedmnativehelper:
  • DUMPOFSERVICEenterprise_license_policy:
  • DUMPOFSERVICEenterprise_policy:
  • DUMPOFSERVICEentropy:
  • DUMPOFSERVICEgfxinfo:
  • DUMPOFSERVICEhardware:
  • DUMPOFSERVICEharmony_eas_service:
  • DUMPOFSERVICEinput:
  • DUMPOFSERVICEinput_method:
  • DUMPOFSERVICEiphonesubinfo:
  • DUMPOFSERVICEisms:
  • DUMPOFSERVICElicense_log_service:
  • DUMPOFSERVICElocation:
  • DUMPOFSERVICElock_settings:
  • DUMPOFSERVICElog_manager_service:
  • DUMPOFSERVICEmdm.remotedesktop:
  • DUMPOFSERVICEmedia.audio_flinger:
  • DUMPOFSERVICEmedia.audio_policy:
  • DUMPOFSERVICEmedia.camera:
  • DUMPOFSERVICEmedia.player:
  • DUMPOFSERVICEmeminfo:
  • DUMPOFSERVICEmotion_recognition:
  • DUMPOFSERVICEmount:
  • DUMPOFSERVICEmultiwindow:
  • DUMPOFSERVICEnetpolicy:
  • DUMPOFSERVICEnetstats:
  • DUMPOFSERVICEnetwork_management:
  • DUMPOFSERVICEnfc:
  • DUMPOFSERVICEnfccontroller:
  • DUMPOFSERVICEnotification:
  • DUMPOFSERVICEpackage:
  • DUMPOFSERVICEpermission:
  • DUMPOFSERVICEphone:
  • DUMPOFSERVICEphone_restriction_policy:
  • DUMPOFSERVICEphoneext:
  • DUMPOFSERVICEpower:
  • DUMPOFSERVICEremoteinjection:
  • DUMPOFSERVICEsamplingprofiler:
  • DUMPOFSERVICEsamsung.smartfaceservice:
  • DUMPOFSERVICEscheduling_policy:
  • DUMPOFSERVICEsearch:
  • DUMPOFSERVICEsec_analytics:
  • DUMPOFSERVICEsecontroller:
  • DUMPOFSERVICEsensorservice:
  • DUMPOFSERVICEserial:
  • DUMPOFSERVICEservicediscovery:
  • DUMPOFSERVICEsimphonebook:
  • DUMPOFSERVICEsip:
  • DUMPOFSERVICEstatusbar:
  • DUMPOFSERVICEtelephony.registry:
  • DUMPOFSERVICEtextservices:
  • DUMPOFSERVICEtvoutservice:
  • DUMPOFSERVICEuimode:
  • DUMPOFSERVICEupdatelock:
  • DUMPOFSERVICEusagestats:
  • DUMPOFSERVICEusb:
  • DUMPOFSERVICEuser:
  • DUMPOFSERVICEvibrator:
  • DUMPOFSERVICEvoip:
  • DUMPOFSERVICEwallpaper:
  • DUMPOFSERVICEwfd:
  • DUMPOFSERVICEwifi:
  • DUMPOFSERVICEwifi_policy:
  • DUMPOFSERVICEwifip2p:
  • DUMPOFSERVICEwindow:

  • 二、具体命令如何查看帮助

    从上面可以看出Service非常多,“DUMP OF SERVICE”关键字后面的单词都可以直接通过 dumpsys + 单词 查看相关信息,具体每一个如何使用有一种通用的查看帮助的办法。

    查看每一个命令的使用帮助,以下以meminfo 为例演示:

    三、一些关键命令解释


    名字 功能
    account 显示accounts信息
    activity 显示所有的activities的信息
    cpuinfo 显示cpu信息
    window 显示键盘,窗口和它们的关系
    wifi 显示wifi信息
    batteryinfo $package_name 电量信息及cpu 使用时长
    package packagename 获取安装包信息
    usagestats 每个界面启动的时间
    statusbar 显示状态栏相关的信息
    meminfo
    内存信息(meminfo $package_name or $pid
    使用程序的包名或者进程id显示内存信息)
    diskstats 磁盘相关信息
    battery 电池信息
    alarm 显示Alarm信息

    dumpsys statusbar | grep notification=Notification




    四、参考资料

    Dumpsys(官方文档)
    How to discover memory usage of my application in Android
    @L_301_14@(代码分析)



    更多优化相关的文章详见:《 Android 基础学习文章汇总 》 第三部分 性能优化

    猜你在找的Bash相关文章