mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-06-12 05:07:45 +02:00
Use libsuperuser lib
This commit is contained in:
@ -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);
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user