Use BusyBox standalone mode if available

This commit is contained in:
topjohnwu 2020-04-11 02:21:47 -07:00
parent 4066e5bf14
commit e165a1e65c
2 changed files with 9 additions and 5 deletions

View File

@ -30,7 +30,7 @@ open class App() : Application() {
init { init {
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true) AppCompatDelegate.setCompatVectorFromResourcesEnabled(true)
Shell.Config.setFlags(Shell.FLAG_MOUNT_MASTER or Shell.FLAG_USE_MAGISK_BUSYBOX) Shell.Config.setFlags(Shell.FLAG_MOUNT_MASTER)
Shell.Config.verboseLogging(BuildConfig.DEBUG) Shell.Config.verboseLogging(BuildConfig.DEBUG)
Shell.Config.addInitializers(RootInit::class.java) Shell.Config.addInitializers(RootInit::class.java)
Shell.Config.setTimeout(2) Shell.Config.setTimeout(2)

View File

@ -18,10 +18,14 @@ class RootInit : Shell.Initializer() {
fun init(context: Context, shell: Shell): Boolean { fun init(context: Context, shell: Shell): Boolean {
val job = shell.newJob() val job = shell.newJob()
if (Info.env.magiskVersionCode >= Const.Version.DYNAMIC_PATH) if (Info.env.magiskVersionCode >= Const.Version.DYNAMIC_PATH) {
job.add("MAGISKTMP=$(magisk --path)/.magisk") job.add("export ASH_STANDALONE=1")
else .add("[ -x /data/adb/magisk/busybox ] && exec /data/adb/magisk/busybox sh")
job.add("MAGISKTMP=/sbin/.magisk") .add("MAGISKTMP=$(magisk --path)/.magisk")
} else {
job.add("export PATH=\"/sbin/.magisk/busybox:\$PATH\"")
.add("MAGISKTMP=/sbin/.magisk")
}
job.add(context.rawResource(R.raw.manager)) job.add(context.rawResource(R.raw.manager))
if (shell.isRoot) { if (shell.isRoot) {
job.add(context.rawResource(R.raw.util_functions)) job.add(context.rawResource(R.raw.util_functions))