Skip to content

Android-wait-for-emulator consider avd running too early when -no-snapshot option is used with emulator commandΒ #1125

@damienvergnaud

Description

@damienvergnaud

Hey,

Concerning this file, we used it, and it brings us satisfaction to give back the stdin when emulator is ready to go.
But we faced an issue where "init.svc.bootanim" isn't really relevant to use when emulator is started with -no-snapshot option on emulator.

We proceeded to see wich adb shell prop could replace bootanim in 2024 on a booting avd with qemu and we found that sys.boot_completed cover the two cases (with -no-snapshot and without it).

Wich is perfect even to run an emulator in CICD (first run without -no-snapshot is indeed, without snapshot anyway).

We though as it helped us to find this script, even 7Years after, we would share our tweaks to eventually help someone :

#!/bin/bash

# Originally written by Ralf Kistner <[email protected]>, but placed in the public domain

# https://raw.githubusercontent.com/travis-ci/travis-cookbooks/0f497eb71291b52a703143c5cd63a217c8766dc9/community-cookbooks/android-sdk/files/default/android-wait-for-emulator

set +e

sysbootcompleted=""
failcounter=0
timeout_in_sec=360

until [[ "$sysbootcompleted" == "1" ]]; do
  sysbootcompleted=`adb -e shell getprop sys.boot_completed 2>&1 &`
  let "failcounter += 1"
  echo "Waiting for emulator to start"
  if [[ $failcounter -gt timeout_in_sec ]]; then
    echo "Timeout ($timeout_in_sec seconds) reached; failed to start emulator"
    exit 1
  fi
  sleep 1
done

echo "Emulator is ready"

This proposal has been made during my working time at WeScale company ;)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions