1
0
mirror of https://github.com/ARM-software/devlib.git synced 2024-10-06 10:50:51 +01:00

target: add new methods

Added the following method to targets:

- sleep: sleep on target for the specified duration. In some situations,
         e.g. on simulation platforms, it is important that sleep
	 happens on the target rather than the host.

Added the following methods to Android targets:

- ensure_screen_is_off: complements the existing ensure_screen_is_on.
- homescreen: navigate to home screen.
This commit is contained in:
Sergei Trofimov 2017-05-12 11:54:31 +01:00
parent 8b2ac8d29d
commit 69a83d4128

View File

@ -552,6 +552,10 @@ class Target(object):
else: else:
raise ValueError('Unknown compression format: {}'.format(ext)) raise ValueError('Unknown compression format: {}'.format(ext))
def sleep(self, duration):
timeout = duration + 10
self.execute('sleep {}'.format(duration), timeout=timeout)
# internal methods # internal methods
def _execute_util(self, command, timeout=None, check_exit_code=True, as_root=False): def _execute_util(self, command, timeout=None, check_exit_code=True, as_root=False):
@ -1067,6 +1071,13 @@ class AndroidTarget(Target):
if not self.is_screen_on(): if not self.is_screen_on():
self.execute('input keyevent 26') self.execute('input keyevent 26')
def ensure_screen_is_off(self):
if self.is_screen_on():
self.execute('input keyevent 26')
def homescreen(self):
self.execute('am start -a android.intent.action.MAIN -c android.intent.category.HOME')
def _resolve_paths(self): def _resolve_paths(self):
if self.working_directory is None: if self.working_directory is None:
self.working_directory = '/data/local/tmp/devlib-target' self.working_directory = '/data/local/tmp/devlib-target'