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

Commit 9a1c1c8c authored by JohnLai's avatar JohnLai
Browse files

floss: pandora: fix host.Connect

Only wait for bonded if security.OnPairing is not called before
host.Connect. Otherwise, host.Connect will block the caller.

Bug: 320397610
Tag: #floss
Test: m Bluetooth && pts-bot L2CAP/COS/CED/BV-01-C
Test: pts-bot L2CAP/COS/CFD/BV-08-C
Flag: EXEMPT floss only changes
Change-Id: I04a70471f3ddad1fd8e177e67ef6c2776c77535e
parent 2685d108
Loading
Loading
Loading
Loading
+18 −19
Original line number Original line Diff line number Diff line
@@ -130,9 +130,6 @@ class HostService(host_grpc_aio.HostServicer):


            @utils.glib_callback()
            @utils.glib_callback()
            def on_ssp_request(self, remote_device, class_of_device, variant, passkey):
            def on_ssp_request(self, remote_device, class_of_device, variant, passkey):
                if self.security.manually_confirm:
                    return

                address, _ = remote_device
                address, _ = remote_device
                if address != self.task['address']:
                if address != self.task['address']:
                    return
                    return
@@ -170,6 +167,7 @@ class HostService(host_grpc_aio.HostServicer):
                    if not success:
                    if not success:
                        raise RuntimeError(f'Failed to connect to the {address}. Reason: {reason}')
                        raise RuntimeError(f'Failed to connect to the {address}. Reason: {reason}')
                else:
                else:
                    if not self.security.manually_confirm:
                        create_bond = asyncio.get_running_loop().create_future()
                        create_bond = asyncio.get_running_loop().create_future()
                        observer = PairingObserver(
                        observer = PairingObserver(
                            self.bluetooth.adapter_client,
                            self.bluetooth.adapter_client,
@@ -185,6 +183,7 @@ class HostService(host_grpc_aio.HostServicer):
                    if not self.bluetooth.create_bond(address, floss_enums.BtTransport.BREDR):
                    if not self.bluetooth.create_bond(address, floss_enums.BtTransport.BREDR):
                        raise RuntimeError('Failed to call create_bond.')
                        raise RuntimeError('Failed to call create_bond.')


                    if not self.security.manually_confirm:
                        success, reason = await create_bond
                        success, reason = await create_bond


                        if not success:
                        if not success: