mirror of
https://github.com/kuhyx/testsAndMisc.git
synced 2026-11-10 18:07:06 +01:00
Held until last on purpose: all five enforcer splits this session grew
deploy.sh's two hardcoded file lists, so cutting it earlier would have left
every "add to BOTH lists" step pointing at a stale location. Those lists are
final as of the focus_ctl commit, so this is now safe.
do_deploy was 421 lines -- over the cap on its own, so moving it whole would
have achieved nothing. It is cut at the phase boundaries it already prints
("[4/7] Uploading scripts...", "[5/7] Setting permissions...") plus two more
inside the push phase, giving seven named functions instead of one wall.
The two hardcoded lists now live in SEPARATE files, which is the real risk
this commit introduces. deploy_phases.sh holds the push list and
deploy_install.sh the cp list; each header names the other and says what
happens when they drift -- the file is staged, never lands, and whatever
sources it fails to start with no obvious cause. Checked in both directions
after the move: the only asymmetry is config_secrets.sh, which a conditional
block handles so the phone's real coordinates survive a deploy. That was
asymmetric at HEAD too.
check_coords now RETURNS whether the coordinates are placeholders instead of
assigning $NEEDS_GPS_FETCH. The flag is written in deploy.sh and read in
deploy_phases.sh, so assigning it from deploy_gps.sh as well left that file
writing a global it never reads. Behaviour proven identical to HEAD: real
coords -> 0, placeholders -> 1.
NO TESTS, and that is a deliberate limit rather than an omission. Every
phase here is a sequence of adb calls against a real device; a stub layer
deep enough to mean anything would be modelling the phone, not testing the
script. Verification is that deploy.sh parses, sources all six libraries and
reaches its usage message -- which catches a broken split, not a wrong one.
515 assertions across ten phone suites still pass; run_phone.sh --help
exits 0.
Over-cap 16 -> 15, and NO phone_focus_mode file is over the cap any more.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011w2Pj4Ek3ZNMQVYcFHgXDY
84 lines
3.2 KiB
Bash
Executable File
84 lines
3.2 KiB
Bash
Executable File
#!/bin/bash
|
|
# deploy_actions.sh — deploy.sh's non-deploy actions: the help text, passing a
|
|
# control command through to focus_ctl.sh on the phone, pulling the log,
|
|
# searching installed packages, and snapshotting the launcher APK.
|
|
#
|
|
# Sourced by deploy.sh, which owns adb_cmd, adb_root and $REMOTE_DIR.
|
|
|
|
usage() {
|
|
echo "Usage: $0 <phone_ip> [action]"
|
|
echo " or: ADB_SERIAL=<serial> $0 [action]"
|
|
echo ""
|
|
echo "Actions:"
|
|
echo " (none) Full deploy"
|
|
echo " --status Show daemon status and current mode"
|
|
echo " --log Tail the daemon log"
|
|
echo " --stop Stop daemon (re-enables all apps)"
|
|
echo " --start Start daemon"
|
|
echo " --restart Restart daemon"
|
|
echo " --enable Force focus mode on"
|
|
echo " --disable Force focus mode off"
|
|
echo " --list List all third-party apps and whitelist status"
|
|
echo " --pull-log Download log file locally"
|
|
echo " --find-pkg Show installed packages matching a filter (e.g. --find-pkg pomodoro)"
|
|
echo " --capture-coords Capture current GPS as home location (run after WiFi setup)"
|
|
echo " --hosts-status Show hosts enforcer status on the phone"
|
|
echo " --hosts-log Show hosts enforcer log on the phone"
|
|
echo " --launcher-status Show launcher enforcer status on the phone"
|
|
echo " --launcher-log Show launcher enforcer log on the phone"
|
|
echo " --snapshot-launcher Snapshot installed Minimalist Phone APK + default HOME"
|
|
echo " --install-aurora Download & install Aurora Store (open-source Play Store alt)"
|
|
echo ""
|
|
echo "Examples:"
|
|
echo " $0 192.168.1.42"
|
|
echo " $0 192.168.1.42 --status"
|
|
echo " $0 192.168.1.42 --find-pkg stronglift"
|
|
exit 1
|
|
}
|
|
|
|
# ============================================================
|
|
# Control actions (post-deploy)
|
|
# ============================================================
|
|
do_control() {
|
|
local ctl_cmd="$1"
|
|
connect_adb
|
|
adb_root "sh $REMOTE_DIR/focus_ctl.sh $ctl_cmd"
|
|
}
|
|
|
|
do_pull_log() {
|
|
connect_adb
|
|
echo "Downloading log..."
|
|
adb_cmd pull "$REMOTE_DIR/focus_mode.log" "./focus_mode_$(date +%Y%m%d_%H%M%S).log"
|
|
echo "Done."
|
|
}
|
|
|
|
do_find_pkg() {
|
|
local filter="${3:-}"
|
|
if [ -z "$filter" ]; then
|
|
echo "Usage: $0 <ip> --find-pkg <search_term>"
|
|
exit 1
|
|
fi
|
|
connect_adb
|
|
echo "Packages matching '$filter':"
|
|
adb_cmd shell pm list packages | grep -i "$filter" | sed 's/^package:/ /'
|
|
}
|
|
|
|
do_snapshot_launcher() {
|
|
# Run the on-device snapshot command. This captures the APK + HOME
|
|
# activity of the already-installed Minimalist Phone launcher into
|
|
# /data/adb/focus_mode/ so the launcher enforcer can restore it later.
|
|
# The user must install the launcher once (via Aurora/Play) before
|
|
# running this command - we only back up what's already there.
|
|
connect_adb
|
|
echo "Snapshotting currently-installed launcher APK..."
|
|
adb_root "sh $REMOTE_DIR/focus_ctl.sh launcher-snapshot"
|
|
echo ""
|
|
echo "Starting launcher enforcer..."
|
|
# Kill any previous enforcer so it picks up the new snapshot.
|
|
adb_root "kill \$(cat $REMOTE_DIR/launcher_enforcer.pid 2>/dev/null) 2>/dev/null; true"
|
|
adb_root "rm -f $REMOTE_DIR/launcher_enforcer.pid"
|
|
adb_cmd shell su --mount-master -c 'setsid sh /data/local/tmp/focus_mode/launcher_enforcer.sh </dev/null >/dev/null 2>/dev/null &'
|
|
sleep 3
|
|
adb_root "sh $REMOTE_DIR/focus_ctl.sh launcher-status"
|
|
}
|