Re-add busybox

Add check for proper install, install if not.  Needed for flashing zips.
This commit is contained in:
d8ahazard 2016-09-25 02:16:10 -05:00
parent 3b0cec9db6
commit dac85757b3
2 changed files with 29 additions and 0 deletions

View File

@ -10,6 +10,7 @@ import android.support.v7.app.AppCompatActivity;
import com.topjohnwu.magisk.services.MonitorService;
import com.topjohnwu.magisk.utils.Async;
import com.topjohnwu.magisk.utils.Logger;
import com.topjohnwu.magisk.utils.Shell;
import com.topjohnwu.magisk.utils.Utils;
import java.util.HashSet;
@ -64,6 +65,23 @@ public class SplashActivity extends AppCompatActivity {
// Initialize
if (Shell.rootAccess()) {
if (!Utils.busyboxInstalled()) {
String busybox = getApplicationContext().getApplicationInfo().nativeLibraryDir + "/libbusybox.so";
Shell.su(
"rm -rf /data/busybox",
"mkdir -p /data/busybox",
"cp -af " + busybox + " /data/busybox/busybox",
"chmod 755 /data/busybox /data/busybox/busybox",
"chcon u:object_r:system_file:s0 /data/busybox /data/busybox/busybox",
"/data/busybox/busybox --install -s /data/busybox",
"rm -f /data/busybox/su",
"export PATH=/data/busybox:$PATH"
);
}
}
new Async.CheckUpdates(this).execute();
new Async.LoadModules(this).execute();
new Async.LoadRepos(this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);

View File

@ -91,6 +91,17 @@ public class Utils {
return Boolean.parseBoolean(ret.get(0));
}
public static boolean busyboxInstalled() {
List<String> ret;
String command = "if [ -d /data/busybox ]; then echo true; else echo false; fi";
if (Shell.rootAccess()) {
ret = Shell.su(command);
} else {
ret = Shell.sh(command);
}
return Boolean.parseBoolean(ret.get(0));
}
public static boolean rootEnabled() {
List<String> ret;
String command = "if [ -z $(which su) ]; then echo false; else echo true; fi";