Android的:如何能在扎根devides执行文件模式 [英] Android: how can execute a chmod on rooted devides

查看:129
本文介绍了Android的:如何能在扎根devides执行文件模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我会在我的根的Andr​​oid 2.1设备中执行命令

I would execute a command on my rooted Android 2.1 device

字符串路径=/data/data/com.android.providers.settings/databases/settings.db;   。调用Runtime.getRuntime()EXEC(/系统/斌/ CHMOD -f 777+路径);

String path = "/data/data/com.android.providers.settings/databases/settings.db"; Runtime.getRuntime().exec("/system/bin/chmod -f 777 " + path);

但这个命令不执行任何操作上的目标文件。你知道吗?

But this command does nothing on the targeted file. Any idea?

推荐答案

您需要得到运行时作为根用户至上。还有就是你可以从 MarketEnabler源使用适用于谷歌$ C一个很好的ShellInterface类$ C 。虽然记住这个源$ C ​​$ C是在GPL下发布的。

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.

从本质上讲,你需要做的是确定您的命令,并使用了STDIN和STDOUT输入流和输出流的一种外壳。有了这些,你就可以把你的命令,你的终端。当您完成所有的命令,刷新你的缓冲区,然后等待运行完成。一旦完成,你就可以关闭运行时的界面。

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.

这篇关于Android的:如何能在扎根devides执行文件模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