mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-10-16 07:41:25 +00:00
Use libsuperuser lib
This commit is contained in:
@@ -22,10 +22,11 @@ android {
|
||||
|
||||
dependencies {
|
||||
compile fileTree(include: ['*.jar'], dir: 'libs')
|
||||
compile project(':lib:RootCommands')
|
||||
compile 'com.android.support:recyclerview-v7:24.2.0'
|
||||
compile 'com.android.support:cardview-v7:24.2.0'
|
||||
compile 'com.android.support:design:24.2.0'
|
||||
compile 'eu.chainfire:libsuperuser:1.0.0.201607041850'
|
||||
|
||||
compile 'com.jakewharton:butterknife:8.2.1'
|
||||
apt 'com.jakewharton:butterknife-compiler:8.2.1'
|
||||
}
|
||||
|
@@ -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