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

Commit 399b28d0 authored by Hui Peng's avatar Hui Peng
Browse files

Add bredr/ssp pairing tests (keyboard_only)

Bug: 277282212
Test: atest avatar
Flag: EXEMPT, Tests
Change-Id: I92ac32230b2061ac93273f4334d9fa4400137662
parent 904bb3a4
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@ from pairing.br_edr.misc.service_access_tests import ServiceAccessTempBondingTes

from pairing.br_edr.ssp.display_output_and_yes_no_input.tests import BREDRDisplayYesNoTestClass
from pairing.br_edr.ssp.display_output_only.tests import BREDRDisplayOnlyTestClass
from pairing.br_edr.ssp.keyboard_input_only.tests import BREDRKeyboardOnlyTestClass
from pairing.br_edr.ssp.no_output_no_input.tests import BREDRNoOutputNoInputTestClass

from pairing.smp_test import SmpTest
@@ -24,6 +25,7 @@ from pairing.smp_test import SmpTest
_test_class_list = [
    BREDRDisplayYesNoTestClass,
    BREDRDisplayOnlyTestClass,
    # BREDRKeyboardOnlyTestClass,
    BREDRNoOutputNoInputTestClass,
    BREDRLegacyTestClass,
    ServiceAccessTempBondingTest,
+63 −0
Original line number Diff line number Diff line
# Copyright 2024 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import logging

from mobly.asserts import assert_equal

from pairing.br_edr.ssp.test_base import BREDRSSPPairTestBase

from pandora.security_pb2 import PairingEventAnswer

class BREDRKeyboardOnlyTestClass(BREDRSSPPairTestBase):

    def _setup_devices(self) -> None:
        self.ref.config.setdefault('classic_enabled', True)
        self.ref.config.setdefault('le_enabled', False)
        self.ref.config.setdefault('classic_ssp_enabled', True)
        self.ref.config.setdefault('classic_sc_enabled', False)

        self.ref.config.setdefault(
            'server',
            {
                'pairing_sc_enable': False,
                'pairing_mitm_enable': False,
                'pairing_bonding_enable': True,
                # Android IO CAP: Display_YESNO
                # Ref IO CAP:
                'io_capability': 'keyboard_input_only',
            },
        )

    async def accept_pairing(self):
        # this io cap is not supported on bumble side:
        # see https://source.corp.google.com/h/googleplex-android/platform/superproject/main/+/main:external/python/bumble/bumble/device.py;l=2976?q=%22exception%20while%20confirming%22&sq=repo:googleplex-android%2Fplatform%2Fsuperproject%2Fmain%20b:main
        # thus, this testcase does not run at all at this moment
        # Android side triggers a pairing event 'justworks'
        # TODO: decide what to do with this testcase
        #       - ignore this case, or
        #       - fix bumble to allow this case to run

        init_ev = await anext(self.initiator_pairing_event_stream)
        logging.debug(f'[{self.initiator_pairing_event_stream.device.name}] init_ev.method_variant():{init_ev.method_variant()}')

        init_ev_ans = PairingEventAnswer(event=init_ev, confirm=True)
        self.initiator_pairing_event_stream.send_nowait(init_ev_ans)

        # responder receives just works
        responder_ev = await anext(self.responder_pairing_event_stream)
        logging.debug(f'[{self.responder_pairing_event_stream.device.name}] responder_ev.method_variant():{responder_ev.method_variant()}')

        responder_ev_ans = PairingEventAnswer(event=responder_ev, confirm=True)
        self.responder_pairing_event_stream.send_nowait(responder_ev_ans)