def run(self, out_dir, duration_s, collect=''):
        """
        Run single idle/suspend workload.

        :param out_dir: Path to experiment directory where to store results.
        :type out_dir: str

        :param duration_s: Duration of test
        :type duration_s: int

        :type force: str

        :param collect: Specifies what to collect. Possible values:
            - 'energy'
            - 'systrace'
            - 'ftrace'
            - any combination of the above
        :type collect: list(str)
        """

        # Idle/resume should always disconnect USB so rely on
        # the Energy meter to disconnect USB (We only support USB disconnect
        # mode for energy measurement, like with Monsoon
        if 'energy' not in collect:
            collect = collect + ' energy'

        # Keep track of mandatory parameters
        self.out_dir = out_dir
        self.collect = collect

        # Set min brightness
        Screen.set_brightness(self._target, auto=False, percent=0)

        # Set timeout to min value
        Screen.set_timeout(self._target, seconds=0)

        # Prevent screen from dozing
        Screen.set_doze_always_on(self._target, on=False)

        # Turn on airplane mode
        System.set_airplane_mode(self._target, on=True)

        # Unlock device screen (assume no password required)
        Screen.unlock(self._target)

        # Force the device to suspend
        System.force_suspend_start(self._target)

        # Prevent the device from fully suspending by holding a partial wakelock
        System.wakelock(self._target, take=True)

        sleep(1)
        Screen.set_screen(self._target, on=False)
        sleep(1)
        self.tracingStart(screen_always_on=False)

        self._log.info('Waiting for duration {}'.format(duration_s))
        sleep(duration_s)

        self.tracingStop(screen_always_on=False)

        # Resume normal function
        System.force_suspend_stop(self._target)

        # Release wakelock
        System.wakelock(self._target, take=False)

        Screen.set_defaults(self._target)
        System.set_airplane_mode(self._target, on=False)
    def run(self, out_dir, duration_s, brightness, filepath, collect=''):
        """
        Run single display image workload.

        :param out_dir: Path to experiment directory where to store results.
        :type out_dir: str

        :param duration_s: Duration of test
        :type duration_s: int

        :param brightness: Brightness of the screen 0-100
        :type brightness: int

        :param out_dir: Path to the image to display
        :type out_dir: str

        :param collect: Specifies what to collect. Possible values:
            - 'energy'
            - 'time_in_state'
            - 'systrace'
            - 'ftrace'
            - any combination of the above, except energy and display-energy
              cannot be collected simultaneously.
        :type collect: list(str)
        """

        # Keep track of mandatory parameters
        self.out_dir = out_dir
        self.collect = collect

        # Set brightness
        Screen.set_brightness(self._target, auto=False, percent=brightness)

        # Set timeout to be sufficiently longer than the duration of the test
        Screen.set_timeout(self._target, seconds=(duration_s+60))

        # Turn on airplane mode
        System.set_airplane_mode(self._target, on=True)

        # Unlock device screen (assume no password required)
        Screen.unlock(self._target)

        # Push the image to the device
        device_filepath = '/data/local/tmp/image'
        self._target.push(filepath, device_filepath)
        sleep(1)

        # Put image on the screen
        System.start_action(self._target, self.action,
                '-t image/* -d file://{}'.format(device_filepath))
        sleep(1)

        # Dimiss the navigation bar by tapping the center of the screen
        System.tap(self._target, 50, 50)

        self.tracingStart(screen_always_on=False)

        self._log.info('Waiting for duration {}'.format(duration_s))
        sleep(duration_s)

        self.tracingStop(screen_always_on=False)

        # Close app and dismiss image
        System.force_stop(self._target, self.package, clear=True)

        # Remove image
        self._target.execute('rm /data/local/tmp/image')

        Screen.set_defaults(self._target)
        System.set_airplane_mode(self._target, on=False)

        Screen.set_screen(self._target, on=False)
Ejemplo n.º 3
0
    def run(self, out_dir, package, permissions, duration_s, collect=''):
        """
        Run single AppStartup workload.

        :param out_dir: Path to experiment directory where to store results.
        :type out_dir: str

        :param package: Name of the apk package
        :type package: str

        :param permissions: List of permissions the app requires
        :type permissions: list of str

        :param duration_s: Run benchmak for this required number of seconds
        :type duration_s: int

        :param collect: Specifies what to collect. Possible values:
            - 'energy'
            - 'time_in_state'
            - 'systrace'
            - 'ftrace'
            - any combination of the above
        :type collect: list(str)
        """

        # Keep track of mandatory parameters
        self.out_dir = out_dir
        self.collect = collect

        # Check if the package exists on the device
        if not System.contains_package(self._target, package):
            raise RuntimeError('System does not contain the requried package')

        # Unlock device screen (assume no password required)
        Screen.unlock(self._target)

        # Close and clear application
        System.force_stop(self._target, package, clear=True)
        sleep(3)

        # Grant permissions
        for permission in permissions:
            System.grant_permission(self._target, package, permission)
        sleep(3)

        # Set min brightness
        Screen.set_brightness(self._target, auto=False, percent=100)

        # Set screen timeout
        Screen.set_timeout(self._target, seconds=duration_s + 60)

        # Force screen in PORTRAIT mode
        Screen.set_orientation(self._target, portrait=True)

        # Start the main view of the app
        System.monkey(self._target, package)

        # Start tracing
        self.tracingStart()

        # Sleep for duration
        sleep(duration_s)

        # Stop tracing
        self.tracingStop()

        # Reset permissions
        System.reset_permissions(self._target, package)

        # Close and clear application
        System.force_stop(self._target, package, clear=True)

        # Go back to home screen
        System.home(self._target)

        # Switch back to original settings
        Screen.set_defaults(self._target)