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
8 files changed