简体   繁体   English

何时以及为何需要PARTIAL_WAKE_LOCK?

[英]When and why PARTIAL_WAKE_LOCK is required?

All other wake locks makes sense eg developer want screen not to go off while performing something. 所有其他唤醒锁定是有道理的,例如开发人员希望屏幕在执行某些操作时不会熄 But in partial wake lock documentation says that : 但在部分唤醒锁文档中说:

If you hold a partial wake lock, the CPU will continue to run, regardless of any display timeouts or the state of the screen and even after the user presses the power button. 如果保持部分唤醒锁定,CPU将继续运行,无论显示超时或屏幕状态如何,甚至在用户按下电源按钮之后。 In all other wake locks, the CPU will run, but the user can still put the device to sleep using the power button. 在所有其他唤醒锁中,CPU将运行,但用户仍然可以使用电源按钮使设备进入休眠状态。

Does that mean while performing some operation CPU can go off? 这是否意味着在执行某些操作时CPU可以关闭? Is it required to acquire wake lock in a service? 是否需要在服务中获取唤醒锁定?

Does that mean while performing some operation CPU can go off? 这是否意味着在执行某些操作时CPU可以关闭? Is it required to acquire wake lock in a service? 是否需要在服务中获取唤醒锁定?

Of course (and here - for the power off button) ! 当然这里 - 关闭电源按钮)! Things are even more complicated if you are trying to start your service while the device is asleep . 如果您在设备处于睡眠状态时尝试启动服务情况会更加复杂。 You most probably won't make it. 你很可能不会成功。 Have a look at Commonsware WakefulIntentService - the notion is that using an alarm manager Receiver (which holds a wake lock) you must afterwards get a (static) wakelock while still in onReceive() to keep awake. 看看Commonsware WakefulIntentService - 这个概念是使用一个警报管理器Receiver(它有一个唤醒锁定),你必须在仍然在onReceive()同时获得(静态)唤醒锁,以保持清醒。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM