打开777权限
public class SystemManager extends Activity {
public static boolean RootCommand(String command){
Process process = null;
DataOutputStream os = null;
try{
process = Runtime.getRuntime().exec("su");
os = new DataOutputStream(process.getOutputStream());
os.writeBytes(command + "
");
os.writeBytes("exit
");
os.flush();
process.waitFor();
} catch (Exception e){
return false;
} finally{
if (os != null){
try {
os.close();
}catch (IOException e){
e.printStackTrace();
}
}
if(process!=null) {
process.destroy();
}
}
return true;
}
}
String apkRoot="chmod 777 "+getPackageCodePath();
SystemManager.RootCommand(apkRoot);
常用adb命令
//打开文件夹
adb shell cd path1
//打开文件
adb shell cat path1
//重命名文件
adb shell rename path1 path2
//删除文件或文件夹
adb shell rm path1
//移动文件
adb shell mv path1 path2
//拷贝文件
adb shell cp path1
//创建目录
adb shell mkdir path1
//将system分区重新挂在为可读写分区
adb remount
//启动adb服务
adb start-server
//终止adb服务
adb kill-server
//查看连接的设备
adb devices
//查看设备分辨率
adb shell wm size
//查看所有包名和apk名字
adb shell pm list packages -f
//安装apk -r覆盖安装 -s安装到SD卡
adb install path1+test.apk -r
//卸载apk
adb uninstall 包名