Household and Play editions, one version-code counter (build 40: 400 household, 402 Play)
pauljd/davidson-ci: Davidson CI / quality (push) Failing after 3m38s
release-gate / verify (push) Successful in 11m53s
pauljd/davidson-ci: Davidson CI / ai-review (push) Failing after 2m50s

Both editions are tv.orbit.classic. The Play edition has no room updater, no
PackageInstaller, no REQUEST_INSTALL_PACKAGES, no adb install check and no
adb test hooks; Google Play updates it. The household edition keeps all of
them. Release builds and the Play bundle are unsigned until signing is
approved. The release gate builds both editions and the bundle, tests both,
and checks what was built: ids, codes above every earlier one (the reserved
390 included), Play isolation, household intact, nothing signed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-10 09:49:38 +00:00
co-authored by Claude Opus 5.5
parent 1f1f78b668
commit 11af81c859
19 changed files with 302 additions and 70 deletions
@@ -1,83 +0,0 @@
package tv.orbit.classic
import org.junit.Assert.*
import org.junit.Rule
import org.junit.Test
import org.junit.rules.TemporaryFolder
import java.io.File
import java.security.MessageDigest
/** 8 November 2026 (audit U12): a pulled snapshot can be put back, only deliberately, only checked, keeping what was there. */
class InstallRestoreTest {
@get:Rule val tmp = TemporaryFolder()
private fun sha(f: File) = MessageDigest.getInstance("SHA-256").digest(f.readBytes()).joinToString("") { "%02x".format(it) }
private fun put(root: File, path: String, text: String) = File(root, path).apply { parentFile.mkdirs(); writeText(text) }
private fun manifest(src: File, paths: List<String>) = File(src, "restore.txt").writeText(paths.joinToString("") { "${sha(File(src, it))} $it\n" })
private fun box(): Pair<File, File> {
val data = tmp.newFolder("data"); val src = tmp.newFolder("src")
put(data, "no_backup/schedule/booked-0.json", "now"); put(data, "no_backup/schedule/only-now.json", "x")
put(data, "shared_prefs/orbit_profiles.xml", "<now/>"); put(data, "no_backup/catalogue.db", "library")
put(src, "no_backup/schedule/booked-0.json", "then"); put(src, "no_backup/schedule/taste/grown.events.jsonl", "{}\n")
put(src, "shared_prefs/orbit_profiles.xml", "<then/>")
return data to src
}
@Test fun putsTheSnapshotBackAndKeepsWhatWasThere() {
val (data, src) = box()
manifest(src, listOf("no_backup/schedule/booked-0.json", "no_backup/schedule/taste/grown.events.jsonl", "shared_prefs/orbit_profiles.xml"))
val said = InstallRestore.apply(data, src, "RESTORE", 1000L)
assertEquals("restored 3; aside before-restore-1000", said)
assertEquals("then", File(data, "no_backup/schedule/booked-0.json").readText())
assertEquals("{}\n", File(data, "no_backup/schedule/taste/grown.events.jsonl").readText())
assertFalse(File(data, "no_backup/schedule/only-now.json").exists())
assertEquals("<then/>", File(data, "shared_prefs/orbit_profiles.xml").readText())
// What was there, kept aside; the library untouched; nothing half-done left behind.
assertEquals("now", File(data, "no_backup/before-restore-1000/schedule/booked-0.json").readText())
assertEquals("<now/>", File(data, "no_backup/before-restore-1000/shared_prefs/orbit_profiles.xml").readText())
assertEquals("library", File(data, "no_backup/catalogue.db").readText())
assertFalse(File(data, "no_backup/schedule.restoring").exists()); assertFalse(File(data, "no_backup/schedule.replaced").exists())
}
@Test fun nothingChangesWithoutConfirmOrWithABadChecksum() {
val (data, src) = box()
manifest(src, listOf("no_backup/schedule/booked-0.json"))
assertTrue(InstallRestore.apply(data, src, null, 1L).startsWith("refused"))
File(src, "no_backup/schedule/booked-0.json").writeText("tampered")
assertTrue(InstallRestore.apply(data, src, "RESTORE", 1L).startsWith("refused: checksum"))
assertEquals("now", File(data, "no_backup/schedule/booked-0.json").readText())
assertFalse(File(data, "no_backup/before-restore-1").exists())
}
@Test fun onlyWhatASnapshotTakesCanComeBack() {
val (data, src) = box()
put(src, "no_backup/catalogue.db", "other library"); put(src, "shared_prefs/orbit_lock.xml", "<pin/>")
for (bad in listOf("no_backup/catalogue.db", "shared_prefs/orbit_lock.xml", "no_backup/schedule/../catalogue.db", "no_backup/orbit-connection.v1")) {
File(src, "restore.txt").writeText("${"0".repeat(64)} $bad\n")
assertTrue(bad, InstallRestore.apply(data, src, "RESTORE", 1L).startsWith("refused"))
}
assertEquals("library", File(data, "no_backup/catalogue.db").readText())
}
@Test fun keepsOnlyTheLastTwoSetAsides() {
val (data, src) = box()
manifest(src, listOf("no_backup/schedule/booked-0.json"))
for (t in 1L..4L) InstallRestore.apply(data, src, "RESTORE", t)
assertEquals(listOf("before-restore-3", "before-restore-4"), File(data, "no_backup").list()!!.filter { it.startsWith("before-restore-") }.sorted())
}
@Test fun aZipFromThePcIsUnpackedAndRestored() {
val (data, src) = box()
manifest(src, listOf("no_backup/schedule/booked-0.json", "shared_prefs/orbit_profiles.xml"))
val folder = tmp.newFolder("pushed")
java.util.zip.ZipOutputStream(File(folder, "restore.zip").outputStream()).use { z ->
for (n in listOf("no_backup/schedule/booked-0.json", "shared_prefs/orbit_profiles.xml", "restore.txt")) { z.putNextEntry(java.util.zip.ZipEntry(n)); z.write(File(src, n).readBytes()); z.closeEntry() }
}
assertTrue(InstallRestore.apply(data, folder, "RESTORE", 5L).startsWith("restored 2"))
assertEquals("then", File(data, "no_backup/schedule/booked-0.json").readText())
}
@Test fun aZipCantWriteOutsideTheSnapshot() {
val (data, _) = box()
val folder = tmp.newFolder("evil")
java.util.zip.ZipOutputStream(File(folder, "restore.zip").outputStream()).use { z -> z.putNextEntry(java.util.zip.ZipEntry("../../no_backup/catalogue.db")); z.write("x".toByteArray()); z.closeEntry() }
assertTrue(InstallRestore.apply(data, folder, "RESTORE", 5L).startsWith("refused"))
assertEquals("library", File(data, "no_backup/catalogue.db").readText())
}
}
@@ -1,30 +0,0 @@
package tv.orbit.classic
import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
import org.junit.Test
class PlaybackTestTest {
@Test fun labelsAreShortAndSafe() {
assertEquals("text/x-ssa", playTestLabel("text/x-ssa"))
assertEquals("jpn", playTestLabel("jpn"))
assertEquals("unknown", playTestLabel(null))
for (hostile in listOf("https://host/stream?api_key=SECRET", "/mnt/media/Beerus.mkv", "media/anime/Beerus.mkv", "Japanese (Crunchyroll)", "a".repeat(41))) assertEquals("unknown", playTestLabel(hostile))
}
@Test fun theSummaryHoldsFormatsAndCountsOnly() {
val record = PlaybackTestRecord().apply {
ready = true; firstFrame = true; video = "video/avc 1920x1080"; audio = "audio/mp4a-latm jpn 2ch"
subtitles = listOf("text/x-ssa eng selected", "text/x-ssa por"); subtitleSelected = "eng"; cueUpdates = 41; firstCueMs = 12_345
}
assertEquals("playtest result ready=true firstFrame=true video=video/avc 1920x1080 audio=audio/mp4a-latm jpn 2ch subtitles=2[text/x-ssa eng selected, text/x-ssa por]" +
" subtitleSelected=eng cueUpdates=41 firstCuePositionMs=12345 errors=0", record.summary())
assertFalse(PlaybackTestRecord().summary().contains("null"))
}
@Test fun englishIsChosenTheWayOrbitChoosesIt() {
// The test asks for subtitles as Orbit's setting does: English where there is some, whatever the track order.
assertEquals(2, subtitleFor(SUBTITLES_BY_DEFAULT, listOf("por", "spa", "eng")))
assertEquals(null, subtitleFor(null, listOf("eng")))
}
}
@@ -1,56 +0,0 @@
package tv.orbit.classic
import android.content.pm.PackageInfo
import org.json.JSONObject
import org.junit.Assert.*
import org.junit.Rule
import org.junit.Test
import org.junit.rules.TemporaryFolder
import java.net.InetAddress
/** Updates shared between rooms (Paul, 6 November 2026): only a newer Orbit, signed as this one is, and only when asked. */
class RoomUpdatesTest {
@get:Rule val folder = TemporaryFolder()
@Test fun onlyANewerVersionIsOfferedAndNotNowSticks() {
val answer = JSONObject().put("code", 220).put("name", "0.108.60-x")
assertEquals(220L, offerFrom("Living Room", "192.168.0.252", answer, 216, emptySet())!!.code)
assertNull(offerFrom("Living Room", "192.168.0.252", answer, 220, emptySet())) // the same version
assertNull(offerFrom("Living Room", "192.168.0.252", answer, 230, emptySet())) // older than this one
assertNull(offerFrom("Living Room", "192.168.0.252", answer, 216, setOf(220L))) // turned down this time
assertEquals("0.108.60", shortVersion("0.108.60-x"))
}
@Suppress("DEPRECATION")
private fun info(name: String, code: Int) = PackageInfo().apply { packageName = name; versionCode = code }
@Test fun theDownloadMustBeNewerOrbitSignedTheSameWay() {
val installed = info("tv.orbit.classic", 216)
fun signers(same: Boolean): (PackageInfo) -> Set<String> = { p -> if (p === installed || same) setOf("abc") else setOf("xyz") }
assertNull(acceptableUpdate(info("tv.orbit.classic", 217), installed, signers(true)))
assertNotNull(acceptableUpdate(info("tv.orbit.classic", 217), installed, signers(false))) // another key: refused
assertNotNull(acceptableUpdate(info("tv.orbit.classic", 216), installed, signers(true))) // not newer
assertNotNull(acceptableUpdate(info("com.example.other", 300), installed, signers(true))) // another app
assertNotNull(acceptableUpdate(null, installed, signers(true)))
}
@Test fun theOtherRoomServesItsVersionAndCopyOnlyWhileShared() {
PhoneLink.initForTest(object : PhoneStore {
override fun all() = emptyMap<String, String>(); override fun get(id: String): String? = null
override fun put(id: String, value: String) {}; override fun remove(id: String) {} })
PhoneLink.bindTo = InetAddress.getLoopbackAddress(); PhoneLink.port = 18_099; PhoneLink.allowed = { it.isLoopbackAddress }
val apk = folder.newFile("orbit.apk").apply { writeBytes(ByteArray(300_000) { (it % 251).toByte() }) }
fun get(path: String): Pair<Int, ByteArray> {
val c = java.net.URL("http://127.0.0.1:18099$path").openConnection() as java.net.HttpURLConnection
val s = c.responseCode; return s to ((if (s < 400) c.inputStream else c.errorStream)?.use { it.readBytes() } ?: ByteArray(0))
}
try {
PhoneLink.shared = SharedBuild(220, "0.108.60-x", apk); PhoneLink.listening = true
val (status, body) = get("/room/version")
assertEquals(200, status); assertEquals(220L, JSONObject(String(body)).getLong("code"))
assertArrayEquals(apk.readBytes(), get("/room/orbit.apk").second)
PhoneLink.shared = null
assertEquals(404, get("/room/version").first); assertEquals(404, get("/room/orbit.apk").first)
} finally { PhoneLink.listening = false; PhoneLink.stop(); PhoneLink.allowed = EmbyServer::isHomeAddress; PhoneLink.bindTo = null; PhoneLink.port = PhoneLink.PORT }
}
}