ソフトウェア申請root権限の取得
2876 ワード
rootを申請するツールクラス
// root
RootManager manager=new RootManager();
manager.upgradeRootPermission(getPackageCodePath());
public class RootManager {
/**
* Root , ( ROOT )
*
* @return / Root
*/
public boolean upgradeRootPermission(String pkgCodePath) {
Process process = null;
DataOutputStream os = null;
try {
String cmd="chmod 777 " + pkgCodePath;
process = Runtime.getRuntime().exec("su"); // root
os = new DataOutputStream(process.getOutputStream());
os.writeBytes(cmd + "
");
os.writeBytes("exit
");
os.flush();
process.waitFor();
} catch (Exception e) {
return false;
} finally {
try {
if (os != null) {
os.close();
}
process.destroy();
} catch (Exception e) {
}
}
return true;
}
}