From 01a12134636068582d71d15262fa796f4213187b Mon Sep 17 00:00:00 2001 From: vvb2060 Date: Fri, 18 Mar 2022 03:56:34 +0800 Subject: [PATCH] /data/adb/magisk/magisk.apk no longer exists --- native/jni/core/bootstages.cpp | 26 +++++--------------------- native/jni/include/magisk.hpp | 1 - scripts/util_functions.sh | 11 ++++------- 3 files changed, 9 insertions(+), 29 deletions(-) diff --git a/native/jni/core/bootstages.cpp b/native/jni/core/bootstages.cpp index 80130794c..7bfdf12d7 100644 --- a/native/jni/core/bootstages.cpp +++ b/native/jni/core/bootstages.cpp @@ -131,7 +131,7 @@ static bool magisk_env() { // Alternative binaries paths const char *alt_bin[] = { "/cache/data_adb/magisk", "/data/magisk", buf }; for (auto alt : alt_bin) { - struct stat st; + struct stat st{}; if (lstat(alt, &st) == 0) { if (S_ISLNK(st.st_mode)) { unlink(alt); @@ -143,15 +143,7 @@ static bool magisk_env() { break; } } - - // Remove stuffs rm_rf("/cache/data_adb"); - rm_rf("/data/adb/modules/.core"); - unlink("/data/adb/magisk.img"); - unlink("/data/adb/magisk_merge.img"); - unlink("/data/magisk.img"); - unlink("/data/magisk_merge.img"); - unlink("/data/magisk_debug.log"); // Directories in /data/adb xmkdir(DATABIN, 0755); @@ -379,17 +371,9 @@ void boot_complete(int client) { xmkdir(SECURE_DIR, 0700); if (!get_manager()) { - if (access(MANAGERAPK, F_OK) == 0) { - // Only try to install APK when no manager is installed - // Magisk Manager should be upgraded by itself, not through recovery installs - rename(MANAGERAPK, "/data/magisk.apk"); - install_apk("/data/magisk.apk"); - } else { - // Install stub - auto init = MAGISKTMP + "/magiskinit"; - exec_command_sync(init.data(), "-x", "manager", "/data/magisk.apk"); - install_apk("/data/magisk.apk"); - } + // Install stub + auto init = MAGISKTMP + "/magiskinit"; + exec_command_sync(init.data(), "-x", "manager", "/data/magisk.apk"); + install_apk("/data/magisk.apk"); } - unlink(MANAGERAPK); } diff --git a/native/jni/include/magisk.hpp b/native/jni/include/magisk.hpp index a79a2ef6a..466e5f439 100644 --- a/native/jni/include/magisk.hpp +++ b/native/jni/include/magisk.hpp @@ -13,7 +13,6 @@ #define MODULEUPGRADE SECURE_DIR "/modules_update" #define DATABIN SECURE_DIR "/magisk" #define MAGISKDB SECURE_DIR "/magisk.db" -#define MANAGERAPK DATABIN "/magisk.apk" // tmpfs paths extern std::string MAGISKTMP; diff --git a/scripts/util_functions.sh b/scripts/util_functions.sh index d437a39e8..30cbe2eee 100644 --- a/scripts/util_functions.sh +++ b/scripts/util_functions.sh @@ -577,16 +577,13 @@ check_data() { find_magisk_apk() { local DBAPK - [ -z $APK ] && APK=$NVBASE/magisk.apk - [ -f $APK ] || APK=$MAGISKBIN/magisk.apk - [ -f $APK ] || APK=/data/app/com.topjohnwu.magisk*/*.apk - [ -f $APK ] || APK=/data/app/*/com.topjohnwu.magisk*/*.apk + [ -z $APK ] && APK=/data/app/com.topjohnwu.magisk*/base.apk + [ -f $APK ] || APK=/data/app/*/com.topjohnwu.magisk*/base.apk if [ ! -f $APK ]; then DBAPK=$(magisk --sqlite "SELECT value FROM strings WHERE key='requester'" 2>/dev/null | cut -d= -f2) [ -z $DBAPK ] && DBAPK=$(strings $NVBASE/magisk.db | grep -oE 'requester..*' | cut -c10-) - [ -z $DBAPK ] || APK=/data/user_de/*/$DBAPK/dyn/*.apk - [ -f $APK ] || [ -z $DBAPK ] || APK=/data/app/$DBAPK*/*.apk - [ -f $APK ] || [ -z $DBAPK ] || APK=/data/app/*/$DBAPK*/*.apk + [ -z $DBAPK ] || APK=/data/user_de/0/$DBAPK/dyn/current.apk + [ -f $APK ] || [ -z $DBAPK ] || APK=/data/data/$DBAPK/dyn/current.apk fi [ -f $APK ] || ui_print "! Unable to detect Magisk app APK for BootSigner" }