Initialize Android physical interfaces and preserve macOS scoped routes. Add redacted diagnostics, default DNS, ordered auto-save, simplified controls, scanner rotation settings, and native regression coverage. Restore vendored build sources and document validation and stability checks.
51 lines
2.0 KiB
Bash
51 lines
2.0 KiB
Bash
#!/bin/sh
|
|
# Keep user storage and restore the normal APP even when device tests fail.
|
|
set -eu
|
|
cd "$(dirname "$0")/.."
|
|
root="$PWD"
|
|
if [ "$#" -lt 4 ]; then
|
|
printf '%s\n' 'usage: test-android-device.sh SERIAL NORMAL_APK BUILD_NUMBER network|proxy [FIXTURE_IP]' >&2
|
|
exit 2
|
|
fi
|
|
serial="$1"
|
|
apk="$2"
|
|
case "$apk" in /*) ;; *) apk="$root/$apk" ;; esac
|
|
[ -f "$apk" ] || { printf '%s\n' 'Normal APK not found' >&2; exit 2; }
|
|
number="$3"
|
|
case "$number" in ''|*[!0-9]*) printf '%s\n' 'Numeric build number required' >&2; exit 2 ;; esac
|
|
case "$4" in
|
|
network) target=integration_test/android_network_test.dart ;;
|
|
proxy) target=integration_test/android_proxy_test.dart; [ "$#" -ge 5 ] || exit 2 ;;
|
|
*) exit 2 ;;
|
|
esac
|
|
restore() {
|
|
result=$?
|
|
trap - EXIT HUP INT TERM
|
|
printf '%s\n' 'Restoring the normal MeshPort APP (keeping stored profiles)'
|
|
adb -s "$serial" shell am force-stop com.example.meshport_lab || true
|
|
if adb -s "$serial" install -r -d "$apk"; then
|
|
adb -s "$serial" shell am start -W -n com.example.meshport_lab/.MainActivity || result=1
|
|
else
|
|
result=1
|
|
fi
|
|
exit "$result"
|
|
}
|
|
trap restore EXIT
|
|
trap 'exit 130' HUP INT TERM
|
|
cd apps/meshport_lab
|
|
# Matching build numbers avoid Flutter's uninstall/reinstall downgrade fallback.
|
|
# drive's keep-app-running also suppresses the default test-package uninstall.
|
|
if [ "$4" = proxy ]; then
|
|
flutter build apk --debug --target-platform android-arm64 --target="$target" \
|
|
--build-number="$number" --dart-define="ANDROID_PROXY_FIXTURE=$5"
|
|
flutter drive -d "$serial" --target="$target" \
|
|
--driver=test_driver/integration_test.dart --keep-app-running \
|
|
--use-application-binary="$PWD/build/app/outputs/flutter-apk/app-debug.apk"
|
|
else
|
|
flutter build apk --debug --target-platform android-arm64 --target="$target" \
|
|
--build-number="$number"
|
|
flutter drive -d "$serial" --target="$target" \
|
|
--driver=test_driver/integration_test.dart --keep-app-running \
|
|
--use-application-binary="$PWD/build/app/outputs/flutter-apk/app-debug.apk"
|
|
fi
|