Skip to content

Commit d978c66

Browse files
committed
[green] Stabilize Android drive attachment
Signed-off-by: Viwat Vchirawongkwin <viwat.v@chula.ac.th>
1 parent 44e58ff commit d978c66

1 file changed

Lines changed: 58 additions & 2 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 58 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ jobs:
370370
# cannot select an earlier device-profile value from a duplicate.
371371
python3 ../tools/ci/android_avd_config.py "$AVD_CONFIG" \
372372
--set 'hw.ramSize=2048' \
373-
--set 'hw.cpu.ncore=1' \
373+
--set 'hw.cpu.ncore=2' \
374374
--set 'vm.heapSize=384' \
375375
--set 'disk.dataPartition.size=6144M' \
376376
--set 'hw.lcd.width=2560' \
@@ -426,7 +426,7 @@ jobs:
426426
-accel on \
427427
-gpu swiftshader_indirect \
428428
-memory 2048 \
429-
-cores 1 \
429+
-cores 2 \
430430
>"$PYBLE_ANDROID_RAW_EMULATOR_LOG" 2>&1 &
431431
EMULATOR_PID=$!
432432
printf '%s\n' "$EMULATOR_PID" \
@@ -464,6 +464,16 @@ jobs:
464464
465465
"$PYBLE_ANDROID_ADB" -s "$PYBLE_ANDROID_SERIAL" shell \
466466
input keyevent 82
467+
"$PYBLE_ANDROID_ADB" -s "$PYBLE_ANDROID_SERIAL" shell \
468+
wm dismiss-keyguard
469+
"$PYBLE_ANDROID_ADB" -s "$PYBLE_ANDROID_SERIAL" shell \
470+
settings put global device_provisioned 1
471+
"$PYBLE_ANDROID_ADB" -s "$PYBLE_ANDROID_SERIAL" shell \
472+
settings put secure user_setup_complete 1
473+
"$PYBLE_ANDROID_ADB" -s "$PYBLE_ANDROID_SERIAL" shell \
474+
settings put system accelerometer_rotation 0
475+
"$PYBLE_ANDROID_ADB" -s "$PYBLE_ANDROID_SERIAL" shell \
476+
settings put system user_rotation 0
467477
"$PYBLE_ANDROID_ADB" -s "$PYBLE_ANDROID_SERIAL" shell \
468478
settings put global window_animation_scale 0
469479
"$PYBLE_ANDROID_ADB" -s "$PYBLE_ANDROID_SERIAL" shell \
@@ -472,6 +482,52 @@ jobs:
472482
settings put global animator_duration_scale 0
473483
"$PYBLE_ANDROID_ADB" -s "$PYBLE_ANDROID_SERIAL" shell \
474484
svc power stayon true
485+
486+
READY_FOR_DRIVER=0
487+
for ATTEMPT in $(seq 1 60); do
488+
BOOT_ANIMATION="$(
489+
"$PYBLE_ANDROID_ADB" -s "$PYBLE_ANDROID_SERIAL" shell \
490+
getprop init.svc.bootanim 2>/dev/null | tr -d '\r' || true
491+
)"
492+
BOOT_ANIMATION_EXIT="$(
493+
"$PYBLE_ANDROID_ADB" -s "$PYBLE_ANDROID_SERIAL" shell \
494+
getprop service.bootanim.exit 2>/dev/null | tr -d '\r' || true
495+
)"
496+
CE_AVAILABLE="$(
497+
"$PYBLE_ANDROID_ADB" -s "$PYBLE_ANDROID_SERIAL" shell \
498+
getprop sys.user.0.ce_available 2>/dev/null \
499+
| tr -d '\r' || true
500+
)"
501+
USER_UNLOCKED="$(
502+
"$PYBLE_ANDROID_ADB" -s "$PYBLE_ANDROID_SERIAL" shell \
503+
cmd user is-user-unlocked 0 2>/dev/null \
504+
| tr -d '\r' || true
505+
)"
506+
if {
507+
[ "$BOOT_ANIMATION" = "stopped" ] ||
508+
[ "$BOOT_ANIMATION_EXIT" = "1" ]
509+
} && {
510+
[ "$CE_AVAILABLE" = "true" ] ||
511+
[ "$CE_AVAILABLE" = "1" ] ||
512+
[ "$USER_UNLOCKED" = "true" ]
513+
}; then
514+
READY_FOR_DRIVER=1
515+
echo "Android services stabilized after $ATTEMPT poll(s)."
516+
break
517+
fi
518+
sleep 2
519+
done
520+
if [ "$READY_FOR_DRIVER" -ne 1 ]; then
521+
echo "Android services did not stabilize within 120 seconds" >&2
522+
echo "bootanim=$BOOT_ANIMATION exit=$BOOT_ANIMATION_EXIT" >&2
523+
echo "ce_available=$CE_AVAILABLE unlocked=$USER_UNLOCKED" >&2
524+
exit 1
525+
fi
526+
527+
# A cold Google APIs image keeps dispatching setup broadcasts after
528+
# sys.boot_completed. Let them settle before the prebuilt app is
529+
# installed, so driver attachment cannot race an Activity relaunch.
530+
sleep 20
475531
"$PYBLE_ANDROID_ADB" -s "$PYBLE_ANDROID_SERIAL" logcat -c
476532
- name: Real About + Blockly integration (Android API 34)
477533
shell: bash

0 commit comments

Comments
 (0)