From 4a1730f7c8135b2dc367fe7a84751d717aaabc7c Mon Sep 17 00:00:00 2001 From: Hawk <28853569+WebF1yin@users.noreply.github.com> Date: Mon, 23 Nov 2026 11:33:23 -0800 Subject: [PATCH] Up next shows what's queued as soon as the media app connects, not only once the song changes Symfonium handed the controller Gearslip attached to it no queue at all, with 26 tracks queued, and sent them only when the song next changed, so Up next said nothing was queued until then. An app that attaches with no queue is now asked again a second and three seconds later, through the framework's view of its session and, failing that, the support library's. Co-Authored-By: Claude Opus 5.5 --- .../seb3thehacker/gearslip/media/CarMedia.kt | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/gearslip/src/main/java/app/seb3thehacker/gearslip/media/CarMedia.kt b/gearslip/src/main/java/app/seb3thehacker/gearslip/media/CarMedia.kt index 7cc0672..0354b65 100644 --- a/gearslip/src/main/java/app/seb3thehacker/gearslip/media/CarMedia.kt +++ b/gearslip/src/main/java/app/seb3thehacker/gearslip/media/CarMedia.kt @@ -257,6 +257,32 @@ class CarMedia(private val context: Context) { } }.onFailure { GearslipLog.w("media: no support-library view of the session: ${it.message}") }.getOrNull() refreshModes() + // Symfonium handed a controller attaching to it no queue at all, with 26 tracks queued, + // and sent them only when the song next changed: Up next stayed empty until then. + if (_queue.value.isEmpty()) { + QUEUE_RETRY_MS.forEach { wait -> main.postDelayed({ if (controller === c) askForQueue(c) }, wait) } + } + } + + /** The session's queue again, from the framework's view of it or else the support library's. */ + private fun askForQueue(c: MediaController) { + if (_queue.value.isNotEmpty()) return + val framework = queueOf(c.queue) + val tracks = framework.ifEmpty { + compat?.queue.orEmpty().map { item -> + val d = item.description + QueueTrack( + queueId = item.queueId, + title = d.title?.toString().orEmpty(), + subtitle = d.subtitle?.toString().orEmpty(), + iconUri = d.iconUri, + iconBitmap = d.iconBitmap, + ) + } + } + if (tracks.isEmpty()) return + GearslipLog.i("media: asked again, the queue has ${tracks.size} tracks (${if (framework.isEmpty()) "support library" else "framework"})") + _queue.value = tracks } private fun refreshModes() { @@ -267,6 +293,9 @@ class CarMedia(private val context: Context) { } _modes.value = modes } + /** When to ask an app that attached with no queue for it again. */ + private val QUEUE_RETRY_MS = listOf(1_000L, 3_000L) + private var subscribed: String? = null private var rootId: String? = null private val path = ArrayDeque>() // id to title