Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Skip to content
Commit 25157e45 authored by Jeff Brown's avatar Jeff Brown
Browse files

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
parent a5d552fc
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment