A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
mobile: fix boot service crash on boot
Ammar Ahmed78f07b23dfe0
diff --git a/apps/mobile/native/android/app/src/main/AndroidManifest.xml b/apps/mobile/native/android/app/src/main/AndroidManifest.xmlindex 1146cf760..28582954f 100644--- a/apps/mobile/native/android/app/src/main/AndroidManifest.xml+++ b/apps/mobile/native/android/app/src/main/AndroidManifest.xml@@ -19,6 +19,8 @@<uses-permission android:name="android.permission.CAMERA"/><uses-permission android:name="android.permission.POST_NOTIFICATIONS"/><uses-permission android:name="android.permission.USE_FULL_SCREEN_INTENT" tools:node="remove" />+ <uses-permission android:name="android.permission.FOREGROUND_SERVICE_SPECIAL_USE" />+<queries><intent>@@ -174,7 +176,7 @@android:resource="@xml/file_viewer_provider_paths" /></provider>- <receiver android:exported="true" android:name=".BootRecieverService" >+ <receiver android:exported="true" android:name=".BootRecieverService" android:foregroundServiceType="specialUse" ><intent-filter><action android:name="android.intent.action.BOOT_COMPLETED" /><action android:name="android.intent.action.QUICKBOOT_POWERON" />diff --git a/apps/mobile/native/android/app/src/main/java/com/streetwriters/notesnook/BootTaskService.java b/apps/mobile/native/android/app/src/main/java/com/streetwriters/notesnook/BootTaskService.javaindex 60edfe16f..f2f66f52c 100644--- a/apps/mobile/native/android/app/src/main/java/com/streetwriters/notesnook/BootTaskService.java+++ b/apps/mobile/native/android/app/src/main/java/com/streetwriters/notesnook/BootTaskService.java@@ -5,6 +5,7 @@ import android.app.NotificationChannel;import android.app.NotificationManager;import android.content.Context;import android.content.Intent;+import android.content.pm.ServiceInfo;import android.util.Log;import androidx.core.app.NotificationCompat;@@ -12,20 +13,22 @@ import androidx.core.app.NotificationCompat;import com.facebook.react.HeadlessJsTaskService;import com.facebook.react.bridge.Arguments;import com.facebook.react.jstasks.HeadlessJsTaskConfig;+import javax.annotation.Nullable;public class BootTaskService extends HeadlessJsTaskService {Notification notification;+@Override- protected @Nullable HeadlessJsTaskConfig getTaskConfig(Intent intent) {- Log.d("BootTask", "Task Started");- return new HeadlessJsTaskConfig(- "com.streetwriters.notesnook.BOOT_TASK",- Arguments.createMap(),- 30000, // timeout for the task- false // optional: defines whether or not the task is allowed in foreground. Default is false- );- }+ protected @Nullable HeadlessJsTaskConfig getTaskConfig(Intent intent) {+ Log.d("BootTask", "Task Started");+ return new HeadlessJsTaskConfig(+ "com.streetwriters.notesnook.BOOT_TASK",+ Arguments.createMap(),+ 30000, // timeout for the task+ false // optional: defines whether or not the task is allowed in foreground. Default is false+ );+ }@Overridepublic void onHeadlessJsTaskFinish(int taskId) {@@ -48,7 +51,17 @@ public class BootTaskService extends HeadlessJsTaskService {.setContentText("").setSmallIcon(R.drawable.ic_stat_name).build();- startForeground(1, notification);+ if (android.os.Build.VERSION.SDK_INT >= 34) {+ this.startForeground(+ 1,+ notification,+ ServiceInfo.FOREGROUND_SERVICE_TYPE_SPECIAL_USE);+ } else {+ this.startForeground(+ 1,+ notification);+ }+}return super.onStartCommand(intent, flags, startId);