当前位置: 动力学知识库 > 问答 > 编程问答 >

android - System app : can't execute commands (Permission denied)

问题描述:

I have a system app (in the /system/app folder and also signed with the system signature) and I would like to execute some commands.

It works well with adb and superuser rights, but everytime I get a "Permission denied" when I make the call from my application.

This is the kind of command I'm doing :

Runtime.getRuntime().exec("iptables --flush");

Do you know why I have this error ? And how to correct it ?

Thanks !

网友答案:

You need to ask for a SU permissions first from the system.
I would suggest you to use roottools:

RootTools provides rooted developers a standardized set of tools for use in the development of rooted applications. In the end, we will accomplish this by providing developers with robust, easy-to-use libraries that will drastically improve development times as well as promote code reuse. This project is open to any proven developer that feels they have something to contribute. By pitching in together we can streamline our own processes, improve the effectiveness of our apps, learn new techniques, and provide a better experience for our users.

EDIT: Can you please describe the process of signing your APK with the system certificates? Have you edited your AndroidManifest.xml as well?

分享给朋友:
您可能感兴趣的文章:
随机阅读: