music: fix car browse screen crash from titled play-all FAB
- Commit
a38c79c0e7d0df05fbc7e6b0e615822866085c24- Author
- Vayun Mathur <[email protected]>
- When
- 2026-11-01 05:53 UTC (1 month ago)
- Parents
a45dbf6
Opening Music on the car display (DHU via the auto host) crashed the
app every time the host fetched its browse template:
IllegalArgumentException: Action list exceeded max number of 0
actions with custom titles
at ActionsConstraints.validateOrThrow
at MusicCarBrowseScreen.onGetTemplate
playAllAction() built the header/FAB action with setTitle("Play") and
no icon. Car App Library FAB constraints allow zero custom-titled
actions and require an icon. The sectioned path wrapped the failure in
runCatching, but the ListTemplate fallback did not, so onGetTemplate
threw and the process died, then rebound and crashed again.
The play-all action is now icon-only, using a new ic_car_play vector
drawable (Material play_arrow path, white fill so the host can tint).
Verified on a Pixel 9 Pro XL with the DHU: Music binds, completes the
car-app handshake and serves templates with no FATAL EXCEPTION or
getTemplate failure. :music compile and lint pass.Diff
music/src/main/java/com/vayunmathur/music/service/car/MusicCarBrowseScreen.kt
diff --git a/music/src/main/java/com/vayunmathur/music/service/car/MusicCarBrowseScreen.kt b/music/src/main/java/com/vayunmathur/music/service/car/MusicCarBrowseScreen.ktindex 280ccec1c8..828aee1386 100644--- a/music/src/main/java/com/vayunmathur/music/service/car/MusicCarBrowseScreen.kt+++ b/music/src/main/java/com/vayunmathur/music/service/car/MusicCarBrowseScreen.kt@@ -265,7 +265,7 @@ class MusicCarBrowseScreen( row.build() } - /** Single FAB: Play-all (media apps get max 1 on API 9+ hosts). */+ /** Single FAB: Play-all. Media FABs must be icon-only (0 custom titles allowed). */ @Suppress("DEPRECATION") private fun playAllAction(): Action? { val items = state.tree.children(nodeId)@@ -273,7 +273,7 @@ class MusicCarBrowseScreen( return null } return Action.Builder()- .setTitle("Play")+ .setIcon(CarIcon.Builder(IconCompat.createWithResource(carContext, R.drawable.ic_car_play)).build()) .setOnClickListener { playAll(items.map { it.mediaId }) } .build() }
music/src/main/res/drawable/ic_car_play.xml
diff --git a/music/src/main/res/drawable/ic_car_play.xml b/music/src/main/res/drawable/ic_car_play.xmlnew file mode 100644index 0000000000..186c1a6ace--- /dev/null+++ b/music/src/main/res/drawable/ic_car_play.xml@@ -0,0 +1,9 @@+<vector xmlns:android="http://schemas.android.com/apk/res/android"+ android:width="24dp"+ android:height="24dp"+ android:viewportWidth="24"+ android:viewportHeight="24">+ <path+ android:fillColor="#FFFFFFFF"+ android:pathData="M8,5.14V19.14L19,12.14L8,5.14Z" />+</vector>