-
Notifications
You must be signed in to change notification settings - Fork 303
Description
On Android 14, TorrServer binary is killed randomly by the system.
Root cause: Android 14 requires explicit foregroundServiceType declared in both the manifest and startForeground() call.
Suggested fix in AndroidManifest.xml:
Add permissions after existing FOREGROUND_SERVICE:
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC" /> <uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK" /> <uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" /> <uses-permission android:name="android.permission.WAKE_LOCK" />
Add 2 attributes to <service android:name=".service.TorrService">: android:foregroundServiceType="dataSync|mediaPlayback" android:stopWithTask="false" So the service declaration will look like this: <service android:name=".service.TorrService" android:exported="false" android:foregroundServiceType="dataSync|mediaPlayback" android:stopWithTask="false" />
Changes:
Added FOREGROUND_SERVICE_DATA_SYNC permission
Added FOREGROUND_SERVICE_MEDIA_PLAYBACK permission
Added REQUEST_IGNORE_BATTERY_OPTIMIZATIONS permission
Added WAKE_LOCK permission
Added foregroundServiceType="dataSync|mediaPlayback" to TorrService
Added stopWithTask="false" to keep service alive when app is closed
Tested on: Android 14