1

I want to execute the "su" comand from an app..I have rooted the emulator and installed Superuser.apk(superuser 2.3.6.1)

Process pr= Runtime.getRuntime().exec("su");
process.waitFor();
Log.d("Ex.Value",Integer.toString(process.exitValue()));

But I'm getting 255 as the exit value which seems to be some error in executing "su". I have included RootTools library (http://code.google.com/p/roottools/). When checked with the methods RootTools.isRootAvailable(), RootTools.isAccessGiven()...Its found that the emulator has SU, but my application is not granted Root permissions. Will it be the real issue?? ..If so Can you plz tell how to grant my app the Root permission?

user2068522
  • 11
  • 1
  • 1
  • 3
  • Did you set the permissions in Superuser application that your application can be executed as a root? – Yury Feb 13 '13 at 16:23
  • @Yury I'm not sure how to do it properly...can you please help.. – user2068522 Feb 13 '13 at 18:36
  • AFAIK, you can read about them here: http://getandroidstuff.com/superuser-vs-supersu-android-root-management-at-its-best/ – Yury Feb 13 '13 at 18:39
  • There is no such thing as "root permission" - there is only launching a helper executable which runs as root, while your application's own process continues to be confined (as it always must be) to it's assigned non-root user ID. Apart from that, your return value is likely a result of running an official Android `su` rather than a hacked one, or else running a hacked one that is denying your particular app. – Chris Stratton Sep 12 '13 at 18:04

1 Answers1

1

When you execute 'su', you should have root access within that process. The app should then automatically ask for root permission to the user via a dialog box. This dialog box is provided by android but is only present in devices that have been rooted.

This blog post has an example that might help you:

http://www.stealthcopter.com/blog/2010/01/android-requesting-root-access-in-your-app/

The comments at the end are very informative as well.

Anup Cowkur
  • 20,443
  • 6
  • 51
  • 84
  • Thanks for the Reply Anup...But in the code given in post,there is exec("su") initially... p = Runtime.getRuntime().exec("su"); In my case, this is throwing exit value 255...is there any way to give the app Rootpermission. Im using an emulator and it is rooted... – user2068522 Feb 13 '13 at 15:18
  • rooting on emulators is always a problem. That's why I prefer actual devices. This thread might help you: http://stackoverflow.com/questions/5095234/how-to-get-root-access-on-android-emulator – Anup Cowkur Feb 13 '13 at 15:21
  • I tried to root this way itself...And when checked with RootTools.isRootAvailable() method it shows the device(emulator) is rooted...but the application lacks root permisssion – user2068522 Feb 13 '13 at 15:27