欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

adb shell dumpsys 命令

程序员文章站 2024-02-29 18:44:40
...

adb shell dumpsys 命令

Tags: adb_shell


dumpsys

adb shell 进入shell 环境执行dumpsys命令
dumpsys Service [cmd]

dumpsys --help
usage: dumpsys
         To dump all services.
or:
       dumpsys [-t TIMEOUT] [--help | -l | --skip SERVICES | SERVICE [ARGS]]
         --help: shows this help
         -l: only list services, do not dump them
         -t TIMEOUT: TIMEOUT to use in seconds instead of default 10 seconds
         --skip SERVICES: dumps all services but SERVICES (comma-separated list)

         SERVICE [ARGS]: dumps only service SERVICE, optionally passing ARGS to it
# 列出当前的所有服务名
dumpsys -l
# 列出当前所有的Service和对应的服务,配合dumpsys命令查看指定Service信息
srevice list

dumpsys activity

# 查看ActivityManagerService相关功能
dumpsys activity -h
dumpsys activity -h
Activity manager dump options:
  [-a] [-c] [-p PACKAGE] [-h] [WHAT] ...
  WHAT may be one of:
    a[ctivities]: activity stack state
    r[recents]: recent activities state
    b[roadcasts] [PACKAGE_NAME] [history [-s]]: broadcast state
    broadcast-stats [PACKAGE_NAME]: aggregated broadcast statistics
    i[ntents] [PACKAGE_NAME]: pending intent state
    p[rocesses] [PACKAGE_NAME]: process state
    o[om]: out of memory management
    perm[issions]: URI permission grant state
    prov[iders] [COMP_SPEC ...]: content provider state
    provider [COMP_SPEC]: provider client-side state
    s[ervices] [COMP_SPEC ...]: service state
    as[sociations]: tracked app associations
    service [COMP_SPEC]: service client-side state
    package [PACKAGE_NAME]: all state related to given package
    all: dump all activities
    top: dump the top activity
  WHAT may also be a COMP_SPEC to dump activities.
  COMP_SPEC may be a component name (com.foo/.myApp),
    a partial substring in a component name, a
    hex object identifier.
  -a: include all available server state.
  -c: include client state.
  -p: limit output to given package.
  --checkin: output checkin format, resetting data.
  --C: output checkin format, not resetting data.

dumpsys activity activities或者dumpsys activity a查看Activity堆栈信息

查看Activity/Task信息

dumpsys activity

查看指定包名当前窗口显示布局结构信息,如果不在当前窗口,则报错

dumpsys activity pkg

查看处于当前栈顶的Window和Activity

adb shell dumpsys window windows | grep -E 'mCurrentFocus'
adb shell dumpsys activity | grep mFocusedActivity

dumpsys meminfo

不指定包,查看内存信息:

dumpsys meminfo

查看指定包的内存信息:

dumpsys meminfo pgk -d

查看是否内存泄漏

adb shell dumpsys meminfo packagename -d
在进入一个界面之前查看一遍Activity和View的数量,在退出这个界面之后再查看一遍Activity和View的数量,对比进入前和进入后Activity和View数量的变化情况,如果有差异,则说明存在内存泄露(在使用命令查看Activity和View的数量之前,记得手动触发GC)。

转载于:https://www.jianshu.com/p/9f9be64379f2