ADB-Explorer
ADB-Explorer copied to clipboard
Add support for root access in Android ≥ 12
I am using the latest app on Microsoft Store (v0.8.24121) on Windows 11 24H2 (26100.2605) and tried to enable root access. However the root access cannot be enabled on any of my 3 devices (a Xiaomi phone running CarbonOS (Android 12) and Magisk, a Samsung phone running LineageOS 21 and Magisk, WSA with Magisk).
Root access are shown as "forbidden" for all devices in the app and there was no prompt on any device about granting root access.
On all rooted devices, root access for ADB shell were already granted.
Did you try it in terminal? The app just calls adb root and checks the response
Did you try it in terminal? The app just calls
adb rootand checks the response
This might be the issue. The response says: adbd cannot run as root in production builds
In that case I don't think I can help, and other means of root access are not supported.
Okay. Too bad.
adb root requires insecure adbd, which is phased out in Android from 12.
The workaround I can think of is either using adb shell su -c for all commands that require root, or including an Android app that asks for root privilege then using the app as an interface to do changes on the filesystem. Both methods would require huge works.
You mean adb shell su -c ...? That doesn't sound too complicated to implement, but the problem is that my only rooted device doesn't seem to support it (OnePlus 3T with Android 11).
I'm gonna have to try a rooted emulator, but that might not work, or work differently.
FWIW - I've got a Magisk rooted Android 15 Pixel (& have been using your app for long time, thank you!)
I went to command prompt on my pc with the phone attached to usb, and from cmd.exe prompt did:
adb shell su -c cat /data/adb/modules/hosts/system/etc/hosts
and I get a dump of the adblocker's hosts file, so I think the concept is valid.
I also tried
'adb shell su -c cp /data/adb/modules/hosts/system/etc/hosts /sdcard/' and got a copy of the file on the root of the sdcard
I don't know about linux cp to work over adb, but probably could use a temp file on the sdcard to copy to/from the phone's root with the cp and then push or pull from the sdcard?
FWIW - I've got a Magisk rooted Android 15 Pixel (& have been using your app for long time, thank you!)
I went to command prompt on my pc with the phone attached to usb, and from cmd.exe prompt did:
adb shell su -c cat /data/adb/modules/hosts/system/etc/hostsand I get a dump of the adblocker's hosts file, so I think the concept is valid.
I also tried
'adb shell su -c cp /data/adb/modules/hosts/system/etc/hosts /sdcard/' and got a copy of the file on the root of the sdcard
I don't know about linux cp to work over adb, but probably could use a temp file on the sdcard to copy to/from the phone's root with the cp and then push or pull from the sdcard?
My thought exactly. Commands such as adb shell su -c 'ls /data/app' can enable reading /data partition not available to non-root user. And while pushing file directly to /data or /system won't work without root, pushing a file or folder to a temporary folder in sdcard then use a command adb shell su -c 'mv /storage/emulated/0/.tmp_ADB_Explorer/1.jpg /data/app' shall work.
For @Alex4SSB: I use a rooted Windows Subsystem for Android instance for testing. WSA is based on Android 13 and is relatively new enough for testing. You can download it on https://github.com/MustardChef/WSABuilds if you have Windows 10 19044/19045 or Windows 11.
Thanks! The rooted WSA will help a lot.
Although, this feature is indeed a bit heavy, not sure I will include it in the next version (v0.9)
Here's what you can run with adb:
adb shell
su
magiskpolicy --live 'allow adbd adbd process setcurrent'
magiskpolicy --live 'allow adbd su process dyntransition'
magiskpolicy --live 'permissive { su }'
resetprop ro.secure 0
resetprop ro.adb.secure 0
resetprop ro.force.debuggable 1
resetprop ro.debuggable 1
resetprop service.adb.root 1
resetprop ctl.restart adbd
This one is what ADB Explorer toggles on:
resetprop service.adb.root 1
But it depends on others.
I made a little app for myself 2 years ago but haven't finished it. But, if ADB Explorer is using adb.exe already, then it really just needs to run those commands and it'll work fully, and you can freely browse the root folders.
So ADB Explorer could actually enable root access if it runs those commands itself, and it'd be seamless. But I don't know how it'd work for people not using Magisk yet still need those things set. As it stands, I use my little app to toggle things on/off.
That's what I figured out a couple of years ago using a rooted Pixel 7 on Android 13, I believe. No other major modifications. Still works on my Pixel 9 on Android 16 now. So my phone is the closest to a worst case scenario and it works.
I just tried this on rooted WSA running Android 13, and it works! Did you try to insert all of this into the root args that we created in #181 ?
I haven't tried it yet. I figured it'd just be handy to directly implement it for people wanting quick and easy root access by clicking on the button.
I've just added this, but I had to drop support for your previous feature, #181. Tested on WSA with Android 13.
This will be available soon in a new version with #54.