Ejemplo n.º 1
0
    def check_ims_registration_before_timeout(self, timeout=30):
        """
        Waits a maximum of the given timeout (in seconds) for IMS registration.

        If the IMS registration does not occur before the timeout, a
        DeviceException is raised.
        """
        start = time.time()
        ims_registered_state = ImsRegistrationStatus.in_service()
        current_status = None
        registration_time = 0
        while time.time() - start < timeout:
            time.sleep(1)
            current_status = ImsRegistrationStatus(
                self.get_ims_registration_status())
            if current_status == ims_registered_state:
                registration_time = time.time()
                break
        if current_status is None or current_status != ims_registered_state:
            return_msg = "The device could not register to IMS before " \
                "%d seconds." % timeout
            raise DeviceException(DeviceException.TIMEOUT_REACHED, return_msg)
        else:
            # Update the time needed for registration
            registration_time -= start
            # Log the computed time
            self._logger.info("IMS registration complete after %ds"
                % int(registration_time))
    def _check_registration_second_dut(self):
        """
        Check if secondary DUT is registered or not to NW

        :raise DeviceException: in case 2nd DUT not registered
        """
        in_service_status = ImsRegistrationStatus.in_service()
        reg_status = ImsRegistrationStatus(
            self._networking_api2.get_ims_registration_status())

        # If not registered
        if reg_status != in_service_status:
            self._logger.warning(
                "The secondary DUT is NOT registered! Airplane on/off will be performed!"
            )
            self._networking_api2.set_flight_mode("on")
            # Wait 10 seconds
            time.sleep(10)
            self._networking_api2.set_flight_mode("off")
            # Wait 10 seconds
            time.sleep(10)
            try:
                self._networking_api2.check_ims_registration_before_timeout(60)
            except DeviceException:
                message = "Secondary DUT still not registered after airplane on/off !"
                raise DeviceException(DeviceException.TIMEOUT_REACHED, message)
Ejemplo n.º 3
0
    def _perform_ims_deregistration(self):
        """
        Perform IMS de-registration using AT command / IMS config

        :return: the verdict and its corresponding message
        :rtype: int, str

        :raise AcsToolException OPERATION_FAILED: if an error occurred during the
            AT command execution.
        """
        # Initialize local variables
        verdict = Global.SUCCESS
        message = "No error"

        # AT Command for un register fails if the DUT is not registered to IMS
        registration_status = self._get_registration_status()
        self._logger.info("Registration status: %s (expected %s)." % (
            str(registration_status),
            str(ImsRegistrationStatus.in_service())))
        state = (registration_status != ImsRegistrationStatus.in_service())
        self._logger.debug("Comparison status: %s" % str(state))
        if registration_status != ImsRegistrationStatus.in_service():
            self._logger.info("DUT is not registered to IMS, nothing to do.")
            return (Global.SUCCESS, "Nothing to do.")

        if self._ims_configure_modem_procedure == "IMS_ANDROID":
            # Turn off IMS
            self._modem_api.turn_ims("OFF")
            # Wait 5 seconds
            time.sleep(5)
        else:
            # Execute at+xireg=0 command
            (status, message) = self._execute_at_command("at+xireg=0")
            if status != Global.SUCCESS:
                message = "%s (%s)." % (
                    "An error occured during IMS de-registration",
                    message)
                raise AcsToolException(
                    AcsToolException.OPERATION_FAILED,
                    message)
            # Wait 15 seconds
            time.sleep(15)

        # Check the registration status for IMS, should be "OUT_OF_SERVICE"
        ims_service_status = ImsRegistrationStatus.out_of_service()
        # Log the latest IMS registration status
        registration_status = self._get_registration_status()
        self._logger.info("Registration status: %s (%d)" % (
            str(registration_status),
            registration_status.as_int()))

        if registration_status != ims_service_status:
            verdict = Global.FAILURE
            message = "IMS is still registered after registration OFF."

        return (verdict, message)
Ejemplo n.º 4
0
    def run_test(self):
        """
        Runs the test.
        """

        # Call inherited run_test method which will ensure IMS
        # IMS registration on device 1
        LiveLteImsVcDualBase.run_test(self)

        # Perform the IMS call procedure
        (verdict, message) = self._perform_ims_call(self._call_direction)

        # Because in case of failure the IMS stack may have crashed
        # we need to double-check the IMS registration status.
        in_service_status = ImsRegistrationStatus.in_service()
        registration_status = self._get_registration_status()
        self._logger.info(
            "Registration status: %s (%d)" %
            (str(registration_status), registration_status.as_int()))
        # Compute the verdict
        if registration_status != in_service_status:
            message = "IMS stack has crashed or IMS registration is lost."
            self._logger.error(message)
            verdict = Global.FAILURE

        # Return the test result
        return (verdict, message)
