When I just run adb shell
, I get shell running from uid=2000(shell) gid=2000(shell)
, without ptrace access to my application.
How to open a shell with the same UID as launched application?
Workaround way using socat:
android.permission.INTERNET
to your application;/data/local/tmp/
. Ensure everybody can start it;Runtime.getRuntime().exec("/data/local/tmp/socat tcp-l:4446,fork,reuseaddr exec:/system/bin/sh,pty,stderr,setsid");
at startup of your Java-based application;adb forward tcp:4446 tcp:4446
socat `tty`,raw,echo=0,opost=1 tcp:127.0.0.1:4446
on host to connect to the shell in your application context.Note that this setup is not secure and should not be left in production app.