From 5fb071d80bfe024e912aaa6e463833c80a172e3b Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Mon, 10 Feb 2020 03:36:28 -0800 Subject: [PATCH] Merge app scripts --- .../topjohnwu/magisk/core/utils/RootInit.kt | 5 ++--- app/src/main/res/raw/{utils.sh => manager.sh} | 22 ++++++++++++++++++- app/src/main/res/raw/nonroot_utils.sh | 13 ----------- 3 files changed, 23 insertions(+), 17 deletions(-) rename app/src/main/res/raw/{utils.sh => manager.sh} (82%) delete mode 100644 app/src/main/res/raw/nonroot_utils.sh diff --git a/app/src/main/java/com/topjohnwu/magisk/core/utils/RootInit.kt b/app/src/main/java/com/topjohnwu/magisk/core/utils/RootInit.kt index 5f75e1819..7b28cabc7 100644 --- a/app/src/main/java/com/topjohnwu/magisk/core/utils/RootInit.kt +++ b/app/src/main/java/com/topjohnwu/magisk/core/utils/RootInit.kt @@ -16,12 +16,11 @@ class RootInit : Shell.Initializer() { fun init(context: Context, shell: Shell): Boolean { val job = shell.newJob() + job.add(context.rawResource(R.raw.manager)) if (shell.isRoot) { job.add(context.rawResource(R.raw.util_functions)) - .add(context.rawResource(R.raw.utils)) + .add("SHA1=`grep_prop SHA1 /sbin/.magisk/config`") Const.MAGISK_DISABLE_FILE = SuFile("/cache/.disable_magisk") - } else { - job.add(context.rawResource(R.raw.nonroot_utils)) } job.add( diff --git a/app/src/main/res/raw/utils.sh b/app/src/main/res/raw/manager.sh similarity index 82% rename from app/src/main/res/raw/utils.sh rename to app/src/main/res/raw/manager.sh index 0b3f9e87a..8cd82e402 100644 --- a/app/src/main/res/raw/utils.sh +++ b/app/src/main/res/raw/manager.sh @@ -1,3 +1,7 @@ +################################## +# Magisk Manager internal scripts +################################## + env_check() { for file in busybox magisk magiskboot magiskinit util_functions.sh boot_patch.sh; do [ -f $MAGISKBIN/$file ] || return 1 @@ -116,4 +120,20 @@ force_pm_install() { return $res } -SHA1=`grep_prop SHA1 /sbin/.magisk/config` +########################## +# Non-root util_functions +########################## + +mount_partitions() { + [ "`getprop ro.build.ab_update`" = "true" ] && SLOT=`getprop ro.boot.slot_suffix` + # Check whether non rootfs root dir exists + grep ' / ' /proc/mounts | grep -qv 'rootfs' && SYSTEM_ROOT=true || SYSTEM_ROOT=false +} + +get_flags() { + $SYSTEM_ROOT && KEEPVERITY=true || KEEPVERITY=false + [ "`getprop ro.crypto.state`" = "encrypted" ] && KEEPFORCEENCRYPT=true || KEEPFORCEENCRYPT=false + RECOVERYMODE=false +} + +run_migrations() { return; } diff --git a/app/src/main/res/raw/nonroot_utils.sh b/app/src/main/res/raw/nonroot_utils.sh deleted file mode 100644 index 88a5db68b..000000000 --- a/app/src/main/res/raw/nonroot_utils.sh +++ /dev/null @@ -1,13 +0,0 @@ -mount_partitions() { - [ "`getprop ro.build.ab_update`" = "true" ] && SLOT=`getprop ro.boot.slot_suffix` - # Check whether non rootfs root dir exists - grep ' / ' /proc/mounts | grep -qv 'rootfs' && SYSTEM_ROOT=true || SYSTEM_ROOT=false -} - -get_flags() { - $SYSTEM_ROOT && KEEPVERITY=true || KEEPVERITY=false - [ "`getprop ro.crypto.state`" = "encrypted" ] && KEEPFORCEENCRYPT=true || KEEPFORCEENCRYPT=false - RECOVERYMODE=false -} - -run_migrations() { return; }