Use dumpsys deviceidle get screen in CMD_SCREEN_ON - #369
Open
tgrushka wants to merge 1 commit into
Open
Conversation
tgrushka
force-pushed
the
avoid-early-exit-grep-on-dumpsys
branch
2 times, most recently
from
August 2, 2026 22:02
de9e1ce to
45f0456
Compare
This PR: - fixes a broken pipe like in JeffLIrion#351, but from `grep -q` instead of `grep -m 1` - uses a much more efficient call to get screen state On Android 14, both `dumpsys power` greps no longer match. It prints `Display Power: com.android.server.power.PowerManagerService$1@a8a75e6` with no `state=` field, and `mScreenOn=true` is gone. So each poll, every 10 seconds, falls back to `dumpsys display`, a much more expensive call. Because `grep -q` terminates on first match, the pipe is broken, resulting in a stack trace every 10 seconds that looks like: ``` W FastPrintWriter: Write failure W FastPrintWriter: java.io.IOException: write failed: EPIPE (Broken pipe) W FastPrintWriter: at libcore.io.IoBridge.write(IoBridge.java:651) W FastPrintWriter: at java.io.FileOutputStream.write(FileOutputStream.java:432) W FastPrintWriter: at com.android.internal.util.FastPrintWriter.flushBytesLocked(FastPrintWriter.java:355) W FastPrintWriter: at com.android.internal.util.FastPrintWriter.flushLocked(FastPrintWriter.java:378) W FastPrintWriter: at com.android.internal.util.FastPrintWriter.flush(FastPrintWriter.java:413) W FastPrintWriter: at android.os.Binder.dump(Binder.java:1158) W FastPrintWriter: at android.os.Binder.onTransact(Binder.java:1022) W FastPrintWriter: Caused by: android.system.ErrnoException: write failed: EPIPE (Broken pipe) W FastPrintWriter: at libcore.io.IoBridge.write(IoBridge.java:646) W FastPrintWriter: ... 9 more ``` This PR fixes the issue: - uses `dumpsys deviceidle get screen` to check screen state, which is cheap and has been available since Android 7 - removes `-q` so grep will not stop on first match and cause broken pipe
tgrushka
force-pushed
the
avoid-early-exit-grep-on-dumpsys
branch
from
August 2, 2026 22:04
45f0456 to
21b2836
Compare
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.
This PR:
grep -qinstead ofgrep -m 1On Android 14, both
dumpsys powergreps no longer match. It printsDisplay Power: com.android.server.power.PowerManagerService$1@a8a75e6with nostate=field, andmScreenOn=trueis gone. So each poll, every 10 seconds, falls back todumpsys display, a much more expensive call.EDIT: Tested on LineageOS 21 (Android 14, SDK 34), x86_64 Android TV.
Because
grep -qterminates on first match, the pipe is broken, resulting in a stack trace every 10 seconds that looks like:This PR fixes the issue:
dumpsys deviceidle get screento check screen state, which is cheap and has been available since Android 7-qso grep will not stop on first match and cause broken pipe> /dev/nullis now needed to replace output suppression that-qprovided