唤醒锁定和打瞌睡模式 [英] Wakelock and doze mode

查看:23
本文介绍了唤醒锁定和打瞌睡模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据 Android Marshmallow 文档,当系统处于打盹模式时,任何唤醒锁都会被忽略.但是我不清楚唤醒锁是否可以防止打瞌睡模式.

According to Android Marshmallow documentation when the system is in doze mode, any wakelock is ignored. However it's not clear to me if a wakelock prevent doze mode or not.

推荐答案

基于一些测试,使用 Nexus 5 并安装了 Android 6.0 的最终(?)预览版:

Based on some testing, using a Nexus 5 with the the final(?) preview of Android 6.0 installed:

  • 持有 PARTIAL_WAKE_LOCK 不足以阻止打瞌睡模式 —即使您拥有 WakeLock 并且正在尝试执行常规工作(例如,setExactAndAllowWhileIdle() 以每分钟获得控制权),设备仍会打瞌睡.

  • Holding a PARTIAL_WAKE_LOCK is insufficient to block Doze mode — the device will still doze, even though you have the WakeLock and are trying to do regular work (e.g., setExactAndAllowWhileIdle() to get control every minute)

使用 android:keepScreenOn(或 Java 等价物)保持屏幕开启,在屏幕开启的情况下,足以阻止打瞌睡模式

Keeping the screen on using android:keepScreenOn (or the Java equivalent), with the screen on, is sufficient to block Doze mode

使用 android:keepScreenOn(或 Java 等效项)保持屏幕开启,同时屏幕关闭(用户按下电源按钮),不足以阻止打瞌睡模式

Keeping the screen on using android:keepScreenOn (or the Java equivalent), with the screen off (user presses POWER button), is insufficient to block Doze mode

IOW、视频播放器等不应在用户观看视频时受到影响,即使播放器可能没有移动或充电.但是,如果用户按下电源按钮,您又会面临打瞌睡的风险.

IOW, video players and the like should not be affected while the user is watching the video, even though the player may not be moving or charging. However, if the user presses the POWER button, you're back into having Doze risk.

我还没有尝试过使用 FULL_WAKE_LOCK(我希望行为与 android:keepScreenOn 相同,但我不确定).

I have not tried using FULL_WAKE_LOCK (I would expect behavior identical to android:keepScreenOn, but I am far from certain).

这篇关于唤醒锁定和打瞌睡模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