From d1b5ebad7dc7fb58878e02b8756919f7a6453a13 Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Tue, 7 Feb 2017 07:32:40 +0800 Subject: [PATCH] Several fixes --- app/build.gradle | 4 ++-- .../java/com/topjohnwu/magisk/MagiskManager.java | 2 +- .../java/com/topjohnwu/magisk/SplashActivity.java | 12 +++++++++--- .../com/topjohnwu/magisk/receivers/BootReceiver.java | 9 +++++++-- .../main/java/com/topjohnwu/magisk/utils/Async.java | 6 +++--- 5 files changed, 22 insertions(+), 11 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index cd9b1ef58..6d6a9739d 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -8,8 +8,8 @@ android { applicationId "com.topjohnwu.magisk" minSdkVersion 21 targetSdkVersion 25 - versionCode 20 - versionName "4.0" + versionCode 22 + versionName "4.1" jackOptions { enabled true jackInProcess true diff --git a/app/src/main/java/com/topjohnwu/magisk/MagiskManager.java b/app/src/main/java/com/topjohnwu/magisk/MagiskManager.java index fd7da5ca1..6896ddf5d 100644 --- a/app/src/main/java/com/topjohnwu/magisk/MagiskManager.java +++ b/app/src/main/java/com/topjohnwu/magisk/MagiskManager.java @@ -56,8 +56,8 @@ public class MagiskManager extends Application { // Configurations public static boolean shellLogging; public static boolean devLogging; - public static boolean magiskHide; + public boolean magiskHide; public boolean isDarkTheme; public int suRequestTimeout; public int suLogTimeout = 14; diff --git a/app/src/main/java/com/topjohnwu/magisk/SplashActivity.java b/app/src/main/java/com/topjohnwu/magisk/SplashActivity.java index ad879fbf4..6f756bff9 100644 --- a/app/src/main/java/com/topjohnwu/magisk/SplashActivity.java +++ b/app/src/main/java/com/topjohnwu/magisk/SplashActivity.java @@ -5,8 +5,11 @@ import android.os.Bundle; import com.topjohnwu.magisk.components.Activity; import com.topjohnwu.magisk.utils.Async; +import com.topjohnwu.magisk.utils.Shell; import com.topjohnwu.magisk.utils.Utils; +import java.util.List; + public class SplashActivity extends Activity { @Override @@ -18,13 +21,16 @@ public class SplashActivity extends Activity { // Init the info and configs and root shell magiskManager.init(); - boolean boot_done = Utils.itemExist(MagiskManager.MAGISK_MANAGER_BOOT); + + // Check MagiskHide status + List ret = Shell.sh("getprop persist.magisk.hide"); + boolean started = Utils.isValidShellResponse(ret) && Integer.parseInt(ret.get(0)) != 0; // Now fire all async tasks new Async.CheckUpdates(magiskManager).exec(); new Async.GetBootBlocks(magiskManager).exec(); - if (magiskManager.prefs.getBoolean("magiskhide", false) && !magiskManager.disabled && - magiskManager.magiskVersion > 10.3 && boot_done) { + if (magiskManager.magiskHide && !magiskManager.disabled && + magiskManager.magiskVersion > 11 && !started) { new Async.MagiskHide().enable(); } new Async.LoadModules(magiskManager) { diff --git a/app/src/main/java/com/topjohnwu/magisk/receivers/BootReceiver.java b/app/src/main/java/com/topjohnwu/magisk/receivers/BootReceiver.java index 6b9e43ca8..712c5e237 100644 --- a/app/src/main/java/com/topjohnwu/magisk/receivers/BootReceiver.java +++ b/app/src/main/java/com/topjohnwu/magisk/receivers/BootReceiver.java @@ -10,6 +10,9 @@ import com.topjohnwu.magisk.MagiskManager; import com.topjohnwu.magisk.R; import com.topjohnwu.magisk.utils.Async; import com.topjohnwu.magisk.utils.Shell; +import com.topjohnwu.magisk.utils.Utils; + +import java.util.List; public class BootReceiver extends BroadcastReceiver { @@ -29,11 +32,13 @@ public class BootReceiver extends BroadcastReceiver { MagiskManager magiskManager = (MagiskManager) getApplicationContext(); magiskManager.initSuAccess(); magiskManager.updateMagiskInfo(); + List ret = Shell.sh("getprop persist.magisk.hide"); + boolean started = Utils.isValidShellResponse(ret) && Integer.parseInt(ret.get(0)) != 0; if (magiskManager.prefs.getBoolean("magiskhide", false) && - !magiskManager.disabled && magiskManager.magiskVersion > 10.3) { + !magiskManager.disabled && !started && magiskManager.magiskVersion > 11) { magiskManager.toast(R.string.start_magiskhide, Toast.LENGTH_LONG); Shell.su(true, Async.MAGISK_HIDE_PATH + "enable", - "touch " + MagiskManager.MAGISK_MANAGER_BOOT); + "setprop persist.magisk.hide 1"); } } } diff --git a/app/src/main/java/com/topjohnwu/magisk/utils/Async.java b/app/src/main/java/com/topjohnwu/magisk/utils/Async.java index 00f57c1ba..4d80a6edd 100644 --- a/app/src/main/java/com/topjohnwu/magisk/utils/Async.java +++ b/app/src/main/java/com/topjohnwu/magisk/utils/Async.java @@ -229,7 +229,7 @@ public class Async { @Override protected void onPreExecute() { - progress = new ProgressDialog(magiskManager); + progress = new ProgressDialog(mContext); progress.setTitle(R.string.zip_install_progress_title); progress.show(); } @@ -323,11 +323,11 @@ public class Async { } public void enable() { - exec("enable"); + exec("enable; setprop persist.magisk.hide 1"); } public void disable() { - exec("disable"); + exec("disable; setprop persist.magisk.hide 0"); } }