考古以前放在有道的笔记,仅作记录
休眠
所谓自动休眠,就是指用户长时间内没有跟设备进行交互,然后触发了自动息屏流程。
而按power键灭屏或者自动息屏事件都是在PowerManagerService中处理的。
具体的流程分析,// TODO
先帖两篇相关的博客:https://www.jianshu.com/p/9241f3a91095 && https://www.cnblogs.com/rainey-forrest/p/13292638.html
总之,在PowerManagerService的updateUserActivitySummaryLocked方法中,会计算用户没有活动的时间,当这个时间达到用户设置的timeout时,就会触发休眠流程。用户设置的休眠时间通过getScreenOffTimeoutLocked获取,在getScreenOffTimeoutLocked中,发现有一个系统最小的屏幕超时变量mMinimumScreenOffTimeoutConfig,这个值在frameworks/base/core/res/res/values/config.xml中的config_minimumScreenOffTimeout定义,所以,我们实现禁止设备自动休眠的方法为,将这个config_minimumScreenOffTimeout设置为尽可能大的值。
diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml
index 1170fbe..e4ac8d7 100644
--- a/core/res/res/values/config.xml
+++ b/core/res/res/values/config.xml
@@ -2428,7 +2428,7 @@
This value must be greater than zero, otherwise the device will immediately
fall asleep again as soon as it is awoken.
-->
-
+