安卓SU权限:如何使用他们?如何使用、权限、SU

2023-09-05 01:01:59 作者:- 心软是个不治之症 *

还有一种情况在这里,我开发一个Android应用程序,使用Java。我是pretty的熟悉所有这些东西,但现在它的第一次,当我需要用SU权限。我只需要更换(实际上,重命名)系统/应用程序目录中的文件,但它看起来像我不能够在通常的方式执行它(renameTo方法在文件级),它只是返回我假,这意味着有在运行一些错误。

There is a situation here, I'm developing an Android application, using Java. I'm pretty familiar with all this stuff, but now it's the first time when I need to use SU permissions. I just need to replace (actually, rename) the file in system/app directory, but it looks like I'm not able to perform it in a usual way (renameTo method in File class), it just returns me FALSE, which means that there was some error in operation.

所以,任何人可以告诉我怎么用SU?我的测试手机是完全植根与SU 3.0.3.2,需要SU工作完全正常的任何应用程序。

So can anybody tell me how to use SU? My test phone is fully rooted with SU 3.0.3.2, any app that require SU works perfectly fine.

我将使用同样的方法,但添加了一些新的表现?要我以某种方式使用BusyBox的?

Shall I use the same method but with some additions in manifest? Shall I use busybox in some way?

我已经用Google搜索这一点,我无法找到任何有用的信息。而且也没有对官方Android超级用户的网站没有文档。

I already googled for this, and I can't find any useful information. And also, there is no documentation on official Android Superuser website.

在此先感谢!

推荐答案

你可能还需要重新安装为RW因为/系统为只读文件系统。所以,你可能需要调用SU下面类似的命令:

You'll probably also need to remount the filesystem as RW since /system is read-only. So you might need to call SU with a similar command below:

安装 - 或者,重新安装-t YAFFS2的/ dev /块/ mtdblock3 /系统

要执行的命令,你可以尝试两种方法(我已经通知机器人有时一部作品和其他不会)

To execute the command, you can try two ways (I've notice in android sometimes one works and the other won't )

Process p = Runtime.getRuntime().exec(new String[]{"su", "-c", "mount -o r,remount -t yaffs2 /dev/block/mtdblock3 /system"});

或者你也可以做

Or you can do

Process p =  Runtime.getRuntime().exec("su");
p.getOutputStream().write("mount -o r,remount -t yaffs2 /dev/block/mtdblock3 /system".getBytes());
p.getOutputStream().write(<my next command>);