Wakelock and doze mode

后端 未结 4 1255
一整个雨季
一整个雨季 2020-11-30 05:26

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

4条回答
  •  無奈伤痛
    2020-11-30 05:41

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

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

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

    • 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, 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.

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

提交回复
热议问题