Sensors could be disabled by any application

In the SensorManager API unregisterListener any application could
unregister any sensor. This lets any application disable a sensor
which another application is using.
This fix restricts the applications to only be able to unregister
a sensor it has previously registered to.

Change-Id: Ief926dd29f480dd97626160810dff87a8d3ac8dc
This commit is contained in:
Magnus Hallqvist
2012-09-11 12:46:15 +02:00
committed by Johan Redestig
parent bfe1ab8257
commit 6d7a473764

View File

@@ -373,7 +373,8 @@ public class SystemSensorManager extends SensorManager {
for (Sensor s : l.getSensors()) {
disableSensorLocked(s);
}
} else if (l.removeSensor(sensor) == 0) {
// Check if the ListenerDelegate has the sensor it is trying to unregister.
} else if (l.hasSensor(sensor) && l.removeSensor(sensor) == 0) {
// if we have no more sensors enabled on this listener,
// take it off the list.
sListeners.remove(i);