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

Commit 00040ba3 authored by Rahul Sabnis's avatar Rahul Sabnis
Browse files

Register the service-to-app callback whenever the service comes up for

BluetoothConnectionCallback. This ensures that if the bluetooth process
dies, the callbacks will be re-established once it comes back up.

Tag: #feature
Bug: 175700972
Test: Manual
Change-Id: I2a20b229fcc1d8f69ccc1b24b62c26ce8155c29f
parent 049f0f5f
Loading
Loading
Loading
Loading
+25 −15
Original line number Diff line number Diff line
@@ -2933,6 +2933,16 @@ public final class BluetoothAdapter {
                            }
                        });
                    }
                    synchronized (mBluetoothConnectionCallbackExecutorMap) {
                        if (!mBluetoothConnectionCallbackExecutorMap.isEmpty()) {
                            try {
                                mService.registerBluetoothConnectionCallback(mConnectionCallback);
                            } catch (RemoteException e) {
                                Log.e(TAG, "onBluetoothServiceUp: Failed to register bluetooth"
                                        + "connection callback", e);
                            }
                        }
                    }
                }

                public void onBluetoothServiceDown() {
@@ -3582,6 +3592,7 @@ public final class BluetoothAdapter {
            return false;
        }

        synchronized (mBluetoothConnectionCallbackExecutorMap) {
            // If the callback map is empty, we register the service-to-app callback
            if (mBluetoothConnectionCallbackExecutorMap.isEmpty()) {
                try {
@@ -3600,7 +3611,6 @@ public final class BluetoothAdapter {
            }

            // Adds the passed in callback to our map of callbacks to executors
        synchronized (mBluetoothConnectionCallbackExecutorMap) {
            if (mBluetoothConnectionCallbackExecutorMap.containsKey(callback)) {
                throw new IllegalArgumentException("This callback has already been registered");
            }