fix(android): UPnP select - loud logs on every code path
android / Build + lint + test (push) Has been cancelled

Two silent early returns in selectUpnp were swallowing the most
likely failure modes:
  - currentTrack null (nothing playing locally → can't cast a track)
  - transportFor() returns null (route disappeared or id mismatch)

On-device verification reported 'tap collapses the sheet but no
audio routes', with logcat empty - one of these was firing without
any signal.

Each early-return now Timber.w's why; the runCatching block adds
Timber.i breadcrumbs at every step (mint token, SetAVTransportURI,
Play, done) so the next failure shows exactly how far we got.
This commit is contained in:
2026-06-03 14:59:57 -04:00
parent 036da9dea8
commit 96f12d6aac
@@ -178,13 +178,28 @@ class OutputPickerController @Inject constructor(
* deserialize / SOAP-parse code paths).
*/
private suspend fun selectUpnp(route: OutputRoute) {
val trackId = playerController.uiState.value.currentTrack?.id ?: return
val transport = upnpDiscovery.transportFor(route.id) ?: return
val trackId = playerController.uiState.value.currentTrack?.id
if (trackId == null) {
Timber.w("UPnP select skipped: no currentTrack (start playback first)")
return
}
val transport = upnpDiscovery.transportFor(route.id)
if (transport == null) {
Timber.w(
"UPnP select skipped: no transport for route id=${route.id} " +
"(route disappeared or id mismatch with discovery list)",
)
return
}
runCatching {
Timber.i("UPnP select: mint token for track=$trackId, route=${route.name}")
val token = castApi.streamToken(StreamTokenRequest(trackId = trackId))
Timber.i("UPnP select: SetAVTransportURI to ${token.url}")
transport.setAVTransportURI(token.url)
Timber.i("UPnP select: Play")
transport.play()
playerController.pause()
Timber.i("UPnP select: done")
}.onFailure { e ->
Timber.w(e, "UPnP select failed for route ${route.id}")
}