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

Commit c6be603d authored by Bhakthavatsala Raghavendra's avatar Bhakthavatsala Raghavendra Committed by Automerger Merge Worker
Browse files

Merge changes I091456bb,Icddc949e,Ie056ee87,Ibf1336b2,I491ade44, ... into main...

Merge changes I091456bb,Icddc949e,Ie056ee87,Ibf1336b2,I491ade44, ... into main am: 615bfa3a am: a86f54c1

Original change: https://android-review.googlesource.com/c/platform/packages/modules/Bluetooth/+/2806138



Change-Id: I151c7433e38de14316826f803568c5466f470f7e
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 9c436db9 a86f54c1
Loading
Loading
Loading
Loading
+39 −0
Original line number Diff line number Diff line
@@ -12,8 +12,47 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from pairing.br_edr.legacy.tests import BREDRLegacyTestClass
from pairing.br_edr.misc.service_access_tests import ServiceAccessTempBondingTest

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.ble.legacy.display_output_and_keyboard_input.tests import BLELegDisplayKbdTestClass
from pairing.ble.legacy.display_output_and_yes_no_input.tests import BLELegDisplayYesNoTestClass
from pairing.ble.legacy.display_output_only.tests import BLELegDisplayOnlyTestClass
from pairing.ble.legacy.keyboard_input_only.tests import BLELegKbdOnlyTestClass
from pairing.ble.legacy.no_output_no_input.tests import BLELegNoInputNoOutputTestClass


from pairing.ble.sc.display_output_and_keyboard_input.tests import BLESCDisplayKbdTestClass
from pairing.ble.sc.display_output_and_yes_no_input.tests import BLESCDisplayYesNoTestClass
from pairing.ble.sc.display_output_only.tests import BLESCDisplayOnlyTestClass
from pairing.ble.sc.keyboard_input_only.tests import BLESCKbdOnlyTestClass
from pairing.ble.sc.no_output_no_input.tests import BLESCNoInputNoOutputTestClass


from pairing.smp_test import SmpTest


_test_class_list = [
    BLELegDisplayKbdTestClass,
    BLELegDisplayOnlyTestClass,
    BLELegDisplayYesNoTestClass,
    BLELegKbdOnlyTestClass,
    # BLELegNoInputNoOutputTestClass,
    BLESCDisplayKbdTestClass,
    # BLESCDisplayOnlyTestClass,
    BLESCDisplayYesNoTestClass,
    # BLESCKbdOnlyTestClass,
    BLESCNoInputNoOutputTestClass,
    BREDRDisplayYesNoTestClass,
    BREDRDisplayOnlyTestClass,
    # BREDRKeyboardOnlyTestClass,
    BREDRNoOutputNoInputTestClass,
    BREDRLegacyTestClass,
    # ServiceAccessTempBondingTest,
    SmpTest,
]
+79 −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.ble.test_base import BLEPairTestBaseWithGeneralAndDedicatedPairingTests

from pandora.security_pb2 import PairingEventAnswer


class BLELegDisplayKbdTestClass(BLEPairTestBaseWithGeneralAndDedicatedPairingTests):

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

        self.ref.config.setdefault('classic_enabled', False)
        self.ref.config.setdefault('classic_ssp_enabled', False)
        self.ref.config.setdefault('classic_sc_enabled', False)

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

    async def accept_pairing(self):
        notif_expected_pairing_method = 'passkey_entry_notification'
        req_expected_pairing_method = 'passkey_entry_request'

        responder_ev = await anext(self.responder_pairing_event_stream)
        logging.debug(f'responder_ev.method_variant():{responder_ev.method_variant()}')

        if responder_ev.method_variant() == 'just_works':
            logging.debug('>>> confirming pairing request')
            ans = PairingEventAnswer(event=responder_ev, confirm=True)
            self.responder_pairing_event_stream.send_nowait(ans)

            responder_ev = await anext(self.responder_pairing_event_stream)
            logging.debug(f'responder_ev.method_variant()_2:{responder_ev.method_variant()}')

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

        if init_ev.method_variant() == req_expected_pairing_method:
            notif_ev = responder_ev
            req_ev = init_ev
            req_stream = self.initiator_pairing_event_stream
        else:
            notif_ev = init_ev
            req_ev = responder_ev
            req_stream = self.responder_pairing_event_stream

        assert_equal(notif_ev.method_variant(), notif_expected_pairing_method)
        assert_equal(req_ev.method_variant(), req_expected_pairing_method)

        notified_passkey = notif_ev.passkey_entry_notification

        ans = PairingEventAnswer(event=req_ev, passkey=notified_passkey)
        req_stream.send_nowait(ans)
+80 −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.ble.test_base import BLEPairTestBaseWithGeneralAndDedicatedPairingTests

from pandora.security_pb2 import PairingEventAnswer

