Merge change 25012 into eclair

* changes:
  PowerManagerService: Use 5 cm threshold for the proximity sensor.
This commit is contained in:
Android (Google) Code Review
2009-09-15 10:32:13 -04:00

View File

@@ -88,6 +88,9 @@ class PowerManagerService extends IPowerManager.Stub
private static final int LONG_KEYLIGHT_DELAY = 6000; // t+6 sec private static final int LONG_KEYLIGHT_DELAY = 6000; // t+6 sec
private static final int LONG_DIM_TIME = 7000; // t+N-5 sec private static final int LONG_DIM_TIME = 7000; // t+N-5 sec
// trigger proximity if distance is less than 5 cm
private static final float PROXIMITY_THRESHOLD = 5.0f;
// Cached Gservices settings; see updateGservicesValues() // Cached Gservices settings; see updateGservicesValues()
private int mShortKeylightDelay = SHORT_KEYLIGHT_DELAY_DEFAULT; private int mShortKeylightDelay = SHORT_KEYLIGHT_DELAY_DEFAULT;
@@ -2084,18 +2087,19 @@ class PowerManagerService extends IPowerManager.Stub
public void onSensorChanged(SensorEvent event) { public void onSensorChanged(SensorEvent event) {
long milliseconds = event.timestamp / 1000000; long milliseconds = event.timestamp / 1000000;
synchronized (mLocks) { synchronized (mLocks) {
if (event.values[0] == 0.0) { float distance = event.values[0];
if (distance >= 0.0 && distance < PROXIMITY_THRESHOLD) {
if (mSpew) { if (mSpew) {
Log.d(TAG, "onSensorChanged: proximity active"); Log.d(TAG, "onSensorChanged: proximity active, distance: " + distance);
} }
goToSleepLocked(milliseconds); goToSleepLocked(milliseconds);
mProximitySensorActive = true; mProximitySensorActive = true;
} else { } else {
// proximity sensor negative events user activity. // proximity sensor negative events trigger as user activity.
// temporarily set mUserActivityAllowed to true so this will work // temporarily set mUserActivityAllowed to true so this will work
// even when the keyguard is on. // even when the keyguard is on.
if (mSpew) { if (mSpew) {
Log.d(TAG, "onSensorChanged: proximity inactive"); Log.d(TAG, "onSensorChanged: proximity inactive, distance: " + distance);
} }
mProximitySensorActive = false; mProximitySensorActive = false;
boolean savedActivityAllowed = mUserActivityAllowed; boolean savedActivityAllowed = mUserActivityAllowed;