android auto: a catalog row is handed to the app, not failed at
Every entry in a streamed playlist is `kind='stream'` with no file on this phone — only a catalog id. A service-only process cannot turn that into audio: the resolver is hundreds of lines of shared JS that exist while a WebView does and not otherwise. So the car tapped those rows and nothing happened, which is the worst of the three possible answers. Now the process asks whether the APP can do it instead. Rust, finding nothing local, reports WHICH playlist and entry were meant rather than just failing — a catalog row is not a broken row, it is one this process cannot do alone, and that difference is what decides between an error and a hand-off. Kotlin carries it over `MediaHub.onRemote`, which is non-null only while the plugin is loaded, which is only while a WebView exists: the same fact is both the channel and the test for "is the app warm". And the JS plays it with `playFrom(playlist, items, item)` — the exact call the half-sheet makes when the same row is tapped in the app, so the queue, the provenance and the failure message are the app's own. Nothing about the car is special once it arrives. Cold, it says so instead of pretending: the focus is handed back rather than held for silence, and the log names the row. A phone in a pocket genuinely cannot play a Deezer id, and a tap that quietly does nothing is worse than one that stops. Two things the same change fixed on the way past. A streamed entry has no cover FILE, only a remote URL, so `COALESCE(art_path, art_url)` gives those rows their sleeves and a remote uri now goes to the host untouched instead of through a FileProvider whose root check it could never pass. And Recent, playlists and an artist's albums join Albums as GRIDS — all four are things known by the picture, which is what the grid is for. `probe.sh` gained `SS_KEEP=1`, without which the warm path cannot be tested at all: the script force-stops SoulStream, which is precisely the app the hand-off needs alive. **Proven:** cold answers `auto cold, cannot resolve` and releases focus; warm answers `auto hand-off to the app` and the event reaches the JS with no console error. **Not proven:** that the audio then starts. Those Deezer ids have to go through the resolver exactly as they do when tapped in the app, and if the app cannot play them the car will not either — which is correct behaviour and indistinguishable, from here, from a bridge that silently failed. It wants checking with the app in front of you.
This commit is contained in:
1 parent
54245a33b5
commit
8f46f9c663
8 files changed
+192
-9
No files matched your search
@@ -325,7 +325,10 @@ fn playlists(conn: &Connection) -> rusqlite::Result<Vec<Node>> {
|
||||
let mut stmt = conn.prepare(
|
||||
"SELECT p.id, p.name, COUNT(i.id),
|
||||
SUM(CASE WHEN i.kind = 'local' AND i.path IS NOT NULL THEN 1 ELSE 0 END),
|
||||
MAX(i.art_path)
|
||||
-- A streamed entry has no cover FILE, it has a remote URL.
|
||||
-- Auto fetches an https artwork uri itself, so the row gets a
|
||||
-- sleeve either way rather than a grey tile.
|
||||
COALESCE(MAX(i.art_path), MAX(i.art_url))
|
||||
FROM playlists p LEFT JOIN playlist_items i ON i.playlist_id = p.id
|
||||
GROUP BY p.id
|
||||
ORDER BY p.created_at DESC
|
||||
@@ -363,7 +366,7 @@ fn playlists(conn: &Connection) -> rusqlite::Result<Vec<Node>> {
|
||||
/// are shown rather than hidden so the list matches the phone's.
|
||||
fn playlist_items(conn: &Connection, playlist_id: i64) -> rusqlite::Result<Vec<Node>> {
|
||||
let mut stmt = conn.prepare(
|
||||
"SELECT id, title, artist, album, path, art_path, kind
|
||||
"SELECT id, title, artist, album, path, COALESCE(art_path, art_url), kind
|
||||
FROM playlist_items
|
||||
WHERE playlist_id = ?1
|
||||
ORDER BY position",
|
||||
@@ -753,6 +756,32 @@ pub extern "system" fn Java_com_soulstream_mediasession_AutoNative_search(
|
||||
.unwrap_or(std::ptr::null_mut())
|
||||
}
|
||||
|
||||
/// What a row would need the APP for, when it cannot play from here.
|
||||
///
|
||||
/// A playlist entry with `kind='stream'` has no file on this phone — only a
|
||||
/// catalog id — and turning that into audio is the resolver's job, which is
|
||||
/// hundreds of lines of shared JS that exist only while a WebView does. So
|
||||
/// this does not try. It reports WHICH playlist and entry were meant, and the
|
||||
/// warm path hands that to the app, which already knows how to play it.
|
||||
pub(crate) fn remote_ref(data_dir: &str, media_id: &str) -> Option<(i64, i64)> {
|
||||
let conn = open_read_only(&db_path(Path::new(data_dir))).ok()?;
|
||||
if let Some(id) = media_id.strip_prefix("ss:playlist:") {
|
||||
return Some((id.parse::<i64>().ok()?, 0));
|
||||
}
|
||||
if let Some(id) = media_id.strip_prefix("ss:pitem:") {
|
||||
let item = id.parse::<i64>().ok()?;
|
||||
let pl: i64 = conn
|
||||
.query_row(
|
||||
"SELECT playlist_id FROM playlist_items WHERE id = ?1",
|
||||
[item],
|
||||
|r| r.get(0),
|
||||
)
|
||||
.ok()?;
|
||||
return Some((pl, item));
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
/// `AutoNative.shuffle()` — reorder what is still ahead in the headless
|
||||
/// queue. Returns how many tracks were reordered, so the car can be told
|
||||
/// nothing happened rather than showing a button that silently does nothing.
|
||||
|
||||
@@ -346,11 +346,27 @@ fn notify_track(t: &PlayTrack, has_next: bool) {
|
||||
/// Returns the number of tracks queued; 0 means nothing playable was found,
|
||||
/// which the caller turns into an error state on the car rather than silence.
|
||||
pub fn play_media_id(data_dir: &str, media_id: &str) -> String {
|
||||
// Nothing local: say whether the APP could play it, and which row was
|
||||
// meant. A catalog entry is not a failure, it is a thing this process
|
||||
// cannot do — and the difference decides between an error on the car and
|
||||
// a hand-off to the phone.
|
||||
let needs_app = || -> String {
|
||||
match crate::auto_browse::remote_ref(data_dir, media_id) {
|
||||
Some((playlist, item)) => serde_json::json!({
|
||||
"queued": 0,
|
||||
"remote": true,
|
||||
"playlist": playlist,
|
||||
"item": item,
|
||||
})
|
||||
.to_string(),
|
||||
None => "{\"queued\":0}".to_owned(),
|
||||
}
|
||||
};
|
||||
let Some((items, idx)) = crate::auto_browse::resolve_playable(data_dir, media_id) else {
|
||||
return "{\"queued\":0}".to_owned();
|
||||
return needs_app();
|
||||
};
|
||||
if items.is_empty() {
|
||||
return "{\"queued\":0}".to_owned();
|
||||
return needs_app();
|
||||
}
|
||||
let n = items.len();
|
||||
let audio = audio(None);
|
||||
|
||||
Reference in new issue
Block a user