diff options
author | Mike Lockwood <lockwood@android.com> | 2009-11-07 20:33:47 -0500 |
---|---|---|
committer | Mike Lockwood <lockwood@android.com> | 2009-11-07 20:33:47 -0500 |
commit | 20ee6f2dd30b8f0940b5f447ef2df340628e1876 (patch) | |
tree | 3fb51fb90c413448126e031057a969e9caf2d879 | |
parent | 638d86535264b24b54698fca7e18e68571fe0bad (diff) | |
download | frameworks_base-20ee6f2dd30b8f0940b5f447ef2df340628e1876.zip frameworks_base-20ee6f2dd30b8f0940b5f447ef2df340628e1876.tar.gz frameworks_base-20ee6f2dd30b8f0940b5f447ef2df340628e1876.tar.bz2 |
Do not apply light sensor debounce logic while the light sensor is still warming up.
This allows us to adjust immediately when we receive a correct light sensor reading
after the screen turns on.
Change-Id: I627047365640761727348e577c9164a6d6be2772
Signed-off-by: Mike Lockwood <lockwood@android.com>
-rw-r--r-- | core/res/res/values/config.xml | 5 | ||||
-rw-r--r-- | services/java/com/android/server/PowerManagerService.java | 35 |
2 files changed, 29 insertions, 11 deletions
diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml index 9058221..aaa1d8b 100644 --- a/core/res/res/values/config.xml +++ b/core/res/res/values/config.xml @@ -200,6 +200,11 @@ <integer-array name="config_autoBrightnessKeyboardBacklightValues"> </integer-array> + <!-- Amount of time it takes for the light sensor to warm up in milliseconds. + For this time after the screen turns on, the Power Manager + will not debounce light sensor readings --> + <integer name="config_lightSensorWarmupTime">0</integer> + <!-- Enables swipe versus poly-finger touch disambiguation in the KeyboardView --> <bool name="config_swipeDisambiguation">true</bool> </resources> diff --git a/services/java/com/android/server/PowerManagerService.java b/services/java/com/android/server/PowerManagerService.java index 2e1cf56..af93d36 100644 --- a/services/java/com/android/server/PowerManagerService.java +++ b/services/java/com/android/server/PowerManagerService.java @@ -212,8 +212,12 @@ class PowerManagerService extends IPowerManager.Stub private volatile boolean mPokeAwakeOnSet = false; private volatile boolean mInitComplete = false; private HashMap<IBinder,PokeLock> mPokeLocks = new HashMap<IBinder,PokeLock>(); + // mScreenOnTime and mScreenOnStartTime are used for computing total time screen + // has been on since boot private long mScreenOnTime; private long mScreenOnStartTime; + // mLastScreenOnTime is the time the screen was last turned on + private long mLastScreenOnTime; private boolean mPreventScreenOn; private int mScreenBrightnessOverride = -1; private boolean mUseSoftwareAutoBrightness; @@ -222,6 +226,7 @@ class PowerManagerService extends IPowerManager.Stub private int[] mLcdBacklightValues; private int[] mButtonBacklightValues; private int[] mKeyboardBacklightValues; + private int mLightSensorWarmupTime; // Used when logging number and duration of touch-down cycles private long mTotalTouchDownTime; @@ -456,6 +461,8 @@ class PowerManagerService extends IPowerManager.Stub com.android.internal.R.array.config_autoBrightnessButtonBacklightValues); mKeyboardBacklightValues = resources.getIntArray( com.android.internal.R.array.config_autoBrightnessKeyboardBacklightValues); + mLightSensorWarmupTime = resources.getInteger( + com.android.internal.R.integer.config_lightSensorWarmupTime); } ContentResolver resolver = mContext.getContentResolver(); @@ -886,6 +893,7 @@ class PowerManagerService extends IPowerManager.Stub pw.println(" mPreventScreenOn=" + mPreventScreenOn + " mScreenBrightnessOverride=" + mScreenBrightnessOverride); pw.println(" mTotalDelaySetting=" + mTotalDelaySetting); + pw.println(" mLastScreenOnTime=" + mLastScreenOnTime); pw.println(" mBroadcastWakeLock=" + mBroadcastWakeLock); pw.println(" mStayOnWhilePluggedInScreenDimLock=" + mStayOnWhilePluggedInScreenDimLock); pw.println(" mStayOnWhilePluggedInPartialLock=" + mStayOnWhilePluggedInPartialLock); @@ -1299,15 +1307,18 @@ class PowerManagerService extends IPowerManager.Stub private int setScreenStateLocked(boolean on) { int err = Power.setScreenState(on); - if (err == 0 && mUseSoftwareAutoBrightness) { - enableLightSensor(on); - if (!on) { - // make sure button and key backlights are off too - mHardware.setLightBrightness_UNCHECKED(HardwareService.LIGHT_ID_BUTTONS, 0); - mHardware.setLightBrightness_UNCHECKED(HardwareService.LIGHT_ID_KEYBOARD, 0); - // clear current value so we will update based on the new conditions - // when the sensor is reenabled. - mLightSensorValue = -1; + if (err == 0) { + mLastScreenOnTime = (on ? SystemClock.elapsedRealtime() : 0); + if (mUseSoftwareAutoBrightness) { + enableLightSensor(on); + if (!on) { + // make sure button and key backlights are off too + mHardware.setLightBrightness_UNCHECKED(HardwareService.LIGHT_ID_BUTTONS, 0); + mHardware.setLightBrightness_UNCHECKED(HardwareService.LIGHT_ID_KEYBOARD, 0); + // clear current value so we will update based on the new conditions + // when the sensor is reenabled. + mLightSensorValue = -1; + } } } return err; @@ -2431,13 +2442,15 @@ class PowerManagerService extends IPowerManager.Stub public void onSensorChanged(SensorEvent event) { synchronized (mLocks) { int value = (int)event.values[0]; + long milliseconds = event.timestamp / 1000000; if (mDebugLightSensor) { Log.d(TAG, "onSensorChanged: light value: " + value); } mHandler.removeCallbacks(mAutoBrightnessTask); if (mLightSensorValue != value) { - if (mLightSensorValue == -1) { - // process the value immediately + if (mLightSensorValue == -1 || + milliseconds < mLastScreenOnTime + mLightSensorWarmupTime) { + // process the value immediately if screen has just turned on lightSensorChangedLocked(value); } else { // delay processing to debounce the sensor |