如何判断屏幕上与亚洲开发银行亚洲、开发银行、如何判断、屏幕上

2023-09-06 04:23:51 作者:谈天

我期待找出是否有可能确定如果屏幕上使用亚洲开发银行在Android设备上。我需要知道这对于一些测试我试图用猴子亚军运行。是否有一个shell命令我可以进去了,因此包括作为猴子亚军命令的一部分,这会告诉我明确如果屏幕是打开还是关闭?

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?

推荐答案

在做一些测试,我发现,使用亚行外壳dumpsys电源| grep的mScreenOn 将工作的有4.2版本号设备+

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.

在测试范围内对所有的Andr​​oid模拟器2.2 - 4.4.2,三星Galaxy SII(4.0.4),三星Galaxy Tab 8.9(4.0.4),和Nexus 4 CM11

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

另外值得一提的是,在pre 4.2设备,您可以使用命令亚行外壳dumpsys电源| grep的mPowerState 来得到这样的:

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

和检测是否SCREEN_ON_BIT字符串是present

and detect if the SCREEN_ON_BIT string is present