App Idle 相关流程图
2020-12-14 14:59:05 1 举报
App Standby
作者其他创作
大纲/内容
UserActionsReceiver
DeviceStateReceiver
强制进入 idle
After 24 hours
postParoleEndTimeout
MSG_REPORT_EVENT
AppIdleHistory.updateDisplayLocked
informListeners
deviceIdle
postParoleStateChanged
!deviceIdle && timeSinceLastParole = mAppIdleParoleIntervalMillis
监听电量的变化
Y
packageHistory.lastUsedScreenTime = getScreenOnTimeLocked(elapsedRealtime) - mScreenOnTimeThresholdpackageHistory.lastUsedElapsedTime = getElapsedTimeLocked(elapsedRealtime) - mElapsedTimeThreshold
如果充电状态发生了变化,发送该广播
监听屏幕亮灭
idle
reportContentProviderUsage
After timeLeft
mScreenOnDuration += elapsedRealtime - mScreenOnSnapshot;mElapsedDuration += elapsedRealtime - mElapsedSnapshot;mElapsedSnapshot = elapsedRealtime;
DisplayManager.DisplayListener
设置下一次进入假释状态的消息,每一次假释状态的进入相隔 24 小时
MSG_CHECK_PAROLE_TIMEOUT
MSG_PAROLE_STATE_CHANGED
LocalService
isAppIdleUnfiltered
用户被自动后,会触发 idle 检查
调整时间变量!
isAppIdleFiltered
Intent.ACTION_USER_STARTED
informParoleStateChanged
AppIdleStateChangeListener.onParoleStateChanged
不是 device idle 状态(doze 模式),且距离上次假释状态超过了 24 hours,进入假释状态
checkParoleTimeout
setChargingState
AppIdleHistory.setIdleLocked
ScreenOn
否则就继续延迟进入假释
reportEvent
mAppIdleTempParoled = paroled;
如果距离上一次进入假释状态超过了 24 小时,那么就进入假释
AppIdleHistory.setIdle
MSG_PAROLE_END_TIMEOUT
checkIdleStates
判断是否进入 idle 状态
idle 状态的条件
N
setAppIdleParoled(false)
MSG_INFORM_LISTENERS
假释状态只能持续 10 mins,设置用于退出假释状态的消息
isParoledOrCharging
forceIdleState
postCheckIdleStates
setAppIdleParoled(true)
是 device idle 状态,退出假释!
packageHistory.lastUsedElapsedTime = mElapsedDuration + (elapsedRealtime - mElapsedSnapshot);packageHistory.lastUsedScreenTime = getScreenOnTimeLocked(elapsedRealtime);
onDeviceIdleModeChanged
ScreenOnSnapshot = elapsedRealtime
onDisplayChanged
Intent.ACTION_BATTERY_CHANGED
AppIdleHistory.isIdleLocked
every 8 hours
PowerManager.ACTION_DEVICE_IDLE_MODE_CHANGED
处理假释状态的变化
long timeLeft = (mLastAppIdleParoledTime + mAppIdleParoleIntervalMillis) - checkAndGetTimeLocked();
MSG_REPORT_CONTENT_PROVIDER_USAGE
MSG_CHECK_IDLE_STATES
long timeSinceLastParole = checkAndGetTimeLocked() - mLastAppIdleParoledTime;
判断是否是充电或者是假释状态变化了
After 10 mins
监听设备状态
timeSinceLastParole mAppIdleParoleIntervalMillis
postNextParoleTimeout
AppIdleHistory.hasPassedThresholdsLocked
通知所有的 app idle 监听器
AppIdleHistory.reportUsageLocked
设置充电状态
监听 doze 模式的状态
更新 app 使用信息
0 条评论
下一页