summaryrefslogtreecommitdiff
path: root/services/java/com/android/server/PowerManagerService.java
diff options
context:
space:
mode:
authorJeff Brown <jeffbrown@google.com>2012-04-16 12:13:05 -0700
committerJeff Brown <jeffbrown@google.com>2012-04-16 13:03:55 -0700
commit25157e458d6e10b027d1ba6b78b0487156c9f57a (patch)
treeefa43a5f2f1ec18fef855b56c3f6b99442375c64 /services/java/com/android/server/PowerManagerService.java
parenta5d552fc2bad6aea2087f56e88fb1ce836a79571 (diff)
Refactor SensorManager to move non-API bits into a subclass.
Changed the SensorManager class so that it only contains API-related bits including what's needed to support legacy sensors. Mostly just moved stuff around. Making the class abstract is safe because it does not have a visible constructor in the API. One minor change is that the cache of sensor type to sensor lists is now per instance of SensorManager instead of being static. We can fix this if desired. Another small change is that we bail out early from registerListener if the listener has already been registered for the particular sensor. This happened for both legacy and standard listeners. The problem is that the ListenerDelegate maintains two lists of sensors, one is a Map and the other is a List. Adding a sensor twice causes one entry to be added to the Map and two entries to be added to the List, but when the sensor is removed the next time, only one entry is removed from the List, leaving it in an inconsistent state. Removed Sensor.getLegacyType() since the value it provides is only needed in LegacyListener and we don't really save any significant computation by caching it. Removing the field makes support for legacy sensors a little more self-contained. Bug: 6339552 Change-Id: I50d41ac97cf535924f2bfa2026d28547a4d00286
Diffstat (limited to 'services/java/com/android/server/PowerManagerService.java')
-rw-r--r--services/java/com/android/server/PowerManagerService.java3
1 files changed, 2 insertions, 1 deletions
diff --git a/services/java/com/android/server/PowerManagerService.java b/services/java/com/android/server/PowerManagerService.java
index 2d2a88113b34..9a371c6c5539 100644
--- a/services/java/com/android/server/PowerManagerService.java
+++ b/services/java/com/android/server/PowerManagerService.java
@@ -37,6 +37,7 @@ import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;
+import android.hardware.SystemSensorManager;
import android.os.BatteryManager;
import android.os.BatteryStats;
import android.os.Binder;
@@ -2946,7 +2947,7 @@ public class PowerManagerService extends IPowerManager.Stub
}
void systemReady() {
- mSensorManager = new SensorManager(mHandlerThread.getLooper());
+ mSensorManager = new SystemSensorManager(mHandlerThread.getLooper());
mProximitySensor = mSensorManager.getDefaultSensor(Sensor.TYPE_PROXIMITY);
// don't bother with the light sensor if auto brightness is handled in hardware
if (mUseSoftwareAutoBrightness) {