我正在创建一个应用程序,但现在及时检查root,它每次按下“check for root”按钮冻结。有什么想法吗?
这里是“检查root”代码:
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) {
}