tools: recovery rehearsal with the separate test app (downgrade refused, fix-forward keeps data)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-09 15:19:56 +00:00
co-authored by Claude Opus 5.5
parent be7b4e963e
commit d9131d3979
+20
View File
@@ -0,0 +1,20 @@
#!/usr/bin/env bash
# Recovery rehearsal (9 November 2026), using the separate playtest app so Orbit itself is never touched.
# Shows, on the real TV and with the same signing key, that:
# 1. Android refuses to put an older version over a newer one (adb install -r -d), and nothing changes when it refuses;
# 2. a higher-version build installs over it as an upgrade, keeping the app's data (the fix-forward recovery path).
# The app's data is checked by firstInstallTime (unchanged unless the app was wiped) and a result file in its folder.
# tools/rehearse-recovery.sh <adb-device>
set -uo pipefail
A=${ADB:-/opt/android-sdk/platform-tools/adb}; D=$1; R=/home/pauljd/Documents/OrbitTV/apks
PKG=tv.orbit.classic.playtest; MARK=/sdcard/Android/data/$PKG/files/playtest/results/none.json
state() { echo "$($A -s $D shell dumpsys package $PKG | grep -m3 -E 'versionCode|firstInstallTime' | tr -s ' ' | tr '\n' ' ') marker=$($A -s $D shell sha256sum $MARK 2>/dev/null | cut -c1-16)"; }
echo "1. install the test app at 315"; $A -s $D install -r $R/orbit-playtest-0.123.0.apk | tail -1
$A -s $D shell am start -W -n $PKG/tv.orbit.classic.PlaytestFileActivity --es file none >/dev/null; sleep 6 # writes a result file: the app's data
S1=$(state); echo " $S1"
echo "2. try to go back to 314 (allow-downgrade flag)"; $A -s $D install -r -d $R/rehearsal/orbit-playtest-vc314.apk 2>&1 | tail -1
S2=$(state); echo " $S2"; [ "$S1" = "$S2" ] && echo " unchanged: refused, nothing lost" || echo " CHANGED"
echo "3. fix forward to 390"; $A -s $D install -r $R/rehearsal/orbit-playtest-vc390.apk | tail -1
S3=$(state); echo " $S3"
[ "$(echo "$S1" | grep -o 'firstInstallTime=[^ ]*')" = "$(echo "$S3" | grep -o 'firstInstallTime=[^ ]*')" ] && [ "${S1##*marker=}" = "${S3##*marker=}" ] \
&& echo " upgraded with its data kept" || echo " DATA NOT KEPT"