Does anyone know how to use uiautomator within android appsupport?

I want to get the ui tree xml of an app running inside appsupport by using uiautomator. I got into the appsupport shell as root by using the command

[root@Xperia10V android_storage]# appsupport-attach
:/# id
uid=0(root) gid=0(root) groups=0(root)

When I execute the following command

:/# uiautomator dump                                                                                                                                                            
:/# echo $?
0

It shows it executed successfully but when I look in the standard dump folder /data/local/window_dump.xml there is nothing. On waydroid it shows a message too that the window has been succesfully dumped.

So I tried to find a way of logging in as a shell user like how it’s done with waydroid over adb because it doesn’t work as a root user on waydroid.

After finding the running container name of appsupport with this command.

[root@Xperia10V android_storage]# lxc-ls --lxcpath=$(appsupport-config --lxc-path) --line --running
defaultuser

I was then able to login as user id 2000 (shell) with this command.

[root@Xperia10V android_storage]# lxc-attach -n defaultuser --lxcpath=$(appsupport-config --lxc-path) -u 2000 -g 2000 
[\u@\h \W]$ id
uid=2000(shell) gid=2000(shell) groups=2000(shell)

And then I tried to dump the UI again without any result. Did anyone try this before and maybe knows what is going wrong here?

Found a different way of executing uiautomator from my host PC. I got access to the android appsupport instance over adb. If you want to be able to connect to the android instance over adb you have to enter the following command to open the global android settings.

[defaultuser@Xperia10V ~]$ devel-su -p apkd-launcher com.android.settings
Password: 
Launching Android Intent android.intent.action.MAIN com.android.settings as android.intent.category.LAUNCHER

Then go to About Phone → Build Number, tap the Build Number seven times and you’ll see an on-screen countdown indicating how many more taps are needed. You’ll see a confirmation message when Developer options are enabled. Now go back to the settings menu and go to System there you’ll find a new menu entry called Developer Options where you can enable USB-debugging and Wireless Debugging. Now you can connect with adb from your host computer by the following command.

adb connect <phone-ip>:5555
adb devices
List of devices attached
<phone-ip>:5555       device

Now you can dump the ui tree from adb with uiautomator and retreive the xml.

❯ adb shell uiautomator dump
UI hierchary dumped to: /sdcard/window_dump.xml
❯ adb pull /sdcard/window_dump.xml
/sdcard/window_dump.xml: 1 file pulled, 0 skipped. 4.9 MB/s (22584 bytes in 0.004s)

Now I just have to figure out how to install adb on my phone to connect to the android instance. The system is aarch64 I can’t find a working adb binary for it yet.

1 Like

Perhaps one way would be to un-remove adb from the official package?

Presumably it is removed for a reason, but no idea what that is - so it can be more or less annoying.