#!/usr/bin/env bash # Emulator proof for the Phase 5.1 Android client. Runs on .27. # bash emu-proof.sh set -uo pipefail exec /dev/null || true # Toggle so the system binds the service even if it was already set. adb shell settings put secure accessibility_enabled 0 adb shell settings delete secure enabled_accessibility_services 2>/dev/null || true sleep 1 adb shell settings put secure enabled_accessibility_services $PKG/$PKG.BlockAccessibilityService adb shell settings put secure accessibility_enabled 1 sleep 4 echo "a11y services: $(adb shell settings get secure enabled_accessibility_services)" echo "a11y enabled: $(adb shell settings get secure accessibility_enabled)" echo "overlay appop: $(adb shell appops get $PKG SYSTEM_ALERT_WINDOW)" echo "== launch app once (seed config, start mqtt) ==" adb shell am start -n $PKG/.MainActivity sleep 4 echo "== launch a blocked app: Settings ==" adb shell am force-stop com.android.settings sleep 1 adb shell am start -a android.settings.SETTINGS sleep 5 echo "== window state: overlay ==" adb shell dumpsys window windows | grep -i -A30 "u0 $PKG}:" | grep -E "Window #|ty=|isOnScreen|isVisible|mPolicyVisibility|shown=|mForceHide" | head -20 echo "current focus:" adb shell dumpsys window | grep -E "mCurrentFocus" | head -2 echo "== screenshot: block overlay ==" adb exec-out screencap -p > "$OUT/block-overlay.png" echo "wrote $OUT/block-overlay.png ($(stat -c%s "$OUT/block-overlay.png") bytes)" echo "== logcat: service + overlay ==" adb logcat -d -s WebRestrictService WebRestrictOverlay WebRestrictConfig WebRestrictMqtt 2>/dev/null | tail -30 echo "== TAMPER: disable the Accessibility Service ==" adb shell settings put secure accessibility_enabled 0 adb shell settings delete secure enabled_accessibility_services 2>/dev/null || true sleep 5 adb logcat -d -s WebRestrictTamper 2>/dev/null | tail -20 | tee "$OUT/tamper-logcat.txt" echo "== tamper log file (persisted on device) ==" adb shell run-as $PKG cat files/tamper.log 2>/dev/null | tail -20 | tee "$OUT/tamper-file.txt" || true echo "== screenshot: status screen after tamper ==" adb shell am start -n $PKG/.MainActivity sleep 3 adb exec-out screencap -p > "$OUT/after-tamper.png" echo "wrote $OUT/after-tamper.png ($(stat -c%s "$OUT/after-tamper.png") bytes)" echo "== done =="