屏保流程网上资料以及很多,还是按照自己思路整理下。
屏保控制参数
序号 | 参数名称 | 参数说明 | 默认参数值 |
---|---|---|---|
1 | screensaver_enabled | 屏保使能开关 | 1 |
2 | screensaver_activate_on_dock | 屏保启动场景,连接底座时启动屏保 | 0 |
3 | screensaver_activate_on_sleep | 屏保启动场景,睡眠时启动屏保 | 1 |
4 | screen_off_timeout | 进入dream状态前未活动时间 | def_screen_off_timeout,60000 |
5 | sleep_timeout | 进入sleep状态前未活动时间 | def_sleep_timeout,-1 |
6 | screensaver_components | 屏保应用包名 | screensaver_default_component |
用户活动,更新UserActivity时间
按键/输入法 --> pm.userActivity() --> userActivityInternal() -> userActivityNoUpdateLocked()
--> updatePowerStateLocked() --> updateUserActivitySummaryLocked()
进入Dream流程
设计到源码:
DreamController.java
DreamManagerService.java
PowerManagerService.java:
handleUserActivityTimeout() --> updatePowerStateLocked() --> updateWakefulnessLocked() --> napNoUpdateLocked() --> setWakefulnessLocked(WAKEFULNESS_DREAMING, 0)
startDream() --> DreamManagerService --> DreamController ->拉起screensaver_components对应的应用
进入屏保日志:
01-25 09:05:06.581 622 1502 I PowerManagerService: Nap time (uid 1000)...
01-25 09:05:06.607 622 662 I DreamManagerService: Entering dreamland.
01-25 09:05:06.614 622 662 I PowerManagerService: Dreaming...
01-25 09:05:06.626 622 656 I DreamController: Starting dream: name=ComponentInfo{com.google.android.backdrop/com.google.android.backdrop.Backdrop}, isTest=false, canDoze=false, userId=0
唤醒:
01-25 09:05:20.793 622 633 I DreamManagerService: Gently waking up from dream.
01-25 09:05:20.796 622 656 I DreamManagerService: Performing gentle wake from dream.
01-25 09:05:22.316 622 633 I DreamManagerService: Leaving dreamland.
01-25 09:05:22.316 622 656 I DreamManagerService: Performing gentle wake from dream.
01-25 09:05:22.316 622 656 I DreamController: Stopping dream: name=ComponentInfo{com.google.android.backdrop/com.google.android.backdrop.Backdrop}, isTest=false, canDoze=false, userId=0
01-25 09:05:22.320 622 662 I PowerManagerService: Waking up from dream (uid=1000 reason=android.server.power:DREAM)...
网友评论