File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -459,17 +459,24 @@ jobs:
459459 local timestamp_ms="${timestamp_sec}000"
460460 echo "Using emulator console to set time (timestamp ms: $timestamp_ms)"
461461
462- # Use telnet to emulator console - format: <unixtime in ms>
463- # Port is typically 5554 for first emulator
464- local emu_port="$(adb -s "$emulator_serial" emu avd status 2>&1 | grep -o 'console on port [0-9]*' | grep -o '[0-9]*' || echo '5554')"
465- echo "Emulator console port: $emu_port"
466-
467- # Try using adb shell date command with formatted time
462+ # Prefer emulator console clock command first.
463+ if adb -s "$emulator_serial" emu avd setclock "$timestamp_ms" </dev/null >/dev/null 2>&1; then
464+ echo "Time set via emulator console clock"
465+ else
466+ echo "::warning::Emulator console clock command failed; falling back to shell date command."
467+ fi
468+
469+ # Try using adb shell date command with formatted time.
468470 local date_format
469471 date_format="$(date -u -j -f "%Y-%m-%dT%H:%M:%SZ" "$iso_utc" "+%m%d%H%M%Y.%S" 2>/dev/null)"
470472 echo "Trying to set date to: $date_format"
471-
472- adb -s "$emulator_serial" shell "settings put global auto_time 0; date -u $date_format" </dev/null 2>&1 | head -5
473+
474+ if shell_date_output="$(adb -s "$emulator_serial" shell "settings put global auto_time 0; date -u $date_format" </dev/null 2>&1)"; then
475+ printf '%s\n' "$shell_date_output" | head -5
476+ else
477+ printf '%s\n' "$shell_date_output" | head -5
478+ echo "::warning::Shell date command failed. Continuing with emulator-provided clock."
479+ fi
473480 else
474481 echo "::warning::Failed to parse timestamp from $iso_utc"
475482 fi
You can’t perform that action at this time.
0 commit comments