I am looking to find out whether or not it is possible to determine if the screen is on on an android device using ADB. I need to know this for some tests I am trying to run using monkey runner. Is there a shell command I can enter, and thus include as part of a monkey runner command, that will tell me definitively if the screen is on or off?
-
http://stackoverflow.com/a/19612157/1778421 – Alex P. Jan 28 '14 at 15:04
-
@AlexP. Yeah it is, I missed that while looking for this answer. – Andrew T. Jan 28 '14 at 15:15
2 Answers
In doing some testing I've found that using adb shell dumpsys power | grep mScreenOn
will work on devices that have a version number of 4.2+
The command that I have found to work on all devices I have tested so far is to use:
adb shell dumpsys input_method | grep mScreenOn
which will produce something like:
mSystemReady=true mScreenOn=true
which you can use to determine if the screen is on.
Tested on all Android Emulators in the range 2.2 - 4.4.2, Samsung Galaxy SII (4.0.4), Samsung Galaxy Tab 8.9 (4.0.4), and Nexus 4 with CM11
Also worth mentioning, on pre 4.2 devices you can use the command adb shell dumpsys power | grep mPowerState
to get something like this:
mIsPowered=true mPowerState=3 mScreenOffTime=24970 ms
mPowerState=SCREEN_BRIGHT_BIT SCREEN_ON_BIT
and detect if the SCREEN_ON_BIT string is present

- 1,183
- 1
- 11
- 23
-
8On Lollipop (Nexus 6), the first command responds with `mInteractive=true` when the screen is on, or `mInteractive=false` when off; and the second command responds with `Display Power: state=ON` when on, and `state=OFF` when the screen is off. – Joe Feb 18 '15 at 21:41
-
On my Sony Bravia Android 8 TV, `dumpsys power` has no `mScreenOn`. But I see `mWakefulness=Asleep` when the TV screen is off, `mWakefulness=Awake` when the TV screen is on. – Simon Kissane Jan 31 '21 at 18:02
Yes, if you enter:
adb shell dumpsys power | grep mScreenOn
This will return a true or false value telling you whether or not the screen is currently on. It should look like this:
mScreenOn=true
Knowing this, all you need to do is parse the true/false value out of the result, and feed the shell command into a monkey runner script.
This was tested on an android device running 4.4.2.

- 4,598
- 4
- 35
- 54
-
The service to dump may vary depending on the device you are using. On my Nexus 4 emulator I needed to dump input_method instead of power. – Carlo B. Jan 28 '14 at 16:39
-
@CarloB. That is also good to know, I have a physical Nexus 4 and 5 both running 4.4.2, both will respond to dumpsys power. I'm curious if your command is specific to the emulator, or a specific version of android. – Andrew T. Jan 28 '14 at 20:20