1# Copyright 2024 Google LLC 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# https://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14 15import logging 16 17from mobly.asserts import assert_equal 18 19from pairing.ble.test_base import BLEPairTestBaseWithGeneralAndDedicatedPairingTests 20 21from pandora.security_pb2 import PairingEventAnswer 22 23class BLELegNoInputNoOutputTestClass(BLEPairTestBaseWithGeneralAndDedicatedPairingTests): 24 25 def _setup_devices(self) -> None: 26 self.ref.config.setdefault('le_enabled', True) 27 28 self.ref.config.setdefault('classic_enabled', False) 29 self.ref.config.setdefault('classic_ssp_enabled', False) 30 self.ref.config.setdefault('classic_sc_enabled', False) 31 32 self.ref.config.setdefault( 33 'server', 34 { 35 # legacy pairing 36 'pairing_sc_enable': False, 37 'pairing_mitm_enable': True, 38 'pairing_bonding_enable': True, 39 # Android IO CAP: Display_KBD 40 # Ref IO CAP: 41 'io_capability': 'no_output_no_input', 42 }, 43 ) 44 45 async def accept_pairing(self): 46 # we just need to confirm on Android 47 logging.debug('>>>>> before receiving event from android') 48 android_ev = await anext(self.android_pairing_stream) 49 logging.debug(f'>>>>> received android_ev.method_variant():{android_ev.method_variant()}') 50 51 ans = PairingEventAnswer(event=android_ev, confirm=True) 52 self.android_pairing_stream.send_nowait(ans) 53 54 if (self.responder_pairing_event_stream == self.android_pairing_stream) and (self.acl_initiator == self.dut): 55 # in test_dedicated_pairing_dut_initiate_2 56 # there is an additional user confirmation 57 android_ev = await anext(self.android_pairing_stream) 58 ans = PairingEventAnswer(event=android_ev, confirm=True) 59 self.android_pairing_stream.send_nowait(ans) 60