Fix root shell crash

This commit is contained in:
topjohnwu 2016-10-06 00:36:50 +08:00
parent ae76ae4025
commit a7da6cf172

View File

@ -40,6 +40,7 @@ public class Shell {
rootSTDOUT.start(); rootSTDOUT.start();
List<String> ret = su("echo -BOC-", "id"); List<String> ret = su("echo -BOC-", "id");
if (ret == null) { if (ret == null) {
// Something wrong with root, not allowed? // Something wrong with root, not allowed?
rootStatus = -1; rootStatus = -1;
@ -115,21 +116,18 @@ public class Shell {
DataOutputStream STDIN; DataOutputStream STDIN;
StreamGobbler STDOUT; StreamGobbler STDOUT;
if (!rootAccess()) {
return null;
}
if (newShell) { if (newShell) {
res = Collections.synchronizedList(new ArrayList<String>()); res = Collections.synchronizedList(new ArrayList<String>());
try { try {
process = Runtime.getRuntime().exec(sh("getprop magisk.supath").get(0) + "/su"); process = Runtime.getRuntime().exec("su");
STDIN = new DataOutputStream(process.getOutputStream()); STDIN = new DataOutputStream(process.getOutputStream());
STDOUT = new StreamGobbler(process.getInputStream(), res); STDOUT = new StreamGobbler(process.getInputStream(), res);
} catch (IOException e) { } catch (IOException err) {
try { return null;
// Improper root
process = Runtime.getRuntime().exec("su");
STDIN = new DataOutputStream(process.getOutputStream());
STDOUT = new StreamGobbler(process.getInputStream(), res);
} catch (IOException err) {
return null;
}
} }
STDOUT.start(); STDOUT.start();
} else { } else {