我正在创建一个应用程序,但现在及时检查根,每次我按下“检查根”按钮时它都会冻结。有任何想法吗?
这是“检查根”代码:
Process p;
try {
// Perform SU to get root privileges
p = Runtime.getRuntime().exec("su");
DataOutputStream os = new DataOutputStream(p.getOutputStream());
os.writeBytes("remount rw");
os.writeBytes("echo Root Test > /system/rootcheck.txt");
os.writeBytes("exit\n");
os.flush();
try {
p.waitFor();
if (p.exitValue() != 255){
//Phone is rooted
Toast.makeText(getApplicationContext(), "Your device is rooted\r\n\r\n(Long Press to know how to get root acess)", 0).show();
break;
}
else {
//Phone is not rooted
Toast.makeText(getApplicationContext(), "Your device is not rooted\r\n\r\n(Long Press to know how to get root acess)", 0).show();
break;
}
} catch (InterruptedException e) {
}
} catch (IOException e) {
}