        return { owner: "com.soulstream.app", state: state[1] || "", position: state[2] ? +state[2] / 1000 : null };
    } catch { return { owner: "", state: "" }; }
}

/* The queue window the phone was last handed, as MediaSessionPlugin logged
 *  it. Round forty-six put a bounded slice of the queue into every card
 *  update — the current item and ten either side — and left MediaService
 *  ignoring all of it, so there is nothing on any screen to read it back
 *  from: logcat is the only place on the device it exists, one line per
 *  update, and the LAST line is the state now. `at=` is last in the line
 *  because a title may hold anything, spaces and `=` included. */
function mediaWindow() {
    try {
        const out = adb("logcat", "-d", "-s", "SoulStream:D").toString();
        const lines = out.split(/\r?\n/).filter((l) => l.includes("media window "));
        const m = (lines[lines.length - 1] || "").match(/media window n=(\d+) i=(-?\d+) art=(\d+) at=(.*)$/);
        if (!m) return { n: -1, i: -1, art: -1, at: "", lines: lines.length };
        return { n: +m[1], i: +m[2], art: +m[3], at: m[4].trim(), lines: lines.length };
    } catch (e) { return { n: -1, i: -1, art: -1, at: "ERR " + e.message, lines: 0 }; }
}