Example #1
0
    def _get_device_boot_mode(self):
        """
            get the boot mode from adb

            :rtype: str
            :return: device state : MOS, ROS, COS or UNKNOWN
        """

        # checkDeviceBootMode is useful when device does not support ro.bootmode property
        if not self._check_device_boot_mode:
            current_state = AndroidDeviceBase._get_device_boot_mode(self)

        else:
            current_state = "UNKNOWN"
            output = self.run_cmd("adb shell getprop ro.bootmode", 10, True)

            if output[0] != Global.FAILURE:
                mode = (output[1].strip()).lower()
                for key in self.BOOT_STATES:
                    if mode in self.BOOT_STATES[key]:
                        current_state = key
                        break
            if current_state == "MOS":
                # In case of MOS we also check sys.boot_completed value to be sure that the device is fully booted
                current_state = AndroidDeviceBase._get_device_boot_mode(self)
        return current_state
Example #2
0
    def _stop_extra_threads(self):
        """
        Stops extra threads required by ACS
        like logger & watchdog and embedded logs
        :return: None
        """
        AndroidDeviceBase._stop_extra_threads(self)

        # Stop embedded log thread
        if self._embedded_log:
            self._embedded_log.stop("APPLICATION")
        self.stop_device_log()
Example #3
0
    def _start_extra_threads(self):
        """
        Starts extra threads required by ACS
        like logger & watchdog and embedded logs
        :return: None
        """
        AndroidDeviceBase._start_extra_threads(self)

        # Start embedded log thread
        if self._embedded_log:
            self._embedded_log.start("APPLICATION")
        if self._device_log_file is not None:
            self._device_log_file.start()
    def __init__(self, config, logger):
        """
        Constructor

        :type  phone_name: string
        :param phone_name: Name of the current phone(e.g. PHONE1)
        """

        AndroidDeviceBase.__init__(self, config, logger)
        self._logger.info("Reference device initialized")
        if self._enableIntelImage:
            self._logger.info("Intel image forced")
        if self._enableAdbRoot:
            self._logger.info("Adb root enabled")
Example #5
0
    def __init__(self, phone_name, device_config):
        """
        Constructor

        :type  phone_name: str
        :param phone_name: Name of the current phone(e.g. PHONE1)
        """
        AndroidDeviceBase.__init__(self, phone_name, device_config)

        self._multiple_devices = self.config.get_value("multipleDevices", "False", "str_to_bool")
        #The process id. If none is provided have a negative value so we don't kill a real process
        self.pid = -1
        self.timeout = self.config.get_value("flashTimeout", 120 ,int)

        flash_file = self._acs_flash_file_path
Example #6
0
    def cleanup_final_state(self, final_dut_state, campaign_error):
        """
        Set final state of the device
        :param campaign_error:
        :param final_dut_state:
        :return: dut state
        """

        if final_dut_state == Util.DeviceState.COS:
            # Specific actions for Intel device
            self.cleanup_logs(campaign_error)
            if self.get_boot_mode() != "COS":
                # Leave the DUT in charging mode
                if not self.reboot("COS", wait_for_transition=True, skip_failure=True):
                    # Trying to power off the DUT if COS fails
                    self.get_logger().warning("Unable to configure the device in charging mode ! "
                                              "Trying to switch off the device.")
                    if self.switch_off()[0] != Global.SUCCESS:
                        final_dut_state = Util.DeviceState.UNKNOWN
                    else:
                        final_dut_state = Util.DeviceState.OFF
            else:
                self.get_logger().info("Board already in charging mode.")

        else:
            final_dut_state = AndroidDeviceBase.cleanup_final_state(self, final_dut_state, campaign_error)

        return final_dut_state
Example #7
0
    def _get_device_boot_mode(self):
        """
        get the boot mode from adb

        :rtype: str
        :return: device state : MOS or UNKNOWN
        """
        return AndroidDeviceBase._get_device_boot_mode(self)
Example #8
0
    def connect_board(self):
        """
        Connect to the device
        """
        connected = AndroidDeviceBase.connect_board(self)

        if self._embedded_log:
            # Route logcat to PTI if required
            self._embedded_log.enable_log_on_pti()
        return connected
