Screen Wake-Up from Dozing State - Workaround
Problem
On Android 16 (Pixel 10 Pro Fold), when the device is in Dozing state (screen_on: false, wakefulness: "Dozing"), standard tap() commands may not wake the screen. This blocks any UI automation that requires screen interaction, including WeChat image sending.
Observed Behavior (2026-06-26)
get_lock_status()returns:{"screen_on": false, "wakefulness": "Dozing", "locked": false}- Multiple
tap(500, 500)calls (20+ attempts) did not wake the screen - Screenshots taken during this state showed all-black images (15KB, consistent with black screen)
- The device was not locked (
locked: false), just in Dozing power state
Root Cause
Android 16's Dozing state (part of Doze mode) aggressively suppresses wake-up from non-physical interactions. ADB tap events may be ignored or deferred until the device exits Dozing.
Workarounds (in order of preference)
1. Pre-check and early abort (Recommended for cron jobs)
Before starting any UI automation sequence, check screen state. If Dozing, either:
- Abort and schedule retry for when device is likely active
- Send a notification (which may wake device) before retrying
# Check screen state first
status = get_lock_status()
if not status['screen_on']:
# Device is sleeping - cannot proceed with UI automation
# Options:
# 1. Send a push notification to wake device
# 2. Log failure and exit silently (cron will retry)
# 3. Use vibrate() as a wake signal
vibrate(duration_ms=500) # May trigger wake
time.sleep(3)
# Re-check
status = get_lock_status()
if not status['screen_on']:
print("[SILENT] Device in Dozing, cannot proceed with UI automation")
exit(0)
2. Power key press (keyevent 26) — MOST RELIABLE
Use hardware key simulation. This has proven most reliable across all Dozing states (verified 2026-06-27, 2026-06-29). Persistence matters: the first keyevent 26 may not always work. A compound sequence with keyevent 82 (unlock) and retries has succeeded when single attempts failed:
# Compound wake sequence (2026-06-29 verified: took 3 rounds)
su -c "input keyevent 26" && sleep 2 && su -c "input keyevent 82"
sleep 1
# Check - if still Dozing, repeat
su -c "input keyevent 26" && sleep 3 && su -c "input keyevent 26" && sleep 2 && su -c "input keyevent 82"
# Verify
# mcp_android_phone_get_lock_status → screen_on: true, wakefulness: Awake
If 3+ compound rounds fail (2026-06-29: first 2 rounds of single keyevent 26 failed, 3rd compound round succeeded), device needs physical interaction.
3. Vibrate as wake signal
Use vibrate() to generate a haptic event that may trigger the power manager to wake:
vibrate(duration_ms=500)
time.sleep(3)
# Check if screen woke up
3. Force screen on via settings (requires root)
# Force screen to stay on (temporary)
su -c "settings put system screen_off_timeout 600000"
# Or use wake lock
su -c "dumpsys power | grep -i wake"
4. Physical interaction simulation
For foldable devices, the fold/unfold action reliably wakes the device. If running on a foldable:
# If device has hinge sensor, simulate fold state change
# This requires device-specific implementation
5. Alternative: Send without UI automation
If the device is consistently in Dozing during cron execution, consider:
- Sending via WeChat web API (if available)
- Queueing the message for when user next unlocks device
- Using FCM/notification-based delivery instead of direct UI automation
Detection Pattern
def is_device_interactive():
"""Check if device screen is on and interactive."""
status = get_lock_status()
return status.get('screen_on', False) and status.get('wakefulness') in ['Awake', 'Interactive']
def wake_device(max_attempts=5):
"""Attempt to wake device from Dozing."""
for i in range(max_attempts):
if is_device_interactive():
return True
vibrate(duration_ms=300)
time.sleep(2)
tap(500, 500) # Center screen tap
time.sleep(2)
return is_device_interactive()
When to Apply
- Cron jobs: Always check screen state before UI automation
- Interactive sessions: User can manually wake device
- Foldable devices: Consider fold state in wake strategy
Related
screen-wakeskill: General screen wake-up techniquespixel-fold-screen-detectorskill: Foldable-specific screen state detectionwechat-image-senderskill: Image sending workflow that depends on screen being active