Tried to check device Screen ON or OFF using mScreenOn=true
or mPowerState=SCREEN_BRIGHT_BIT
. But the following commands are NOT working in latest android versions. It is returning nothing
Following commands working fine in Android - 4.3 Jelly Bean
using input_method dumpsys
adb shell dumpsys input_method | grep mScreenOn
using power dumpsys
adb shell dumpsys power | grep mScreenOn
or
adb shell dumpsys power | grep mPowerState
is there any other way to verify the screen OFF or ON state using adb shell command on latest android versions (Lollipop, Nougat, Oreo, Pie,..etc)
Recently I had same problem and found out below solution.
mInteractive value would be "true" in dumpsys input_method for display ON and "false" for display OFF.
Ex usage in shell script:
screen_info=`adb shell dumpsys input_method | grep mInteractive=true`
if [[ $screen_info == *"mInteractive"* ]]
then
echo "Screen is ON"
#Do something
else
echo "Screen is OFF"
#Do something
fi