From 96b93bd87671aa3cdf537c6cf88ab14080c3c982 Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Thu, 15 Nov 2018 03:12:31 -0500 Subject: [PATCH] Add function to find manager APK Close #673 --- scripts/addon.d.sh | 4 +--- scripts/util_functions.sh | 10 ++++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/scripts/addon.d.sh b/scripts/addon.d.sh index 52f199fed..3674bf9c9 100644 --- a/scripts/addon.d.sh +++ b/scripts/addon.d.sh @@ -34,9 +34,7 @@ initialize() { # Load utility functions . $MAGISKBIN/util_functions.sh - APK=/data/adb/magisk.apk - [ -f $APK ] || APK=/data/magisk/magisk.apk - [ -f $APK ] || APK=/data/app/com.topjohnwu.magisk*/*.apk + find_manager_apk } show_logo() { diff --git a/scripts/util_functions.sh b/scripts/util_functions.sh index f9409bf10..61198e375 100644 --- a/scripts/util_functions.sh +++ b/scripts/util_functions.sh @@ -434,3 +434,13 @@ unmount_magisk_img() { $MAGISKBIN/magisk imgtool resize $IMG $newSizeM >&2 fi } + +find_manager_apk() { + APK=/data/adb/magisk.apk + [ -f $APK ] || APK=/data/magisk/magisk.apk + [ -f $APK ] || APK=/data/app/com.topjohnwu.magisk*/*.apk + if [ ! -f $APK ]; then + DBAPK=`magisk --sqlite "SELECT value FROM strings WHERE key='requester'" | cut -d= -f2` + [ -z "$DBAPK" ] || APK=/data/app/$DBAPK*/*.apk + fi +}