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

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

Merge "Encapsulate call to beginBroadcast in synchronized"

parents 81a255b6 f7865b0c
Loading
Loading
Loading
Loading
+37 −46
Original line number Diff line number Diff line
@@ -1740,7 +1740,6 @@ public class BluetoothManagerService extends IBluetoothManager.Stub {
        IBinder mService;
        ComponentName mClassName;
        Intent mIntent;
        boolean mInvokingProxyCallbacks = false;

        ProfileServiceConnections(Intent intent) {
            mService = null;
@@ -1832,12 +1831,7 @@ public class BluetoothManagerService extends IBluetoothManager.Stub {
                Log.e(TAG, "Unable to linkToDeath", e);
            }

            if (mInvokingProxyCallbacks) {
                Log.e(TAG, "Proxy callbacks already in progress.");
                return;
            }
            mInvokingProxyCallbacks = true;

            synchronized (mProxies) {
                final int n = mProxies.beginBroadcast();
                try {
                    for (int i = 0; i < n; i++) {
@@ -1849,7 +1843,7 @@ public class BluetoothManagerService extends IBluetoothManager.Stub {
                    }
                } finally {
                    mProxies.finishBroadcast();
                mInvokingProxyCallbacks = false;
                }
            }
        }

@@ -1866,24 +1860,19 @@ public class BluetoothManagerService extends IBluetoothManager.Stub {
            mService = null;
            mClassName = null;

            if (mInvokingProxyCallbacks) {
                Log.e(TAG, "Proxy callbacks already in progress.");
                return;
            }
            mInvokingProxyCallbacks = true;

            synchronized (mProxies) {
                final int n = mProxies.beginBroadcast();
                try {
                    for (int i = 0; i < n; i++) {
                        try {
                            mProxies.getBroadcastItem(i).onServiceDisconnected(className);
                        } catch (RemoteException e) {
                        Log.e(TAG, "Unable to disconnect from proxy", e);
                            Log.e(TAG, "Unable to disconnect from proxy #" + i, e);
                        }
                    }
                } finally {
                    mProxies.finishBroadcast();
                mInvokingProxyCallbacks = false;
                }
            }
        }

@@ -1901,6 +1890,7 @@ public class BluetoothManagerService extends IBluetoothManager.Stub {
    }

    private void sendBluetoothStateCallback(boolean isUp) {
        synchronized (mStateChangeCallbacks) {
            try {
                int n = mStateChangeCallbacks.beginBroadcast();
                if (DBG) {
@@ -1918,6 +1908,7 @@ public class BluetoothManagerService extends IBluetoothManager.Stub {
                mStateChangeCallbacks.finishBroadcast();
            }
        }
    }

    /**
     * Inform BluetoothAdapter instances that Adapter service is up