def power_voice_call_test(self):
        """ Measures power during a voice call.

        Measurement step in this test. Starts the voice call and
        initiates power measurement. Pass or fail is decided with a
        threshold value.
        """

        # Initiate the voice call
        initiate_call(self.log, self.dut, "+11112223333")

        # Wait for the callbox to pick up
        time.sleep(self.CALL_SETTLING_TIME)

        # Mute the call
        self.dut.droid.telecomCallMute()

        # Turn of screen
        self.dut.droid.goToSleepNow()

        # Measure power
        result = self.collect_power_data()

        # End the call
        hangup_call(self.log, self.dut)

        # Check if power measurement is within the required values
        self.pass_fail_check(result.average_current)
Ejemplo n.º 2
0
 def initiate_call_avrcp_controls_with_iperf(self):
     """Wrapper function to start iperf, initiate call from hf and answer
     call from secondary device.
     """
     initiate_call(self.log, self.sec_ad, self.ag_phone_number)
     time.sleep(CALL_WAIT_TIME)
     self.run_iperf_and_get_result()
     answer_call(self.iperf["duration"], self.bus, avrcp_flag=True)
     return self.teardown_result()
    def call_from_sec_ad_to_pri_ad_and_change_volume(self):
        """Initiates the call from secondary device and accepts the call
        from HF connected to primary device.

        Steps:
        1. Initiate call from secondary device to primary device.
        2. Accept the call from HF.
        3. Hangup the call from primary device.

        Returns:
            True if successful, False otherwise.
        """

        if not initiate_call(self.log, self.sec_ad, self.ag_phone_number):
            self.log.error("Failed to initiate call")
            return False
        time.sleep(5)  # Wait until initiate call.
        if not self.audio_receiver.press_accept_call():
            self.log.error("Failed to answer call from HF.")
            return False
        self.audio_receiver.press_volume_up()
        time.sleep(2)  #Wait until volume changes.
        self.audio_receiver.press_volume_down()
        time.sleep(self.iperf["duration"])
        if not hangup_call(self.log, self.pri_ad):
            self.log.error("Failed to hangup call.")
            return False
        return True
 def outgoing_call_hsp_disabled_then_enabled_during_call(
         self, pri_dut, sec_dut):
     self.log.info(
         "Test outgoing call hsp disabled then enable during call.")
     input("Press enter to execute this testcase...")
     outgoing_num = get_phone_number(self.log, sec_dut)
     if not pri_dut.droid.bluetoothHspDisconnect(self.target_mac_address):
         self.log.error("Failed to disconnect HSP service...")
         return False
     time.sleep(self.short_timeout)
     if len(pri_dut.droid.bluetoothHspGetConnectedDevices()) != 0:
         self.log.error("Failed to disconnect from HSP service")
         return False
     if not initiate_call(self.log, pri_dut, outgoing_num):
         self.log.error("Failed to initiate call")
         return False
     time.sleep(default_timeout)
     pri_dut.droid.bluetoothConnectBonded(self.target_mac_address)
     time.sleep(self.short_timeout)
     test_result = True
     if len(pri_dut.droid.bluetoothHspGetConnectedDevices()) != 1:
         self.log.error("Failed to reconnect to HSP service...")
         return
     if not hangup_call(self.log, pri_dut):
         self.log.error("Failed to hangup call")
         return False
     return test_result
    def initiate_call_when_a2dp_streaming_on(self):
        """Initiates HFP call when a2dp is streaming, then check for call is
        present or not.

        Disconnect a2dp profile and then connect HFP profile and
        answer the call from reference device.

        Returns:
            True if successful, False otherwise.
        """
        if not self.play_music_and_connect_wifi():
            return False

        if not initiate_call(self.log, self.pri_ad, self.re_phone_number):
            self.log.error("Failed to initiate call")
            return False
        if wait_for_dialing(self.log, self.pri_ad):
            self.pri_ad.droid.bluetoothDisconnectConnectedProfile(
                self.audio_receiver.mac_address,
                [BtEnum.BluetoothProfile.A2DP.value])
            if not connect_dev_to_headset(
                    self.pri_ad, self.audio_receiver.mac_address,
                [BtEnum.BluetoothProfile.HEADSET.value]):
                return False
        if not wait_and_answer_call(self.log, self.sec_ad):
            self.log.error("Failed to answer call in second device")
            return False
        time.sleep(self.iperf["duration"])
        if not hangup_call(self.log, self.pri_ad):
            self.log.error("Failed to hangup call")
            return False
        return True
 def setup_multi_call(self, caller0, caller1, callee):
     outgoing_num = get_phone_number(self.log, callee)
     if not initiate_call(self.log, caller0, outgoing_num):
         self.log.error("Failed to initiate call")
         return False
     if not wait_and_answer_call(self.log, callee):
         self.log.error("Failed to answer call.")
         return False
     time.sleep(self.short_timeout)
     if not initiate_call(self.log, caller1, outgoing_num):
         self.log.error("Failed to initiate call")
         return False
     if not wait_and_answer_call(self.log, callee):
         self.log.error("Failed to answer call.")
         return False
     return True
