【问题标题】:How do you get an Android hierarchy dump based on display id?如何根据显示 ID 获取 Android 层次结构转储?
【发布时间】:2021-09-06 01:11:53
【问题描述】:

通过 adb,我试图确定是否有办法为用户指定的显示获取层次结构转储。目前可以通过adb完成以下操作

uiautomator 转储

生成默认屏幕的 xml 转储。我假设屏幕为 0。但我没有看到任何用于指定显示 ID 的 uiautomator 参数。例如,screencap 应用程序允许“-d”参数指定屏幕,而不是默认的 0。

screencap -d 1

那么,如何获得显示 ID 1 的层次结构转储?

【问题讨论】:

  • 也许可以试试adb shell dumpsys window?我知道这不是你要找的东西,但我正在寻找类似的东西,这是我能得到的最接近的东西:stackoverflow.com/q/58209133/8298909

标签: android adb


【解决方案1】:

考虑到uiautomator 转储活动窗口的 UI(请参阅source code),一种可能的解决方法是在特定显示器上以编程方式启动某些应用程序,以便设置焦点并转储 UI 层次结构:

adb shell am start com.google.android.calendar --display 0
adb shell uiautomator dump /sdcard/window_dump0.xml 
adb pull /sdcard/window_dump0.xml

对辅助显示器重复相同的步骤,您将获得相应的 UI 层次结构:

adb shell am start com.google.android.calendar --display 1
adb shell uiautomator dump /sdcard/window_dump1.xml 
adb pull /sdcard/window_dump1.xml

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-02-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多