From a904f5c60d26403ffc034f0b9864b66febe004a9 Mon Sep 17 00:00:00 2001 From: Pauljd Date: Sun, 8 Nov 2026 13:33:03 +0000 Subject: [PATCH] Phones stay joined: Lax cookie and a kept token to put it back (0.110.2) Paul, 8 November 2026: the phone kept asking to join again on the same Wi-Fi. The TV never forgot it (two joins today); the phone arrived without its cookie. SameSite=Strict cookies are withheld when the page is opened from another app (a home-screen shortcut, the camera), so the cookie is now Lax; changes still need X-Orbit and an address as Host. The phone also keeps the token (handed over in the #fragment, never sent to the network again) and the join page quietly puts the cookie back via POST /rejoin; wrong tokens count as strikes. Co-Authored-By: Claude Opus 5.5 --- android/app/build.gradle.kts | 4 ++-- android/app/src/main/assets/phone/app.html | 3 +++ .../app/src/main/assets/phone/companion.html | 3 +++ .../main/java/tv/orbit/classic/EmbyClient.kt | 4 ++-- .../main/java/tv/orbit/classic/PhoneLink.kt | 22 ++++++++++++++++++- .../main/java/tv/orbit/classic/PhonePages.kt | 5 ++++- .../tv/orbit/classic/SecureMediaDataSource.kt | 2 +- .../java/tv/orbit/classic/PhoneLinkTest.kt | 7 ++++++ 8 files changed, 43 insertions(+), 7 deletions(-) diff --git a/android/app/build.gradle.kts b/android/app/build.gradle.kts index 38cb463a..f7a4ee40 100644 --- a/android/app/build.gradle.kts +++ b/android/app/build.gradle.kts @@ -9,8 +9,8 @@ android { applicationId = "tv.orbit.classic" minSdk = 26 targetSdk = 36 - versionCode = 276 - versionName = "0.110.1-features" + versionCode = 277 + versionName = "0.110.2-phone-remembered" } buildFeatures { compose = true } // The finished build for the TVs (Paul, 6 November 2026: the test build stuttered on the box). Not debuggable, so diff --git a/android/app/src/main/assets/phone/app.html b/android/app/src/main/assets/phone/app.html index 10f33a54..820fbcb7 100644 --- a/android/app/src/main/assets/phone/app.html +++ b/android/app/src/main/assets/phone/app.html @@ -14,6 +14,9 @@ button.wide{width:100%;padding:15px;font-size:18px}button:disabled{opacity:.5}in .bar div{max-width:480px;margin:0 auto}.note{color:var(--gold);margin:10px 0}.chosen li{margin:4px 0}.ok{color:var(--mint);font-size:13px}
""" fun join(note: String?) = """Orbit$STYLE

Orbit

Enter the code shown on the TV in Settings › Rooms and phones › Connect a phone.

${note?.let { "

${esc(it)}

" }.orEmpty()} -
""" +
$REJOIN""" fun pin(k: String?, code: String?, wrong: Boolean) = """Orbit$STYLE

Adult PIN

The code worked. Joining a phone is for adults, so now enter your Adult PIN: the four digits that unlock After Dark on the TV.

It isn't the code on the TV screen.

${if (wrong) "

That PIN didn't match. It's the After Dark PIN, not the TV's code.

" else ""} diff --git a/android/app/src/main/java/tv/orbit/classic/SecureMediaDataSource.kt b/android/app/src/main/java/tv/orbit/classic/SecureMediaDataSource.kt index 0699535c..90d788e9 100644 --- a/android/app/src/main/java/tv/orbit/classic/SecureMediaDataSource.kt +++ b/android/app/src/main/java/tv/orbit/classic/SecureMediaDataSource.kt @@ -39,7 +39,7 @@ internal class SecureMediaDataSource(private val session: EmbySampleSession) : B next.instanceFollowRedirects = false next.connectTimeout = 10_000 next.readTimeout = 20_000 - next.setRequestProperty("User-Agent", "OrbitTV/0.110.1") + next.setRequestProperty("User-Agent", "OrbitTV/0.110.2") next.setRequestProperty("Accept-Encoding", "identity") session.mediaHeaders(address).forEach { (key, value) -> next.setRequestProperty(key, value) } if (dataSpec.position != 0L || dataSpec.length != C.LENGTH_UNSET.toLong()) { diff --git a/android/app/src/test/java/tv/orbit/classic/PhoneLinkTest.kt b/android/app/src/test/java/tv/orbit/classic/PhoneLinkTest.kt index 87c902c0..8f37b89b 100644 --- a/android/app/src/test/java/tv/orbit/classic/PhoneLinkTest.kt +++ b/android/app/src/test/java/tv/orbit/classic/PhoneLinkTest.kt @@ -70,6 +70,13 @@ class PhoneLinkTest { assertEquals(302, joined.status); val cookie = joined.cookie!! assertEquals(1, phones.size); assertNull(PhoneLink.pairing) assertTrue(call("/join", "POST", "code=${p.code}", form = true).body.contains("run out")) // once only + // A phone that lost its cookie (8 November 2026) puts it back from the token it kept; nothing else gets in that way. + val token = cookie.substringAfter('=') + val back = call("/rejoin", "POST", token, cookie = null) + assertEquals(200, back.status); assertEquals(cookie, back.cookie) + assertEquals(403, call("/rejoin", "POST", "f".repeat(64)).status) + assertEquals(403, call("/rejoin", "POST", "not a token").status) + assertFalse(call("/rejoin", "POST", token, orbit = false).body.contains("joined")) // no X-Orbit: just the join page // The API, joined. assertEquals(0, JSONObject(call("/api/channels", cookie = cookie).body).getJSONArray("channels").length()) assertEquals("The X-Files", JSONArray(call("/api/suggest?d=90s%20sci-fi", cookie = cookie).body).getJSONObject(0).getString("title"))