From 68c448bc34b55587d30ae21ce816114402f16b75 Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Wed, 11 Jul 2018 20:44:29 +0800 Subject: [PATCH] Let ShellInitializer run in BusyBox environment --- build.gradle | 2 +- .../com/topjohnwu/magisk/utils/ShellInitializer.java | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/build.gradle b/build.gradle index 4f83fa4ba..d8d3c9df9 100644 --- a/build.gradle +++ b/build.gradle @@ -57,7 +57,7 @@ dependencies { fullImplementation "com.android.support:recyclerview-v7:${rootProject.ext.supportLibVersion}" fullImplementation "com.android.support:cardview-v7:${rootProject.ext.supportLibVersion}" fullImplementation "com.android.support:design:${rootProject.ext.supportLibVersion}" - fullImplementation 'com.github.topjohnwu:libsu:1.2.0' + fullImplementation 'com.github.topjohnwu:libsu:1.3.0' fullImplementation 'com.atlassian.commonmark:commonmark:0.11.0' fullImplementation 'org.kamranzafar:jtar:2.3' fullImplementation 'com.jakewharton:butterknife:8.8.1' diff --git a/src/full/java/com/topjohnwu/magisk/utils/ShellInitializer.java b/src/full/java/com/topjohnwu/magisk/utils/ShellInitializer.java index 4f7f0fd11..317e2aa14 100644 --- a/src/full/java/com/topjohnwu/magisk/utils/ShellInitializer.java +++ b/src/full/java/com/topjohnwu/magisk/utils/ShellInitializer.java @@ -6,20 +6,26 @@ import android.support.annotation.NonNull; import com.topjohnwu.magisk.R; import com.topjohnwu.superuser.BusyBox; import com.topjohnwu.superuser.Shell; +import com.topjohnwu.superuser.ShellUtils; import java.io.File; import java.io.InputStream; public class ShellInitializer extends Shell.Initializer { + static { + BusyBox.BB_PATH = new File(Const.BUSYBOX_PATH); + } + @Override public boolean onRootShellInit(Context context, @NonNull Shell shell) throws Exception { - BusyBox.BB_PATH = new File(Const.BUSYBOX_PATH); try (InputStream magiskUtils = context.getResources().openRawResource(R.raw.util_functions); InputStream managerUtils = context.getResources().openRawResource(R.raw.utils) ) { - shell.loadInputStream(null, null, magiskUtils); - shell.loadInputStream(null, null, managerUtils); + shell.execTask((in, err, out) -> { + ShellUtils.pump(magiskUtils, in); + ShellUtils.pump(managerUtils, in); + }); } shell.run(null, null, "mount_partitions",