【发布时间】:2013-07-15 03:25:09
【问题描述】:
我正在尝试创建一个需要对 /system 文件夹进行读/写访问的小型应用程序(它正在尝试删除一个文件,并创建一个新文件而不是它)。 我可以使用 adb 重新挂载文件夹而不会出现问题,如果我这样做了,我的应用程序肯定可以正常工作,直到重新启动。
我的设备已植根(带有库存 4.1.2 的 sgs3)。我可以毫无问题地获得 root 访问权限 - 我收到弹出消息,我可以在其中启用它。但在那之后它并没有真正响应命令。
我有这样的事情:
//at this point I get the popup to grant root access
Runtime.getRuntime().exec("su");
//no error messages - not on console, not in logcat
Runtime.getRuntime().exec("mount -w -o remount -t ext4 /dev/block/mmcblk0p9 /system");
//trying to do things in the system folder...
FileWriter fw=new FileWriter(file);
fw.write("a");
fw.close();
//trying to remount the folder as read only only once everything is done
Runtime.getRuntime().exec("mount -r -o remount -t ext4 /dev/block/mmcblk0p9 /system");
如果我从 adb shell 运行相同的重新安装命令,一切都会完美。如果我不运行它,而是尝试依赖应用程序,当我尝试从文件系统写入/删除时,我会收到以下错误消息(抛出 IOException):
open failed: EROFS (read-only file system)
一些附加信息:我正在使用 2.2 SDK,在我的清单文件中有 WRITE_EXTERNAL_STORAGE 权限(虽然我不确定我是否需要它,因为我正在尝试使用内部存储)。
欢迎所有想法。
【问题讨论】: