Пример #1
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
Пример #2
0
def initiate_disconnect_from_hf(audio_receiver, pri_ad, sec_ad, duration):
    """Initiates call and disconnect call on primary device.

    Steps:
    1. Initiate call from HF.
    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:
        audio_receiver: An relay device object.
        pri_ad: An android device to disconnect call.
        sec_ad: An android device accepting call.
        duration: Duration of call in seconds.

    Returns:
        True if successful, False otherwise.
    """
    audio_receiver.press_initiate_call()
    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
    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
Пример #3
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
Пример #4
0
    def test_call_transfer_connect_disconnect_connect(self):
        """
        Test that when we go from connect -> disconnect -> connect on an active
        call then the call is restored on HF.

        Precondition:
        1. AG & HF are paired

        Steps:
        0. Connect AG & HF
        1. Make a call from HF role
        2. Accept from RE role and transition the call to Active
        3. Disconnect AG & HF
        4. Verify that we don't have any calls on HF
        5. Connect AG & HF
        6. Verify that HF gets the call back.

        Returns:
          Pass if True
          Fail if False

        Priority: 1
        """
        # 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

        # make a call on HF
        if not car_telecom_utils.dial_number(self.log, self.hf,
                                             self.re_phone_number):
            self.hf.log.error("HF not in dialing state.")
            return False

        # Wait for HF, AG to be dialing and RE to be ringing
        ret = True
        ret &= car_telecom_utils.wait_for_dialing(self.log, self.hf)
        #uncomment once sl4a code has been merged.
        ret &= car_telecom_utils.wait_for_dialing(self.log, self.ag)
        ret &= car_telecom_utils.wait_for_ringing(self.log, self.re)

        if not ret:
            self.log.error("Outgoing call did not get established")
            return False

        # Accept 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

        ret &= car_telecom_utils.wait_for_active(self.log, self.hf)
        ret &= car_telecom_utils.wait_for_active(self.log, self.ag)
        ret &= car_telecom_utils.wait_for_active(self.log, self.re)

        if not ret:
            self.log.error("Outgoing call did not transition to active")
            return False

        # Disconnect HF & AG
        self.hf.droid.bluetoothDisconnectConnected(
            self.ag.droid.bluetoothGetLocalAddress())

        # We use the proxy of the Call going away as HF disconnected
        if not car_telecom_utils.wait_for_not_in_call(self.log, self.hf):
            self.hf.log.error("HF still in call after disconnection.")
            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))
            # Additional profile connection check for b/
            if not bt_test_utils.is_hfp_client_device_connected(
                    self.hf, self.ag.droid.bluetoothGetLocalAddress()):
                self.hf.log.info(
                    "HFP Client connected even though connection state changed "
                    + " event not found")
                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 &= 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
Пример #5
0
    def dial_a_hangup_b(self, a, b, ph=""):
        """
        a, b and c can be either of AG, HF or Remote.
        1. Make a call from 'a' on a fixed number.
        2. Wait for the call to get connected (check on both 'a' and 'b')
           Check that 'c' is in ringing state.
        3. Hangup the call on 'b'.
        4. Wait for call to get completely disconnected
        (check on both 'a' and 'b')
        It is assumed that scenarios will not go into voice mail.
        """
        if ph == "": ph = self.re_phone_number

        # Determine if this is outgoing or incoming call.
        call_type = None
        if a == self.ag or a == self.hf:
            call_type = CALL_TYPE_OUTGOING
            if b != self.ag and b != self.hf:
                self.log.info("outgoing call should terminate at AG or HF")
                return False
        elif a == self.re:
            call_type = CALL_TYPE_INCOMING
            if b != self.re:
                self.log.info("Incoming call should terminate at Re")
                return False

        self.log.info("Call type is {}".format(call_type))

        # make a call on 'a'
        if not car_telecom_utils.dial_number(self.log, a, ph):
            return False

        # Check that everyone is in dialing/ringing state.
        ret = True
        if call_type == CALL_TYPE_OUTGOING:
            ret &= car_telecom_utils.wait_for_dialing(self.log, self.hf)
            ret &= car_telecom_utils.wait_for_dialing(self.log, self.ag)
            ret &= car_telecom_utils.wait_for_ringing(self.log, self.re)
        else:
            ret &= car_telecom_utils.wait_for_ringing(self.log, self.hf)
            ret &= car_telecom_utils.wait_for_ringing(self.log, self.ag)
            ret &= car_telecom_utils.wait_for_dialing(self.log, self.re)
        if not ret:
            return False

        # Check if we have any calls with dialing or active state on 'b'.
        # We assume we never disconnect from 'ringing' state since it will lead
        # to voicemail.
        call_state_dialing_or_active = \
            [tel_defines.CALL_STATE_CONNECTING,
             tel_defines.CALL_STATE_DIALING,
             tel_defines.CALL_STATE_ACTIVE]

        calls_in_dialing_or_active = car_telecom_utils.get_calls_in_states(
            self.log, b, call_state_dialing_or_active)

        # Make sure there is only one!
        if len(calls_in_dialing_or_active) != 1:
            self.log.info("Call State in dialing or active failed {}".format(
                calls_in_dialing_or_active))
            return False

        # Hangup the *only* call on 'b'
        if not car_telecom_utils.hangup_call(self.log, b,
                                             calls_in_dialing_or_active[0]):
            return False

        # Make sure everyone got out of in call state.
        for d in self.android_devices:
            ret &= car_telecom_utils.wait_for_not_in_call(self.log, d)
        return ret