PowerManagerService.java

2022/1/10 14:04:02

本文主要是介绍PowerManagerService.java,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

判断显示屏保还是息屏

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      }



这篇关于PowerManagerService.java的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程