summaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
authorMike Lockwood <lockwood@android.com>2011-10-25 07:02:45 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2011-10-25 07:02:45 -0700
commit141fc9868bb56c498dad072a84a80dac8cdb85e5 (patch)
treefd669dfc7b19afbaa7d189c0c4b74fc3357e98ec /services
parentee403c6e1223d6384de6a8517055a56061c20c0b (diff)
parent55174b663b4f01853a8a821bdf1ffe0fb910eab8 (diff)
downloadframeworks_base-141fc9868bb56c498dad072a84a80dac8cdb85e5.zip
frameworks_base-141fc9868bb56c498dad072a84a80dac8cdb85e5.tar.gz
frameworks_base-141fc9868bb56c498dad072a84a80dac8cdb85e5.tar.bz2
Merge "Revert "PowerManagerService: Remove assumption that light sensor will always send a value as soon as it is enabled."" into ics-mr0
Diffstat (limited to 'services')
-rw-r--r--services/java/com/android/server/PowerManagerService.java78
1 files changed, 35 insertions, 43 deletions
diff --git a/services/java/com/android/server/PowerManagerService.java b/services/java/com/android/server/PowerManagerService.java
index 99dcd9b..bb9b86e 100644
--- a/services/java/com/android/server/PowerManagerService.java
+++ b/services/java/com/android/server/PowerManagerService.java
@@ -1698,6 +1698,11 @@ public class PowerManagerService extends IPowerManager.Stub
// make sure button and key backlights are off too
mButtonLight.turnOff();
mKeyboardLight.turnOff();
+ // clear current value so we will update based on the new conditions
+ // when the sensor is reenabled.
+ mLightSensorValue = -1;
+ // reset our highest light sensor value when the screen turns off
+ mHighestLightSensorValue = -1;
}
}
}
@@ -2467,7 +2472,6 @@ public class PowerManagerService extends IPowerManager.Stub
synchronized (mLocks) {
mIsDocked = (state != Intent.EXTRA_DOCK_STATE_UNDOCKED);
if (mIsDocked) {
- // allow brightness to decrease when docked
mHighestLightSensorValue = -1;
}
if ((mPowerState & SCREEN_ON_BIT) != 0) {
@@ -3043,21 +3047,11 @@ public class PowerManagerService extends IPowerManager.Stub
long identity = Binder.clearCallingIdentity();
try {
if (enable) {
- // reset our highest value when reenabling
- mHighestLightSensorValue = -1;
- // force recompute of backlight values
- if (mLightSensorValue >= 0) {
- int value = (int)mLightSensorValue;
- mLightSensorValue = -1;
- handleLightSensorValue(value);
- }
mSensorManager.registerListener(mLightListener, mLightSensor,
SensorManager.SENSOR_DELAY_NORMAL);
} else {
mSensorManager.unregisterListener(mLightListener);
mHandler.removeCallbacks(mAutoBrightnessTask);
- mLightSensorPendingDecrease = false;
- mLightSensorPendingIncrease = false;
}
} finally {
Binder.restoreCallingIdentity(identity);
@@ -3109,45 +3103,43 @@ public class PowerManagerService extends IPowerManager.Stub
}
};
- private void handleLightSensorValue(int value) {
- long milliseconds = SystemClock.elapsedRealtime();
- if (mLightSensorValue == -1 ||
- milliseconds < mLastScreenOnTime + mLightSensorWarmupTime) {
- // process the value immediately if screen has just turned on
- mHandler.removeCallbacks(mAutoBrightnessTask);
- mLightSensorPendingDecrease = false;
- mLightSensorPendingIncrease = false;
- lightSensorChangedLocked(value);
- } else {
- if ((value > mLightSensorValue && mLightSensorPendingDecrease) ||
- (value < mLightSensorValue && mLightSensorPendingIncrease) ||
- (value == mLightSensorValue) ||
- (!mLightSensorPendingDecrease && !mLightSensorPendingIncrease)) {
- // delay processing to debounce the sensor
- mHandler.removeCallbacks(mAutoBrightnessTask);
- mLightSensorPendingDecrease = (value < mLightSensorValue);
- mLightSensorPendingIncrease = (value > mLightSensorValue);
- if (mLightSensorPendingDecrease || mLightSensorPendingIncrease) {
- mLightSensorPendingValue = value;
- mHandler.postDelayed(mAutoBrightnessTask, LIGHT_SENSOR_DELAY);
- }
- } else {
- mLightSensorPendingValue = value;
- }
- }
- }
-
SensorEventListener mLightListener = new SensorEventListener() {
public void onSensorChanged(SensorEvent event) {
- if (mDebugLightSensor) {
- Slog.d(TAG, "onSensorChanged: light value: " + event.values[0]);
- }
synchronized (mLocks) {
// ignore light sensor while screen is turning off
if (isScreenTurningOffLocked()) {
return;
}
- handleLightSensorValue((int)event.values[0]);
+
+ int value = (int)event.values[0];
+ long milliseconds = SystemClock.elapsedRealtime();
+ if (mDebugLightSensor) {
+ Slog.d(TAG, "onSensorChanged: light value: " + value);
+ }
+ if (mLightSensorValue == -1 ||
+ milliseconds < mLastScreenOnTime + mLightSensorWarmupTime) {
+ // process the value immediately if screen has just turned on
+ mHandler.removeCallbacks(mAutoBrightnessTask);
+ mLightSensorPendingDecrease = false;
+ mLightSensorPendingIncrease = false;
+ lightSensorChangedLocked(value);
+ } else {
+ if ((value > mLightSensorValue && mLightSensorPendingDecrease) ||
+ (value < mLightSensorValue && mLightSensorPendingIncrease) ||
+ (value == mLightSensorValue) ||
+ (!mLightSensorPendingDecrease && !mLightSensorPendingIncrease)) {
+ // delay processing to debounce the sensor
+ mHandler.removeCallbacks(mAutoBrightnessTask);
+ mLightSensorPendingDecrease = (value < mLightSensorValue);
+ mLightSensorPendingIncrease = (value > mLightSensorValue);
+ if (mLightSensorPendingDecrease || mLightSensorPendingIncrease) {
+ mLightSensorPendingValue = value;
+ mHandler.postDelayed(mAutoBrightnessTask, LIGHT_SENSOR_DELAY);
+ }
+ } else {
+ mLightSensorPendingValue = value;
+ }
+ }
}
}