diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index c86e264c0..6bad618a8 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -60,6 +60,8 @@
+
+
blockDetectionDone = new CallbackEvent<>();
@@ -64,12 +67,22 @@ public class MagiskManager extends Application {
public SharedPreferences prefs;
+ private static Handler mHandler = new Handler();
+
@Override
public void onCreate() {
super.onCreate();
prefs = PreferenceManager.getDefaultSharedPreferences(this);
}
+ public void toast(String msg, int duration) {
+ mHandler.post(() -> Toast.makeText(this, msg, duration).show());
+ }
+
+ public void toast(int resId, int duration) {
+ mHandler.post(() -> Toast.makeText(this, resId, duration).show());
+ }
+
public void init() {
isDarkTheme = prefs.getBoolean("dark_theme", false);
devLogging = prefs.getBoolean("developer_logging", false);
diff --git a/app/src/main/java/com/topjohnwu/magisk/SplashActivity.java b/app/src/main/java/com/topjohnwu/magisk/SplashActivity.java
index 117ff4c24..ad879fbf4 100644
--- a/app/src/main/java/com/topjohnwu/magisk/SplashActivity.java
+++ b/app/src/main/java/com/topjohnwu/magisk/SplashActivity.java
@@ -5,6 +5,7 @@ import android.os.Bundle;
import com.topjohnwu.magisk.components.Activity;
import com.topjohnwu.magisk.utils.Async;
+import com.topjohnwu.magisk.utils.Utils;
public class SplashActivity extends Activity {
@@ -17,10 +18,15 @@ public class SplashActivity extends Activity {
// Init the info and configs and root shell
magiskManager.init();
+ boolean boot_done = Utils.itemExist(MagiskManager.MAGISK_MANAGER_BOOT);
// 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) {
+ new Async.MagiskHide().enable();
+ }
new Async.LoadModules(magiskManager) {
@Override
protected void onPostExecute(Void v) {
diff --git a/app/src/main/java/com/topjohnwu/magisk/StatusFragment.java b/app/src/main/java/com/topjohnwu/magisk/StatusFragment.java
index 936a54dec..094a5c10c 100644
--- a/app/src/main/java/com/topjohnwu/magisk/StatusFragment.java
+++ b/app/src/main/java/com/topjohnwu/magisk/StatusFragment.java
@@ -1,6 +1,6 @@
package com.topjohnwu.magisk;
-import android.app.AlertDialog;
+import android.support.v7.app.AlertDialog;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
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 53a8fd4a9..6b9e43ca8 100644
--- a/app/src/main/java/com/topjohnwu/magisk/receivers/BootReceiver.java
+++ b/app/src/main/java/com/topjohnwu/magisk/receivers/BootReceiver.java
@@ -1,27 +1,40 @@
package com.topjohnwu.magisk.receivers;
+import android.app.IntentService;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
-import android.content.SharedPreferences;
-import android.preference.PreferenceManager;
import android.widget.Toast;
import com.topjohnwu.magisk.MagiskManager;
import com.topjohnwu.magisk.R;
import com.topjohnwu.magisk.utils.Async;
+import com.topjohnwu.magisk.utils.Shell;
public class BootReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
- MagiskManager magiskManager = (MagiskManager) context.getApplicationContext();
- magiskManager.initSuAccess();
- magiskManager.updateMagiskInfo();
- SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
- if (prefs.getBoolean("magiskhide", false) && !magiskManager.disabled && magiskManager.magiskVersion > 10.3) {
- Toast.makeText(context, R.string.start_magiskhide, Toast.LENGTH_SHORT).show();
- new Async.MagiskHide(true).enable();
+ context.startService(new Intent(context, BootupIntentService.class));
+ }
+
+ public static class BootupIntentService extends IntentService {
+
+ public BootupIntentService() {
+ super("BootupIntentService");
+ }
+
+ @Override
+ protected void onHandleIntent(Intent intent) {
+ MagiskManager magiskManager = (MagiskManager) getApplicationContext();
+ magiskManager.initSuAccess();
+ magiskManager.updateMagiskInfo();
+ if (magiskManager.prefs.getBoolean("magiskhide", false) &&
+ !magiskManager.disabled && magiskManager.magiskVersion > 10.3) {
+ magiskManager.toast(R.string.start_magiskhide, Toast.LENGTH_LONG);
+ Shell.su(true, Async.MAGISK_HIDE_PATH + "enable",
+ "touch " + MagiskManager.MAGISK_MANAGER_BOOT);
+ }
}
}
}
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 b65535625..00f57c1ba 100644
--- a/app/src/main/java/com/topjohnwu/magisk/utils/Async.java
+++ b/app/src/main/java/com/topjohnwu/magisk/utils/Async.java
@@ -307,18 +307,10 @@ public class Async {
public static class MagiskHide extends RootTask