Ejemplo n.º 5
0
    def _deactivate_ss_feature(self):
        """
        Supplementary Service de-activation

        :rtype: int, str
        :return: the verdict and the message
        """

        # Initialize the verdict
        verdict = Global.SUCCESS
        message = "No error."

        # For 'CALL_FORWARDING' scenario
        if self._ims_ss_feature == "CALL_FORWARDING":
            # For 'NOT_REACHABLE' case perform the re-registration scenario upon flight mode off
            if self._ims_ss_mode != "NOT_REACHABLE":
                # Flight mode off for main DUT
                self._networking_api.set_flight_mode("off")
                # Sleep 30 seconds
                time.sleep(30)
                # Check the registration status for IMS, should be "IN_SERVICE"
                ims_service_status = ImsRegistrationStatus.in_service()
                self._networking_api.check_ims_registration_before_timeout(
                    self._ims_registration_timeout)
                # Check the IMS registration status
                registration_status = self._get_registration_status()
                if registration_status != ims_service_status:
                    verdict = Global.FAILURE
                    message = "IMS is not registered after registration ON for main DUT"
                    self._logger.error(message)
                    return (verdict, message)

            # De-activate the call forwarding on main DUT
            self._phone_system_api.wake_screen()
            self._voice_call_api.disable_call_forwarding(
                self._ims_ss_mode.lower())
            # Sleep few seconds for activation of Supplementary Service
            self._logger.info("Sleep for %s seconds" % self._wait_ss_response)
            time.sleep(self._wait_ss_response)

            try:
                # Check the call forwarding state
                self._voice_call_api.check_call_forwarding_state(
                    LiveLteImsVcSSDual.STATE_DISABLED)
            except DeviceException as device_ex:
                message = "Exception caught: %s" % (str(device_ex))
                self._logger.error(message)
                verdict = Global.FAILURE

        # For 'CALL_BARRING' scenario
        elif self._ims_ss_feature == "CALL_BARRING":
            # Disable the call barring
            self._voice_call_api.disable_call_barring(
                self._ims_ss_mode.lower(), self._cb_activation_code)
            # Sleep few seconds for activation of Supplementary Service
            self._logger.info("Sleep for %s seconds" % self._wait_ss_response)
            time.sleep(self._wait_ss_response)

        return (verdict, message)
Ejemplo n.º 6
0
 def _get_registration_status(self):
     """
     Returns an ImsRegistrationStatus object describing the current
     IMS registration status of the device.
     :return: the current registration status
     :rtype: ImsRegistrationStatus
     """
     return ImsRegistrationStatus(
         self._networking_api.get_ims_registration_status())
Ejemplo n.º 7
0
    def run_test(self):
        """
        Execute the test
        """
        # Call inherited run_test method
        UseCaseBase.run_test(self)

        # Initialize some local variables
        registration_message = "IMS registration failure."
        verdict = Global.FAILURE
        in_service_status = ImsRegistrationStatus.in_service()

        # Proceed with the proper execution of the test.
        if "REGISTER" == self._ims_reg_operation:
            # Sleep during registration timeout + IMS registration timeout
            self._logger.info("Waiting %d seconds for IMS registration..." % \
                self._ims_registration_timeout)

            # Check the registration status from DUT as returned by the API
            self._networking_api.check_ims_registration_before_timeout(
                self._ims_registration_timeout)

        # Log the latest IMS registration status
        registration_status = self._get_registration_status()
        self._logger.info("Registration status: %s (%d)" % (
            str(registration_status),
            registration_status.as_int()))
        # Compute the verdict
        if registration_status == in_service_status:
            verdict = Global.SUCCESS
            registration_message = "IMS registration success."

        # Check IMS registration after registration OFF/ON procedures
        if self._deregistration_method:
            self._logger.info("Check IMS registration during registration OFF/ON procedures")
            (verdict, registration_message) = \
                self._check_registration_off_on()

        # Return the test result
        return (verdict, registration_message)
