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

Commit b4bc8991 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "AdapterService ConcurrentModificationException fix"

parents f01a7695 1577ff10
Loading
Loading
Loading
Loading
+8 −8
Original line number Diff line number Diff line
@@ -148,13 +148,14 @@ import java.time.Duration;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
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.Set;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.Executor;
import java.util.function.Predicate;
@@ -286,8 +287,7 @@ public class AdapterService extends Service {
    private boolean mQuietmode = false;
    private HashMap<String, CallerInfo> mBondAttemptCallerInfo = new HashMap<>();

    private final Map<UUID, RfcommListenerData> mBluetoothServerSockets =
            Collections.synchronizedMap(new HashMap<>());
    private final Map<UUID, RfcommListenerData> mBluetoothServerSockets = new ConcurrentHashMap<>();
    private final Executor mSocketServersExecutor = r -> new Thread(r).start();

    private AlarmManager mAlarmManager;
@@ -1511,11 +1511,11 @@ public class AdapterService extends Service {
    }

    private void stopRfcommServerSockets() {
        synchronized (mBluetoothServerSockets) {
            mBluetoothServerSockets.forEach((key, value) -> {
                mBluetoothServerSockets.remove(key);
                value.closeServerAndPendingSockets(mHandler);
            });
        Iterator<Map.Entry<UUID, RfcommListenerData>> socketsIterator =
                mBluetoothServerSockets.entrySet().iterator();
        while (socketsIterator.hasNext()) {
            socketsIterator.next().getValue().closeServerAndPendingSockets(mHandler);
            socketsIterator.remove();
        }
    }