Repository navigation
Discard dumpsys stderr so "Broken pipe" does not corrupt parsed output - #376
Open
JordiRubio93 wants to merge 1 commit into
Open
JordiRubio93 wants to merge 1 commit into
JordiRubio93 wants to merge 1 commit into
Conversation
grep -q / grep -m 1 can exit early; dumpsys then writes a Broken pipe error to stderr, which the ADB shell merges into the output (fixes JeffLIrion#373).
JordiRubio93
force-pushed
the
fix-dumpsys-stderr-broken-pipe
branch
from
October 25, 2026 11:46
223f0d9 to
f67e1c5
Compare
Author
|
A note on the red CI. Neither failure comes from this change:
Because lint stops each job, the tests never run in CI. Locally, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #373.
Problem
Several
CMD_*commands pipedumpsysintogrep -qorgrep -m 1. Oncegrepexits early,dumpsyswritesFailed to write while dumping service <name>: Broken pipeto stderr. The ADB shell merges stderr into the output, so the parsers read the wrong characters.On an Android 14 TCL TV (Google TV launcher),
Display Powerno longer has astate=field andmScreenOnis gone.CMD_SCREEN_ONtherefore falls through todumpsys display | grep -q ..., and the first character of the output isFinstead of1._screen_on_awake_wake_lock_size()then reports the screen as off, and the media player staysoffwhile the TV is on.Output of
CMD_SCREEN_ON_AWAKE_WAKE_LOCK_SIZE, captured through Home Assistant's own ADB connection:On an Android 11 TCL TV the output is identical before and after the change.
Change
2>/dev/nullto everydumpsyscall inandroidtv/constants.py, right before its pipe. Only stderr is discarded, so nothing the parsers read from stdout changes.tests/test_constants.py.test_dumpsys_stderr_discarded, which fails if aCMD_*constant contains adumpsyscall that does not discard stderr.This complements #369, which avoids the expensive
dumpsys displayfallback for the screen state. This PR also coversCMD_AWAKE, the current-app commands that usegrep -m 1, and the audio commands, which hit the same broken pipe.Testing
pytest tests: 233 passed.constants.py.idlewhile the screensaver is on) instead ofoff.