当前位置: 首页 > news >正文

【Android】功能丰富的dumpsys activity

在Android中,要查看客户端Binder的连接数,可以通过dumpsys命令结合service参数来获取相关信息。请按照以下步骤进行操作:

  1. 连接到设备的计算机上,打开命令行终端。

  2. 使用adb shell命令进入设备的Shell环境。

  3. 执行以下命令来查看服务的信息:

    Copy

    dumpsys activity services
    ```该命令将列出设备上所有活动的服务信息,包括服务的名称、PID(进程ID)等。
  4. 在输出中找到您感兴趣的服务,并查看其详细信息。通常,客户端Binder连接数会在服务的详细信息中列出。

    例如,如果要查看名为"com.example.myapp.MyService"的服务的客户端Binder连接数,可以使用以下命令:

    Copy

    dumpsys activity services | grep "com.example.myapp.MyService"
    

    这将过滤输出,只显示包含所查找服务名称的行。

    在输出中,您可能会找到类似以下的行:

    Copy

    Client Bindings: [com.example.client1.IBinderConnection] @ 0x12345678 (pid=123, uid=456)
    Client Bindings: [com.example.client2.IBinderConnection] @ 0x87654321 (pid=789, uid=987)
    

    上述行显示了与服务绑定的客户端Binder连接数,每个连接对应一个客户端。通过计数这些行,您可以确定客户端Binder的连接数。

请注意,对于非系统应用程序,您可能只能查看与自己应用程序相关的服务信息。而对于系统级服务,可能需要具有root权限或系统签名才能查看其详细信息。

dumpsys activity 功能查看

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
    allowed-associations: current package association restrictions
    as[sociations]: tracked app associations
    exit-info [PACKAGE_NAME]: historical process exit information
    lmk: stats on low memory killer
    lru: raw LRU process list
    binder-proxies: stats on binder objects and IPCs
    settings: currently applied config settings
    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.
  --proto: output dump in protocol buffer format.
  --dump-dumpable: dump just the DUMPABLE-related state of an activity. Use the --list-dumpables option to list the supported DUMPABLEs
  --list-dumpables: show the available dumpables in an activity

exit-info [PACKAGE_NAME]  可以查看应用退出的时间,原因等信息,

binder-proxies 可以来查看应用中binder proxy情况

dumpsys activity 信息量很大,是非常强大的工具,也是学习了解AMS的一个很好的切入点

http://www.lryc.cn/news/156070.html

相关文章:

  • 亚马逊云科技 云技能孵化营——我的云技能之旅
  • 南大通用数据库-Gbase-8a-学习-38-常规日志(general log)
  • 汽车信息安全导图
  • 【元宇宙】区块链,元宇宙最大化的驱动力
  • $ref属性的介绍与使用
  • Holistic Evaluation of Language Models
  • android 布局 横屏 android横屏适配
  • 北京已收录2023开学了《乡村振兴战略下传统村落文化旅游设计》中国建筑出版传媒许少辉八一新书
  • 【Linux】Ubuntu20.04版本配置pytorch环境2023.09.05【教程】
  • 11 Python的正则表达式
  • 关于工信部发布的app备案以及小程序备案流程
  • 【高等数学基础知识篇】——不定积分
  • python使用鼠标在图片上画框
  • 算法通关村第十五关:青铜-用4KB内存寻找重复元素
  • SQL注入 - 宽字节注入
  • Flink基础
  • javaee spring aop 注解实现
  • Qt应用开发(基础篇)——按钮基类 QAbstractButton
  • 2023年最新的 前端面试题(个人总结)
  • 服务器基本故障排查方法
  • docker从零部署jenkins保姆级教程
  • 什么是 MVVM 模式?
  • WebGL Varing变量的作用和内插过程,及执行Varing时涉及的图形装配、光栅化、颜色插值、片元着色器执行机制等详解
  • 赢在起跑线:战略定位咨询带来的核心价值
  • 【链表OJ 11】复制带随机指针的链表
  • Jenkins自动构建(Gitee)
  • nginx离线安装
  • Oracle Merge Into ORA-00001: unique constaint violated问题
  • javaScript:DOM中的CSS操作
  • 2023最新UI工作室官网个人主页源码/背景音乐/随机壁纸/一言