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 asyncio 16import logging 17 18from pandora.security_pb2 import PairingEventAnswer 19 20from pairing.br_edr.ssp.test_base import BREDRSSPPairTestBase 21 22 23class BREDRNoOutputNoInputTestClass(BREDRSSPPairTestBase): 24 25 def _setup_devices(self) -> None: 26 27 self.ref.config.setdefault('classic_enabled', True) 28 29 self.ref.config.setdefault('le_enabled', False) 30 self.ref.config.setdefault('classic_ssp_enabled', True) 31 self.ref.config.setdefault('classic_sc_enabled', False) 32 33 self.ref.config.setdefault( 34 'server', 35 { 36 'pairing_sc_enable': False, 37 'pairing_mitm_enable': False, 38 'pairing_bonding_enable': True, 39 # Android IO CAP: Display_YESNO 40 # Ref IO CAP: 41 'io_capability': 'no_output_no_input', 42 }, 43 ) 44 45 async def accept_pairing(self): 46 47 # responder receives just works 48 responder_ev = await anext(self.responder_pairing_event_stream) 49 logging.debug(f'[{self.responder_pairing_event_stream.device.name}] responder_ev.method_variant():{responder_ev.method_variant()}') 50 51 init_ev = await anext(self.initiator_pairing_event_stream) 52 logging.debug( 53 f'[{self.initiator_pairing_event_stream.device.name}] init_ev.method_variant():{init_ev.method_variant()}' 54 ) 55 56 init_ev_ans = PairingEventAnswer(event=init_ev, confirm=True) 57 self.initiator_pairing_event_stream.send_nowait(init_ev_ans) 58 responder_ev_ans = PairingEventAnswer(event=responder_ev, confirm=True) 59 self.responder_pairing_event_stream.send_nowait(responder_ev_ans) 60