Skip to content

Commit f1ab498

Browse files
author
Lalit Sharma
committed
Fix: Add stdin redirection to all adb commands to prevent consuming while loop input
1 parent a27fa25 commit f1ab498

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -444,20 +444,20 @@ jobs:
444444
compact_utc="$(printf '%s' "$iso_utc" | tr -d ':-' | sed -E 's/T/./; s/Z$//')"
445445
fi
446446
447-
adb -s "$emulator_serial" shell "date -u $compact_utc" >/dev/null 2>&1 || true
448-
adb -s "$emulator_serial" emu avd host-time-scale 1 >/dev/null 2>&1 || true
447+
adb -s "$emulator_serial" shell "date -u $compact_utc" </dev/null >/dev/null 2>&1 || true
448+
adb -s "$emulator_serial" emu avd host-time-scale 1 </dev/null >/dev/null 2>&1 || true
449449
}
450450
451451
set_emulator_geo_gibraltar() {
452452
local lat="36.1408"
453453
local lon="-5.3536"
454-
adb -s "$emulator_serial" emu geo fix "$lon" "$lat" >/dev/null 2>&1 || true
454+
adb -s "$emulator_serial" emu geo fix "$lon" "$lat" </dev/null >/dev/null 2>&1 || true
455455
}
456456
457457
wait_for_app_foreground() {
458458
local package_name="$1"
459459
for _ in {1..30}; do
460-
if adb -s "$emulator_serial" shell dumpsys activity activities 2>/dev/null | grep -E 'mResumedActivity|topResumedActivity|mFocusedApp' | grep -Fq "$package_name"; then
460+
if adb -s "$emulator_serial" shell dumpsys activity activities </dev/null 2>/dev/null | grep -E 'mResumedActivity|topResumedActivity|mFocusedApp' | grep -Fq "$package_name"; then
461461
return 0
462462
fi
463463
sleep 1
@@ -468,9 +468,9 @@ jobs:
468468
open_deep_link() {
469469
local url="$1"
470470
471-
adb -s "$emulator_serial" shell am force-stop "$BUNDLE_ID" >/dev/null 2>&1 || true
471+
adb -s "$emulator_serial" shell am force-stop "$BUNDLE_ID" </dev/null >/dev/null 2>&1 || true
472472
473-
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 2>&1 </dev/null; then
473+
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
474474
return 0
475475
fi
476476
@@ -485,7 +485,7 @@ jobs:
485485
mkdir -p "$shots_dir"
486486
printf "index,url,file\n" > "$shots_dir/manifest.csv"
487487
488-
adb -s "$emulator_serial" shell am start -W -n "$BUNDLE_ID/$MAIN_ACTIVITY" >/dev/null 2>&1 || true
488+
adb -s "$emulator_serial" shell am start -W -n "$BUNDLE_ID/$MAIN_ACTIVITY" </dev/null >/dev/null 2>&1 || true
489489
if ! wait_for_app_foreground "$BUNDLE_ID"; then
490490
echo "::warning::App did not enter the foreground after initial launch."
491491
fi
@@ -559,7 +559,7 @@ jobs:
559559
fi
560560
echo "[$index] App is in foreground, waiting ${PER_PAGE_WAIT_SECONDS}s before screenshot..."
561561
sleep "$PER_PAGE_WAIT_SECONDS"
562-
if adb -s "$emulator_serial" exec-out screencap -p > "$shots_dir/$filename"; then
562+
if adb -s "$emulator_serial" exec-out screencap -p </dev/null > "$shots_dir/$filename"; then
563563
echo "[$index] Screenshot saved: $filename"
564564
printf "%02d,%s,%s\n" "$index" "$url" "$filename" >> "$shots_dir/manifest.csv"
565565
else

0 commit comments

Comments
 (0)