Files
frida-interception-and-unpi…/test/android/setup-emulator.sh
T
Tim Perry 7722e20adc Use a large screen test device in CI
Previously not all buttons were being detected by Appium - I strongly
suspect that's becuase the default profile is some tiny phone.

Also added another API test level (just to confirm) and switched arch
because it turns out modern API levels don't support x86, only _64.
2025-07-04 10:02:41 +02:00

49 lines
1.6 KiB
Bash
Executable File

#!/bin/bash
set -e
# Assumes: Android emulator/device is available via ADB and Frida CLI is installed on computer
# Wait for device, install APK, and set up Frida server (all idempotent)
# Wait for emulator/device to be available
adb wait-for-device
adb shell 'while [[ -z $(getprop sys.boot_completed) ]]; do sleep 1; done;'
echo "Emulator/device booted."
# Download and install APK if not already installed
APK_VERSION="v1.5.0"
APK_PATH="/tmp/pinning-demo.apk"
APK_URL="https://github.com/httptoolkit/android-ssl-pinning-demo/releases/download/${APK_VERSION}/pinning-demo.apk"
PACKAGE="tech.httptoolkit.pinning_demo"
if ! adb shell pm list packages | grep -q "$PACKAGE"; then
wget -q $APK_URL -O $APK_PATH
adb install -r $APK_PATH
echo "APK installed."
else
echo "APK already installed."
fi
# Set up Frida server
FRIDA_VERSION=$(frida --version)
FRIDA_SERVER_URL="https://github.com/frida/frida/releases/download/${FRIDA_VERSION}/frida-server-${FRIDA_VERSION}-android-x86_64.xz"
FRIDA_SERVER_LOCAL="/tmp/frida-server"
FRIDA_SERVER_REMOTE="/data/local/tmp/frida-server"
if ! adb shell pgrep -f frida-server > /dev/null; then
if [ ! -f $FRIDA_SERVER_LOCAL ]; then
wget -q $FRIDA_SERVER_URL -O /tmp/frida-server.xz
unxz -f /tmp/frida-server.xz
chmod +x $FRIDA_SERVER_LOCAL
fi
adb root || true
sleep 1
adb push $FRIDA_SERVER_LOCAL $FRIDA_SERVER_REMOTE
echo 'Pushed'
adb shell "chmod 755 $FRIDA_SERVER_REMOTE"
echo 'chmoded'
adb shell "ls -l $FRIDA_SERVER_REMOTE"
adb shell "$FRIDA_SERVER_REMOTE" &
echo "Frida server started on device."
else
echo "Frida server already running."
fi