Wakelock和打盹模式 [英] Wakelock and doze mode

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

问题描述

据当系统处于休眠模式的Andr​​oid棉花糖文档,任何wakelock被忽略。但是这不是我清楚,如果wakelock prevent打盹模式或不。

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的最后$ P $的Andr​​oid 6.0的PVIEW安装(?):

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)

保持在屏幕上使用安卓keepScreenOn (或相当于Java),在屏幕上,的足够块打盹模式

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

保持在屏幕上使用安卓keepScreenOn (或相当于Java),与屏幕关闭(用户presses POWER键),是不够的阻止打盹模式

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,视频播放器等,不应当用户正在观看的视频,即使玩家可能不被移动或充电受到影响。但是,如果用户presses POWER键,你回有打盹的危险。

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).

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

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