How to modify AOSP to allow specific apps to get r

2019-01-22 21:15发布

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?

2条回答
Evening l夕情丶
2楼-- · 2019-01-22 21:38

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.

查看更多
Evening l夕情丶
3楼-- · 2019-01-22 21:59

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" },
查看更多
登录 后发表回答