Ejemplo n.º 8
0
    def run_test(self):
        """
        Runs the test.
        """
        # Call inherited run_test method which will ensure IMS
        # IMS registration on device 1
        self._logger.info("")
        self._logger.info("Calling inherited run_test step.")
        self._logger.info("")
        LiveLteImsVcDualBase.run_test(self)

        # Initialize verdict variables
        verdict = Global.SUCCESS
        message = "No error."

        # Proceed with the scenario based on the Supplementary service
        self._logger.info("")
        self._logger.info("Executing requested tests.")
        self._logger.info("")
        if self._ims_ss_feature == "CALL_FORWARDING":
            (verdict, message) = self._check_call_forwarding()
        elif self._ims_ss_feature == "CALL_BARRING":
            (verdict, message) = self._perform_call_barring()

        if verdict == Global.FAILURE:
            # Because in case of failure the IMS stack may have crashed
            # we need to double-check the IMS registration status.
            in_service_status = ImsRegistrationStatus.in_service()
            registration_status = self._get_registration_status()
            self._logger.info(
                "Registration status: %s (%d)" %
                (str(registration_status), registration_status.as_int()))
            # Compute the verdict
            if registration_status != in_service_status:
                message = "IMS stack has crashed or IMS registration is lost."
                self._logger.error(message)
                verdict = Global.FAILURE

        # Return the test result
        return (verdict, message)
Ejemplo n.º 9
0
    def _check_registration_off_on(self):
        """
        Performs the registration OFF->ON and checks
        the IMS registration status for both cases.

        :return: the verdict and its corresponding message
        :rtype: int, str
        """

        verdict = Global.SUCCESS

        # Registration OFF depending on the method (AIRPLANE/AT Command)
        if self._deregistration_method == "AIRPLANE_ON_OFF":
            self._networking_api.set_flight_mode("on")
        else:
            # IMS Config
            if self._ims_configure_modem_procedure == "IMS_ANDROID":
                self._modem_api.turn_ims("OFF")
            # AT commands
            else:
                (status, message) = self._execute_at_command("at+xireg=0")
                if status != Global.SUCCESS:
                    message = "%s (%s)." % (
                        "An error occured during IMS de-registration",
                        message)
                    raise AcsToolException(
                        AcsToolException.OPERATION_FAILED,
                        message)
        # Wait 5 seconds
        time.sleep(5)

        # Check the registration status for IMS, should be "OUT_OF_SERVICE"
        ims_service_status = ImsRegistrationStatus.out_of_service()
        # Log the latest IMS registration status
        registration_status = self._get_registration_status()
        self._logger.info("Registration status: %s (%d)" % (
            str(registration_status),
            registration_status.as_int()))

        if registration_status != ims_service_status:
            verdict = Global.FAILURE
            message = "IMS is still registered after registration OFF."

        # Checks that LTE network registration
        if self._deregistration_method == "AT_COMMAND":
            self._modem_api.check_rat_with_pref_network(PreferredNetwork.LTE_ONLY, self._registration_timeout)
            # Wait 5 seconds
            time.sleep(5)

        # Registration ON depending on the method (AIRPLANE/AT Command)
        if self._deregistration_method == "AIRPLANE_ON_OFF":
            self._networking_api.set_flight_mode("off")
        else:
            # IMS Config
            if self._ims_configure_modem_procedure == "IMS_ANDROID":
                self._modem_api.turn_ims("ON")
            # AT commands
            else:
                (status, message) = self._execute_at_command("at+xireg=1")
                if status != Global.SUCCESS:
                    message = "%s (%s)." % (
                        "An error occured during IMS re-registration",
                        message)
                    raise AcsToolException(
                        AcsToolException.OPERATION_FAILED,
                        message)
        # Wait 5 seconds
        time.sleep(5)

        # Check the registration status for IMS, should be "IN_SERVICE"
        ims_service_status = ImsRegistrationStatus.in_service()
        self._networking_api.check_ims_registration_before_timeout(
            self._ims_registration_timeout)
        # Log the latest IMS registration status
        registration_status = self._get_registration_status()
        self._logger.info("Registration status: %s (%d)" % (
            str(registration_status),
            registration_status.as_int()))

        if registration_status != ims_service_status:
            verdict = Global.FAILURE
            message = "IMS is not registered after registration ON."

        if verdict == Global.SUCCESS:
            message = "IMS registration successful after registration OFF/ON procedures"

        # Return the verdict
        return (verdict, message)
