android系统添加永不休眠选项

修改点:

android/frameworks/base/packages/SettingsProvider/res/values/defaults.xml

-    604800000

+    0


android/frameworks/base/services/core/java/com/android/server/policy/PhoneWindowManager.java

private void updateLockScreenTimeout() {

      synchronized (mScreenLockTimeout) {

          boolean enable = (mAllowLockscreenWhenOn && mAwake &&

                  mKeyguardDelegate != null && mKeyguardDelegate.isSecure(mCurrentUserId));

          if (mLockScreenTimerActive != enable) {

              if (enable) {

                  if (localLOGV) Log.v(TAG, "setting lockscreen timer");

                  mHandler.removeCallbacks(mScreenLockTimeout); // remove any pending requests

                                      if (mLockScreenTimeout != 0) {//time is 0 never sleep,not is 0 keep

                  mHandler.postDelayed(mScreenLockTimeout, mLockScreenTimeout);

                                      }

              } else {

                  if (localLOGV) Log.v(TAG, "clearing lockscreen timer");

                  mHandler.removeCallbacks(mScreenLockTimeout);

              }

              mLockScreenTimerActive = enable;

          }

      }

  }


android/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.java

private void updateUserActivitySummaryLocked(long now, int dirty) {

        // Update the status of the user activity timeout timer.

        if ((dirty & (DIRTY_WAKE_LOCKS | DIRTY_USER_ACTIVITY

                | DIRTY_WAKEFULNESS | DIRTY_SETTINGS)) != 0) {

            mHandler.removeMessages(MSG_USER_ACTIVITY_TIMEOUT);

            long nextTimeout = 0;

            if (mWakefulness == WAKEFULNESS_AWAKE

                    || mWakefulness == WAKEFULNESS_DREAMING

                    || mWakefulness == WAKEFULNESS_DOZING) {

                final int sleepTimeout = getSleepTimeoutLocked();

                final int screenOffTimeout = getScreenOffTimeoutLocked(sleepTimeout);

                final int screenDimDuration = getScreenDimDurationLocked(screenOffTimeout);

                final boolean userInactiveOverride = mUserInactiveOverrideFromWindowManager;

                mUserActivitySummary = 0;

                if (mLastUserActivityTime >= mLastWakeTime) {

                    nextTimeout = mLastUserActivityTime

                            + screenOffTimeout - screenDimDuration;

                    if (now < nextTimeout) {

                        mUserActivitySummary = USER_ACTIVITY_SCREEN_BRIGHT;

                    } else {

                        nextTimeout = mLastUserActivityTime + screenOffTimeout;

                        if (now < nextTimeout) {

                            mUserActivitySummary = USER_ACTIVITY_SCREEN_DIM;

                        }

                    }

                }

                if (mUserActivitySummary == 0

                        && mLastUserActivityTimeNoChangeLights >= mLastWakeTime) {

                    nextTimeout = mLastUserActivityTimeNoChangeLights + screenOffTimeout;

                    if (now < nextTimeout) {

                        if (mDisplayPowerRequest.policy == DisplayPowerRequest.POLICY_BRIGHT

                                || mDisplayPowerRequest.policy == DisplayPowerRequest.POLICY_VR) {

                            mUserActivitySummary = USER_ACTIVITY_SCREEN_BRIGHT;

                        } else if (mDisplayPowerRequest.policy == DisplayPowerRequest.POLICY_DIM) {

                            mUserActivitySummary = USER_ACTIVITY_SCREEN_DIM;

                        }

                    }

                }

                if (mUserActivitySummary == 0) {

                    if (sleepTimeout >= 0) {

                        final long anyUserActivity = Math.max(mLastUserActivityTime,

                                mLastUserActivityTimeNoChangeLights);

                        if (anyUserActivity >= mLastWakeTime) {

                            nextTimeout = anyUserActivity + sleepTimeout;

                            if (now < nextTimeout) {

                                mUserActivitySummary = USER_ACTIVITY_SCREEN_DREAM;

                            }

                        }

                    } else {

                        mUserActivitySummary = USER_ACTIVITY_SCREEN_DREAM;

                        nextTimeout = -1;

                    }

                }

                if (mUserActivitySummary != USER_ACTIVITY_SCREEN_DREAM && userInactiveOverride) {

                    if ((mUserActivitySummary &

                            (USER_ACTIVITY_SCREEN_BRIGHT | USER_ACTIVITY_SCREEN_DIM)) != 0) {

                        // Device is being kept awake by recent user activity

                        if (nextTimeout >= now && mOverriddenTimeout == -1) {

                            // Save when the next timeout would have occurred

                            mOverriddenTimeout = nextTimeout;

                        }

                    }

                    mUserActivitySummary = USER_ACTIVITY_SCREEN_DREAM;

                    nextTimeout = -1;

                }

                        if(mScreenOffTimeoutSetting != 0){//add never screen off

                if (mUserActivitySummary != 0 && nextTimeout >= 0) {

                    Message msg = mHandler.obtainMessage(MSG_USER_ACTIVITY_TIMEOUT);

                    msg.setAsynchronous(true);

                    mHandler.sendMessageAtTime(msg, nextTimeout);

                }

                        } else {


                                mUserActivitySummary |= USER_ACTIVITY_SCREEN_BRIGHT;

                        }

            } else {

                mUserActivitySummary = 0;

            }

            if (DEBUG_SPEW) {

                Slog.d(TAG, "updateUserActivitySummaryLocked: mWakefulness="

                        + PowerManagerInternal.wakefulnessToString(mWakefulness)

                        + ", mUserActivitySummary=0x" + Integer.toHexString(mUserActivitySummary)

                        + ", nextTimeout=" + TimeUtils.formatUptime(nextTimeout));

            }

        }

    }


android/packages/apps/Settings/res/values-zh-rCN/arrays.xml

 "5分钟"

     "10分钟"

     "30分钟"

+       "永不休眠"

   

   

     "永不"



android/packages/apps/Settings/res/values/arrays.xml

5 minutes

         10 minutes

         30 minutes

+               never

     


     

         600000

         

         1800000

+               

+               0

     


android/packages/apps/Settings/res/xml/display_settings.xml

 android:title="@string/screen_timeout"

         android:summary="@string/summary_placeholder"

         android:entries="@array/screen_timeout_entries"

-        android:entryValues="@array/screen_timeout_values" />

+        android:entryValues="@array/screen_timeout_values" 

+               android:defaultValue="0"/>

你可能感兴趣的:(android系统添加永不休眠选项)