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

Commit 420d3fe1 authored by William Escande's avatar William Escande Committed by Automerger Merge Worker
Browse files

Prevent concurrentModification of profilesServices am: 122f9da1

parents 1924b53d 122f9da1
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
@@ -1598,13 +1600,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 {
@@ -1614,6 +1619,7 @@ public class BluetoothManagerService extends IBluetoothManager.Stub {
                }
                psc.removeAllProxies();
            }
            mUnbindingAll = false;
            mProfileServices.clear();
        }
    }