1
0
mirror of https://github.com/ARM-software/workload-automation.git synced 2024-10-05 18:31:12 +01:00

fw/rt_config: Add unlock_screen config option in runtime_parameters

Introduce 'unlock_screen' option in order to help in automating Android
tests by unlocking device screen automatically. Surely this works only
if no passcode is set.

'unlock_screen' option implicitly requires turning on the screen. IOW,
it will override value of 'screen_on' option.

'diagonal', 'vertical' and 'horizontal' are valid values for
'unlock_screen' option as of now.

Note that this patch depends on
https://github.com/ARM-software/devlib/pull/659 in devlib repo.

Signed-off-by: Metin Kaya <metin.kaya@arm.com>
This commit is contained in:
Metin Kaya 2024-01-05 14:48:49 +00:00 committed by Marc Bonnici
parent 23fcb2c120
commit 41f7984243
2 changed files with 31 additions and 0 deletions

View File

@ -33,6 +33,7 @@ states.
iterations: 1
runtime_parameters:
screen_on: false
unlock_screen: 'vertical'
- name: benchmarkpi
iterations: 1
sections:
@ -208,6 +209,13 @@ Android Specific Runtime Parameters
:screen_on: A ``boolean`` to specify whether the devices screen should be
turned on. Defaults to ``True``.
:unlock_screen: A ``String`` to specify how the devices screen should be
unlocked. Unlocking screen is disabled by default. ``vertical``, ``diagonal``
and ``horizontal`` are the supported values (see :meth:`devlib.AndroidTarget.swipe_to_unlock`).
Note that unlocking succeeds when no passcode is set. Since unlocking screen
requires turning on the screen, this option overrides value of ``screen_on``
option.
.. _setting-sysfiles:
Setting Sysfiles

View File

@ -878,6 +878,11 @@ class AndroidRuntimeConfig(RuntimeConfig):
if value is not None:
obj.config['screen_on'] = value
@staticmethod
def set_unlock_screen(obj, value):
if value is not None:
obj.config['unlock_screen'] = value
def __init__(self, target):
self.config = defaultdict(dict)
super(AndroidRuntimeConfig, self).__init__(target)
@ -930,6 +935,16 @@ class AndroidRuntimeConfig(RuntimeConfig):
Specify whether the device screen should be on
""")
param_name = 'unlock_screen'
self._runtime_params[param_name] = \
RuntimeParameter(
param_name, kind=str,
default=None,
setter=self.set_unlock_screen,
description="""
Specify how the device screen should be unlocked (e.g., vertical)
""")
def check_target(self):
if self.target.os != 'android' and self.target.os != 'chromeos':
raise ConfigError('Target does not appear to be running Android')
@ -940,6 +955,7 @@ class AndroidRuntimeConfig(RuntimeConfig):
pass
def commit(self):
# pylint: disable=too-many-branches
if 'airplane_mode' in self.config:
new_airplane_mode = self.config['airplane_mode']
old_airplane_mode = self.target.get_airplane_mode()
@ -964,13 +980,20 @@ class AndroidRuntimeConfig(RuntimeConfig):
if 'brightness' in self.config:
self.target.set_brightness(self.config['brightness'])
if 'rotation' in self.config:
self.target.set_rotation(self.config['rotation'])
if 'screen_on' in self.config:
if self.config['screen_on']:
self.target.ensure_screen_is_on()
else:
self.target.ensure_screen_is_off()
if self.config.get('unlock_screen'):
self.target.ensure_screen_is_on()
if self.target.is_screen_locked():
self.target.swipe_to_unlock(self.config['unlock_screen'])
def clear(self):
self.config = {}