Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 31 additions & 7 deletions build/scripts/android-sdk-emu.inc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -74,20 +74,41 @@ EMU_UPDATE_FILE="$HOME/.android/emu-update-last-check.ini"

mkdir -p "$UNO_UITEST_SCREENSHOT_PATH"

# Retry wrapper for sdkmanager --install to handle transient network/unzip failures.
# Retries up to 3 times with increasing back-off (10s, 20s).
sdkmanager_install() {
local max_attempts=3
local attempt=1
while (( attempt <= max_attempts )); do
if echo "y" | "$LATEST_CMDLINE_TOOLS_PATH/bin/sdkmanager" \
"--sdk_root=${ANDROID_HOME}" --install "$@" | tr '\r' '\n' | uniq; then
return 0
fi
if (( attempt < max_attempts )); then
local delay=$((attempt * 10))
echo "sdkmanager --install $* failed (attempt $attempt/$max_attempts), retrying in ${delay}s..."
sleep "$delay"
fi
((attempt++))
done
echo "sdkmanager --install $* failed after $max_attempts attempts"
return 1
}

install_android_sdk() {
SIMULATOR_APILEVEL="$1"

if [[ ! -f "$SDK_MGR_TOOLS_FLAG" ]]; then
touch "$SDK_MGR_TOOLS_FLAG"

echo "y" | "$LATEST_CMDLINE_TOOLS_PATH/bin/sdkmanager" "--sdk_root=${ANDROID_HOME}" --install 'tools'| tr '\r' '\n' | uniq
echo "y" | "$LATEST_CMDLINE_TOOLS_PATH/bin/sdkmanager" "--sdk_root=${ANDROID_HOME}" --install 'platform-tools' | tr '\r' '\n' | uniq
echo "y" | "$LATEST_CMDLINE_TOOLS_PATH/bin/sdkmanager" "--sdk_root=${ANDROID_HOME}" --install 'build-tools;36.0.0' | tr '\r' '\n' | uniq
echo "y" | "$LATEST_CMDLINE_TOOLS_PATH/bin/sdkmanager" "--sdk_root=${ANDROID_HOME}" --install 'extras;android;m2repository' | tr '\r' '\n' | uniq
sdkmanager_install 'tools'
sdkmanager_install 'platform-tools'
sdkmanager_install 'build-tools;36.0.0'
sdkmanager_install 'extras;android;m2repository'
Comment thread
agneszitte marked this conversation as resolved.
fi

echo "y" | "$LATEST_CMDLINE_TOOLS_PATH/bin/sdkmanager" "--sdk_root=${ANDROID_HOME}" --install "platforms;android-$SIMULATOR_APILEVEL" | tr '\r' '\n' | uniq
echo "y" | "$LATEST_CMDLINE_TOOLS_PATH/bin/sdkmanager" "--sdk_root=${ANDROID_HOME}" --install "system-images;android-$SIMULATOR_APILEVEL;google_apis_playstore;$ANDROID_SIMULATOR_ABI" | tr '\r' '\n' | uniq
sdkmanager_install "platforms;android-$SIMULATOR_APILEVEL"
sdkmanager_install "system-images;android-$SIMULATOR_APILEVEL;google_apis_playstore;$ANDROID_SIMULATOR_ABI"
}

if [[ ! -f "$EMU_UPDATE_FILE" ]]; then
Expand All @@ -102,7 +123,10 @@ if [[ -f "$AVD_CONFIG_FILE" ]]; then
else
# Install AVD files
install_android_sdk "$ANDROID_SIMULATOR_APILEVEL"
install_android_sdk 36

# API-36 platform is needed for build-tools/apkanalyzer, but the full
# system image (~1.5 GB) is not used for the emulator — skip it.
sdkmanager_install "platforms;android-36"

if [[ -f "$ANDROID_HOME/platform-tools/platform-tools/adb" ]]; then
# It appears that the platform-tools 29.0.6 are extracting into an incorrect path
Expand Down
17 changes: 16 additions & 1 deletion build/scripts/android-test-run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,22 @@ export ANDROID_SIMULATOR_APILEVEL=34

source "$BUILD_SOURCESDIRECTORY/build/scripts/android-sdk-emu.inc.sh"

"$ANDROID_HOME/platform-tools/adb" install -r "$UNO_TEST_ANDROIDAPK_PATH"
# Retry adb install — the emulator may be transiently unresponsive right after boot.
Comment thread
agneszitte marked this conversation as resolved.
adb_install_ok=false
for i in 1 2 3; do
if "$ANDROID_HOME/platform-tools/adb" install -r "$UNO_TEST_ANDROIDAPK_PATH"; then
adb_install_ok=true
break
fi
if [ "$i" -lt 3 ]; then
echo "adb install failed (attempt $i/3), retrying in ${i}s..."
sleep "$i"
fi
done
if [ "$adb_install_ok" = false ]; then
echo "ERROR: adb install failed after 3 attempts."
exit 1
Comment thread
agneszitte marked this conversation as resolved.
fi

package_name=$("$LATEST_CMDLINE_TOOLS_PATH/bin/apkanalyzer" manifest application-id "$UNO_TEST_ANDROIDAPK_PATH")

Expand Down
16 changes: 9 additions & 7 deletions build/scripts/android-uitest-wait-systemui.sh
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,10 @@ while [[ -z ${LAUNCHER_READY} ]]; do
case $UI_FOCUS in
*"Not Responding"*)
echo "Detected an ANR! Dismissing..."
$ANDROID_HOME/platform-tools/adb shell input keyevent KEYCODE_DPAD_RIGHT
$ANDROID_HOME/platform-tools/adb shell input keyevent KEYCODE_ENTER
# Guard keyevent calls: adb can transiently return 255 when the
# emulator is still settling, and set -e would kill the script.
$ANDROID_HOME/platform-tools/adb shell input keyevent KEYCODE_DPAD_RIGHT || true
$ANDROID_HOME/platform-tools/adb shell input keyevent KEYCODE_ENTER || true
Comment thread
agneszitte marked this conversation as resolved.
;;
*"Launcher"*)
LAUNCHER_READY=true
Expand All @@ -86,17 +88,17 @@ while [[ -z ${LAUNCHER_READY} ]]; do
# For some reason the messaging app can be brought up in front
# (DEBUG) Current focus: mCurrentFocus=Window{1170051 u0 com.google.android.apps.messaging/com.google.android.apps.messaging.ui.ConversationListActivity}
# Try bringing back the home screen to check on the launcher.
$ANDROID_HOME/platform-tools/adb shell input keyevent KEYCODE_HOME
$ANDROID_HOME/platform-tools/adb shell input keyevent KEYCODE_HOME || true
;;
esac
done

# Force terminate system UI to restart clean
"$ANDROID_HOME/platform-tools/adb" shell am force-stop com.android.systemui
"$ANDROID_HOME/platform-tools/adb" shell am force-stop com.android.systemui || true

"$ANDROID_HOME/platform-tools/adb" shell settings put global animator_duration_scale 0
"$ANDROID_HOME/platform-tools/adb" shell settings put global transition_animation_scale 0
"$ANDROID_HOME/platform-tools/adb" shell settings put global window_animation_scale 0
"$ANDROID_HOME/platform-tools/adb" shell settings put global animator_duration_scale 0 || true
"$ANDROID_HOME/platform-tools/adb" shell settings put global transition_animation_scale 0 || true
"$ANDROID_HOME/platform-tools/adb" shell settings put global window_animation_scale 0 || true
Comment thread
agneszitte marked this conversation as resolved.

echo "Launcher is ready!"

Loading