diff --git a/tools/rehearse-recovery.sh b/tools/rehearse-recovery.sh new file mode 100755 index 00000000..1de22345 --- /dev/null +++ b/tools/rehearse-recovery.sh @@ -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 +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"