music: catch ExecutionException from MediaController connect in PlaybackManager
- Commit
e3f13ff299bcc285615deb44ea972b8dab770c79- Author
- Vayun Mathur <[email protected]>
- When
- 2026-11-07 13:57 UTC (28 days ago)
- Parents
f7f860b
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.
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())