コード例 #1
0
    def route_audio_from_hf_to_speaker(self):
        """Route audio from HF to primary device inbuilt speakers and
        vice_versa.

        Steps:
        1. Initiate call from HF.
        2. Toggle audio from HF to speaker and vice-versa from N iterations.
        3. Hangup call from primary device.

        Returns:
            True if successful, False otherwise.
        """
        if not self.audio_receiver.press_initiate_call():
            self.log.error("Failed to initiate call.")
            return False
        for i in range(self.iterations):
            self.log.info("DUT speaker iteration = {}".format(i))
            if not set_audio_route(self.log, self.pri_ad, AUDIO_ROUTE_SPEAKER):
                self.log.error("Failed switching to primary device speaker.")
                hangup_call(self.log, self.pri_ad)
                return False
            time.sleep(2)
            if not set_audio_route(self.log, self.pri_ad,
                                   AUDIO_ROUTE_BLUETOOTH):
                self.log.error("Failed switching to bluetooth headset.")
                hangup_call(self.log, self.pri_ad)
                return False
        if not hangup_call(self.log, self.pri_ad):
            self.log.error("Failed to hang up the call.")
            return False
        return True
 def multi_call_audio_routing(self, pri_dut, sec_dut, ter_dut):
     self.log.info(
         "Test 2 incomming calls scenario to phone, then test audio routing."
     )
     input("Press enter to execute this testcase...")
     if not self.setup_multi_call(sec_dut, ter_dut, pri_dut):
         return False
     input("Press enter to switch to earpiece...")
     self.log.info("Switching to earpiece.")
     set_audio_route(self.log, pri_dut, AUDIO_ROUTE_EARPIECE)
     time.sleep(self.short_timeout)
     if get_audio_route(self.log, pri_dut) != AUDIO_ROUTE_EARPIECE:
         self.log.error(
             "Audio Route not set to {}".format(AUDIO_ROUTE_EARPIECE))
         return False
     input("Press enter to switch to Bluetooth...")
     self.log.info("Switching to Bluetooth...")
     set_audio_route(self.log, pri_dut, AUDIO_ROUTE_BLUETOOTH)
     time.sleep(self.short_timeout)
     if get_audio_route(self.log, pri_dut) != AUDIO_ROUTE_BLUETOOTH:
         self.log.error(
             "Audio Route not set to {}".format(AUDIO_ROUTE_BLUETOOTH))
         return False
     input("Press enter to hangup call 1...")
     if not hangup_call(self.log, sec_dut):
         self.log.error("Failed to hangup call")
         return False
     input("Press enter to hangup call 2...")
     if not hangup_call(self.log, ter_dut):
         self.log.error("Failed to hangup call")
         return False
     return True
 def multi_call_join_conference_call_audio_routes(self, pri_dut, sec_dut,
                                                  ter_dut):
     self.log.info(
         "Test 2 incomming calls scenario to phone then join the calls, then test different audio routes."
     )
     input("Press enter to execute this testcase...")
     if not self.setup_multi_call(sec_dut, ter_dut, pri_dut):
         return False
     input("Press enter to join active calls...")
     calls = pri_dut.droid.telecomCallGetCallIds()
     pri_dut.droid.telecomCallJoinCallsInConf(calls[0], calls[1])
     time.sleep(WAIT_TIME_IN_CALL)
     if num_active_calls(self.log, pri_dut) != 4:
         self.log.error("Total number of call ids in {} is not 4.".format(
             pri_dut.serial))
         return False
     input("Press enter to switch to phone speaker...")
     self.log.info("Switching to earpiece.")
     set_audio_route(self.log, pri_dut, AUDIO_ROUTE_EARPIECE)
     time.sleep(self.short_timeout)
     if get_audio_route(self.log, pri_dut) != AUDIO_ROUTE_EARPIECE:
         self.log.error(
             "Audio Route not set to {}".format(AUDIO_ROUTE_EARPIECE))
         return False
     input("Press enter to switch to Bluetooth...")
     self.log.info("Switching to Bluetooth...")
     set_audio_route(self.log, pri_dut, AUDIO_ROUTE_BLUETOOTH)
     time.sleep(self.short_timeout)
     if get_audio_route(self.log, pri_dut) != AUDIO_ROUTE_BLUETOOTH:
         self.log.error(
             "Audio Route not set to {}".format(AUDIO_ROUTE_BLUETOOTH))
         return False
     input("Press enter to hangup conf call...")
     if not hangup_call(self.log, pri_dut):
         self.log.error("Failed to hangup call")
         return False
     return True
 def call_audio_routes(self, pri_dut, sec_dut):
     self.log.info("Test various audio routes scenario from phone.")
     input("Press enter to execute this testcase...")
     outgoing_num = get_phone_number(self.log, sec_dut)
     if not initiate_call(self.log, pri_dut, outgoing_num):
         self.log.error("Failed to initiate call")
         return False
     if not wait_and_answer_call(self.log, sec_dut):
         self.log.error("Failed to answer call.")
         return False
     time.sleep(self.short_timeout)
     call_id = pri_dut.droid.telecomCallGetCallIds()[0]
     pri_dut.droid.telecomCallPlayDtmfTone(call_id, "9")
     input("Press enter to switch to speaker...")
     self.log.info("Switching to speaker.")
     set_audio_route(self.log, pri_dut, AUDIO_ROUTE_SPEAKER)
     time.sleep(self.short_timeout)
     if get_audio_route(self.log, pri_dut) != AUDIO_ROUTE_SPEAKER:
         self.log.error(
             "Audio Route not set to {}".format(AUDIO_ROUTE_SPEAKER))
         return False
     input("Press enter to switch to earpiece...")
     self.log.info("Switching to earpiece.")
     set_audio_route(self.log, pri_dut, AUDIO_ROUTE_EARPIECE)
     time.sleep(self.short_timeout)
     if get_audio_route(self.log, pri_dut) != AUDIO_ROUTE_EARPIECE:
         self.log.error(
             "Audio Route not set to {}".format(AUDIO_ROUTE_EARPIECE))
         return False
     input("Press enter to switch to Bluetooth...")
     self.log.info("Switching to Bluetooth...")
     set_audio_route(self.log, pri_dut, AUDIO_ROUTE_BLUETOOTH)
     time.sleep(self.short_timeout)
     if get_audio_route(self.log, pri_dut) != AUDIO_ROUTE_BLUETOOTH:
         self.log.error(
             "Audio Route not set to {}".format(AUDIO_ROUTE_BLUETOOTH))
         return False
     input("Press enter to hangup call...")
     self.log.info("Hanging up call...")
     pri_dut.droid.telecomCallStopDtmfTone(call_id)
     if not hangup_call(self.log, pri_dut):
         self.log.error("Failed to hangup call")
         return False
     return True