开发者

Run secure API calls as root, android

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

java.lang.SecurityException: Permission Denial: not allowe开发者_运维知识库d 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();


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