Or Continue to Thread: Superuser App - fix the su sec…
Find Your Device:
24th November 2008, 10:31 PM   |  #7  
OP Retired Recognized Developer
Thanks Meter: 894
 
917 posts
Join Date:Joined: Sep 2007
Quote:
Originally Posted by persiansown

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:
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:
Runtime.getRuntime().exec("su -c <your privileged command here>");
Otherwise, that command will fail.
Last edited by Koush; 24th November 2008 at 10:33 PM.