且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

有没有办法检查Android设备屏幕是否通过adb锁定?

更新时间:2022-06-22 23:12:58

此命令将输出与设备电源有关的所有信息:

This command will output everything relating to power for the device:

adb shell dumpsys power

您可以将其通过管道传输到grep获取 mHoldingWakeLockSuspendBlocker mHoldingDisplaySuspendBlocker 的值:

You can pipe this to a grep to get the values of mHoldingWakeLockSuspendBlocker and mHoldingDisplaySuspendBlocker:

adb shell dumpsys power | grep 'mHolding'

如果两者都为假,则显示关闭。

If both are false, the display is off.

如果 mHoldingWakeLockSuspendBlocker 为false,而 mHoldingDisplaySuspendBlocker 为true,则显示处于打开状态,但

If mHoldingWakeLockSuspendBlocker is false, and mHoldingDisplaySuspendBlocker is true, the display is on, but locked.

如果两个都为真,则显示处于打开状态。

If both are true, the display is on.