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

Commit 3922c31a authored by Hall Liu's avatar Hall Liu Committed by android-build-merger
Browse files

Fix locking for BluetoothDeviceManager am: c46c161f

am: c7a37521

Change-Id: I82e5beac37a6eedf89b647622c5df9eb4979033d
parents b59c5b86 c7a37521
Loading
Loading
Loading
Loading
+12 −3
Original line number Diff line number Diff line
@@ -30,7 +30,9 @@ import com.android.server.telecom.BluetoothAdapterProxy;
import com.android.server.telecom.BluetoothHeadsetProxy;
import com.android.server.telecom.TelecomSystem;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
@@ -103,11 +105,16 @@ public class BluetoothDeviceManager {
    }

    public int getNumConnectedDevices() {
        synchronized (mLock) {
            return mConnectedDevicesByAddress.size();
        }
    }

    public Collection<BluetoothDevice> getConnectedDevices() {
        return mConnectedDevicesByAddress.values();
        synchronized (mLock) {
            return Collections.unmodifiableCollection(
                    new ArrayList<>(mConnectedDevicesByAddress.values()));
        }
    }

    public String getMostRecentlyConnectedDevice(String excludeAddress) {
@@ -131,8 +138,10 @@ public class BluetoothDeviceManager {
    }

    public BluetoothDevice getDeviceFromAddress(String address) {
        synchronized (mLock) {
            return mConnectedDevicesByAddress.get(address);
        }
    }

    void onDeviceConnected(BluetoothDevice device) {
        synchronized (mLock) {
+1 −4
Original line number Diff line number Diff line
@@ -33,9 +33,7 @@ import com.android.server.telecom.BluetoothHeadsetProxy;
import com.android.server.telecom.TelecomSystem;
import com.android.server.telecom.Timeouts;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashSet;
@@ -572,8 +570,7 @@ public class BluetoothRouteManager extends StateMachine {
    }

    public Collection<BluetoothDevice> getConnectedDevices() {
        return Collections.unmodifiableCollection(
                new ArrayList<>(mDeviceManager.getConnectedDevices()));
        return mDeviceManager.getConnectedDevices();
    }

    private String connectHfpAudio(String address) {