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

Commit cf1c8860 authored by Kyunglyul Hyun's avatar Kyunglyul Hyun
Browse files

Register connect callback when the service is up

Re-register connection callback when the service is up.
This could enable callbacks to work even when they're
registered before the service is up.

Tag: #feature
Bug: 274812502
Test: atest BluetoothInstrumentationTests
Change-Id: I49500cb71e816256427f56d5a3319022140fd9cc
parent 0d002650
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -3983,6 +3983,22 @@ public final class BluetoothAdapter {
                                }
                            }
                        }
                        synchronized (mBluetoothConnectionCallbackExecutorMap) {
                            if (!mBluetoothConnectionCallbackExecutorMap.isEmpty()) {
                                try {
                                    final SynchronousResultReceiver recv =
                                            SynchronousResultReceiver.get();
                                    mService.registerBluetoothConnectionCallback(
                                            mConnectionCallback,
                                            mAttributionSource, recv);
                                    recv.awaitResultNoInterrupt(getSyncTimeout())
                                            .getValue(null);
                                } catch (RemoteException | TimeoutException e) {
                                    Log.e(TAG, "onBluetoothServiceUp: Failed to register "
                                            + "bluetooth connection callback", e);
                                }
                            }
                        }
                    } finally {
                        mServiceLock.readLock().unlock();
                    }