diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 6ab4491b8..989feed5a 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -70,7 +70,7 @@
-
+
= Build.VERSION_CODES.O) {
+ context.startForegroundService(new Intent(context, OnBootIntentService.class));
+ } else {
+ context.startService(new Intent(context, OnBootIntentService.class));
+ }
+ }
+
@Override
public void onReceive(Context context, Intent intent) {
- context.startService(new Intent(context, BootupIntentService.class));
+ if (intent.getAction().equals(Intent.ACTION_BOOT_COMPLETED)) {
+ Utils.getMagiskManager(context).initSU();
+ // There is currently no need to start an IntentService onBoot
+ // startIntentService(context);
+ }
}
}
diff --git a/app/src/main/java/com/topjohnwu/magisk/services/BootupIntentService.java b/app/src/main/java/com/topjohnwu/magisk/services/BootupIntentService.java
deleted file mode 100644
index b15ec7bc4..000000000
--- a/app/src/main/java/com/topjohnwu/magisk/services/BootupIntentService.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package com.topjohnwu.magisk.services;
-
-import android.app.IntentService;
-import android.content.Intent;
-
-import com.topjohnwu.magisk.MagiskManager;
-
-public class BootupIntentService extends IntentService {
-
- public BootupIntentService() {
- super("BootupIntentService");
- }
-
- @Override
- protected void onHandleIntent(Intent intent) {
- ((MagiskManager) getApplication()).initSU();
- }
-}
diff --git a/app/src/main/java/com/topjohnwu/magisk/services/OnBootIntentService.java b/app/src/main/java/com/topjohnwu/magisk/services/OnBootIntentService.java
new file mode 100644
index 000000000..38a6bfe35
--- /dev/null
+++ b/app/src/main/java/com/topjohnwu/magisk/services/OnBootIntentService.java
@@ -0,0 +1,34 @@
+package com.topjohnwu.magisk.services;
+
+import android.app.IntentService;
+import android.content.Intent;
+import android.os.Build;
+import android.support.v7.app.NotificationCompat;
+
+import com.topjohnwu.magisk.R;
+
+public class OnBootIntentService extends IntentService {
+
+ private static final int ONBOOT_NOTIFICATION_ID = 3;
+
+ public OnBootIntentService() {
+ super("OnBootIntentService");
+ }
+
+ @Override
+ public void onCreate() {
+ super.onCreate();
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
+ NotificationCompat.Builder builder = new NotificationCompat.Builder(this);
+ builder.setSmallIcon(R.drawable.ic_magisk)
+ .setContentTitle("onBoot")
+ .setContentText("Running onBoot operations...");
+ startForeground(ONBOOT_NOTIFICATION_ID, builder.build());
+ }
+ }
+
+ @Override
+ protected void onHandleIntent(Intent intent) {
+ // Currently nothing to do
+ }
+}