Dan S
Dan S

Reputation: 23

How do you get an Android hierarchy dump based on display id?

Through adb, I'm trying to determine if there is a way to get a hierarchy dump for a user specified display. currently the following can be done through adb

uiautomator dump

which produces an xml dump of the default screen. I'm assuming screen 0. But I don't see any parameters for uiautomator for specifying the display id. For example, the screencap app allows the "-d" parameter to specify the screen other then the default 0.

screencap -d 1

So, how would I get a hierarchy dump for display id 1?

Upvotes: 2

Views: 3615

Answers (1)

Lino
Lino

Reputation: 6160

Considering that uiautomator dumps the UI of the active window (see source code), one possible workaround might be to programmatically start some app on the specific display in order to set the focus and dump the UI hierarchy:

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

and repeating the same steps against the secondary display you will get the corresponding UI hierarchy:

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

Upvotes: 1

Related Questions