OSDN Git Service

Refactor SensorManager to move non-API bits into a subclass.
authorJeff Brown <jeffbrown@google.com>
Mon, 16 Apr 2012 19:13:05 +0000 (12:13 -0700)
committerJeff Brown <jeffbrown@google.com>
Mon, 16 Apr 2012 20:03:55 +0000 (13:03 -0700)
commit25157e458d6e10b027d1ba6b78b0487156c9f57a
treeefa43a5f2f1ec18fef855b56c3f6b99442375c64
parenta5d552fc2bad6aea2087f56e88fb1ce836a79571
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
api/16.txt
api/current.txt
core/java/android/app/ContextImpl.java
core/java/android/hardware/Sensor.java
core/java/android/hardware/SensorManager.java
core/java/android/hardware/SystemSensorManager.java [new file with mode: 0644]
core/jni/android_hardware_SensorManager.cpp
services/java/com/android/server/PowerManagerService.java