I'm working on AOSP. I've successfully added my apk to build. Now I want to give root access to my app. I don't want to provide root access to other apps or to install the Superuser app in my build. I just want to add my app to get root access. How can I achieve that?
I went through the su.c file in path system/extras/su but I'm unable to understand the whole code.
When I went through the code, I think my objective can be achieved if I could modify
su.c to provide root access to my app,compile it and add the binary
to the build. Am I right?
In most versions of Android, that goes like this: Head to Settings, tap Security, scroll down to Unknown Sources and toggle the switch to the on position. Now you can install KingoRoot. Then run the app, tap One Click Root, and cross your fingers. If all goes well, your device should be rooted within about 60 seconds.
You're moving in the right direction. You need to check the sources for su.c
The only problem that you can face is how to run your program as root. To do this you need to set SUID sticky bit for the executable of your application. To do this you need to modify system/core/include/private/android_filesystem_config.h
file (structure android_files[]
), for instance for su program you can see how this bit is set:
{ 06755, AID_ROOT, AID_ROOT, "system/xbin/su" },
ChainFire has written a a guide on su and how to use it for normal apps. If you're intending on working with anything other than your own phone I suggest this is the approach you follow.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With