Ejemplo n.º 7
0
    def test_call_transfer_disconnect_connect(self):
        """
        Tests that after we connect when an active call is in progress,
        we show the call.

        Precondition:
        1. AG & HF are disconnected but paired.

        Steps:
        1. Make a call from AG role (since disconnected)
        2. Accept from RE role and transition the call to Active
        3. Connect AG & HF
        4. HF should transition into Active call state.

        Returns:
          Pass if True
          Fail if False

        Priority: 1
        """
        # make a call on AG
        if not initiate_call(self.log, self.ag, self.re_phone_number):
            self.ag.log.error("Failed to initiate call from ag.")
            return False
        if not wait_and_answer_call(self.log, self.re):
            self.re.log.error("Failed to accept call on re.")
            return False

        # Wait for AG, RE to go into an Active state.
        if not car_telecom_utils.wait_for_active(self.log, self.ag):
            self.ag.log.error("AG not in Active state.")
            return False
        if not car_telecom_utils.wait_for_active(self.log, self.re):
            self.re.log.error("RE not in Active state.")
            return False

        # Now connect the devices.
        if not bt_test_utils.connect_pri_to_sec(
                self.hf, self.ag,
                set([BtEnum.BluetoothProfile.HEADSET_CLIENT.value])):
            self.log.error("Could not connect HF and AG {} {}".format(
                self.hf.serial, self.ag.serial))
            return False

        # Check that HF is in active state
        if not car_telecom_utils.wait_for_active(self.log, self.hf):
            self.hf.log.error("HF not in Active state.")
            return False

        # Hangup the call and check all devices are clean
        self.hf.droid.telecomEndCall()
        ret = True
        ret &= car_telecom_utils.wait_for_not_in_call(self.log, self.hf)
        ret &= car_telecom_utils.wait_for_not_in_call(self.log, self.ag)
        ret &= car_telecom_utils.wait_for_not_in_call(self.log, self.re)

        return ret
Ejemplo n.º 8
0
def initiate_video_call(log, ad_caller, callee_number):
    """Make phone call from caller to callee.

    Args:
        log: logging handle
        ad_caller: Caller android device object.
        callee_number: Callee phone number.

    Returns:
        result: if phone call is placed successfully.
    """
    return initiate_call(log, ad_caller, callee_number, video=True)
Ejemplo n.º 9
0
def initiate_disconnect_call_dut(pri_ad, sec_ad, duration, callee_number):
    """Initiates call and disconnect call on primary device.

    Steps:
    1. Initiate call from DUT.
    2. Wait for dialing state at DUT and wait for ringing at secondary device.
    3. Accepts call from secondary device.
    4. Wait for call active state at primary and secondary device.
    5. Sleeps until given duration.
    6. Disconnect call from primary device.
    7. Wait for call is not present state.

    Args:
        pri_ad: An android device to disconnect call.
        sec_ad: An android device accepting call.
        duration: Duration of call in seconds.
        callee_number: Secondary device's phone number.

    Returns:
        True if successful, False otherwise.
    """
    if not initiate_call(logging, pri_ad, callee_number):
        pri_ad.log.error("Failed to initiate call")
        return False
    time.sleep(2)

    flag = True
    flag &= wait_for_dialing(logging, pri_ad)
    flag &= wait_for_ringing(logging, sec_ad)
    if not flag:
        pri_ad.log.error("Outgoing call did not get established")
        return False

    if not wait_and_answer_call(logging, sec_ad):
        pri_ad.log.error("Failed to answer call in second device.")
        return False
    # Wait for AG, RE to go into an Active state.
    if not wait_for_active(logging, pri_ad):
        pri_ad.log.error("AG not in Active state.")
        return False
    if not wait_for_active(logging, sec_ad):
        pri_ad.log.error("RE not in Active state.")
        return False
    time.sleep(duration)
    if not hangup_call(logging, pri_ad):
        pri_ad.log.error("Failed to hangup call.")
        return False
    flag = True
    flag &= wait_for_not_in_call(logging, pri_ad)
    flag &= wait_for_not_in_call(logging, sec_ad)

    return flag
 def outgoing_multi_call_join_conference_call(self, pri_dut, sec_dut,
                                              ter_dut):
     self.log.info(
         "Test 2 outgoing calls scenario from phone then join the calls.")
     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)
     outgoing_num = get_phone_number(self.log, ter_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, ter_dut):
         self.log.error("Failed to answer call.")
         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 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 incomming_call_unknown_contact(self, pri_dut, ter_dut):
     self.log.info(
         "Test incomming call scenario to phone from unknown contact")
     input("Press enter to execute this testcase...")
     outgoing_num = get_phone_number(self.log, pri_dut)
     if not initiate_call(self.log, ter_dut, outgoing_num):
         self.log.error("Failed to initiate call")
         return False
     if not wait_and_answer_call(self.log, pri_dut):
         self.log.error("Failed to answer call.")
         return False
     time.sleep(self.short_timeout)
     input("Press enter to hangup call...")
     if not hangup_call(self.log, ter_dut):
         self.log.error("Failed to hangup call")
         return False
     return True
 def outgoing_call_private_number(self, pri_dut, ter_dut):
     self.log.info(
         "Test outgoing call scenario from phone to private number")
     input("Press enter to execute this testcase...")
     outgoing_num = "*67" + get_phone_number(self.log, ter_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, ter_dut):
         self.log.error("Failed to answer call.")
         return False
     time.sleep(self.short_timeout)
     input("Press enter to hangup call...")
     if not hangup_call(self.log, pri_dut):
         self.log.error("Failed to hangup call")
         return False
     return True
