1
0
mirror of https://github.com/ARM-software/workload-automation.git synced 2025-02-07 05:31:21 +00:00

target/runtime_config: Add support for stay-on

Adds runtime config support for the android setting
``stay_on_while_plugged_in``.
This commit is contained in:
Jonathan Paynter 2020-08-11 12:24:29 +01:00 committed by Marc Bonnici
parent 7bea3a69bb
commit ba5a65aad7
2 changed files with 33 additions and 1 deletions

View File

@ -35,6 +35,9 @@ class LinuxAssistant(object):
def __init__(self, target): def __init__(self, target):
self.target = target self.target = target
def initialize(self):
pass
def start(self): def start(self):
pass pass
@ -44,6 +47,9 @@ class LinuxAssistant(object):
def stop(self): def stop(self):
pass pass
def finalize(self):
pass
class AndroidAssistant(object): class AndroidAssistant(object):
@ -68,12 +74,29 @@ class AndroidAssistant(object):
temporary locaiton on the host. Setting the value of the poll temporary locaiton on the host. Setting the value of the poll
period enables this behavior. period enables this behavior.
"""), """),
Parameter('stay_on_mode', kind=int,
constraint=lambda x: 0 <= x <= 7,
description="""
Specify whether the screen should stay on while the device is
charging:
0: never stay on
1: with AC charger
2: with USB charger
4: with wireless charger
Values can be OR-ed together to produce combinations, for
instance ``7`` will cause the screen to stay on when charging
under any method.
"""),
] ]
def __init__(self, target, logcat_poll_period=None, disable_selinux=True): def __init__(self, target, logcat_poll_period=None, disable_selinux=True, stay_on_mode=None):
self.target = target self.target = target
self.logcat_poll_period = logcat_poll_period self.logcat_poll_period = logcat_poll_period
self.disable_selinux = disable_selinux self.disable_selinux = disable_selinux
self.stay_on_mode = stay_on_mode
self.orig_stay_on_mode = self.target.get_stay_on_mode() if stay_on_mode is not None else None
self.logcat_poller = None self.logcat_poller = None
self.logger = logging.getLogger('logcat') self.logger = logging.getLogger('logcat')
self._logcat_marker_msg = None self._logcat_marker_msg = None
@ -82,8 +105,11 @@ class AndroidAssistant(object):
if self.logcat_poll_period: if self.logcat_poll_period:
signal.connect(self._after_workload, signal.AFTER_WORKLOAD_EXECUTION) signal.connect(self._after_workload, signal.AFTER_WORKLOAD_EXECUTION)
def initialize(self):
if self.target.is_rooted and self.disable_selinux: if self.target.is_rooted and self.disable_selinux:
self.do_disable_selinux() self.do_disable_selinux()
if self.stay_on_mode is not None:
self.target.set_stay_on_mode(self.stay_on_mode)
def start(self): def start(self):
if self.logcat_poll_period: if self.logcat_poll_period:
@ -98,6 +124,10 @@ class AndroidAssistant(object):
if self.logcat_poller: if self.logcat_poller:
self.logcat_poller.stop() self.logcat_poller.stop()
def finalize(self):
if self.stay_on_mode is not None:
self.target.set_stay_on_mode(self.orig_stay_on_mode)
def extract_results(self, context): def extract_results(self, context):
logcat_file = os.path.join(context.output_directory, 'logcat.log') logcat_file = os.path.join(context.output_directory, 'logcat.log')
self.dump_logcat(logcat_file) self.dump_logcat(logcat_file)

View File

@ -57,6 +57,7 @@ class TargetManager(object):
def initialize(self): def initialize(self):
self._init_target() self._init_target()
self.assistant.initialize()
# If target supports hotplugging, online all cpus before perform discovery # If target supports hotplugging, online all cpus before perform discovery
# and restore original configuration after completed. # and restore original configuration after completed.
@ -77,6 +78,7 @@ class TargetManager(object):
def finalize(self): def finalize(self):
if not self.target: if not self.target:
return return
self.assistant.finalize()
if self.disconnect or isinstance(self.target.platform, Gem5SimulationPlatform): if self.disconnect or isinstance(self.target.platform, Gem5SimulationPlatform):
self.logger.info('Disconnecting from the device') self.logger.info('Disconnecting from the device')
with signal.wrap('TARGET_DISCONNECT'): with signal.wrap('TARGET_DISCONNECT'):