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

Commit 20a7ca2f authored by Jeff DeCew's avatar Jeff DeCew
Browse files

Fix a concurrent modification in ProximityCheck

The error occurs when a callback is added to ProximityCheck while an notifying the consumers.

Change-Id: I9083d6e87ad199099c117f00dcdc9e7e811435f5
Fixes: 354293532
Test: atest ProximityTestCheck
Flag: EXEMPT bugfix
parent dfb8d416
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -86,11 +86,12 @@ public class ProximityCheck implements Runnable {
    }

    private void onProximityEvent(ThresholdSensorEvent proximityEvent) {
        mCallbacks.forEach(
        List<Consumer<Boolean>> oldCallbacks = mCallbacks;
        mCallbacks = new ArrayList<>();
        oldCallbacks.forEach(
                booleanConsumer ->
                        booleanConsumer.accept(
                                proximityEvent == null ? null : proximityEvent.getBelow()));
        mCallbacks.clear();
        unregister();
        mRegistered.set(false);
    }