Ejemplo n.º 13
0
    def check_incall_data(self):
        if verify_internet_connection_by_ping(self.log, self.dut):
            self.internet_connection_check_method = verify_internet_connection_by_ping
        elif verify_http_connection(self.log, self.dut):
            self.internet_connection_check_method = verify_http_connection
        else:
            self.dut.log.error("Data test failed")
            raise signals.TestFailure("Data check failed")
        if self.single_phone_test:
            if not initiate_call(
                    self.log, self.dut,
                    self.call_server_number) and wait_for_in_call_active(
                        self.dut, 60, 3):
                self._take_bug_report(self.test_name, self.begin_time)
                raise signals.TestFailure("Unable to make phone call")
        else:
            if not call_setup_teardown(
                    self.log, self.dut, self.android_devices[1],
                    ad_hangup=None):
                self._take_bug_report(self.test_name, self.begin_time)
                raise signals.TestFailure("Unable to make phone call")
        voice_rat = self.dut.droid.telephonyGetCurrentVoiceNetworkType()
        data_rat = self.dut.droid.telephonyGetCurrentDataNetworkType()
        self.dut.log.info("Voice in RAT %s, Data in RAT %s", voice_rat,
                          data_rat)
        try:
            if is_rat_svd_capable(voice_rat.upper()) and is_rat_svd_capable(
                    data_rat.upper()):
                self.dut.log.info("Capable for simultaneous voice and data")

                if not self.internet_connection_check_method(
                        self.log, self.dut):
                    self.dut.log.error("Incall data check failed")
                    raise signals.TestFailure("Incall data check failed")
                else:
                    return True
            else:
                self.dut.log.info(
                    "Not capable for simultaneous voice and data")
                return False
            hangup_call(self.log, self.dut)
        finally:
            for ad in self.android_devices:
                if ad.droid.telecomIsInCall():
                    hangup_call(self.log, ad)
 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
 def outgoing_call_multiple_iterations(self, pri_dut, sec_dut):
     iteration_count = 3
     self.log.info(
         "Test outgoing call scenario from phone {} times from known contact"
         .format(iteration_count))
     input("Press enter to execute this testcase...")
     outgoing_num = get_phone_number(self.log, sec_dut)
     for _ in range(iteration_count):
         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)
         if not hangup_call(self.log, pri_dut):
             self.log.error("Failed to hangup call")
             return False
     return True
 def sms_during_incomming_call(self, pri_dut, sec_dut):
     self.log.info(
         "Test incomming call scenario to phone from unknown contact")
     input("Press enter to execute this testcase...")
     outgoing_num = get_phone_number(self.log, pri_dut)
     if not initiate_call(self.log, sec_dut, outgoing_num):
         self.log.error("Failed to initiate call")
         return False
     if not wait_and_answer_call(self.log, pri_dut):
         self.log.error("Failed to answer call.")
         return False
     time.sleep(self.short_timeout)
     msg = [rand_ascii_str(10)]
     if not sms_send_receive_verify(self.log, sec_dut, pri_dut, msg):
         return False
     else:
         self.log.info("Successfully sent sms. Please verify on carkit.")
     input("Press enter to hangup call...")
     if not hangup_call(self.log, sec_dut):
         self.log.error("Failed to hangup call")
         return False
     return True
Ejemplo n.º 17
0
    def call_from_sec_ad_to_pri_ad(self):
        """Initiates the call from secondary device and accepts the call
        from HF.

        Steps:
        1. Initiate call from secondary device to primary device.
        2. Accept the call from HF.
        3. Hangup the call from primary device.

        Returns:
            True if successful, False otherwise.
        """
        if not initiate_call(self.log, self.sec_ad, self.ag_phone_number):
            self.log.error("Failed to initiate call")
            return False
        if not self.audio_receiver.press_accept_call():
            self.log.error("Failed to answer call from HF.")
            return False
        if not hangup_call(self.log, self.pri_ad):
            self.log.error("Failed to hangup call.")
            return False
        return False
 def outgoing_call_a2dp_play_before_and_after(self, pri_dut, sec_dut):
     self.log.info(
         "Test outgoing call scenario while playing music. Music should resume after call."
     )
     pri_dut.adb.shell(KEYCODE_EVENT_PREVIOUS)
     input(
         "Press enter to execute this testcase when music is in a play state..."
     )
     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)
     input("Press enter to hangup call...")
     if not hangup_call(self.log, pri_dut):
         self.log.error("Failed to hangup call")
         return False
     input("Press enter when music continues to play.")
     self.log.info("Pausing Music...")
     pri_dut.adb.shell(KEYCODE_EVENT_PLAY_PAUSE)
     return True
 def call_test(self):
     failure = 0
     total_count = 0
     while time.time() < self.finishing_time:
         total_count += 1
         try:
             self.dut.log.info(dict(self.result_info))
             self.result_info["Total Calls"] += 1
             duration = random.randrange(self.min_phone_call_duration,
                                         self.max_phone_call_duration)
             # Current Voice RAT
             self.dut.log.info("Current Voice RAT is %s",
                               get_current_voice_rat(self.log, self.dut))
             self.dut.log.info("Make call to %s with call duration %s",
                               self.call_server_number, duration)
             if not initiate_call(self.log, self.dut,
                                  self.call_server_number):
                 self.dut.log.error("Initiate phone call to %s failed.",
                                    self.call_server_number)
                 self.result_info["Call initiation failure"] += 1
                 failure += 1
                 self._take_bug_report("%s_call_initiation_failure" %
                                       self.test_name,
                                       time.strftime("%m-%d-%Y-%H-%M-%S"))
                 continue
             elapse_time = 0
             interval = min(60, duration)
             while elapse_time < duration:
                 interval = min(duration - elapse_time, interval)
                 time.sleep(interval)
                 elapse_time += interval
                 if not is_phone_in_call(self.log, self.dut):
                     self.dut.log.error("Call droped.")
                     self.result_info["Call drop"] += 1
                     failure += 1
                     self._take_bug_report(
                         "%s_call_drop" % self.test_name,
                         time.strftime("%m-%d-%Y-%H-%M-%S"))
                     break
                 else:
                     self.dut.log.info("DUT is in call")
             else:
                 hangup_call(self.log, self.dut)
                 self.dut.log.info("Call test succeed.")
                 ensure_phone_idle(self.log, self.dut)
                 self.dut.droid.goToSleepNow()
                 time.sleep(random.randrange(0, self.max_sleep_time))
         except IGNORE_EXCEPTIONS as e:
             self.log.error("Exception error %s", str(e))
             self.result_info["Exception Errors"] += 1
             if self.result_info["Exception Errors"] > EXCEPTION_TOLERANCE:
                 self.finishing_time = time.time()
                 raise
         except Exception as e:
             self.finishing_time = time.time()
             raise
         self.dut.log.info("Call test failure: %s/%s", failure, total_count)
     if failure:
         return "Call test failure: %s/%s" % (failure, total_count)
     else:
         return ""
