Files
smoa/scripts/wsl-install-debug.sh
T
defiQUG a2dc194a49 Monorepo: Gitea CI, docs, auth/sync, backend APIs, gitignore
- Add Gitea Actions workflow; point README to gitea.d-bis.org/Sankofa_Phoenix/SMOA
- Expand .gitignore for Spring H2 data, secrets, Kotlin .kotlin/, tooling
- Track docs/api/generated ReDoc bundle; refresh api docs README
- Android: network/auth/sync, UI shell, tests; backend credentials/integrity APIs
- Docs, scripts (generate-api-docs), modules and core updates

Made-with: Cursor
2026-03-23 20:19:24 -07:00

54 lines
1.6 KiB
Bash
Executable File

#!/usr/bin/env bash
# Run in Ubuntu WSL after: usbipd attach --wsl --busid <BUSID> (Windows Admin PowerShell)
set -euo pipefail
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
APK="$ROOT/app/build/outputs/apk/debug/app-debug.apk"
export PATH="${HOME}/Android/Sdk/platform-tools:${PATH}"
export ADB_INSTALL_TIMEOUT="${ADB_INSTALL_TIMEOUT:-3600}"
echo "=== lsusb (expect Samsung / 04e8) ==="
lsusb || true
adb kill-server || true
sleep 1
echo "=== adb devices ==="
adb devices
WAIT_MAX="${WAIT_FOR_DEVICE_SECS:-180}"
elapsed=0
while ! adb devices 2>/dev/null | grep -q $'\tdevice$'; do
if adb devices 2>/dev/null | grep -q $'\tunauthorized$'; then
echo "Unauthorized — unlock the phone and tap Allow on the USB debugging (RSA) prompt..."
else
echo "No device — run usbipd attach (Windows), check cable/USB mode..."
fi
if (( elapsed >= WAIT_MAX )); then
echo "Timed out after ${WAIT_MAX}s waiting for device." >&2
adb devices
exit 1
fi
sleep 5
elapsed=$((elapsed + 5))
# After you tap Allow, reconnecting ADB often flips unauthorized → device.
adb kill-server 2>/dev/null || true
sleep 1
done
echo "=== adb devices (ready) ==="
adb devices
cd "$ROOT"
if [[ ! -f "$APK" ]]; then
echo "=== building debug APK ==="
./gradlew :app:assembleDebug --no-daemon
fi
echo "=== adb install (large APK over usbip can take many minutes) ==="
# --streaming avoids a separate full-file sync that often EOFs over USB/IP.
if ! adb install -r -d --streaming "$APK"; then
echo "Streaming install failed; retrying without --streaming..." >&2
adb install -r -d "$APK"
fi
echo "=== verify ==="
adb shell pm path com.smoa
echo "Done."