我真的尝试了一切:
现在,假设我以 root 身份重新挂载,因此RW
对文件系统具有权限(Android 版本 2.3.7):
Process process = Runtime.getRuntime().exec("su");
DataOutputStream os = new DataOutputStream(process.getOutputStream());
os.writeBytes("chmod -c 0777 /system/etc/customization/settings/com/android/browser/custom_settings.xml\n");
os.writeBytes("exit\n");
os.flush();
process.waitFor();
或者:
Process process = Runtime.getRuntime().exec("su -c \"/system/etc/customization/settings/com/android/browser/custom_settings.xml\"");
或者:
Class<?> fileUtils = Class.forName("android.os.FileUtils");
Method setPermissions =
fileUtils.getMethod("setPermissions", String.class, int.class, int.class, int.class);
int a = (Integer) setPermissions.invoke(null, "/system/etc/customization/settings/com/android/browser/custom_settings.xml", 0777, -1, -1);
行为是相同的:没有任何反应。而如果我chmod
来自 adb shell 工作正常。如何从我的代码中更改该文件的权限?