Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 38 additions & 4 deletions .github/workflows/wearos-emulator-screenshots.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ on:
description: "Deep links separated by comma or newline"
required: false
type: string
default: "eclipsetimer://wear/landing,eclipsetimer://wear/live,eclipsetimer://wear/preview,eclipsetimer://wear/diagnostics"
default: "eclipsetimer://wear/live?scenario=gibraltar-between-c1-c3,eclipsetimer://wear/live?scenario=gibraltar-max"

concurrency:
group: wearos-screenshots-${{ github.ref }}
Expand Down Expand Up @@ -430,6 +430,30 @@ jobs:

adb -s "$emulator_serial" install -r "$APP_PATH"

adb -s "$emulator_serial" shell pm grant "$BUNDLE_ID" android.permission.ACCESS_FINE_LOCATION || true
adb -s "$emulator_serial" shell pm grant "$BUNDLE_ID" android.permission.ACCESS_COARSE_LOCATION || true

adb -s "$emulator_serial" shell settings put global auto_time 0 || true
adb -s "$emulator_serial" shell settings put global auto_time_zone 0 || true

set_emulator_time_utc() {
local iso_utc="$1"
local compact_utc
Comment thread
c0d3rb4b4 marked this conversation as resolved.
compact_utc="$(date -u -j -f "%Y-%m-%dT%H:%M:%SZ" "$iso_utc" "+%Y%m%d.%H%M%S" 2>/dev/null || true)"
if [ -z "$compact_utc" ]; then
compact_utc="$(printf '%s' "$iso_utc" | tr -d ':-' | sed -E 's/T/./; s/Z$//')"
fi

adb -s "$emulator_serial" shell "date -u $compact_utc" >/dev/null 2>&1 || true
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Fail when emulator clock override does not apply

This command masks failures from adb shell date, so on emulator images where shell time changes are rejected or the format is invalid, the workflow still succeeds and captures screenshots at the wrong instant. Because no later check validates the applied clock, the produced Gibraltar scenario artifacts can silently be incorrect while the run appears green.

Useful? React with 👍 / 👎.

adb -s "$emulator_serial" emu avd host-time-scale 1 >/dev/null 2>&1 || true
}

set_emulator_geo_gibraltar() {
local lat="36.1408"
local lon="-5.3536"
adb -s "$emulator_serial" emu geo fix "$lon" "$lat" >/dev/null 2>&1 || true
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Surface GPS injection failures before taking screenshots

The GPS fix is also wrapped with || true, so if adb emu geo fix is unavailable or fails for the selected emulator, captures continue with stale/default coordinates. Since the workflow then packages and uploads screenshots without verifying location, this can silently invalidate the intended Gibraltar-specific output.

Useful? React with 👍 / 👎.

}

wait_for_app_foreground() {
local package_name="$1"
for _ in {1..30}; do
Expand All @@ -450,8 +474,6 @@ jobs:
echo "::warning::App did not enter the foreground after initial launch."
fi
sleep "$STARTUP_WAIT_SECONDS"
adb -s "$emulator_serial" exec-out screencap -p > "$shots_dir/00-launch.png"
printf "00,launch,00-launch.png\n" >> "$shots_dir/manifest.csv"

DEEP_LINKS_INPUT="$(cat <<'EOF'
${{ github.event.inputs.deep_links }}
Expand All @@ -470,13 +492,25 @@ jobs:
index=1
while IFS= read -r url; do
[ -z "$url" ] && continue

case "$url" in
*gibraltar-between-c1-c3*)
set_emulator_time_utc "2027-08-02T08:23:09Z"
set_emulator_geo_gibraltar
;;
*gibraltar-max*)
set_emulator_time_utc "2027-08-02T08:47:59Z"
set_emulator_geo_gibraltar
;;
esac

slug="$(printf '%s' "$url" | sed -E 's#^[a-zA-Z][a-zA-Z0-9+.-]*://##; s#[^A-Za-z0-9._-]+#-#g; s#-+#-#g; s#^-##; s#-$##')"
if [ -z "$slug" ]; then
slug="screen-$index"
fi
filename="$(printf '%02d' "$index")-$slug.png"

if adb -s "$emulator_serial" shell am start -W -a android.intent.action.VIEW -d "$url" "$BUNDLE_ID" >/dev/null 2>&1 </dev/null; then
if adb -s "$emulator_serial" shell am start -W -a android.intent.action.VIEW -d "$url" -n "$BUNDLE_ID/$MAIN_ACTIVITY" >/dev/null 2>&1 </dev/null; then
if ! wait_for_app_foreground "$BUNDLE_ID"; then
echo "::warning::Deep link opened but app is not foregrounded: $url"
index=$((index + 1))
Expand Down