Example #9
0
    def __init__(self, config, logger):
        """
        Constructor

        :type  phone_name: string
        :param phone_name: Name of the current phone(e.g. PHONE1)
        """
        self._provisioning_mode_set = False

        AndroidDeviceBase.__init__(self, config, logger)
        self._enableAdbRoot = self.get_config("enableAdbRoot", "True", "str_to_bool")
        self._enableIntelImage = self.get_config("enableIntelImage", "True", "str_to_bool")
        self._check_device_boot_mode = self.get_config("checkDeviceBootMode", "True", "str_to_bool")

        self._logger.info("Intel device initialized")

        if not self._enableIntelImage:
            self._logger.info("Reference image forced")
        if not self._enableAdbRoot:
            self._logger.info("Adb root disabled")

        # Embedded log feature
        self._embedded_log = EmbeddedLog.EmbeddedLog(self)

        # Start PTI and/or serial logs if required
        # Before establishing first connection to the device, enable PTI and/or Serial logging
        # to capture a maximum of traces. AP and BP logs will be handled further down the line
        if self._embedded_log:
            self._embedded_log.stop("PTI")
            self._embedded_log.stop("SERIAL")
            time.sleep(1)
            self._embedded_log.start("PTI")
            self._embedded_log.start("SERIAL")

        # Flashing configuration elements (This device class only support OS flashing procedure)
        self._soc_serial_number = self.get_config("socSerialNumber")

        # Flag indicating CrashModule has been successfully initialized
        # Will be used, to reinitialize Crash Modules if necessary
        self._init_crash_modules = False
Example #10
0
    def get_boot_mode(self):
        """
        get the boot mode from adb

        :rtype: string
        :return: device state
        """
        if self._android_codeline == "AIA":
            mode = AndroidDeviceBase.get_boot_mode(self)
        else:
            mode = IntelDeviceBase.get_boot_mode(self)

        return mode
Example #11
0
    def cleanup(self, campaign_error):
        """
        Clean up the environment of the target.

        :type campaign_error: boolean
        :param campaign_error: Notify if errors occured

        :rtype: tuple of int and str
        :return: verdict and final dut state
        """
        for crash_module in self.device_modules.get('CrashModule', []):
            crash_module.enable_clota()
        status, dut_state = AndroidDeviceBase.cleanup(self, campaign_error)

        return status, dut_state
Example #12
0
    def setup(self):
        """
        Set up the environment of the target after connecting to it

        :rtype: (bool, str)
        :return: status and message
        """

        status, message = AndroidDeviceBase.setup(self)

        # Debug logging module initialization
        self._init_debug()
        # Crash and device info logging initialization
        status = self._init_crash()

        return status, message
Example #13
0
    def init_device_connection(self, skip_boot_required, first_power_cycle, power_cycle_retry_number):
        """
        Init the device connection.
        Call for first device connection attempt or to restart device before test case execution
        :param skip_boot_required:
        :param first_power_cycle:
        :param power_cycle_retry_number:
            """
        (connection_status,
         error_msg,
         power_cycle_total_count,
         boot_failure_count,
         connection_failure_count) = AndroidDeviceBase.init_device_connection(self,
                                                                              skip_boot_required,
                                                                              first_power_cycle,
                                                                              power_cycle_retry_number)

        return connection_status, error_msg, power_cycle_total_count, boot_failure_count, connection_failure_count
Example #14
0
    def get_reporting_device_info(self):
        """
        Collect all device build info on the device for reporting

        :return: device and build infos
        :rtype: dict
        """

        # Add device / build information for ACS Live Reporting tool
        # No need to test status for AndroidDeviceBase.get_reporting_device_info(self) as always PASS
        _, report_device_info = AndroidDeviceBase.get_reporting_device_info(self)

        # For intel devices CrashToolUploaderModule is installed and retrieve device and build infos
        # These information are analysed and displayed by TCR reporting tool
        status_crashtool_device_info, crash_device_info = self._get_crash_device_info()
        if status_crashtool_device_info != Verdict.FAIL:
            report_device_info.update({"TCR": crash_device_info})

        # Return the status from crash device info as it is the device info reference for Intel Devices
        # and status for android device info is always PASS
        return status_crashtool_device_info, report_device_info
Example #15
0
 def _finalize_os_boot(self, timer, boot_timeout, settledown_duration):
     return AndroidDeviceBase._finalize_os_boot(self,
                                                timer=timer,
                                                boot_timeout=boot_timeout,
                                                settledown_duration=0)
Example #16
0
 def _get_device(self, config=None):
     device_config = self._device_helpers.get_device_config(config)
     device = AndroidDeviceBase(device_config, MagicMock())
     return device