Ejemplo n.º 20
0
    def test_multi_way_call_accept(self):
        """
        Tests if we can have a 3-way calling between re, RE2 and AG/HF.

        Precondition:
        1. Devices are connected over HFP.

        Steps:
        1. Make a call from AG to RE
        2. Wait for dialing on re and ringing on RE/HF.
        3. Accept the call on RE
        4. Make a call from AG to RE2
        5. Wait for dialing on re and ringing on RE2/HF.
        6. Accept the call on RE2.
        7. See that HF/AG have one active and one held call.
        8. Merge the call on HF.
        9. Verify that we have a conference call on HF/AG.
        10. Hangup the call on HF.
        11. Wait for all devices to go back into stable state.

        Returns:
          Pass if True
          Fail if False

        Priority: 0
        """

        # Dial RE from AG
        if not initiate_call(self.log, self.ag, self.re_phone_number):
            self.log.error("Failed to initiate call from re.")
            return False

        # Wait for dialing/ringing
        ret = True
        ret &= wait_for_ringing_call(self.log, self.re)
        ret &= car_telecom_utils.wait_for_ringing(self.log, self.hf)

        if not ret:
            self.log.error("Failed to dial incoming number from")
            return False

        # Give time for state to update due to carrier limitations
        time.sleep(SHORT_TIMEOUT)
        # Extract the call.
        call_1 = car_telecom_utils.get_calls_in_states(
            self.log, self.hf, [tel_defines.CALL_STATE_DIALING])
        if len(call_1) != 1:
            self.hf.log.error("Call State in ringing failed {}".format(call_1))
            return False

        re_ringing_call_id = car_telecom_utils.get_calls_in_states(
            self.log, self.re, [tel_defines.CALL_STATE_RINGING])

        # Accept the call on RE
        if not car_telecom_utils.accept_call(self.log, self.re,
                                             re_ringing_call_id[0]):
            self.hf.log.error("Accepting call failed {}".format(
                self.hf.serial))
            return False

        time.sleep(SHORT_TIMEOUT)
        # Dial another call to RE2
        if not initiate_call(self.log, self.ag, self.re2_phone_number):
            self.re2.log.error("Failed to initiate call from re.")
            return False

        # Wait for dialing/ringing
        ret &= wait_for_ringing_call(self.log, self.re2)
        ret &= car_telecom_utils.wait_for_ringing(self.log, self.hf)

        if not ret:
            self.log.error("AG and HF not in ringing state.")
            return False

        # Give time for state to update due to carrier limitations
        time.sleep(SHORT_TIMEOUT)
        # Extract the call.
        # input("Continue?")
        call_2 = car_telecom_utils.get_calls_in_states(
            self.log, self.hf, [tel_defines.CALL_STATE_DIALING])
        if len(call_2) != 1:
            self.hf.log.info("Call State in ringing failed {}".format(call_2))
            return False

        re2_ringing_call_id = car_telecom_utils.get_calls_in_states(
            self.log, self.re2, [tel_defines.CALL_STATE_RINGING])

        # Accept the call on HF
        if not car_telecom_utils.accept_call(self.log, self.re2,
                                             re2_ringing_call_id[0]):
            self.hf.log.info("Accepting call failed {}".format(self.hf.serial))
            return False

        # Give time before merge for state to update due to carrier limitations
        time.sleep(SHORT_TIMEOUT)

        # Merge the calls now.
        self.hf.droid.telecomCallJoinCallsInConf(call_1[0], call_2[0])

        # Check if we are in conference with call_1 and call_2
        conf_call_id = car_telecom_utils.wait_for_conference(self.log,
                                                             self.hf,
                                                             participants=2)
        if conf_call_id is None:
            self.hf.log.error("Did not get the conference setup correctly")
            return False

        # Now hangup the conference call.
        if not car_telecom_utils.hangup_conf(self.log, self.hf, conf_call_id):
            self.hf.log.error(
                "Could not hangup conference call {}!".format(conf_call_id))
            return False

        return True
    def volte_modechange_volte_test(self):
        failure = 0
        total_count = 0
        sub_id = self.dut.droid.subscriptionGetDefaultSubId()
        while time.time() < self.finishing_time:
            total_count += 1
            try:
                self.dut.log.info(dict(self.result_info))
                self.result_info["Total Calls"] += 1
                duration = random.randrange(self.min_phone_call_duration,
                                            self.max_phone_call_duration)
                # Current Voice RAT
                self.dut.log.info("Current Voice RAT is %s",
                                  get_current_voice_rat(self.log, self.dut))
                self.dut.log.info("Make call to %s with call duration %s",
                                  self.call_server_number, duration)
                if not initiate_call(self.log, self.dut,
                                     self.call_server_number):
                    self.dut.log.error("Initiate phone call to %s failed.",
                                       self.call_server_number)
                    self.result_info["Call initiation failure"] += 1
                    failure += 1
                    self._take_bug_report("%s_call_initiation_failure" %
                                          self.test_name,
                                          time.strftime("%m-%d-%Y-%H-%M-%S"))
                    continue
                elapse_time = 0
                interval = min(5, duration)
                while elapse_time < duration:
                    interval = min(duration - elapse_time, interval)
                    time.sleep(interval)
                    elapse_time += interval
                    if not is_phone_in_call_volte(self.log, self.dut):
                        self.dut.log.error("Call not VoLTE")
                        self.result_info["Call not VoLTE"] += 1
                        failure += 1
                        self._take_bug_report(
                            "%s_not_in_volte" % self.test_name,
                            time.strftime("%m-%d-%Y-%H-%M-%S"))
                        break
                    else:
                        self.dut.log.info("DUT is in VoLTE call")
                else:
                    hangup_call(self.log, self.dut)
                    self.dut.log.info("VoLTE test succeed.")

                    # ModePref change to non-LTE
                    network_preference_list = [
                        NETWORK_MODE_TDSCDMA_GSM_WCDMA,
                        NETWORK_MODE_WCDMA_ONLY, NETWORK_MODE_GLOBAL,
                        NETWORK_MODE_CDMA, NETWORK_MODE_GSM_ONLY
                    ]
                    network_preference = random.choice(network_preference_list)
                    set_preferred_network_mode_pref(self.dut.log, self.dut,
                                                    sub_id, network_preference)
                    time.sleep(WAIT_TIME_AFTER_MODE_CHANGE)
                    self.dut.log.info(
                        "Current Voice RAT is %s",
                        get_current_voice_rat(self.log, self.dut))

                    # ModePref change back to with LTE
                    set_preferred_network_mode_pref(
                        self.dut.log, self.dut, sub_id,
                        NETWORK_MODE_LTE_CDMA_EVDO_GSM_WCDMA)
                    time.sleep(WAIT_TIME_AFTER_MODE_CHANGE)

            except IGNORE_EXCEPTIONS as e:
                self.log.error("Exception error %s", str(e))
                self.result_info["Exception Errors"] += 1
                if self.result_info["Exception Errors"] > EXCEPTION_TOLERANCE:
                    self.finishing_time = time.time()
                    raise
            except Exception as e:
                self.finishing_time = time.time()
                raise
            self.dut.log.info("VoLTE test failure: %s/%s", failure,
                              total_count)
        if failure:
            return "VoLTE test failure: %s/%s" % (failure, total_count)
        else:
            return ""
