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

Commit 9baaf445 authored by William Escande's avatar William Escande Committed by Gerrit Code Review
Browse files

Merge "Prevent concurrentModification of profilesServices"

parents 20044dc0 66ec07e6
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -302,6 +302,8 @@ public class BluetoothManagerService extends IBluetoothManager.Stub {
    // Save a ProfileServiceConnections object for each of the bound
    // bluetooth profile services
    private final Map<Integer, ProfileServiceConnections> mProfileServices = new HashMap<>();
    @GuardedBy("mProfileServices")
    private boolean mUnbindingAll = false;

    private final IBluetoothCallback mBluetoothCallback = new IBluetoothCallback.Stub() {
        @Override
@@ -1600,13 +1602,16 @@ public class BluetoothManagerService extends IBluetoothManager.Stub {
                } catch (IllegalArgumentException e) {
                    Log.e(TAG, "Unable to unbind service with intent: " + psc.mIntent, e);
                }
                if (!mUnbindingAll) {
                    mProfileServices.remove(profile);
                }
            }
        }
    }

    private void unbindAllBluetoothProfileServices() {
        synchronized (mProfileServices) {
            mUnbindingAll = true;
            for (Integer i : mProfileServices.keySet()) {
                ProfileServiceConnections psc = mProfileServices.get(i);
                try {
@@ -1616,6 +1621,7 @@ public class BluetoothManagerService extends IBluetoothManager.Stub {
                }
                psc.removeAllProxies();
            }
            mUnbindingAll = false;
            mProfileServices.clear();
        }
    }