Use libsuperuser lib

This commit is contained in:
dvdandroid
2016-08-22 10:09:36 +02:00
committed by topjohnwu
parent e66496eae7
commit c68e37a8c4
19 changed files with 11 additions and 2045 deletions

View File

@ -60,7 +60,6 @@ public class MainActivity extends Activity {
magiskVersion.setText(getString(R.string.magisk_version, executeCommand("getprop magisk.version")));
selinuxStatus.setText(selinux);
assert selinux != null;
if (selinux.equals("Enforcing")) {
selinuxStatus.setTextColor(Color.GREEN);
selinuxToggle.setChecked(true);

View File

@ -1,28 +1,20 @@
package com.topjohnwu.magisk.ui.utils;
import org.sufficientlysecure.rootcommands.Shell;
import org.sufficientlysecure.rootcommands.command.SimpleCommand;
import java.util.List;
import java.io.IOException;
import java.util.concurrent.TimeoutException;
import eu.chainfire.libsuperuser.Shell;
public class Utils {
public static String executeCommand(String... commands) {
try {
Shell shell = Shell.startRootShell();
SimpleCommand command = new SimpleCommand(commands);
shell.add(command).waitForFinish();
List<String> result = Shell.SU.run(commands);
String output = command.getOutput();
output = output.replaceAll("\n", "");
shell.close();
return output;
} catch (IOException | TimeoutException e) {
return "";
StringBuilder builder = new StringBuilder();
for (String s : result) {
builder.append(s);
}
return builder.toString();
}
}