@@ -731,7 +731,7 @@ create_avd() {
731731 rm -f " $ini_file "
732732 rm -rf " $image_dir "
733733 fi
734- if ! ANDROID_AVD_HOME=" $avd_dir " " $manager " create avd -n " $name " -k " $image " --device " 2.7in QVGA " --force > /dev/null <<< ' no'
734+ if ! ANDROID_AVD_HOME=" $avd_dir " " $manager " create avd -n " $name " -k " $image " --device " pixel_5 " --force > /dev/null <<< ' no'
735735 then
736736 ba_log " Failed to create Android Virtual Device $name using image $image " >&2
737737 find " $avd_dir " -maxdepth 2 -mindepth 1 -print | sed ' s/^/[build-android-app] AVD: /' >&2 || true
@@ -753,14 +753,15 @@ configure_avd() {
753753 return
754754 fi
755755 declare -A settings=(
756- [" hw.ramSize" ]=4096
756+ [" hw.ramSize" ]=2048
757757 [" disk.dataPartition.size" ]=8192M
758758 [" fastboot.forceColdBoot" ]=yes
759759 [" hw.bluetooth" ]=no
760760 [" hw.camera.back" ]=none
761761 [" hw.camera.front" ]=none
762762 [" hw.audioInput" ]=no
763763 [" hw.audioOutput" ]=no
764+ [" hw.cpu.ncore" ]=2
764765 )
765766 local key value
766767 for key in " ${! settings[@]} " ; do
@@ -941,14 +942,15 @@ adb_framework_ready_once() {
941942 local last_log=$SECONDS
942943
943944 while [ $SECONDS -lt $deadline ]; do
944- local boot_ok dev_boot system_pid pm_ok activity_ok service_ok user_ready service_status
945+ local boot_ok dev_boot system_pid pm_ok activity_ok service_ok user_ready service_status cmd_ok
945946 boot_ok=" $( $ADB_BIN -s " $serial " shell getprop sys.boot_completed 2> /dev/null | tr -d ' \r' ) "
946947 dev_boot=" $( $ADB_BIN -s " $serial " shell getprop dev.bootcomplete 2> /dev/null | tr -d ' \r' ) "
947948 system_pid=" $( run_with_timeout " $per_try " " $ADB_BIN " -s " $serial " shell pidof system_server 2> /dev/null | tr -d ' \r' || true) "
948949 pm_ok=0
949950 activity_ok=0
950951 service_ok=0
951952 user_ready=0
953+ cmd_ok=0
952954 if run_with_timeout " $per_try " " $ADB_BIN " -s " $serial " shell pm path android > /dev/null 2>&1 ; then
953955 pm_ok=1
954956 fi
@@ -958,19 +960,23 @@ adb_framework_ready_once() {
958960 if run_with_timeout " $per_try " " $ADB_BIN " -s " $serial " shell am get-current-user > /dev/null 2>&1 ; then
959961 user_ready=1
960962 fi
963+ if run_with_timeout " $per_try " " $ADB_BIN " -s " $serial " shell cmd -l > /dev/null 2>&1 ; then
964+ cmd_ok=1
965+ fi
961966 service_status=" $( run_with_timeout " $per_try " " $ADB_BIN " -s " $serial " shell service check package 2> /dev/null | tr -d ' \r' || true) "
962967 if [ -n " $service_status " ] && printf ' %s' " $service_status " | grep -q " found" ; then
963968 service_ok=1
964969 fi
965970
966971 if [ " $boot_ok " = " 1" ] && [ " $dev_boot " = " 1" ] && [ -n " $system_pid " ] \
967- && [ $pm_ok -eq 1 ] && [ $activity_ok -eq 1 ] && [ $service_ok -eq 1 ] && [ $user_ready -eq 1 ]; then
972+ && [ $pm_ok -eq 1 ] && [ $activity_ok -eq 1 ] && [ $service_ok -eq 1 ] \
973+ && [ $cmd_ok -eq 1 ] && [ $user_ready -eq 1 ]; then
968974 ba_log " Android framework ready on $serial (system_server=$system_pid )"
969975 return 0
970976 fi
971977
972978 if [ $(( SECONDS - last_log)) -ge $log_interval ]; then
973- ba_log " Waiting for Android framework on $serial (system_server=${system_pid:- down} boot_ok=${boot_ok:- ?} /${dev_boot:- ?} pm_ready=$pm_ok activity_ready=$activity_ok package_service_ready=$service_ok user_ready=$user_ready )"
979+ ba_log " Waiting for Android framework on $serial (system_server=${system_pid:- down} boot_ok=${boot_ok:- ?} /${dev_boot:- ?} pm_ready=$pm_ok activity_ready=$activity_ok cmd_ready= $cmd_ok package_service_ready=$service_ok user_ready=$user_ready )"
974980 last_log=$SECONDS
975981 fi
976982 sleep 2
@@ -1152,8 +1158,9 @@ ba_log "Starting headless Android emulator $AVD_NAME on port $EMULATOR_PORT"
11521158ANDROID_AVD_HOME=" $AVD_HOME " " $EMULATOR_BIN " -avd " $AVD_NAME " -port " $EMULATOR_PORT " \
11531159 -no-window -no-snapshot -no-snapshot-load -no-snapshot-save -wipe-data \
11541160 -gpu swiftshader_indirect -no-audio -no-boot-anim \
1155- -accel off -no-accel -camera-back none -camera-front none -skip-adb-auth \
1156- -feature -Vulkan -netfast -memory 4096 > " $EMULATOR_LOG " 2>&1 &
1161+ -accel on -camera-back none -camera-front none -skip-adb-auth \
1162+ -feature -Vulkan -netfast -skin 1080x1920 -memory 2048 -cores 2 \
1163+ -writable-system -selinux permissive > " $EMULATOR_LOG " 2>&1 &
11571164EMULATOR_PID=$!
11581165trap stop_emulator EXIT
11591166
@@ -1239,9 +1246,10 @@ fi
12391246" $ADB_BIN " -s " $EMULATOR_SERIAL " shell locksettings set-disabled true > /dev/null 2>&1 || true
12401247" $ADB_BIN " -s " $EMULATOR_SERIAL " shell settings put global device_provisioned 1 > /dev/null 2>&1 || true
12411248" $ADB_BIN " -s " $EMULATOR_SERIAL " shell settings put secure user_setup_complete 1 > /dev/null 2>&1 || true
1242- " $ADB_BIN " -s " $EMULATOR_SERIAL " shell svc power stayon true > /dev/null 2>&1 || true
1249+ " $ADB_BIN " -s " $EMULATOR_SERIAL " shell svc power stayon usb > /dev/null 2>&1 || true
12431250" $ADB_BIN " -s " $EMULATOR_SERIAL " shell input keyevent 82 > /dev/null 2>&1 || true
12441251" $ADB_BIN " -s " $EMULATOR_SERIAL " shell wm dismiss-keyguard > /dev/null 2>&1 || true
1252+ " $ADB_BIN " -s " $EMULATOR_SERIAL " shell am start -a android.intent.action.MAIN -c android.intent.category.HOME > /dev/null 2>&1 || true
12451253" $ADB_BIN " -s " $EMULATOR_SERIAL " shell settings put global window_animation_scale 0 > /dev/null 2>&1 || true
12461254" $ADB_BIN " -s " $EMULATOR_SERIAL " shell settings put global transition_animation_scale 0 > /dev/null 2>&1 || true
12471255" $ADB_BIN " -s " $EMULATOR_SERIAL " shell settings put global animator_duration_scale 0 > /dev/null 2>&1 || true
0 commit comments