class BLELegDisplayYesNoTestClass(BLEPairTestBaseWithGeneralAndDedicatedPairingTests):

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

        # Explicitly disable BR/EDR
        self.ref.config.setdefault('classic_enabled', False)
        self.ref.config.setdefault('classic_ssp_enabled', False)
        self.ref.config.setdefault('classic_sc_enabled', False)

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

    async def accept_pairing(self):
        notif_expected_pairing_method = 'passkey_entry_notification'
        req_expected_pairing_method = 'passkey_entry_request'

        responder_ev = await anext(self.responder_pairing_event_stream)
        logging.debug(f'responder_ev.method_variant()[1]:{responder_ev.method_variant()}')

        if responder_ev.method_variant() == 'just_works':
            # when pairing is initiated from bumble,
            logging.debug('>>> confirming pairing request')
            ans = PairingEventAnswer(event=responder_ev, confirm=True)
            self.responder_pairing_event_stream.send_nowait(ans)

            responder_ev = await anext(self.responder_pairing_event_stream)
            logging.debug(f'responder_ev.method_variant()[2]:{responder_ev.method_variant()}')

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

        if self.initiator_pairing_event_stream == self.android_pairing_stream:
            notif_ev = responder_ev
            req_ev = init_ev
            req_stream = self.initiator_pairing_event_stream
        else:
            notif_ev = init_ev
            req_ev = responder_ev
            req_stream = self.responder_pairing_event_stream

        assert_equal(notif_ev.method_variant(), notif_expected_pairing_method)
        assert_equal(req_ev.method_variant(), req_expected_pairing_method)

        notified_passkey = notif_ev.passkey_entry_notification

        ans = PairingEventAnswer(event=req_ev, passkey=notified_passkey)
        req_stream.send_nowait(ans)
+79 −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.ble.test_base import BLEPairTestBaseWithGeneralAndDedicatedPairingTests

from pandora.security_pb2 import PairingEventAnswer


class BLELegDisplayOnlyTestClass(BLEPairTestBaseWithGeneralAndDedicatedPairingTests):

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

        self.ref.config.setdefault('classic_enabled', False)
        self.ref.config.setdefault('classic_ssp_enabled', False)
        self.ref.config.setdefault('classic_sc_enabled', False)

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

    async def accept_pairing(self):
        notif_expected_pairing_method = 'passkey_entry_notification'
        req_expected_pairing_method = 'passkey_entry_request'

        responder_ev = await anext(self.responder_pairing_event_stream)
        logging.debug(f'responder_ev.method_variant()[1]:{responder_ev.method_variant()}')

        if responder_ev.method_variant() == 'just_works':
            logging.debug('>>> confirming pairing request')
            ans = PairingEventAnswer(event=responder_ev, confirm=True)
            self.responder_pairing_event_stream.send_nowait(ans)

            responder_ev = await anext(self.responder_pairing_event_stream)
            logging.debug(f'responder_ev.method_variant()[2]:{responder_ev.method_variant()}')

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

        if init_ev.method_variant() == req_expected_pairing_method:
            notif_ev = responder_ev
            req_ev = init_ev
            req_stream = self.initiator_pairing_event_stream
        else:
            notif_ev = init_ev
            req_ev = responder_ev
            req_stream = self.responder_pairing_event_stream

        assert_equal(notif_ev.method_variant(), notif_expected_pairing_method)
        assert_equal(req_ev.method_variant(), req_expected_pairing_method)

        notified_passkey = notif_ev.passkey_entry_notification

        ans = PairingEventAnswer(event=req_ev, passkey=notified_passkey)
        req_stream.send_nowait(ans)
+79 −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.ble.test_base import BLEPairTestBaseWithGeneralAndDedicatedPairingTests

from pandora.security_pb2 import PairingEventAnswer


class BLELegKbdOnlyTestClass(BLEPairTestBaseWithGeneralAndDedicatedPairingTests):

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

        self.ref.config.setdefault('classic_enabled', False)
        self.ref.config.setdefault('classic_ssp_enabled', False)
        self.ref.config.setdefault('classic_sc_enabled', False)

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

    async def accept_pairing(self):
        notif_expected_pairing_method = 'passkey_entry_notification'
        req_expected_pairing_method = 'passkey_entry_request'

        responder_ev = await anext(self.responder_pairing_event_stream)
        logging.debug(f'responder_ev.method_variant()[1]:{responder_ev.method_variant()}')

        if responder_ev.method_variant() == 'just_works':
            logging.debug('>>> confirming pairing request')
            ans = PairingEventAnswer(event=responder_ev, confirm=True)
            self.responder_pairing_event_stream.send_nowait(ans)

            responder_ev = await anext(self.responder_pairing_event_stream)
            logging.debug(f'responder_ev.method_variant()[2]:{responder_ev.method_variant()}')

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

        if init_ev.method_variant() == req_expected_pairing_method:
            notif_ev = responder_ev
            req_ev = init_ev
            req_stream = self.initiator_pairing_event_stream
        else:
            notif_ev = init_ev
            req_ev = responder_ev
            req_stream = self.responder_pairing_event_stream

        assert_equal(notif_ev.method_variant(), notif_expected_pairing_method)
        assert_equal(req_ev.method_variant(), req_expected_pairing_method)

        notified_passkey = notif_ev.passkey_entry_notification

        ans = PairingEventAnswer(event=req_ev, passkey=notified_passkey)
        req_stream.send_nowait(ans)
Loading