Android: how can execute a chmod on rooted devides

时间秒杀一切 提交于 2019-12-01 00:58:26

You need to get the runtime as the root user first. There is a nice ShellInterface class that you can use from the MarketEnabler source available on Google Code. Though keep in mind this source code is released under the GPL.

Essentially what you need to do is determine where your su command is and create a kind of shell using an input stream and output stream for STDIN and STDOUT. With these you can then push your commands to your "terminal". When you are done all your commands, flush your buffer and then wait for the Runtime to complete. Once it is completed, you can then close your runtime interface.

Then take a look at the file you have tried creating/modifying/etc to see if everything worked properly.

The RootTools library offers simple methods to check for root and issue root commands:

RootTools.isRootAvailable()
List<String> output = RootTools.sendShell(command);

http://code.google.com/p/roottools/

Bao Le I believe you are trying to drop shell commands in an Android App, here (Running Android Native Code in your Android app)are few of many ways to run a command from an app.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!