打開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 + "\n");
os.writeBytes("exit\n");
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 包名