You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Ok, so I am developing an app at the moment, my first on actually, so the problem in this case meight be myself.
basically my application tries to gain su permissions and then execute some commands by sending it to a method called ShellInterface in my case:
Example of calling the method:
try {
System.out.println("ShellInterface got the job.");
System.out.println("Requesting SU permissions");
processx = Runtime.getRuntime().exec("su");
System.out.println("Granted?!");
os = new DataOutputStream(processx.getOutputStream());
System.out.println("Stream created?!");
// Doing Stuff ;)
for (String single : commands) {
System.out.println("Doing the commands...");
os.writeBytes("\n" + single + "\n");
os.flush();
System.out.println("Sending exit-signal!");
os.writeBytes("exit\n");
os.flush();
os.close();
Thread.sleep(sleeptime);
}
} catch (Exception e) {
System.out.println("Failure in SU command: " + e.getMessage());
Log.d("Unexpected error - Here is what I know: "
+ e.getMessage(), null, e);
e.printStackTrace();
msg = Message.obtain();
msg.arg1 = 1;
msg.arg2 = 0;
res.add(e.getMessage());
}
The Problem is that, from my perspective it only randomly works. I am executing about 10 commands, after e few ones to processX terminates and it will respawn as intended, but sometimes it does simply not finish the command:
processx = Runtime.getRuntime().exec("su");
It gets stuck there and there is no toast notification showing up the access has been granted or not. Just nothing happens. I found the possibility of not running into this increases when I kill the Superuser.apk in the Settings before executing the commands. But still it does often just randomly run into this state of "nothing" happening anymore. (Su request not granted or rejected)
In the logcat I can't find anything interesting. I just noticed that this happens not only in my app but sometimes even in the SU application:
It happens when your app is running a webview, that is using JavaScript. Then the processes will randomly get stuck, but as far as I know this is not specific to SU. Anyway, Android is behaving very strange here. This is applicable to any application, when JavaScript is enabled. To slove the problem, use webview.destroy(); before executing the commands.
Ok, so I am developing an app at the moment, my first on actually, so the problem in this case meight be myself.
basically my application tries to gain su permissions and then execute some commands by sending it to a method called ShellInterface in my case:
Example of calling the method:
Code:
String[] commands = { "mount -o remount,rw -t yaffs2 /dev/block/mtdblock3 /system", };
sendShell(commands, true, 250);
Part of the ShellInterface class:
Code:
try {
System.out.println("ShellInterface got the job.");
System.out.println("Requesting SU permissions");
processx = Runtime.getRuntime().exec("su");
System.out.println("Granted?!");
} catch (Exception e) {
System.out.println("Failure in SU command: " + e.getMessage());
Log.d("Unexpected error - Here is what I know: "
+ e.getMessage(), null, e);
e.printStackTrace();
msg = Message.obtain();
msg.arg1 = 1;
msg.arg2 = 0;
res.add(e.getMessage());
}
The Problem is that, from my perspective it only randomly works. I am executing about 10 commands, after e few ones to processX terminates and it will respawn as intended, but sometimes it does simply not finish the command:
processx = Runtime.getRuntime().exec("su");
It gets stuck there and there is no toast notification showing up the access has been granted or not. Just nothing happens. I found the possibility of not running into this increases when I kill the Superuser.apk in the Settings before executing the commands. But still it does often just randomly run into this state of "nothing" happening anymore. (Su request not granted or rejected)
In the logcat I can't find anything interesting. I just noticed that this happens not only in my app but sometimes even in the SU application:
http://dl.dropbox.com/u/39401915/Screenshot_2012-07-08-18-43-04.png
http://dl.dropbox.com/u/39401915/Screenshot_2012-07-08-18-42-44.png
The text was updated successfully, but these errors were encountered: