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

Commit d09001fe authored by Steve Block's avatar Steve Block
Browse files

In DeviceMotionService, handle the fact that we may receive updates from...

In DeviceMotionService, handle the fact that we may receive updates from SensorManager after unregistering.

Bug: 5110230
Change-Id: I9be502538517a094c83d2d1a9073dfaee3b436e7
parent f4461fc5
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -99,6 +99,7 @@ final class DeviceMotionService implements SensorEventListener {
        mUpdateRunnable = new Runnable() {
            @Override
            public void run() {
                assert mIsRunning;
                mManager.onMotionChange(new Double(mLastAcceleration[0]),
                        new Double(mLastAcceleration[1]), new Double(mLastAcceleration[2]),
                        INTERVAL_MILLIS);
@@ -157,6 +158,11 @@ final class DeviceMotionService implements SensorEventListener {
        assert WebViewCore.THREAD_NAME.equals(Thread.currentThread().getName());
        assert(event.sensor.getType() == Sensor.TYPE_ACCELEROMETER);

        // We may get callbacks after the call to getSensorManager().unregisterListener() returns.
        if (!mIsRunning) {
            return;
        }

        boolean firstData = mLastAcceleration == null;
        mLastAcceleration = event.values;
        if (firstData) {
+1 −0
Original line number Diff line number Diff line
@@ -188,6 +188,7 @@ final class DeviceOrientationService implements SensorEventListener {
        assert(event.values.length == 3);
        assert WebViewCore.THREAD_NAME.equals(Thread.currentThread().getName());

        // We may get callbacks after the call to getSensorManager().unregisterListener() returns.
        if (!mIsRunning) {
            return;
        }