WP-145: Beta games appear in the TV library: Get and Update tiles

Status: ✅ Done (2026-12-05), every exit criterion met. Fork PR barefootbetters/scummvm#80 merged (1dfbfb7375), private PR barefootbetters/scooby-engine-private#109 merged (67c256a), docs #391. Drafted as WP-143 (#376); renumbered because #375 claimed WP-143 first. Phase: 5 (polish & distribution). Depends on:

Unblocks: outside testers. Today a game reaches a tester only if they know the hidden key gesture and press LOAD MANIFEST. Companion: Publish-BetaGame.ps1, the publishing half, merged in the private repo (barefootbetters/scooby-engine-private#102). Placement: WP-144 (drafted the same day) puts TV-app work on a fork classics branch and in a private Classics repo. If its split lands before this WP starts, the fork work below targets classics instead of scooby-engine, and this WP moves to the Classics repo. Companion EC: none (inline checklist under Exit criteria). Pre-flight: required. The change touches shared gui/ code and backends/platform/android/. Targets generation(s): any format-1 package; proven with the Gen 1 packages and BASS. Estimated effort: two to three days.


Goal

Make publishing a game enough for it to reach the testers. When the test build starts, it reads the tester’s beta manifest in the background. Each game the manifest lists that isn’t installed shows in the library as a tile with its cover and a Get band. Choosing it installs the game, and the tile becomes a normal playable one. An installed game whose package has a newer version in the manifest shows Update.

Background

The fork map (2026-12-03) was taken at origin/scooby-engine b59ea35fd8. Since WP-137’s merge c1f2825762, only engines/terraglyph/** has changed. That matches the TV’s build 26041074 by file hash.

Scope

In scope

  1. Two new optional manifest fields: engineid and gameid.
    • Documented in tv-package-manifest.md.
    • Carried by the runtime file lists (tools/packages/*.json), so New-GamePackage.ps1 and Publish-BetaGame.ps1 write them.
    • Added to BASS’s live entry by hand (sky/sky).
  2. A launch-time fetch (Java, advanced/ only).
    • A new TestFeatures hook, called from ScummVMActivity.onCreate next to beforeScummVMStart (:1242), starts a background fetch of the stored manifest URL. It never blocks the start.
    • On success it writes packages/available.json atomically, with the existing writeJson. That file is the manifest entries with engineid/gameid, each marked get or update against installed.json using compareVersions, without URLs.
    • On a 404 (key revoked or expired) it deletes the file. On a network failure it keeps the last good copy.
    • The release stub does nothing.
  3. Get tiles in the grid (C++).
    • GridItemInfo gains a kind: installed, get or update.
    • LauncherGrid::updateListing reads available.json if it exists and appends a get tile per entry, with _domains kept index-aligned. It also marks installed tiles update by matching each target’s path to packages/<id>/.
    • Without the file, nothing changes: every non-Android build, and release.
    • drawWidget draws the band as Get or Update instead of Play.
    • Get tiles group with WP-138’s metadata through their engineid/gameid.
  4. Choosing a Get tile installs (C++ → Java).
    • A new JNI call, installPackage(id), follows the setCurrentGame recipe and opens the package store on a one-package install screen. That screen shows the title, a progress bar (“MB of MB”, then “Extracting”) and Cancel.
    • It reuses fetch → pending add → restart, which brings the library back with the game playable.
    • Progress gains numeric progress (bytes done and total) for the bar; the text form stays.
    • Selecting the tile or pressing OK on it goes straight to install. A get tile has no Saves or Edit, so it gets no tray.
  5. Update on installed tiles. The tray of an installed game whose package has an update gets an Update button, which calls the same JNI with the package id and keeps the saves (the existing update semantics).
  6. The library notices a fetch that finishes after it’s shown. The launcher dialog checks available.json’s modified time on its tickle and re-lists when the file changes. That’s one stat a second, and it needs no JNI.
  7. Tiles only for playable entries. An entry without engineid/gameid gets no tile. That keeps the neg-* test entries and anything malformed in the hidden screen only.

Out of scope

Decisions

  1. A new tile kind, not fake ConfMan domains. A fake domain would persist in scummvm.ini, collide with --add’s target naming, and let Edit, Saves or Start act on a game that isn’t there.
  2. The install runs on a focused Java screen, not on the tile. The store, its resume and its restart are Java. Drawing progress inside the C++ grid would mean pushing download state across JNI for little gain on a TV. Jeff’s “tile progress” becomes a full-screen install view opened from the tile. Open for Jeff: keep this, or ask for in-tile progress.
  3. Java hands off to C++ through a file plus a tickle check, not a new Java → C++ call. This follows the package store’s existing pattern (files and restart arguments). It adds one C++ → Java call (installPackage) because a tile choice has to reach the store.
  4. engineid and gameid come from the file lists. The publisher knows the game when it builds the package, and one list per edition already exists. BASS, not built from a disc, gets them by hand.
  5. A revoked key hides the Get tiles. It never removes installed games.

Execution

  1. Pre-flight. Write pre-flight-WP-145-<date>.md: a fork worktree from origin/scooby-engine via tools/New-ForkWorktree.ps1 (not the stale C:\dev\scummvm checkout), the shared gui/ files touched, and the release-check baseline.
  2. Manifest fields. Update tv-package-manifest.md, the two Gen 1 lists, New-GamePackage.ps1, then Publish-BetaGame.ps1 (private), and BASS’s live entry. Today Publish-BetaGame.ps1 compares only the zip’s SHA-256, so on Phantom it would report “already published” and leave the new fields out. Give it a metadata-only path that updates the entry, same version and same zip, and republishes the manifest. Re-running it on Showdown and Phantom then adds their fields.
  3. Java: the fetch hook, available.json, the installPackage screen, numeric progress, and the stub counterparts.
  4. C++: the tile kind, updateListing, the band text, the tray’s Update, and the tickle check.
  5. JNI: installPackage across ScummVM.java, MyScummVM, _MID_ and FIND_METHOD, the JNI:: wrapper and jni-android.h.
  6. Build the debug APK in WSL, then run the exit criteria on the TCL.

Exit criteria

On the TCL 65Q77K, test build with the beta manifest URL stored:

  1. Release build: strings | grep -c TVPKG_MANIFEST_URL is 0, no fetch happens, and the library is unchanged.
  2. A Get tile appears. With Phantom removed (keep saves), starting the app shows a Phantom tile with its cover, its series group and a Get band, without opening advanced mode. It appears within a few seconds, even if the fetch finishes after the library is drawn.
  3. The tile installs. Choosing it opens the install screen with a moving progress bar. When it finishes, the library returns with Phantom playable, and its Guest Book save is still there.
  4. Cancel and resume. Cancelling mid-download returns to the library with the Get tile. Choosing it again resumes from the kept part (store log: Resuming).
  5. Update. A newer BASS version in the manifest (published for the test) shows Update on BASS’s tile. The tray’s Update installs it, the saves are kept, and the band goes back to Play. The installed 1.2.1 against the manifest’s older 1.2 shows no Update today.
  6. Revoked key. Revoking the tester and restarting removes the Get tiles. Installed games still play.
  7. Offline. With the network off, the library starts normally with the last known Get tiles, and choosing one fails with a plain message.
  8. No key anywhere. Logcat, the shared diagnostic log and available.json hold no key (WP-139 criterion 7).
  9. Other builds unchanged: the Windows build and a desktop run without available.json.
  10. The neg-wrong-hash entry gets no tile.

Deliverables

Result

Pre-flighted on 2026-12-04 and run on the TCL on 2026-12-04 and 2026-12-05 (pre-flight-WP-145-2026-12-04). D2 kept: Jeff’s answer, “Keep D2 (Recommended)”; the install runs on a full-screen Java view, with no progress inside the tile. WP-144’s split hadn’t landed, so the fork work targets scooby-engine (Jeff, 2026-12-05: “Finish before split”).

Engineering calls

The ten calls are in the pre-flight’s §Engineering calls. Two more came out of the TV run:

Checked

Evidence: capture is a TV or window screenshot, log is logcat, the store’s diagnostic log or a command’s output. The raw files stay outside the repo.

  1. Release build (log). strings | grep -c TVPKG_MANIFEST_URL is 0 in the release .so and classes.dex, before the change and after; the release dex is byte-identical across every build of the run.
  2. A Get tile appears (capture + log). With Phantom removed (saves kept), the library shows its cover under Scooby-Doo with a Get band, without advanced mode. Written under a library already drawn, the tile appears within 2 s. Menu on a Get tile does nothing; a long press opens the install screen.
  3. The tile installs (capture + log). The install screen shows a moving bar in MB; the library returns with Phantom playable; phantomknight-win.001 hashes as before. Run again on the final build.
  4. Cancel and resume (capture + log). Back mid-download returns to the library with the Get tile (CANCELLED, 116,920,549 bytes kept); choosing it again logs Resuming and appends with HTTP 206.
  5. Update (capture + log). The test 1.2.2 shows Update on BASS; the tray’s Update installs it, the SKY-VM.* saves hash as before, and the band goes back to Play. Before the test, 1.2.1 against the manifest’s 1.2 showed no Update.
  6. Revoked key (capture + log). Revoked, then restarted: the 404 deletes available.json, the Get tile goes, and Showdown starts.
  7. Offline (capture + log). With the TV’s DNS pointed at a name that doesn’t resolve, the library keeps the last Get tile; choosing it says “Can’t reach the game server…” with a button back to the library. DNS restored.
  8. No key anywhere (log). 0 matches for the key, its prefix (with and without its dash), key=, /m/ and /p/ in logcat, the store log and available.json; the same grep finds the key in a positive control.
  9. Other builds unchanged (capture + log). The Windows UCRT64 build (--disable-all-engines --enable-engine=terraglyph) has no warnings in gui/; its grid looks as before and its log never mentions packages.
  10. neg-wrong-hash (log). No tile; each fetch logs “1 other entry (no engineid/gameid) left out”.

Not checked: Phantom wasn’t launched after the reinstall (Showdown was, in criterion 6); the logcat for 06:26–06:29 was cleared before it was saved, and the store log covers that fetch. Removing Phantom cleared its title_movies_seen, so its intro movies play again once; that is the store’s existing remove, not this WP.

Notes