Skip to content

feat(app): Android Auto station list - #16

Merged
perminder-klair merged 3 commits into
mainfrom
feat/android-auto
Nov 27, 2026
Merged

perminder-klair merged 3 commits into
mainfrom
feat/android-auto

Conversation

@perminder-klair

@perminder-klair perminder-klair commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Ported from perminder-klair/subwave#2136. On main, after the Siri/Shortcuts PR (#14, cf3e429). Ported as one commit, so the Gradle output the old first commit tracked by mistake is gone. CLAUDE.md, docs/TESTING.md and service.ts conflicted: service.ts keeps remotePlay next to the new remote-play-id/-search listeners, and the old "Android Auto is intentionally not declared" note is replaced.

Summary

SUB/WAVE in Android Auto: the saved stations as a list, a tap tunes in, then Auto's own Now Playing with play and pause. "Hey Google, play Night Shift on SUB/WAVE" picks a station by name. The browse session is the player's own, so Now Playing and the controls are the lock screen's.

car binds SubwaveBrowseService                      # modules/android-auto
  no player session yet?
    start React Native, run SubwaveCarConnect       # src/intents/car.ts
      setupPlayer()                                 # set up only, no autoplay
        MediaBrowserBridge.attach                   # RNTP patch
          session token → browse service → car connects
  onLoadChildren → saved stations (JS-mirrored, names + bases only)

tap a station / voice search
  player session → PlaybackPreparer                 # RNTP patch
    remote-play-id {id} / remote-play-search {query}
      service.ts → tuneIn(id) / tuneInByName(query) # src/intents/tune.ts, as Siri
        tune-flow: player mounted? handed to it (StreamRecovery), else a direct load
      prepare only (playWhenReady false)?          # src/intents/car-picks.ts
        held until the next Play, never played
  • Who gets a root: the car, the Assistant and the system only (CarCallers, after Google's media sample's PackageValidator). The service is exported, so any other app would otherwise read the saved stations' hosts and start the player in the background.
  • System UI's resume-after-reboot query is refused (EXTRA_RECENT → no root): a live station has nothing to resume, and answering would start the app in the background on every boot.
  • A spoken name that matches nothing plays the station listened to last, as Siri does. A generic word ("play radio") names no station, so it lands there too.
  • A session restart: MusicService going clears the bridge's token. A browse service that already published the dead one answers no root until its clients unbind, because MediaBrowserServiceCompat takes a token once; the car's next bind gets a fresh service.
  • A failed pick (not saved, a load error) is a line in the playback log.
  • With the phone app open, a pick goes through the mounted player like any listener's load, via feat(app): Siri, Shortcuts, Control Center and Spotlight for the iOS app #14's tune-flow.ts (playOnMountedPlayer, or tuneInOnArrival for another station), never a direct load beside StreamRecovery. tuneInByName sits in tune-flow.ts too.

The RNTP patch, in three parts:

 MusicService.setupPlayer
+  MediaBrowserBridge.attach(notificationManager)   # preparer + publish session token
 MusicService.onDestroy
+  MediaBrowserBridge.detach()                      # the token dies with the session
 MusicModule.setupPlayer
-  reject if no activity in front
+  reject if no activity in front and no media browser bound
+  a refused background start rejects instead of crashing

Evidence

  • ./gradlew :app:assembleDebug (JDK 17): BUILD SUCCESSFUL. The merged manifest has SubwaveBrowseService (android.media.browse.MediaBrowserService) and the com.google.android.gms.car.application meta-data.
  • npm run lint: no errors (one existing warning in onboarding.tsx); npm test 587 pass, 5 skipped, 0 fail, with new cases for spoken station names ("chill wave radio" → ChillWave Radio, generic words like "radio" match nothing, an exact name beats a partial), a prepare held until Play, car picks by id, by voice and from a prepared Play reaching the mounted player, failures logged, and drift checks for the SubwaveCarConnect task name and matchStations' generic words against Kotlin and Swift.
  • The masked-view manifest was restored after the local build, so the Android fingerprint is unchanged.
  • Not run yet: nothing has been on a phone, the Desktop Head Unit or a car. The riskiest path is a cold start from the car: Android has to allow the player's foreground service while Auto is bound. If it refuses, setupPlayer rejects instead of crashing, and the car shows no session. The checklist is in docs/TESTING.md → Android Auto, now with a session-restart check and a release build (the bridge reads KotlinAudio by reflection). That's why this is a draft.

Merge Danger

Door: one-way at Play review, two-way in code

Play enforced against a manifest-only Auto declaration in June (perminder-klair/subwave#477) because the DJ is TTS readout; a production build with this goes through Auto review again. That's a deliberate second attempt. In code, removing modules/android-auto and the patch hunks reverts it.

Blast Radius: every Android listener

The patch changes paths every Android session uses: the session gains a PlaybackPreparer (Play on an idle player still just prepares, as the connector did without one), and setupPlayer registers its event receiver after the service start instead of before. iOS gets JS only: two service.ts listeners that never fire there and a no-op station mirror. Native, so it ships in a new binary, not over the air.

…, prepare

- MediaBrowserBridge clears its token when MusicService is destroyed and
  tells browse services through a ready/ended listener; a browse service
  still holding a released session's token (MediaBrowserServiceCompat takes
  one) answers no root, so the car's next bind gets a fresh one.
- SubwaveBrowseService gives a root only to the car, the Assistant and the
  system (CarCallers, after Google's media sample's PackageValidator).
- A prepare (playWhenReady false) no longer plays: the patch passes the flag
  and src/intents/car-picks.ts holds the pick until the next Play.
- A refused or failed car pick is a plog line instead of a swallowed error.
- npm test checks the car-connect task name and matchStations' generic words
  and shortest term against their native twins.
- TESTING.md: the bridge and the background-setup bypass in the
  architecture-critical section; a session-restart and release-build check in
  the Android Auto checklist.
A pick from the car's list, a voice search and a prepared pick's Play all
tune in through tune-flow.ts, as Siri's do: handed to the mounted player, and
so to StreamRecovery, whenever one is mounted, and loaded directly only with
none (tuneInByName sits in tune-flow since the rebase onto the fixed #14).
TESTING.md's Android Auto check now covers a pick with the phone app open;
CLAUDE.md names the car beside the App Intents.
@perminder-klair
perminder-klair changed the base branch from feat/ios-intents to main November 27, 2026 18:38
@perminder-klair
perminder-klair marked this pull request as ready for review November 27, 2026 18:39
@perminder-klair
perminder-klair merged commit 967d0bd into main Nov 27, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant