diff options
author | Bartłomiej Rudecki <ejbtrd@gmail.com> | 2023-11-16 11:46:59 +0100 |
---|---|---|
committer | alk3pInjection <webmaster@raspii.tech> | 2023-12-31 21:50:10 +0800 |
commit | 82be2784067ee8f75c7519eb88ce4c2db9f7de2c (patch) | |
tree | 84ab6e377dc0125b14bf51f246658b563215a46f | |
parent | b6dffb380070e085d97b57a60f935aec34d46935 (diff) |
Updater: Define foregroundServiceTypeumineko
Required since Android 14 [1].
11-16 14:05:45.363 20623 20623 E AndroidRuntime: FATAL EXCEPTION: main
11-16 14:05:45.363 20623 20623 E AndroidRuntime: Process: org.lineageos.updater, PID: 20623
11-16 14:05:45.363 20623 20623 E AndroidRuntime: android.app.MissingForegroundServiceTypeException: Starting FGS without a type callerApp=ProcessRecord{6d14558 20623:org.lineageos.updater/u0a149} targetSDK=34
[1] https://developer.android.com/about/versions/14/changes/fgs-types-required
Change-Id: Id6217424177b94d37621062fb1a55778f1dabbab
-rw-r--r-- | AndroidManifest.xml | 15 | ||||
-rw-r--r-- | src/org/lineageos/updater/ExportUpdateService.java | 4 | ||||
-rw-r--r-- | src/org/lineageos/updater/controller/UpdaterService.java | 7 |
3 files changed, 21 insertions, 5 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml index cc485f7..80fd2bc 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -5,6 +5,7 @@ <uses-permission android:name="android.permission.ACCESS_CACHE_FILESYSTEM" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.FOREGROUND_SERVICE" /> + <uses-permission android:name="android.permission.FOREGROUND_SERVICE_SPECIAL_USE" /> <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.POST_NOTIFICATIONS" /> <uses-permission android:name="android.permission.REBOOT" /> @@ -43,8 +44,18 @@ </intent-filter> </activity> - <service android:name=".controller.UpdaterService" /> - <service android:name=".ExportUpdateService" /> + <service + android:name=".controller.UpdaterService" + android:foregroundServiceType="specialUse"> + <property android:name="android.app.PROPERTY_SPECIAL_USE_FGS_SUBTYPE" + android:value="updater"/> + </service> + <service + android:name=".ExportUpdateService" + android:foregroundServiceType="specialUse"> + <property android:name="android.app.PROPERTY_SPECIAL_USE_FGS_SUBTYPE" + android:value="updater"/> + </service> <receiver android:name=".UpdaterReceiver" android:exported="false"> <intent-filter> diff --git a/src/org/lineageos/updater/ExportUpdateService.java b/src/org/lineageos/updater/ExportUpdateService.java index 1c72ad2..4403d7f 100644 --- a/src/org/lineageos/updater/ExportUpdateService.java +++ b/src/org/lineageos/updater/ExportUpdateService.java @@ -20,6 +20,7 @@ import android.app.NotificationManager; import android.app.Service; import android.content.ContentResolver; import android.content.Intent; +import android.content.pm.ServiceInfo; import android.net.Uri; import android.os.IBinder; import android.os.SystemClock; @@ -156,7 +157,8 @@ public class ExportUpdateService extends Service { } }; - startForeground(NOTIFICATION_ID, notificationBuilder.build()); + startForeground(NOTIFICATION_ID, notificationBuilder.build(), + ServiceInfo.FOREGROUND_SERVICE_TYPE_SPECIAL_USE); notificationManager.notify(NOTIFICATION_ID, notificationBuilder.build()); Runnable runnableComplete = () -> { diff --git a/src/org/lineageos/updater/controller/UpdaterService.java b/src/org/lineageos/updater/controller/UpdaterService.java index c279679..e1e0c99 100644 --- a/src/org/lineageos/updater/controller/UpdaterService.java +++ b/src/org/lineageos/updater/controller/UpdaterService.java @@ -24,6 +24,7 @@ import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.content.SharedPreferences; +import android.content.pm.ServiceInfo; import android.os.Binder; import android.os.Bundle; import android.os.IBinder; @@ -275,7 +276,8 @@ public class UpdaterService extends Service { mNotificationBuilder.setTicker(text); mNotificationBuilder.setOngoing(true); mNotificationBuilder.setAutoCancel(false); - startForeground(NOTIFICATION_ID, mNotificationBuilder.build()); + startForeground(NOTIFICATION_ID, mNotificationBuilder.build(), + ServiceInfo.FOREGROUND_SERVICE_TYPE_SPECIAL_USE); mNotificationManager.notify(NOTIFICATION_ID, mNotificationBuilder.build()); break; } @@ -390,7 +392,8 @@ public class UpdaterService extends Service { mNotificationBuilder.setTicker(text); mNotificationBuilder.setOngoing(true); mNotificationBuilder.setAutoCancel(false); - startForeground(NOTIFICATION_ID, mNotificationBuilder.build()); + startForeground(NOTIFICATION_ID, mNotificationBuilder.build(), + ServiceInfo.FOREGROUND_SERVICE_TYPE_SPECIAL_USE); mNotificationManager.notify(NOTIFICATION_ID, mNotificationBuilder.build()); break; } |