Skip to content

Commit 7cbbe14

Browse files
author
Lalit Sharma
committed
Fix: Use shell date command for time setting, add error output for deep link debugging
1 parent 84c304d commit 7cbbe14

1 file changed

Lines changed: 27 additions & 8 deletions

File tree

.github/workflows/wearos-emulator-screenshots.yml

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -459,12 +459,17 @@ jobs:
459459
local timestamp_ms="${timestamp_sec}000"
460460
echo "Using emulator console to set time (timestamp ms: $timestamp_ms)"
461461
462-
# Use emulator console command - more reliable than shell date
463-
if adb -s "$emulator_serial" emu avd setclock "$timestamp_ms" </dev/null 2>&1; then
464-
echo "Time set via emulator console"
465-
else
466-
echo "::warning::Failed to set time via emulator console"
467-
fi
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
468+
local date_format
469+
date_format="$(date -u -j -f "%Y-%m-%dT%H:%M:%SZ" "$iso_utc" "+%m%d%H%M%Y.%S" 2>/dev/null)"
470+
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
468473
else
469474
echo "::warning::Failed to parse timestamp from $iso_utc"
470475
fi
@@ -508,16 +513,30 @@ jobs:
508513
509514
open_deep_link() {
510515
local url="$1"
516+
local tmpout="/tmp/deeplink_output_$$.txt"
511517
512518
adb -s "$emulator_serial" shell am force-stop "$BUNDLE_ID" </dev/null >/dev/null 2>&1 || true
519+
sleep 1
513520
514-
if adb -s "$emulator_serial" shell am start -W -a android.intent.action.VIEW -c android.intent.category.BROWSABLE -d "$url" -p "$BUNDLE_ID" </dev/null >/dev/null 2>&1; then
521+
echo "Attempting to open deep link: $url"
522+
if adb -s "$emulator_serial" shell am start -W -a android.intent.action.VIEW -c android.intent.category.BROWSABLE -d "$url" -p "$BUNDLE_ID" </dev/null >"$tmpout" 2>&1; then
523+
echo "Deep link opened successfully (method 1)"
524+
rm -f "$tmpout"
515525
return 0
516526
fi
527+
528+
echo "Method 1 failed, output:"
529+
cat "$tmpout" 2>/dev/null | head -10
517530
518-
if adb -s "$emulator_serial" shell am start -S -W -a android.intent.action.VIEW -d "$url" -n "$BUNDLE_ID/$MAIN_ACTIVITY" >/dev/null 2>&1 </dev/null; then
531+
if adb -s "$emulator_serial" shell am start -S -W -a android.intent.action.VIEW -d "$url" -n "$BUNDLE_ID/$MAIN_ACTIVITY" </dev/null >"$tmpout" 2>&1; then
532+
echo "Deep link opened successfully (method 2)"
533+
rm -f "$tmpout"
519534
return 0
520535
fi
536+
537+
echo "Method 2 failed, output:"
538+
cat "$tmpout" 2>/dev/null | head -10
539+
rm -f "$tmpout"
521540
522541
return 1
523542
}

0 commit comments

Comments
 (0)