I need my application to execute some su commands programmatically (the phone is rooted).
After using adb, the commands work.
For example: su -c "mkdir /sdcard/testdir" creates the / testdir directory in / sdcard.
When i call:
p = Runtime.getRuntime().exec("su -c \"mkdir /sdcard/testdir\""); p.waitFor();
It simply moves and no changes occur.
I tried reading the input:
DataInputStream dis = new DataInputStream(p.getInputStream()); while((temp = dis.readLine())!=null) Log.d(ctx.TAG,"shell:"+temp);
But it does not report anything (the loop performs 0 iterations).
Has anyone ever encountered this problem before? How can this be solved? Of course, non-su commands work with this method programmatically.
Note. As an example, I gave mkdir (I know that this does not necessarily require su). I need a lot of different commands to be executed under su
Thanks!
EDIT: when I call su -c "id" programmatically, we deduce that uid = 0.
source share