Quote:
Originally Posted by persiansown View Post
I did this and now everything is working fine, however I was wondering how another application can have root access other than the shell program you created.

Great work by the way!
They can use the Intent that is exposed by Superuser, that Shell uses to get root:
Code:
Select Code
final int SUPERUSER_REQUEST = 2323; // arbitrary number of your choosing
Intent intent = new Intent("android.intent.action.superuser"); // superuser request
intent.putExtra("name", "Shell"); // tell Superuser the name of the requesting app
intent.putExtra("packagename", "koushikdutta.shell"); // tel Superuser the name of the requesting package
startActivityForResult(intent, SUPERUSER_REQUEST); // make the request!
Then, if the user presses Yes or Always, that Java application can call su just like normal:
Code:
Select Code
Runtime.getRuntime().exec("su -c <your privileged command here>");
Otherwise, that command will fail.