Ejemplo n.º 10
0
    def _check_call_forwarding(self):  # pylint: disable=too-many-return-statements
        """
        Performs the IMS call forwarding procedure.

        :rtype: int, str
        :return: the verdict and the message
        """

        # Initialize verdict variables
        verdict = Global.SUCCESS
        message = "No error."

        # Check initial call forwarding state
        self._voice_call_api.check_call_forwarding_state(
            LiveLteImsVcSSDual.STATE_DISABLED)

        # Activate call forwarding on main DUT
        self._phone_system_api.wake_screen()
        self._voice_call_api.enable_call_forwarding(self._ims_ss_mode.lower(),
                                                    self._ims_ss_phone_number)
        # Sleep few seconds for activation of Supplementary Service
        self._logger.info("Sleep for %s seconds" % self._wait_ss_response)
        time.sleep(self._wait_ss_response)

        try:
            # Check the call forwarding state
            self._logger.info(
                "Checking Call Fowarding state after activation.")
            self._voice_call_api.check_call_forwarding_state(
                LiveLteImsVcSSDual.STATE_ENABLED)
        except DeviceException as device_ex:
            message = "Exception caught: %s" % (str(device_ex))
            self._logger.error(message)
            verdict = Global.FAILURE
            return (verdict, message)

        # Case for 'NOT_REACHABLE' call forwarding
        if self._ims_ss_mode == "NOT_REACHABLE":
            self._logger.info(
                "For 'NOT_REACHABLE' scenario, the main DUT shall be in out of service"
            )
            # Flight mode ON for main DUT
            self._networking_api.set_flight_mode("on")
            # Sleep 30 seconds
            time.sleep(30)
            # Check that main DUT is not registered
            ims_service_status = ImsRegistrationStatus.out_of_service()
            # Log the latest IMS registration status
            registration_status = self._get_registration_status()
            if registration_status != ims_service_status:
                verdict = Global.FAILURE
                message = "IMS is still registered after airplane mode ON."
                self._logger.error(message)
                return (verdict, message)

        # Dial from the secondary DUT
        self._phone_system_api2.wake_screen()
        self._logger.info("Call initiated from secondary DUT")
        self._voice_call_api2.dial(self._phone_number, check_state=False)

        # Depending on the mode, perform action for main DUT
        # after the call was initiated by the secondary DUT
        (verdict, message) = self._main_dut_action_call_fw()
        if verdict != Global.SUCCESS:
            return (verdict, message)

        try:
            # Wait until the call is established for the secondary DUT with the other party
            self._logger.info(
                "Wait until the call is established for the secondary DUT")
            self._voice_call_api2.wait_for_state(
                self._uecmd_types.VOICE_CALL_STATE.ACTIVE,
                self._call_setup_time)

            if self._ims_ss_mode != "NOT_REACHABLE":
                # Check the call state for main DUT - no active call
                self._voice_call_api.check_state(
                    self._uecmd_types.VOICE_CALL_STATE.NOCALL)

        except DeviceException as device_ex:
            # End the call
            self._voice_call_api2.release()
            # Compute the error message
            message = "Could not establish the voice call from secondary DUT within %d" \
                "exception caught: %s" % (self._call_setup_time, str(device_ex))
            self._logger.error(message)
            verdict = Global.FAILURE
            return (verdict, message)

        # Sleep 30 seconds
        self._logger.info("Wait 30 seconds with call in active state")
        time.sleep(30)

        try:
            if self._ims_ss_mode != "NOT_REACHABLE":
                # Check call state for PHONE1 is still NOCALL
                # Check call state for PHONE2 is still ACTIVE
                self.__check_call_state_both_phones(
                    self._uecmd_types.VOICE_CALL_STATE.NOCALL,
                    self._uecmd_types.VOICE_CALL_STATE.ACTIVE)
            else:
                # For "NOT_REACHABLE" scenario, check the call state only for secondary DUT
                self._voice_call_api.check_state(
                    self._uecmd_types.VOICE_CALL_STATE.ACTIVE)

        except DeviceException as device_ex:
            # Compute the error message
            message = "Problem encountered after the call was established for the secondary DUT" \
                "exception caught: %s" % str(device_ex)
            self._logger.error(message)
            verdict = Global.FAILURE
            return (verdict, message)

        # Release the call for the secondary DUT
        self._voice_call_api2.release()

        if self._ims_ss_mode != "NOT_REACHABLE":
            # Flight mode off for main DUT
            self._networking_api.set_flight_mode("off")
            # Sleep 30 seconds
            time.sleep(30)
            # Check the registration status for IMS, should be "IN_SERVICE"
            ims_service_status = ImsRegistrationStatus.in_service()
            self._networking_api.check_ims_registration_before_timeout(
                self._ims_registration_timeout)
            # Log the latest IMS registration status
            registration_status = self._get_registration_status()
            if registration_status != ims_service_status:
                verdict = Global.FAILURE
                message = "IMS is not registered after registration ON for the main DUT."
                self._logger.error(message)
                return (verdict, message)

        # De-activate the call forwarding feature
        self._logger.info("Call forwarding de-activation")
        self._voice_call_api.disable_call_forwarding(self._ims_ss_mode.lower())

        # Final return
        return (verdict, message)