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

Commit e680e662 authored by Brad Ebinger's avatar Brad Ebinger
Browse files

Don't remove elements while using foreach

We were using a foreach in reuseOutgoingCall and removing an element if
it meets a certain criteria. This is incorrect in Java. Switching to an
iterator.

Bug: 31102577
Change-Id: I086a53a732ee5ab8f6ccea60fec9745ce6821f24
parent 6cfd6208
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -69,6 +69,7 @@ import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Objects;
@@ -741,9 +742,10 @@ public class CallsManager extends Call.ListenerBase
        // Check to see if we can reuse any of the calls that are waiting to disconnect.
        // See {@link Call#abort} and {@link #onCanceledViaNewOutgoingCall} for more information.
        Call reusedCall = null;
        for (Call pendingCall : mPendingCallsToDisconnect) {
        for (Iterator<Call> callIter = mPendingCallsToDisconnect.iterator(); callIter.hasNext();) {
            Call pendingCall = callIter.next();
            if (reusedCall == null && areHandlesEqual(pendingCall.getHandle(), handle)) {
                mPendingCallsToDisconnect.remove(pendingCall);
                callIter.remove();
                Log.i(this, "Reusing disconnected call %s", pendingCall);
                reusedCall = pendingCall;
            } else {