示例#1
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
示例#2
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
示例#3
0
    def dial_a_hangup_b_quick(self, a, b, delay=0, ph=""):
        """
        This test does a quick succession of dial and hangup. We make the test
        case sleep for delay amount between each dial and hangup. This is
        different from other test cases where we give enough time for devices
        to get into a calling state before trying to tear down connection.
        """
        if ph == "": ph = self.re_phone_number

        # Dial from A now.
        self.log.info("Dialing at droid {}".format(a.droid.getBuildDisplay()))
        a.droid.telecomCallTelUri(ph)

        # Wait for delay millis.
        time.sleep(delay)

        # Cancel the call at B. Use end call in this scenario so that we do not
        # wait for looking up the call!
        self.log.info("Hanging up at droid {}".format(
            b.droid.getBuildDisplay()))
        b.droid.telecomEndCall()

        # Check/Wait that we are clear before executing the test.
        for d in self.android_devices:
            if not car_telecom_utils.wait_for_not_in_call(self.log, d):
                self.log.warn(
                    "dial_a_hangup_quick wait_for_not_in_call failed {}".
                    format(d.serial))
                return False

        return True
示例#4
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
示例#5
0
    def stabilize_and_check_sanity(self):
        # Since we dial and hangup very very quickly we may end up in a state
        # where we need to wait to see the results. For instance if the delay is
        # 0.1 sec it may take upto 2 seconds for the platform to respond to a
        # dial() and hence even if we hangup 0.1 sec later we will not see its
        # result immidiately (this may be a false positive on test).
        time.sleep(STABILIZATION_DELAY_SEC)

        # First check if HF is in dialing state, we can send an actual hangup if
        # that is the case and then wait for devices to come back to normal.
        if self.hf.droid.telecomIsInCall():
            self.log.info("HF still in call, send hangup")
            self.hf.droid.telecomEndCall()

        # Wait for devices to go back to normal.
        for d in self.android_devices:
            if not car_telecom_utils.wait_for_not_in_call(self.log, d):
                self.log.warning(
                    "stabilize_and_check_sanity wait_for_not_in_call failed {}"
                    .format(d.serial))
                return False

        return True
示例#6
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
示例#7
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
示例#8
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