Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run secure API calls as root, android

Tags:

android

root

I'm trying to run some secure (internal) api calls, and I'm obviously getting security exceptions:

java.lang.SecurityException: Permission Denial: not allowed to send broadcast android.provider.Telephony.SPN_STRINGS_UPDATED from pid=24864, uid=10107

I'm trying to run the same call from root, but I'm not sure if it's possible in the first place. I can of course get the root permissions like this:

Process p = Runtime.getRuntime().exec("su");

But it doesn't seem to do the trick. I'm getting the same security exception. One of the samples I've seen tries to wait for the su call to finish first, as follows:

Process p = Runtime.getRuntime().exec("su");
p.waitFor();

but that didn't help me either. What am I doing wrong then? Is it possible to do at all?

If it's important, I'm trying to get an instance of the com.android.internal.telephony.Phone class, using the PhoneFactory (getting them with reflection). Getting reflection out of the way, it would look something like this:

// Initialize the telephony framework
PhoneFactory.makeDefaultPhones(this);
// Get the default phone
Phone phone = PhoneFactory.getDefaultPhone();
like image 958
Artiom Chilaru Avatar asked Sep 05 '26 11:09

Artiom Chilaru


1 Answers

Your application or service needs to be signed with the same key as the core system apps, and request a shared user id with them. If you have a usable su command you are probably running a customized firmware; check with whoever provided it on how to add a new system application.

The su command does not change the identity/permission of the process calling it - what it does is let you launch a child process with elevated permissions. But its not very clear how you could launch an android application that way (possibly by using app_process - but really installing as a system app is the proper way to do it).

Note also that making your app a system app still does not make it run as root.

like image 171
Chris Stratton Avatar answered Sep 08 '26 03:09

Chris Stratton



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!