在shell下将文件cp到/system/xxx下, 除了需要root权限,还需要将/system重新挂载为 rw:
code 如下:
/*
* root权限下,cp文件到 "/system/xxx" 下面
*/
private void cpFile2System() {
// 重新挂载为可读写,然后再cp进去
String cmd = "mount -o remount rw /system";
CommandUtil.getInstance().execute(cmd);
String src = CacheTools.getCacheRootPath();
String filePath = src + "26910.zip";
cmd = "cp " + filePath + " /system/xbin";
CommandUtil.getInstance().execute(cmd);
// cp 完成之后,再次挂载未只读
cmd = "mount -o ro,remount /system";
CommandUtil.getInstance().execute(cmd);
}