0

Hi I'm trying to execute the 'su' command as following via an app.

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

I'm getting exit value 1 ..Its returning 0 for other commands like 'id'

I checked it through command prompt and its not showing any error(as given below).

root@android:/ #su
root@android:/ #

Does it mean the emulator is rooted? If it is, then whats would be the real problem? Can anyone Plz guide me..

srooth
  • 33
  • 2
  • 11

1 Answers1

0

Android Applications do not have permission to run su. Only root and shell users are allowed to run su.

Alex P.
  • 30,437
  • 17
  • 118
  • 169
digitizedx
  • 386
  • 5
  • 16
  • you can use a patched su binary which does not check if it is being run under allowed uid. – Alex P. Feb 13 '13 at 22:25
  • As far as I know your application wont get root permission unless you do something like modifying the framework or by doing stuff mentioned by Android user or Alex P. If nothing works and if you have rooted your emulator, create a native service, which has root permission (change init.rc) then use IPC to get your work done by that service. It makes sense only if your purpose is learning. This wont work if you plan to sell your app :p – digitizedx Feb 14 '13 at 03:38