diff --git a/android/app/src/household/java/tv/orbit/classic/Edition.kt b/android/app/src/household/java/tv/orbit/classic/Edition.kt index 4a331e84..55e96b75 100644 --- a/android/app/src/household/java/tv/orbit/classic/Edition.kt +++ b/android/app/src/household/java/tv/orbit/classic/Edition.kt @@ -54,6 +54,39 @@ internal object Edition { suspend fun lookForUpdate(context: Context) = RoomUpdates.look(context) + /** + * The soak test's diary (1.0 RC3, Paul, 13 November 2026: the box's own log keeps only minutes during playback, and the + * server's log can't tell the two TVs apart). Every five minutes, Orbit's own scheduling and player lines since the last + * pass are added to orbit-diary.txt in its folder, and the request counts are written to server-requests.json, for adb to + * pull. Timings, channel numbers and library ids only: no titles, no addresses, nothing sent anywhere. Kept under 2 MB. + */ + fun startDiary(activity: Activity) { + val dir = activity.getExternalFilesDir(null) ?: return + if (diaryRunning) return + diaryRunning = true + Thread({ + var since = "" + while (true) { + runCatching { + val pid = android.os.Process.myPid().toString() + val lines = ProcessBuilder("logcat", "-d", "-v", "time", "--pid=$pid", "-s", "OrbitSchedule:I", "OrbitPlayer:I", "OrbitStartup:I", "OrbitRooms:I", "OrbitRequests:I") + .redirectErrorStream(true).start().inputStream.bufferedReader().readLines() + .filter { it.length > 18 && it[2] == '-' } + val fresh = if (since.isEmpty()) lines else lines.dropWhile { it.take(18) <= since } + if (fresh.isNotEmpty()) { + since = fresh.last().take(18) + val out = java.io.File(dir, "orbit-diary.txt") + if (out.length() > 2_000_000L) out.renameTo(java.io.File(dir, "orbit-diary-1.txt")) + out.appendText(fresh.joinToString("\n", postfix = "\n")) + } + writeSafely(java.io.File(dir, "server-requests.json"), ServerRequests.summary().toString(2)) + } + Thread.sleep(5 * 60_000L) + } + }, "orbit-diary").apply { isDaemon = true; priority = Thread.MIN_PRIORITY }.start() + } + @Volatile private var diaryRunning = false + fun sharedBuild(context: Context): SharedBuild? = RoomUpdates.shared(context) @Composable fun UpdateCard() = RoomUpdateCard() diff --git a/android/app/src/main/java/tv/orbit/classic/MainActivity.kt b/android/app/src/main/java/tv/orbit/classic/MainActivity.kt index c06035f0..7eb1d35c 100644 --- a/android/app/src/main/java/tv/orbit/classic/MainActivity.kt +++ b/android/app/src/main/java/tv/orbit/classic/MainActivity.kt @@ -57,6 +57,7 @@ class MainActivity : ComponentActivity() { RoomBeacon.on(this) // Updates shared between rooms: a newer Orbit in another room is offered, with Install? and Not now. lifecycleScope.launch { runCatching { Edition.lookForUpdate(this@MainActivity) } } + Edition.startDiary(this) } } // Phones stay connected while Orbit is in the background (Paul, 8 November 2026: the web app couldn't connect while the TV diff --git a/android/app/src/play/java/tv/orbit/classic/Edition.kt b/android/app/src/play/java/tv/orbit/classic/Edition.kt index 21ae1fd9..cc5308a8 100644 --- a/android/app/src/play/java/tv/orbit/classic/Edition.kt +++ b/android/app/src/play/java/tv/orbit/classic/Edition.kt @@ -17,6 +17,8 @@ internal object Edition { fun readAdbRequests(activity: Activity, intent: Intent?) {} fun openPlaybackTest(activity: Activity, intent: Intent?) {} suspend fun lookForUpdate(context: Context) {} + /** The household soak diary isn't part of the Play edition. */ + fun startDiary(activity: android.app.Activity) {} fun sharedBuild(context: Context): SharedBuild? = null @Composable fun UpdateCard() {} /** Never answers the update routes: another room asking gets the usual "not found". */