From 8abe2c1ca0a4d4a500f82771797f5f7012f0efbf Mon Sep 17 00:00:00 2001 From: PJ Date: Tue, 18 Aug 2026 20:47:24 +0530 Subject: [PATCH] fix(folio): refuse to install and fuzz a device nobody named adb falls through to the local server when ADB_SERVER_SOCKET is unset, and claims the only device attached there. That could be a personal handset, and a run installs the app, clears its state and fuzzes it. Every recipe that touches a device now resolves the target through _require-device, which only picks on its own when a single local emulator is all adb sees. --- examples/folio/justfile | 72 ++++++++++++++++++++++++++++++++--------- 1 file changed, 57 insertions(+), 15 deletions(-) diff --git a/examples/folio/justfile b/examples/folio/justfile index fcfc615..82d0502 100644 --- a/examples/folio/justfile +++ b/examples/folio/justfile @@ -79,6 +79,51 @@ _ensure-device: echo "emulator did not finish booting in time (see /tmp/folio-emulator.log)" >&2 exit 1 +# Print the serial every device-affecting recipe must act on, or refuse. A run +# installs the app, clears its state and fuzzes it, so the target is never +# inferred from "whatever adb resolved to": the one case it picks on its own is +# a single emulator on the local adb server, which is cheap to rebuild. +_require-device: + #!/usr/bin/env bash + set -euo pipefail + adb="$(just _android-home)/platform-tools/adb" + listing="$("$adb" devices)" + online="$(echo "$listing" | awk 'NR>1 && $2=="device"{print $1}')" + count="$(printf '%s' "$online" | grep -c . || true)" + + refuse() { + cat >&2 <