music: catch ExecutionException from MediaController connect in PlaybackManager
- Commit
698716b90a32432d987540819b3b25447f73be80- Author
- Vayun Mathur <[email protected]>
- When
- 2026-11-07 13:37 UTC (29 days ago)
- Parents
adabd0f
The controller future's listener caught IllegalStateException and SecurityException, but a refused session connection completes the future with ExecutionException. That escaped the listener as an uncaught exception on the main thread. Catch ExecutionException with the same log, and InterruptedException with the interrupt restored. Kept separate from the pass-3 test commit. (cherry picked from commit 954f65ada73c581082dc9b060105ba23c7333aec)
Diff
music/src/main/java/com/vayunmathur/music/platform/PlaybackManager.kt
diff --git a/music/src/main/java/com/vayunmathur/music/platform/PlaybackManager.kt b/music/src/main/java/com/vayunmathur/music/platform/PlaybackManager.ktindex a9b707aec1..5a7e453414 100644--- a/music/src/main/java/com/vayunmathur/music/platform/PlaybackManager.kt+++ b/music/src/main/java/com/vayunmathur/music/platform/PlaybackManager.kt@@ -124,6 +124,14 @@ class PlaybackManager private constructor(context: Context) { Log.error("PlaybackManager", "Error initializing MediaController", e) } catch (e: SecurityException) { Log.error("PlaybackManager", "Error initializing MediaController", e)+ } catch (e: java.util.concurrent.ExecutionException) {+ // A refused session connection surfaces here, not as one of+ // the types above: without this catch the failure escaped+ // the listener as an uncaught exception on the main thread.+ Log.error("PlaybackManager", "Error initializing MediaController", e)+ } catch (e: InterruptedException) {+ Thread.currentThread().interrupt()+ Log.error("PlaybackManager", "Error initializing MediaController", e) } }, MoreExecutors.directExecutor())