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

Commit 7495892b authored by William Escande's avatar William Escande
Browse files

Headset: RemoveActive prior to hold the lock

Bug: 299687033
Test: Manual | Connect 2 devices that support Headset and stress test
      the fallback during disconnection
Change-Id: Ie19ca5092064608a0ce4522578716c83926e304a
parent 8db9f4f3
Loading
Loading
Loading
Loading
+6 −5
Original line number Diff line number Diff line
@@ -891,12 +891,13 @@ public class ActiveDeviceManager implements AdapterService.BluetoothStateCallbac
            Log.d(TAG, "setHearingAidActiveDevice(" + device + ")"
                    + (device == null ? " hasFallbackDevice=" + hasFallbackDevice : ""));
        }
        synchronized (mLock) {

        final HearingAidService hearingAidService = mFactory.getHearingAidService();
        if (hearingAidService == null) {
            return false;
        }

        synchronized (mLock) {
            if (device == null) {
                if (!hearingAidService.removeActiveDevice(!hasFallbackDevice)) {
                    return false;
+4 −4
Original line number Diff line number Diff line
@@ -1384,11 +1384,11 @@ public class HeadsetService extends ProfileService {
    @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
    public boolean setActiveDevice(BluetoothDevice device) {
        Log.i(TAG, "setActiveDevice: device=" + device + ", " + Utils.getUidPidString());
        synchronized (mStateMachines) {
        if (device == null) {
            removeActiveDevice();
            return true;
        }
        synchronized (mStateMachines) {
            if (device.equals(mActiveDevice)) {
                Log.i(TAG, "setActiveDevice: device " + device + " is already active");
                return true;