Ejemplo n.º 1
0
    def adb_install(self, filename, destination=None):
        """
        Install file on the device
        :type filename: str
        :param filename: The file to install on the device

        :type destination: str
        :param destination: Device destination directory to install the file
        """
        # destination no more used
        status, msg = self._app_api.install_device_app(filename)
        if not global_to_bool(status):
            raise DeviceException(DeviceException.OPERATION_FAILED,
                                  "Failed to install application : '%s'" % msg)
Ejemplo n.º 2
0
    def enable_clota(self):
        """
        Enable Crash Log Over the Air on device

        :rtype: bool, str
        :return: disabling status
        """
        status = False
        if self._disable_clota:
            if self.device.is_available():
                result, message = self.device.run_cmd(
                    "adb shell setprop persist.crashreport.disabled 0", 1)
                status = global_to_bool(result)
            else:
                message = "Enabling CLOTA not possible, no adb connection to the device"
                self.logger.error(message)
        else:
            message = "clota feature disabled by user"
            self.logger.warning(message)
        return status
Ejemplo n.º 3
0
    def enable_clota(self):
        """
        Enable Crash Log Over the Air on device

        :rtype: bool
        :return: disabling status
        """
        status = False
        if self._disable_clota:
            if self.device.is_available():
                result, message = self.device.run_cmd(
                    "adb shell setprop persist.crashreport.disabled 0", 1)
                status = global_to_bool(result)
                if status:
                    self.logger.debug("CLOTA enabled")
                else:
                    self.logger.debug(
                        "CLOTA failed to be enable: {0}".format(message))
            else:
                message = "CLOTA failed to be enable, no adb connection to the device"
                self.logger.debug(message)
        return status
Ejemplo n.º 4
0
    def _list(self):
        """
        List crash events available on device

        :rtype: list
        :return: list of crash events
        """
        message = ""
        events_list = []
        if self.device.is_available():
            json_file = absjoin(self._cache_folder, self.JSON_EVENTS_FILE)
            list_cmd = "{0}{1} {2}".format(self._crashtooluploader_cmd,
                                           self.EVENTS_OPTION, json_file)
            result, output = self._run_crashtooluploader_cmd(list_cmd)
            status = global_to_bool(result)
            if status:
                try:
                    with open(json_file) as data_file:
                        events = json.loads(data_file.read())
                except IOError:
                    message = "Failed to list events: no json data file produced by CrashToolUploader"
                    self.logger.error(message)
                else:
                    for event in events:
                        if self._device_serial_number:
                            event["ssn"] = self._device_serial_number
                        events_list.append(
                            CrashEvent(event.get("eventID", ""),
                                       event.get("eventType", ""),
                                       event.get("date", ""),
                                       event.get("crashdir", ""),
                                       event.get("crashtoolUrl", ""), event))
            else:
                self.logger.error(output)
        else:
            message = "Failed to list events: no adb connection established with the device"
            self.logger.error(message)

        return events_list
Ejemplo n.º 5
0
    def _retrieve_event(self, event_id):
        """
        Retrieve crashes from device to host or server

        :type event_id: str
        :param event_id: identifier of event

        :rtype: bool, str
        :return: fetch status and path to the crash event
        """
        status, message = False, "undefined error"
        cmd = None
        if self.device.is_available():
            if self._server_upload and self._host_fetch:
                # fetch&upload
                cmd = "{0}{1} {2}:{3}{4} \"{5}\"{6} {7}".format(
                    self._crashtooluploader_cmd, self.UPLOAD_OPTION,
                    self._server_address, self._server_port, self.FETCH_OPTION,
                    self._cache_folder, self.UPLOAD_EVENT_OPTION, event_id)
            elif self._server_upload:
                # upload only
                cmd = "{0}{1} {2}:{3} \"{4}\"{5} {6}".format(
                    self._crashtooluploader_cmd, self.UPLOAD_OPTION,
                    self._server_address, self._server_port,
                    self._cache_folder, self.UPLOAD_EVENT_OPTION, event_id)
            elif self._host_fetch:
                # fetch only
                cmd = "{0} {1} \"{2}\"{3} {4}{5}".format(
                    self._crashtooluploader_cmd, self.FETCH_OPTION,
                    self._cache_folder, self.UPLOAD_EVENT_OPTION, event_id,
                    self.FETCH_ONLY_OPTION)
            if cmd:
                result, message = self._run_crashtooluploader_cmd(cmd)
                status = global_to_bool(result)
        else:
            message = "Retreiving crashes not possible, no adb connection to the device"

        return status, message