判断显示屏保还是息屏
2112 /** 2113 * Updates the wakefulness of the device. 2114 * 2115 * This is the function that decides whether the device should start dreaming 2116 * based on the current wake locks and user activity state. It may modify mDirty 2117 * if the wakefulness changes. 2118 * 2119 * Returns true if the wakefulness changed and we need to restart power state calculation. 2120 */ 2121 private boolean updateWakefulnessLocked(int dirty) { 2122 boolean changed = false; 2123 if ((dirty & (DIRTY_WAKE_LOCKS | DIRTY_USER_ACTIVITY | DIRTY_BOOT_COMPLETED 2124 | DIRTY_WAKEFULNESS | DIRTY_STAY_ON | DIRTY_PROXIMITY_POSITIVE 2125 | DIRTY_DOCK_STATE)) != 0) { //当前屏幕保持唤醒&&设备将要进入睡眠or屏保状态 2126 if (mWakefulness == WAKEFULNESS_AWAKE && isItBedTimeYetLocked()) { 2127 if (DEBUG_SPEW) { 2128 Slog.d(TAG, "updateWakefulnessLocked: Bed time..."); 2129 } 2130 final long time = SystemClock.uptimeMillis(); //用户活动超时了应该自动的进入屏保模式 2131 if (shouldNapAtBedTimeLocked()) { //进入屏保模式 2132 changed = napNoUpdateLocked(time, Process.SYSTEM_UID); 2133 } else { //进入休眠模式 2134 changed = goToSleepNoUpdateLocked(time, 2135 PowerManager.GO_TO_SLEEP_REASON_TIMEOUT, 0, Process.SYSTEM_UID); 2136 } 2137 } 2138 } 2139 return changed; 2140 }