privatelong mNextWakeup; // 下一个包含 wakeup 的 batch 的开始时间 privatelong mNextNonWakeup; // 下一个包含 no wake up 的 batch 的开始时间 privatelong mLastWakeupSet; privatelong mLastWakeup;
booleanmInteractive=true; // 熄屏亮屏状态,亮屏为 true
long mNonInteractiveStartTime; // 熄灭屏幕的开始时间; long mNonInteractiveTime; // 熄灭屏幕的最长时间间隔;
long mLastAlarmDeliveryTime; // 上一个 alarm 的分发时间! long mStartCurrentDelayTime; // 需要延迟执行的非 wake up 类型的 alarm 开始延迟的时间! long mNextNonWakeupDeliveryTime; // 下一次非 wake up 类型的 alarm 分发时间!
long mLastTimeChangeClockTime; // 上一次时间发生改变的时间点,取值为 System.currentTimeMillis(); long mLastTimeChangeRealtime; // 上一次时间发生改变的时间点,取值为 SystemClock.elapsedRealtime();
long mAllowWhileIdleMinTime; // 可以开始执行 flag 为 ALLOW_WHILE_IDLE 的 alarm 的最小时间间隔!
longmTotalDelayTime=0; longmMaxDelayTime=0; //
int mNumTimeChanged; // 时间改变的次数! intmNumDelayedAlarms=0;
/** * For each uid, this is the last time we dispatched an "allow while idle" alarm, * used to determine the earliest we can dispatch the next such alarm. */ finalSparseLongArraymLastAllowWhileIdleDispatch=newSparseLongArray();
final ArrayList<IdleDispatchEntry> mAllowWhileIdleDispatches = newArrayList();
privatefinal SparseArray<AlarmManager.AlarmClockInfo> mNextAlarmClockForUser = newSparseArray<>(); privatefinal SparseArray<AlarmManager.AlarmClockInfo> mTmpSparseAlarmClockArray = newSparseArray<>(); privatefinalSparseBooleanArraymPendingSendNextAlarmClockChangedForUser= newSparseBooleanArray(); /** * The current set of user whitelisted apps for device idle mode, meaning these are allowed * to freely schedule alarms. */ int[] mDeviceIdleUserWhitelist = newint[0];
final SparseArray<ArrayMap<String, BroadcastStats>> mBroadcastStats = newSparseArray<ArrayMap<String, BroadcastStats>>(); // May only use on mHandler's thread, locking not required. privatefinal SparseArray<AlarmManager.AlarmClockInfo> mHandlerSparseAlarmClockArray = newSparseArray<>(); final LinkedList<WakeupEvent> mRecentWakeups = newLinkedList<WakeupEvent>();
final HashMap<String, PriorityClass> mPriorities = newHashMap<>();
// // alarm批处理对象列表 final ArrayList<Batch> mAlarmBatches = newArrayList<>();
final Comparator<Alarm> mAlarmDispatchComparator = newComparator<Alarm>() { @Override publicintcompare(Alarm lhs, Alarm rhs) { // priority class trumps everything. TICK < WAKEUP < NORMAL if (lhs.priorityClass.priority < rhs.priorityClass.priority) { return -1; } elseif (lhs.priorityClass.priority > rhs.priorityClass.priority) { return1; }
// within each class, sort by nominal delivery time if (lhs.whenElapsed < rhs.whenElapsed) { return -1; } elseif (lhs.whenElapsed > rhs.whenElapsed) { return1; }
// same priority class + same target delivery time return0; } };
finallongRECENT_WAKEUP_PERIOD=1000L * 60 * 60 * 24; // one day
// minimum recurrence period or alarm futurity for us to be able to fuzz it staticfinallongMIN_FUZZABLE_INTERVAL=10000;
// set to null if in idle mode; while in this mode, any alarms we don't want // to run during this time are placed in mPendingWhileIdleAlarms AlarmmPendingIdleUntil=null;