Ejemplo n.º 22
0
    def test_call_transfer_off_on(self):
        """
        Tests that after we turn adapter on when an active call is in
        progress, we show the call.

        Precondition:
        1. AG & HF are disconnected but paired.
        2. HF's adapter is OFF

        Steps:
        1. Make a call from AG role (since disconnected)
        2. Accept from RE role and transition the call to Active
        3. Turn HF's adapter ON
        4. HF should transition into Active call state.

        Returns:
          Pass if True
          Fail if False

        Priority: 1
        """
        # Connect HF & AG
        if not bt_test_utils.connect_pri_to_sec(
                self.hf, self.ag,
                set([BtEnum.BluetoothProfile.HEADSET_CLIENT.value])):
            self.log.error("Could not connect HF and AG {} {}".format(
                self.hf.serial, self.ag.serial))
            return False

        # make a call on AG
        if not initiate_call(self.log, self.ag, self.re_phone_number):
            self.ag.log.error("Failed to initiate call from ag.")
            return False

        # Wait for all HF
        if not car_telecom_utils.wait_for_dialing(self.log, self.hf):
            self.hf.log.error("HF not in ringing state.")
            return False

        # Accept the call on RE
        if not wait_and_answer_call(self.log, self.re):
            self.re.log.error("Failed to accept call on re.")
            return False
        # Wait for all HF, AG, RE to go into an Active state.
        if not car_telecom_utils.wait_for_active(self.log, self.hf):
            self.hf.log.error("HF not in Active state.")
            return False
        if not car_telecom_utils.wait_for_active(self.log, self.ag):
            self.ag.log.error("AG not in Active state.")
            return False
        if not car_telecom_utils.wait_for_active(self.log, self.re):
            self.re.log.error("RE not in Active state.")
            return False

        # Turn the adapter OFF on HF
        if not bt_test_utils.disable_bluetooth(self.hf.droid):
            self.hf.log.error("Failed to turn BT off on HF.")
            return False

        # Turn adapter ON on HF
        if not bt_test_utils.enable_bluetooth(self.hf.droid, self.hf.ed):
            self.hf.log.error("Failed to turn BT ON after call on HF.")
            return False

        # Check that HF is in active state
        if not car_telecom_utils.wait_for_active(self.log, self.hf):
            self.hf.log.error("HF not in Active state.")
            return False

        # Hangup the call and check all devices are clean
        self.hf.droid.telecomEndCall()
        ret = True
        ret &= car_telecom_utils.wait_for_not_in_call(self.log, self.hf)
        ret &= car_telecom_utils.wait_for_not_in_call(self.log, self.ag)
        ret &= car_telecom_utils.wait_for_not_in_call(self.log, self.re)

        return ret
    def _telephony_monitor_test(self):
        """
        Steps -
        1. Reboot the phone
        2. Start Telephony Monitor using adb/developer options
        3. Verify if it is running
        4. Phone Call from A to B
        5. Answer on B
        6. Trigger ModemSSR on B
        7. There will be a call drop with Media Timeout/Server Unreachable
        8. Parse logcat to confirm that

        Expected Results:
            UI Notification is received by User

        Returns:
            True is pass, False if fail.
        """
        # Reboot
        ads = self.android_devices
        ads[0].adb.shell(
            "am start -n com.android.settings/.DevelopmentSettings",
            ignore_status=True)
        ads[0].log.info("reboot!")
        ads[0].reboot()
        ads[0].log.info("wait %d secs for radio up." % WAIT_TIME_AFTER_REBOOT)
        time.sleep(WAIT_TIME_AFTER_REBOOT)

        # Ensure apk is running
        if not ads[0].is_apk_running("com.google.telephonymonitor"):
            ads[0].log.info("TelephonyMonitor is not running, start it now")
            ads[0].adb.shell(
                'am broadcast -a '
                'com.google.gservices.intent.action.GSERVICES_OVERRIDE -e '
                '"ce.telephony_monitor_enable" "true"')

        # Setup Phone Call
        caller_number = ads[0].cfg['subscription'][get_outgoing_voice_sub_id(
            ads[0])]['phone_num']
        callee_number = ads[1].cfg['subscription'][get_incoming_voice_sub_id(
            ads[1])]['phone_num']
        tasks = [(phone_setup_voice_general, (self.log, ads[0])),
                 (phone_setup_voice_general, (self.log, ads[1]))]
        if not multithread_func(self.log, tasks):
            self.log.error("Phone Failed to Set Up Properly.")
            return False

        if not initiate_call(ads[0].log, ads[0], callee_number):
            ads[0].log.error("Phone was unable to initate a call")
            return False
        if not wait_and_answer_call(self.log, ads[1], caller_number):
            ads[0].log.error("wait_and_answer_call failed")
            return False

        # Modem SSR
        time.sleep(5)
        ads[1].log.info("Triggering ModemSSR")
        ads[1].adb.shell("echo restart > /sys/kernel/debug/msm_subsys/modem",
                         ignore_status=True)
        time.sleep(60)

        # Parse logcat for UI notification
        if ads[0].search_logcat("Bugreport notification title Call Drop:"):
            ads[0].log.info("User got the Call Drop Notification")
        else:
            ads[0].log.error("User didn't get Call Drop Notification in 1 min")
            return False
        return True
    def _cbrs_call_sequence(
            self, ads, mo_mt, cbrs_phone_setup_func,
            verify_cbrs_initial_idle_func, verify_data_initial_func,
            verify_cbrs_in_call_state_func, verify_data_in_call_func,
            incall_cbrs_setting_check_func, verify_data_final_func,
            verify_cbrs_final_func, expected_result):
        """_cbrs_call_sequence

        Args:
            ads: list of android devices. This list should have 2 ad.
            mo_mt: indicating this call sequence is MO or MT.
                Valid input: DIRECTION_MOBILE_ORIGINATED and
                DIRECTION_MOBILE_TERMINATED.

        Returns:
            if expected_result is True,
                Return True if call sequence finish without exception.
            if expected_result is string,
                Return True if expected exception happened. Otherwise False.

        """
        class _CBRSCallSequenceException(Exception):
            pass

        if (len(ads) != 2) or (mo_mt not in [
                DIRECTION_MOBILE_ORIGINATED, DIRECTION_MOBILE_TERMINATED
        ]):
            self.log.error("Invalid parameters.")
            return False

        self.cbrs_subid, self.default_subid = get_cbrs_and_default_sub_id(
            ads[0])

        if mo_mt == DIRECTION_MOBILE_ORIGINATED:
            ad_caller = ads[0]
            ad_callee = ads[1]
            caller_number = get_phone_number(self.log, ad_caller)
            callee_number = get_phone_number(self.log, ad_callee)
            mo_operator = get_operator_name(ads[0].log, ads[0])
            mt_operator = get_operator_name(ads[1].log, ads[1])
        else:
            ad_caller = ads[1]
            ad_callee = ads[0]
            caller_number = get_phone_number(self.log, ad_caller)
            callee_number = get_phone_number(self.log, ad_callee)
            mt_operator = get_operator_name(ads[0].log, ads[0])
            mo_operator = get_operator_name(ads[1].log, ads[1])

        self.log.info("-->Begin cbrs_call_sequence: %s to %s<--",
                      caller_number, callee_number)
        self.log.info("--> %s to %s <--", mo_operator, mt_operator)

        try:
            # Setup
            if cbrs_phone_setup_func and not cbrs_phone_setup_func():
                raise _CBRSCallSequenceException("cbrs_phone_setup_func fail.")
            if not phone_setup_voice_general(self.log, ads[1]):
                raise _CBRSCallSequenceException(
                    "phone_setup_voice_general fail.")
            time.sleep(WAIT_TIME_BETWEEN_REG_AND_CALL)

            # Ensure idle status correct
            if verify_cbrs_initial_idle_func and not \
                verify_cbrs_initial_idle_func():
                raise _CBRSCallSequenceException(
                    "verify_cbrs_initial_idle_func fail.")

            # Ensure data checks are performed
            if verify_data_initial_func and not \
                verify_data_initial_func():
                raise _CBRSCallSequenceException(
                    "verify_data_initial_func fail.")

            # Make MO/MT call.
            if not initiate_call(self.log, ad_caller, callee_number):
                raise _CBRSCallSequenceException("initiate_call fail.")
            if not wait_and_answer_call(self.log, ad_callee, caller_number):
                raise _CBRSCallSequenceException("wait_and_answer_call fail.")
            time.sleep(WAIT_TIME_FOR_CBRS_DATA_SWITCH)

            # Check state, wait 30 seconds, check again.
            if (verify_cbrs_in_call_state_func
                    and not verify_cbrs_in_call_state_func()):
                raise _CBRSCallSequenceException(
                    "verify_cbrs_in_call_state_func fail.")

            if is_phone_not_in_call(self.log, ads[1]):
                raise _CBRSCallSequenceException("PhoneB not in call.")

            # Ensure data checks are performed
            if verify_data_in_call_func and not \
                verify_data_in_call_func():
                raise _CBRSCallSequenceException(
                    "verify_data_in_call_func fail.")

            time.sleep(WAIT_TIME_IN_CALL)

            if (verify_cbrs_in_call_state_func
                    and not verify_cbrs_in_call_state_func()):
                raise _CBRSCallSequenceException(
                    "verify_cbrs_in_call_state_func fail after 30 seconds.")
            if is_phone_not_in_call(self.log, ads[1]):
                raise _CBRSCallSequenceException(
                    "PhoneB not in call after 30 seconds.")

            # in call change setting and check
            if (incall_cbrs_setting_check_func
                    and not incall_cbrs_setting_check_func()):
                raise _CBRSCallSequenceException(
                    "incall_cbrs_setting_check_func fail.")

            # Hangup call
            if is_phone_in_call(self.log, ads[0]):
                if not hangup_call(self.log, ads[0]):
                    raise _CBRSCallSequenceException("hangup_call fail.")
            else:
                if incall_cbrs_setting_check_func is None:
                    raise _CBRSCallSequenceException("Unexpected call drop.")

            time.sleep(WAIT_TIME_FOR_CBRS_DATA_SWITCH)

            # Ensure data checks are performed
            if verify_data_final_func and not \
                verify_data_final_func():
                raise _CBRSCallSequenceException(
                    "verify_data_final_func fail.")

            # Ensure data checks are performed
            if verify_cbrs_final_func and not \
                verify_cbrs_final_func():
                raise _CBRSCallSequenceException(
                    "verify_cbrs_final_func fail.")

        except _CBRSCallSequenceException as e:
            if str(e) == expected_result:
                self.log.info("Expected exception: <%s>, return True.", e)
                return True
            else:
                self.log.info("Unexpected exception: <%s>, return False.", e)
                return False
        finally:
            for ad in ads:
                if ad.droid.telecomIsInCall():
                    hangup_call_by_adb(ad)
        self.log.info("cbrs_call_sequence finished, return %s",
                      expected_result is True)
        return (expected_result is True)
