0

I have a rooted device, and want to change the chmod permission of an apk(Prueba.apk) that is inside /system/app , so to achieve that I am using the RootTools library with BusyBox. And my code is:

        Command comando = new Command(0, "chmod 777 /system/app/Prueba.apk");
    try {
        RootTools.getShell(true).add(comando);
    } catch (IOException | RootDeniedException | TimeoutException ex) {
        ex.printStackTrace();
    }

But when I check, after running that code with a Root file explorer I see that the chmod permissions for Prueba.apk didn't change.

4

2 回答 2

0

问题是,当我将系统分区挂载为 RW 时,我是这样做的:

        Command comando = new Command(0, "mount -o remount,rw -t yaffs2 /dev/block/mtdblock3 /system/app";
    try {
        RootTools.getShell(true).add(comando);
    } catch (IOException | RootDeniedException | TimeoutException ex) {
        ex.printStackTrace();
    }

但正确的方法是让所有系统分区 RW 而不是只是 /system/app 文件夹,所以我将代码更改为:

        Command comando = new Command(0, "mount -o remount,rw -t yaffs2 /dev/block/mtdblock3 /system";
    try {
        RootTools.getShell(true).add(comando);
    } catch (IOException | RootDeniedException | TimeoutException ex) {
        ex.printStackTrace();
    }

然后我可以完美地执行 chmod 777 命令。

于 2017-06-06T13:08:36.427 回答
0

您应该在运行需要 root 访问权限的代码之前尝试使用。su -c

/system/*是只读的,命令应该由 root 运行,但首先/system需要将分区挂载为可读写。有多种方法可以做到这一点,但对于我的 Nexus 5x,这是可行的:
mount -o rw,remount /system

但是,此方法可能不起作用,因此请尝试其他方式在此处挂载 r/o

于 2017-04-16T15:26:28.443 回答