Skip to content

A cross platform Audiobookshelf client for Android and iOS

Dart

Let Chromecast sessions reconnect after a background drop instead of dying for good

Barnabas89503b48f40f
diff --git a/android/app/src/fdroid/AndroidManifest.xml b/android/app/src/fdroid/AndroidManifest.xml
index 6455c020..61a91e11 100644
--- a/android/app/src/fdroid/AndroidManifest.xml
+++ b/android/app/src/fdroid/AndroidManifest.xml
@@ -8,12 +8,16 @@
<!-- In-app APK updater: F-Droid updates apps itself -->
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" tools:node="remove"/>
+ <!-- Only needed for the Cast SDK's own reconnection service, below -->
+ <uses-permission android:name="android.permission.FOREGROUND_SERVICE_CONNECTED_DEVICE" tools:node="remove"/>
+
<application>
<!-- Chromecast (GMS) -->
<meta-data
android:name="com.google.android.gms.cast.framework.OPTIONS_PROVIDER_CLASS_NAME"
tools:node="remove"/>
<service android:name=".CastForegroundService" tools:node="remove"/>
+ <service android:name="com.google.android.gms.cast.framework.ReconnectionService" tools:node="remove"/>
<!-- Android Auto (GMS) -->
<meta-data android:name="com.google.android.gms.car.application" tools:node="remove"/>
diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml
index 2f0fed20..e1172e9e 100644
--- a/android/app/src/main/AndroidManifest.xml
+++ b/android/app/src/main/AndroidManifest.xml
@@ -6,6 +6,7 @@
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC"/>
+ <uses-permission android:name="android.permission.FOREGROUND_SERVICE_CONNECTED_DEVICE"/>
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS"/>
@@ -115,6 +116,17 @@
android:exported="false"
android:foregroundServiceType="mediaPlayback" />
+ <!-- The Cast SDK's own session-resume service ships with no
+ foregroundServiceType, so startForeground() throws on API 34+ and
+ a background cast session that drops (e.g. an overnight WiFi
+ blip) can never auto-reconnect. Declaring the type here restores
+ the resume behavior AbsorbCastOptionsProvider already asks for
+ via setEnableReconnectionService(true). Fixes GH #338. -->
+ <service
+ android:name="com.google.android.gms.cast.framework.ReconnectionService"
+ android:foregroundServiceType="connectedDevice"
+ tools:node="merge" />
+
<!-- FileProvider for share_plus file sharing -->
<provider
android:name="androidx.core.content.FileProvider"