Ejemplo n.º 25
0
    def test_call_3g_stress(self):
        """ 3G to 800 call test

        Steps:
        1. Make Sure PhoneA is in 3G mode.
        2. Call from PhoneA to a 800 number, hang up on PhoneA.
        3, Repeat 2 around 100 times based on the config setup

        Expected Results:
        1, Verify phone is at IDLE state
        2, Verify the phone is at ACTIVE, if it is in dialing, then we retry
        3, Verify the phone is IDLE after hung up

        Returns:
            True if pass; False if fail.
        """
        ad_caller = self.ad_caller
        callee_number = self.stress_test_callee_number
        asserts.assert_true(phone_setup_voice_3g(self.log, ad_caller),
                            "Phone Failed to Set Up Properly.")

        # Make sure phone is idle.
        ensure_phone_idle(self.log, ad_caller)
        asserts.assert_true(phone_idle_3g(self.log, ad_caller),
                            "DUT Failed to Reselect")

        self.log.info("Call test:{} to {}".format(ad_caller.serial,
                                                  callee_number))
        subid_caller = ad_caller.droid.subscriptionGetDefaultVoiceSubId()

        total_iteration = self.phone_call_iteration
        current_iteration = 0
        redial_time = 0
        while current_iteration < total_iteration:
            self.log.info("---> Call test: iteration {} redial {}<---".format(
                current_iteration, redial_time))
            self.log.info("Checking Telephony Manager Call State")
            asserts.assert_true(
                self._check_phone_call_status(
                    ad_caller, tel_defines.TELEPHONY_STATE_IDLE),
                INCORRECT_STATE_MSG)

            self.log.info("Making a phone call")
            asserts.assert_true(
                initiate_call(self.log, ad_caller, callee_number),
                "Initiate call failed.")

            self.log.info("Ensure that all internal states are updated")
            time.sleep(tel_defines.WAIT_TIME_ANDROID_STATE_SETTLING)
            asserts.assert_true(is_phone_in_call_3g(self.log, ad_caller),
                                INCORRECT_STATE_MSG)
            asserts.assert_true(
                self._check_phone_call_status(
                    ad_caller, tel_defines.TELEPHONY_STATE_OFFHOOK,
                    tel_defines.CALL_STATE_DIALING), INCORRECT_STATE_MSG)

            time.sleep(tel_defines.WAIT_TIME_IN_CALL)
            self.log.info(
                "Checking Telephony Manager Call State after waiting for a while"
            )
            if (self._check_phone_call_status(
                    ad_caller, tel_defines.TELEPHONY_STATE_OFFHOOK,
                    tel_defines.CALL_STATE_ACTIVE)):
                current_iteration += 1
                redial_time = 0
            elif (self._check_phone_call_status(
                    ad_caller, tel_defines.TELEPHONY_STATE_OFFHOOK,
                    tel_defines.CALL_STATE_DIALING)):
                self.log.info("The line is busy, try again")
                redial_time += 1
                if redial_time > MAX_NUMBER_REDIALS:
                    asserts.assert_true(
                        False,
                        "Re-dial {} times and still having busy signal".format(
                            redial_time))
            else:
                asserts.assert_true(False, INCORRECT_STATE_MSG)
                current_iteration += 1

            self.log.info("Hang up phone for this iteration")
            asserts.assert_true(hangup_call(self.log, ad_caller),
                                "Error in Hanging-Up Call")
            time.sleep(tel_defines.WAIT_TIME_ANDROID_STATE_SETTLING)
            self.log.info(
                "Checking Telephony Manager Call State after hang up")
            asserts.assert_true(
                self._check_phone_call_status(
                    ad_caller, tel_defines.TELEPHONY_STATE_IDLE),
                INCORRECT_STATE_MSG)

            ensure_phone_idle(self.log, ad_caller)
