#!/bin/bash # Capture diverse Android situations with ground truth dumps. Usage: ./capture_situations.sh set -e export PATH=$PATH:/opt/homebrew/bin A="adb -s ${1:-10.30.20.26:5555}" D=~/vision_bench capture() { # $1=name local name=$1 sleep 2 $A exec-out screencap -p > "$D/$name.png" $A shell uiautomator dump /sdcard/ui_tmp.xml >/dev/null 2>&1 || true $A pull /sdcard/ui_tmp.xml "$D/$name.xml" >/dev/null 2>&1 || true local sz=$(stat -f%z "$D/$name.png") echo "$name captured ($sz bytes)" } echo "--- dismiss launcher dialog if present ---" $A shell uiautomator dump /sdcard/ui_tmp.xml >/dev/null 2>&1 || true $A shell cat /sdcard/ui_tmp.xml > /tmp/cur.xml 2>/dev/null if grep -q "ALWAYS" /tmp/cur.xml 2>/dev/null; then $A shell input tap 701 599 # ALWAYS button, screen coords (+24 status bar) sleep 3 fi echo "--- s_home: launcher home ---" $A shell input keyevent 3 capture s_home echo "--- s_settings: settings main ---" $A shell am start -a android.settings.SETTINGS capture s_settings echo "--- s_calc: calculator ---" $A shell am start -n com.android.calculator2/.Calculator 2>/dev/null || $A shell monkey -p com.android.calculator2 1 2>/dev/null || echo "no calculator app" capture s_calc echo "--- s_article: chrome wikipedia ---" $A shell am start -a android.intent.action.VIEW -d "https://en.wikipedia.org/wiki/Linux" sleep 8 # accept chrome welcome if present $A shell uiautomator dump /sdcard/ui_tmp.xml >/dev/null 2>&1 || true $A shell cat /sdcard/ui_tmp.xml > /tmp/cur.xml 2>/dev/null if grep -q "Accept" /tmp/cur.xml 2>/dev/null; then $A shell input tap 511 681 # Accept & continue (+24 offset) sleep 8 $A shell am start -a android.intent.action.VIEW -d "https://en.wikipedia.org/wiki/Linux" sleep 8 fi capture s_article echo "--- s_keyboard: settings search with keyboard ---" $A shell am start -a android.settings.SETTINGS sleep 2 $A shell input tap 512 100 # search box area sleep 3 $A shell input text "wifi" sleep 2 capture s_keyboard echo "--- s_yt or app drawer: home with drawer open ---" $A shell input keyevent 3 sleep 1 $A shell input swipe 512 700 512 100 300 sleep 2 capture s_drawer ls -la $D/s_*.png