Skip to content

Android 14 Google TV: dumpsys … | grep -q writes "Broken pipe" into output → screen_on/awake misparsed, device reported off #373

Open

Description

@steevo

Title: Android 14 Google TV: dumpsys … | grep -q writes "Broken pipe" into output → screen_on/awake misparsed, device reported off

Device

  • Chromecast with Google TV 4K (sabrina), Android 14 (SDK 34)
  • Build: google/sabrina_prod_stable/sabrina:14/UTTC.250917.004/14193937:user/release-keys
  • Home Assistant 2026.10.1, androidtv integration (direct ADB, port 5555, no ADB server), device class auto

Problem
The media player is reported off (sometimes idle) while the TV is on and playing (Disney+ in foreground, media session PLAYING).

Cause
CMD_SCREEN_ON_AWAKE_WAKE_LOCK_SIZE pipes dumpsys power into grep -q. grep -q exits on the first match, and on this firmware dumpsys then prints an error that ends up in the ADB shell output:

$ (dumpsys power | grep 'Display Power' | grep -q 'state=ON' || dumpsys power | grep -q 'mScreenOn=true' || dumpsys display | grep -q 'mScreenState=ON') && echo -n 1 || echo -n 0; dumpsys power | grep mWakefulness | grep -q Awake && echo -n 1 || echo -n 0; dumpsys power | grep Locks | grep 'size='
1Failed to write while dumping service power: Broken pipe
1Wake Locks: size=2

_screen_on_awake_wake_lock_size() reads output[1] as the awake flag. Here it is F, so awake=False. The device is then treated as off, and get_properties(lazy=True) skips the remaining properties. The message is timing-dependent, so the state flips between off and idle.

Each command on its own returns the correct values (screen on, mWakefulness=Awake, Wake Locks: size=2, media session state=PLAYING(3)).

Suggested fix
Send dumpsys stderr to /dev/null (e.g. dumpsys power 2>/dev/null | grep -q …) in the screen/awake/wake-lock commands, or avoid grep -q early exit (grep … > /dev/null). Either one keeps the error text out of the parsed output.

Activity

  1. JordiRubio93 commented on Oct 25, 2026

    @JordiRubio93

    Confirming this on a second device: a TCL TV on Android 14 (Google TV launcher), with the Home Assistant androidtv integration (direct ADB, androidtv 0.0.75).

    Here Display Power has no state= field and mScreenOn is missing, so CMD_SCREEN_ON falls through to dumpsys display | grep -q. That is the call that breaks the pipe. Output of CMD_SCREEN_ON_AWAKE_WAKE_LOCK_SIZE through Home Assistant's own ADB connection:

    'Failed to write while dumping service display: Broken pipe\n10Wake Locks: size=1'
    

    output[0] is F, so screen_on is False and the entity is always off. With 2>/dev/null after each dumpsys:

    '10Wake Locks: size=1'
    

    The entity then shows the real state. An Android 11 TV produces identical output with and without the redirect.

    I opened a PR that adds the redirect to every dumpsys in constants.py and adds a test to keep it that way: #376

  2. added a commit that references this issue on Oct 25, 2026
    f67e1c5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions