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

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

Merge "Prevent ConcurrentModificationException on HandleMap"

parents e94f76ab 83a70949
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -3444,7 +3444,7 @@ public class GattService extends ProfileService {
            return new ArrayList<>(0);
        }
        List<ParcelUuid> serviceUuids = new ArrayList<ParcelUuid>();
        for (HandleMap.Entry entry : mHandleMap.mEntries) {
        for (HandleMap.Entry entry : mHandleMap.getEntries()) {
            serviceUuids.add(new ParcelUuid(entry.uuid));
        }
        return serviceUuids;
+6 −15
Original line number Diff line number Diff line
@@ -17,12 +17,11 @@ package com.android.bluetooth.gatt;

import android.util.Log;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArrayList;

class HandleMap {
    private static final boolean DBG = GattServiceConfig.DBG;
@@ -88,8 +87,8 @@ class HandleMap {
    int mLastCharacteristic = 0;

    HandleMap() {
        mEntries = new ArrayList<Entry>();
        mRequestMap = new HashMap<Integer, Integer>();
        mEntries = new CopyOnWriteArrayList<Entry>();
        mRequestMap = new ConcurrentHashMap<Integer, Integer>();
    }

    void clear() {
@@ -144,16 +143,8 @@ class HandleMap {
    }

    void deleteService(int serverIf, int serviceHandle) {
        for (Iterator<Entry> it = mEntries.iterator(); it.hasNext(); ) {
            Entry entry = it.next();
            if (entry.serverIf != serverIf) {
                continue;
            }

            if (entry.handle == serviceHandle || entry.serviceHandle == serviceHandle) {
                it.remove();
            }
        }
        mEntries.removeIf(entry -> ((entry.serverIf == serverIf)
                && (entry.handle == serviceHandle || entry.serviceHandle == serviceHandle)));
    }

    List<Entry> getEntries() {