Let ShellInitializer run in BusyBox environment

This commit is contained in:
topjohnwu 2018-07-11 20:44:29 +08:00
parent b885ccbd63
commit 68c448bc34
2 changed files with 10 additions and 4 deletions

View File

@ -57,7 +57,7 @@ dependencies {
fullImplementation "com.android.support:recyclerview-v7:${rootProject.ext.supportLibVersion}" fullImplementation "com.android.support:recyclerview-v7:${rootProject.ext.supportLibVersion}"
fullImplementation "com.android.support:cardview-v7:${rootProject.ext.supportLibVersion}" fullImplementation "com.android.support:cardview-v7:${rootProject.ext.supportLibVersion}"
fullImplementation "com.android.support:design:${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 'com.atlassian.commonmark:commonmark:0.11.0'
fullImplementation 'org.kamranzafar:jtar:2.3' fullImplementation 'org.kamranzafar:jtar:2.3'
fullImplementation 'com.jakewharton:butterknife:8.8.1' fullImplementation 'com.jakewharton:butterknife:8.8.1'

View File

@ -6,20 +6,26 @@ import android.support.annotation.NonNull;
import com.topjohnwu.magisk.R; import com.topjohnwu.magisk.R;
import com.topjohnwu.superuser.BusyBox; import com.topjohnwu.superuser.BusyBox;
import com.topjohnwu.superuser.Shell; import com.topjohnwu.superuser.Shell;
import com.topjohnwu.superuser.ShellUtils;
import java.io.File; import java.io.File;
import java.io.InputStream; import java.io.InputStream;
public class ShellInitializer extends Shell.Initializer { public class ShellInitializer extends Shell.Initializer {
static {
BusyBox.BB_PATH = new File(Const.BUSYBOX_PATH);
}
@Override @Override
public boolean onRootShellInit(Context context, @NonNull Shell shell) throws Exception { 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); try (InputStream magiskUtils = context.getResources().openRawResource(R.raw.util_functions);
InputStream managerUtils = context.getResources().openRawResource(R.raw.utils) InputStream managerUtils = context.getResources().openRawResource(R.raw.utils)
) { ) {
shell.loadInputStream(null, null, magiskUtils); shell.execTask((in, err, out) -> {
shell.loadInputStream(null, null, managerUtils); ShellUtils.pump(magiskUtils, in);
ShellUtils.pump(managerUtils, in);
});
} }
shell.run(null, null, shell.run(null, null,
"mount_partitions", "mount_partitions",