From 7d30d26a9e11809bf87341d5dde6504a146e366e Mon Sep 17 00:00:00 2001
From: Katherine Blizard <414924+kabliz@users.noreply.github.com>
Date: Mon, 26 Aug 2024 13:51:15 -0700
Subject: [PATCH] [AND-10935] Fix "failed to bind service"
MediaBrowser only posts an error log with "Failed to bind service" message, MediaBrowser does not use the foreground audio permission.
---
Armadillo/src/main/AndroidManifest.xml | 2 +-
.../java/com/scribd/armadillo/playback/PlaybackService.kt | 8 ++++++++
RELEASE.md | 3 +++
gradle.properties | 2 +-
4 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/Armadillo/src/main/AndroidManifest.xml b/Armadillo/src/main/AndroidManifest.xml
index bd22d28..eafc9f5 100644
--- a/Armadillo/src/main/AndroidManifest.xml
+++ b/Armadillo/src/main/AndroidManifest.xml
@@ -7,6 +7,7 @@
+
@@ -15,7 +16,6 @@
android:exported="true"
android:stopWithTask="false"
android:foregroundServiceType="mediaPlayback"
- android:permission="android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK"
tools:ignore="ExportedService">
diff --git a/Armadillo/src/main/java/com/scribd/armadillo/playback/PlaybackService.kt b/Armadillo/src/main/java/com/scribd/armadillo/playback/PlaybackService.kt
index 4e77a60..79b2362 100644
--- a/Armadillo/src/main/java/com/scribd/armadillo/playback/PlaybackService.kt
+++ b/Armadillo/src/main/java/com/scribd/armadillo/playback/PlaybackService.kt
@@ -103,6 +103,7 @@ class PlaybackService : MediaBrowserServiceCompat() {
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
// Handle media buttons when OS is below API 21
+ Log.v(TAG, "onStartCommand: flags $flags")
MediaButtonReceiver.handleIntent(mediaSession, intent)
return super.onStartCommand(intent, flags, startId)
}
@@ -126,6 +127,7 @@ class PlaybackService : MediaBrowserServiceCompat() {
}
override fun onLoadChildren(parentId: String, result: Result>) {
+ Log.v(TAG, "onLoadChildren from parentId $parentId")
when (val authorizationStatus: ArmadilloMediaBrowse.Browser.AuthorizationStatus = mediaBrowser.checkAuthorization()) {
is ArmadilloMediaBrowse.Browser.AuthorizationStatus.Authorized -> {
mediaBrowser.loadChildrenOf(parentId, result)
@@ -146,6 +148,7 @@ class PlaybackService : MediaBrowserServiceCompat() {
}
override fun onGetRoot(clientPackageName: String, clientUid: Int, rootHints: Bundle?): BrowserRoot? {
+ Log.v(TAG, "onGetRoot from $clientPackageName")
val root = mediaBrowser.determineBrowserRoot(clientPackageName, clientUid, rootHints)
if (root != null) {
mediaBrowser.externalServiceListener = object : ArmadilloMediaBrowse.ExternalServiceListener {
@@ -227,6 +230,7 @@ class PlaybackService : MediaBrowserServiceCompat() {
private inner class PlaybackServiceManager : ServiceManager {
override fun startService(audiobook: AudioPlayable, currentChapterIndex: Int) {
+ Log.v(TAG, "startService")
val token = sessionToken ?: throw MissingDataException("The session's token is missing. Can't begin service.")
if (!isInForeground) {
ContextCompat.startForegroundService(
@@ -241,6 +245,7 @@ class PlaybackService : MediaBrowserServiceCompat() {
}
override fun updateNotificationForPause(audiobook: AudioPlayable, currentChapterIndex: Int) {
+ Log.v(TAG, "updateNotification")
val token = sessionToken ?: throw MissingDataException("The session's token is missing. Cannot pause the notification.")
stopForeground(false)
val notification = playbackNotificationManager.getNotification(audiobook, currentChapterIndex, false, token)
@@ -249,11 +254,13 @@ class PlaybackService : MediaBrowserServiceCompat() {
}
override fun removeNotification() {
+ Log.v(TAG, "removeNotification")
stopForeground(true)
isNotificationShown = false
}
override fun stopService() {
+ Log.v(TAG, "stopService")
onStopService()
}
}
@@ -265,6 +272,7 @@ class PlaybackService : MediaBrowserServiceCompat() {
* here first. If so, we need to clear out the player
*/
private fun onStopService(stopPlayer: Boolean = true) {
+ Log.v(TAG, "onStopService")
playbackNotificationManager.notificationManager.cancel(notificationBuilder.notificationId)
if (stopPlayer) {
mediaSession.controller.transportControls.stop()
diff --git a/RELEASE.md b/RELEASE.md
index 087b9be..c481faa 100644
--- a/RELEASE.md
+++ b/RELEASE.md
@@ -1,5 +1,8 @@
# Project Armadillo Release Notes
+## 1.5.2
+ Fixes "Failed to Bind Service" issue introduced in 1.4, affecting MediaBrowser services.
+
## 1.5.1
- Adds DrmState to ArmadilloState, giving full visibility into DRM status to the client, including the expiration date for content.
- Splits SocketTimeout from HttpResponseCodeException, into ConnectivityException to better differentiate connectivity difficulties from
diff --git a/gradle.properties b/gradle.properties
index 29c7a00..b3c4f40 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -13,7 +13,7 @@ org.gradle.jvmargs=-Xmx1536m
# org.gradle.parallel=true
PACKAGE_NAME=com.scribd.armadillo
GRADLE_PLUGIN_VERSION=7.2.0
-LIBRARY_VERSION=1.5.1
+LIBRARY_VERSION=1.5.2
EXOPLAYER_VERSION=2.19.1
RXJAVA_VERSION=2.2.4
RXANDROID_VERSION=2.0.1