Nel tutorial di oggi vedremo come creare uno script che permette di ottenere il privilegio di root in Java. Iniziamo!

 
Process p;
 
try {
p = Runtime.getRuntime().exec("su");
 
DataOutputStream os = new DataOutputStream(p.getOutputStream());
os.writeBytes("echo \"Do I have root?\" >/system/sd/temporary.txt\n");
os.writeBytes("exit\n");
os.flush();
 
try {
p.waitFor();
if(p.exitValue() != 255)
toastMessage("root");
else
toastMessage("not root");
} catch(InterruptedException e) {
toastMessage("not root");
}
} catch(IOException e) {
toastMessage("not root");
}
 

fonte: www.sastgroup.com ? Vai al post originale