Ejemplo n.º 26
0
 def _make_phone_call(self, call_verification_func=None):
     ads = self.android_devices[:]
     if not self.single_phone_test:
         random.shuffle(ads)
     the_number = self.result_info["Call Total"] + 1
     duration = random.randrange(self.min_phone_call_duration,
                                 self.max_phone_call_duration)
     result = True
     test_name = "%s_No_%s_phone_call" % (self.test_name, the_number)
     log_msg = "[Test Case] %s" % test_name
     self.log.info("%s for %s seconds begin", log_msg, duration)
     begin_time = get_device_epoch_time(ads[0])
     for ad in self.android_devices:
         if self.user_params.get("turn_on_tcpdump", True):
             start_adb_tcpdump(ad, interface="any", mask="all")
         if not getattr(ad, "droid", None):
             ad.droid, ad.ed = ad.get_droid()
             ad.ed.start()
         else:
             try:
                 if not ad.droid.is_live:
                     ad.droid, ad.ed = ad.get_droid()
                     ad.ed.start()
                 else:
                     ad.ed.clear_all_events()
             except Exception:
                 ad.log.info("Create new sl4a session for phone call")
                 ad.droid, ad.ed = ad.get_droid()
                 ad.ed.start()
         ad.droid.logI("%s begin" % log_msg)
     start_qxdm_loggers(self.log, self.android_devices, begin_time)
     failure_reasons = set()
     self.dut_incall = True
     if self.single_phone_test:
         call_setup_result = initiate_call(
             self.log,
             self.dut,
             self.call_server_number,
             incall_ui_display=INCALL_UI_DISPLAY_BACKGROUND
         ) and wait_for_in_call_active(self.dut, 60, 3)
     else:
         call_setup_result = call_setup_teardown(
             self.log,
             ads[0],
             ads[1],
             ad_hangup=None,
             verify_caller_func=call_verification_func,
             verify_callee_func=call_verification_func,
             wait_time_in_call=0,
             incall_ui_display=INCALL_UI_DISPLAY_BACKGROUND)
     if not call_setup_result:
         call_logs = ads[0].search_logcat(
             "ActivityManager: START u0 {act=android.intent.action.CALL",
             begin_time)
         messaging_logs = ads[0].search_logcat(
             "com.google.android.apps.messaging/.ui.conversation.ConversationActivity",
             begin_time)
         if call_logs and messaging_logs:
             if messaging_logs[-1]["datetime_obj"] - call_logs[-1]["datetime_obj"] < 5:
                 ads[0].log.info(
                     "Call setup failure due to simultaneous activities")
                 self.result_info[
                     "Call Setup Failure With Simultaneous Activity"] += 1
                 return True
         self.log.error("%s: Setup Call failed.", log_msg)
         failure_reasons.add("Setup")
         result = False
     else:
         elapsed_time = 0
         check_interval = 5
         while (elapsed_time < duration):
             check_interval = min(check_interval, duration - elapsed_time)
             time.sleep(check_interval)
             elapsed_time += check_interval
             time_message = "at <%s>/<%s> second." % (elapsed_time,
                                                      duration)
             for ad in ads:
                 if not call_verification_func(self.log, ad):
                     ad.log.warning("Call is NOT in correct %s state at %s",
                                    call_verification_func.__name__,
                                    time_message)
                     if call_verification_func.__name__ == "is_phone_in_call_iwlan":
                         if is_phone_in_call(self.log, ad):
                             if getattr(ad, "data_rat_state_error_count",
                                        0) < 1:
                                 setattr(ad, "data_rat_state_error_count",
                                         1)
                                 continue
                     failure_reasons.add("Maintenance")
                     last_call_drop_reason(ad, begin_time)
                     hangup_call(self.log, ads[0])
                     result = False
                 else:
                     ad.log.info("Call is in correct %s state at %s",
                                 call_verification_func.__name__,
                                 time_message)
             if not result:
                 break
     if not hangup_call(self.log, ads[0]):
         failure_reasons.add("Teardown")
         result = False
     for ad in ads:
         if not wait_for_call_id_clearing(ad,
                                          []) or ad.droid.telecomIsInCall():
             ad.log.error("Fail to hang up call")
             failure_reasons.add("Teardown")
             result = False
     self.result_info["Call Total"] += 1
     for ad in self.android_devices:
         try:
             ad.droid.logI("%s end" % log_msg)
         except:
             pass
     self.log.info("%s end", log_msg)
     self.dut_incall = False
     if not result:
         self.log.info("%s failed", log_msg)
         if self.gps_log_file:
             gps_info = job.run(
                 "tail %s" % self.gps_log_file, ignore_status=True)
             if gps_info.stdout:
                 gps_log_path = os.path.join(self.log_path, test_name,
                                             "gps_logs.txt")
                 utils.create_dir(gps_log_path)
                 job.run(
                     "tail %s > %s" % (self.gps_log_file, gps_log_path),
                     ignore_status=True)
                 self.log.info("gps log:\n%s", gps_info.stdout)
             else:
                 self.log.warning("Fail to get gps log %s",
                                  self.user_params["gps_log_file"])
         for reason in failure_reasons:
             self.result_info["Call %s Failure" % reason] += 1
         for ad in ads:
             log_path = os.path.join(self.log_path, test_name,
                                     "%s_binder_logs" % ad.serial)
             utils.create_dir(log_path)
             ad.pull_files(BINDER_LOGS, log_path)
         try:
             self._take_bug_report(test_name, begin_time)
         except Exception as e:
             self.log.exception(e)
         for ad in ads:
             if ad.droid.telecomIsInCall():
                 hangup_call_by_adb(ad)
     else:
         self.log.info("%s test succeed", log_msg)
         self.result_info["Call Success"] += 1
         if self.result_info["Call Total"] % 50 == 0:
             for ad in ads:
                 synchronize_device_time(ad)
                 if not check_is_wifi_connected(self.log, ad,
                                                self.wifi_network_ssid):
                     ensure_wifi_connected(self.log, ad,
                                           self.wifi_network_ssid,
                                           self.wifi_network_pass)
                     force_connectivity_metrics_upload(ad)
                     time.sleep(300)
                     wifi_toggle_state(self.log, ad, False)
                 if self.get_binder_logs:
                     log_path = os.path.join(self.log_path,
                                             "%s_binder_logs" % test_name,
                                             "%s_binder_logs" % ad.serial)
                     utils.create_dir(log_path)
                     ad.pull_files(BINDER_LOGS, log_path)
     return result