Skip to content

Instantly share code, notes, and snippets.

@zach-klippenstein
Last active January 11, 2024 22:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zach-klippenstein/1496b12b281119b68eb66ab7580a15a3 to your computer and use it in GitHub Desktop.
Save zach-klippenstein/1496b12b281119b68eb66ab7580a15a3 to your computer and use it in GitHub Desktop.
Shell script to trigger some jank in the Android emulator.
#!/bin/bash
# Tells an Android emulator to take a snapshot of itself and then
# delete that snapshot immediately. The act of taking a snapshot
# forces the emulator to temporarily pause and trigger unexpected
# system behaviors. When it happens during a test run, it can
# trigger certain hard-to-reproduce flakes.
SNAPSHOT=__TEMPORARY_SNAPSHOT
AUTH="$(cat ~/.emulator_console_auth_token)"
PORT=$1
if [[ -z $PORT ]]; then
echo "usage: $0 [emulator-port]"
adb devices
exit 1
fi
echo "Taking temporary emulator snapshot then deleting it…"
set -e
set -x
nc localhost $1 <<EOF
avd name
auth $AUTH
avd snapshot save $SNAPSHOT
avd snapshot delete $SNAPSHOT
EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment