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

WA Revent: Updated to support vsync version of revent

WA has been updated to automatically install and run vsync service apk and use the vsync version of revent for recording and playback on android platforms.
This commit is contained in:
Marc Bonnici 2017-01-31 17:33:10 +00:00
parent a81fe5555a
commit 601202c2ec
2 changed files with 37 additions and 5 deletions

View File

@ -60,6 +60,16 @@ class ReventCommand(Command):
self.device.connect()
self.device.initialize(context)
# Only install vsync service on android
if self.device.platform is 'android':
self.logger.debug("Installing HelloJni for vsync service")
host_HelloJni_apk = context.resolver.get(Executable(NO_ONE, self.device.abi, 'HelloJni.apk'))
self.target_HelloJni = self.device.install_if_needed(host_HelloJni_apk)
result = self.device.execute('dumpsys activity services | grep "ChoreoService"', check_exit_code=False)
if not result or 'com.example.hellojni/.ChoreoService' not in result:
self.device.execute('am startservice com.example.hellojni/.ChoreoService')
# Install revent
host_binary = context.resolver.get(Executable(NO_ONE, self.device.abi, 'revent'))
self.target_binary = self.device.install_executable(host_binary)
@ -149,7 +159,8 @@ class RecordCommand(ReventCommand):
self.logger.info("Press Enter when you are ready to record...")
raw_input("")
gamepad_flag = '-g ' if args.gamepad else ''
command = "{} record {}-s {}".format(self.target_binary, gamepad_flag, revent_file)
vsync_flag = '-V ' if self.device.platform is 'android' else ''
command = "{} record {}{}-s {}".format(self.target_binary, gamepad_flag, vsync_flag, revent_file)
self.device.kick_off(command)
self.logger.info("Press Enter when you have finished recording...")
@ -195,7 +206,8 @@ class ReplayCommand(ReventCommand):
self.device.execute('monkey -p {} -c android.intent.category.LAUNCHER 1'.format(args.package))
self.logger.info("Replaying recording")
command = "{} replay {}".format(self.target_binary, revent_file)
vsync_flag = '-V ' if self.device.platform is 'android' else ''
command = "{} replay {}{}".format(self.target_binary, vsync_flag, revent_file)
recording = ReventRecording(args.revent)
timeout = ceil(recording.duration) + 30
recording.close()

View File

@ -482,6 +482,7 @@ class ReventWorkload(Workload):
Workload.__init__(self, device, **kwargs)
devpath = self.device.path
self.on_device_revent_binary = devpath.join(self.device.binaries_directory, 'revent')
self.on_device_HelloJni_apk = devpath.join(self.device.binaries_directory, 'HelloJni.apk')
self.setup_timeout = kwargs.get('setup_timeout', None)
self.run_timeout = kwargs.get('run_timeout', None)
self.revent_setup_file = None
@ -494,6 +495,7 @@ class ReventWorkload(Workload):
state_detector.check_match_state_dependencies()
def setup(self, context):
self.device.killall('revent', signal='SIGKILL')
self.revent_setup_file = context.resolver.get(ReventFile(self, 'setup'))
self.revent_run_file = context.resolver.get(ReventFile(self, 'run'))
devpath = self.device.path
@ -508,13 +510,24 @@ class ReventWorkload(Workload):
self.run_timeout = self.run_timeout or default_run_timeout
Workload.setup(self, context)
self.device.killall('revent')
command = '{} replay {}'.format(self.on_device_revent_binary, self.on_device_setup_revent)
if self.device.platform is 'android':
result = self.device.execute('dumpsys activity services | grep "ChoreoService"',
check_exit_code=False)
if not result or 'com.example.hellojni/.ChoreoService' not in result:
self.logger.debug('Starting VSync Service')
self.device.execute('am startservice com.example.hellojni/.ChoreoService')
time.sleep(5) # Allow time for service to start
vsync_flag = '-V ' if self.device.platform is 'android' else ''
command = '{} replay {}{}'.format(self.on_device_revent_binary, vsync_flag, self.on_device_setup_revent)
self.device.execute(command, timeout=self.setup_timeout)
def run(self, context):
command = '{} replay {}'.format(self.on_device_revent_binary, self.on_device_run_revent)
if self.device.platform is 'android':
self.device.execute('am startservice com.example.hellojni/.ChoreoService')
time.sleep(5) # Allow time for service to start
self.logger.debug('Replaying {}'.format(os.path.basename(self.on_device_run_revent)))
vsync_flag = '-V ' if self.device.platform is 'android' else ''
command = '{} replay {}{}'.format(self.on_device_revent_binary, vsync_flag, self.on_device_run_revent)
self.device.execute(command, timeout=self.run_timeout)
self.logger.debug('Replay completed.')
@ -523,6 +536,7 @@ class ReventWorkload(Workload):
def teardown(self, context):
self.device.killall('revent')
self.device.killall("com.example.hellojni")
self.device.delete_file(self.on_device_setup_revent)
self.device.delete_file(self.on_device_run_revent)
@ -533,6 +547,10 @@ class ReventWorkload(Workload):
message = '{} does not exist. '.format(revent_binary)
message += 'Please build revent for your system and place it in that location'
raise WorkloadError(message)
if self.device.platform is 'android':
HelloJni_APK = context.resolver.get(Executable(NO_ONE, self.device.abi, 'HelloJni.apk'))
if not os.path.isfile(HelloJni_APK):
message = '{} does not exist. '.format(HelloJni_APK)
if not self.revent_setup_file:
# pylint: disable=too-few-format-args
message = '{0}.setup.revent file does not exist, Please provide one for your device, {0}'.format(self.device.name)
@ -543,6 +561,8 @@ class ReventWorkload(Workload):
raise WorkloadError(message)
self.on_device_revent_binary = self.device.install_executable(revent_binary)
if self.device.platform is 'android':
self.on_device_HelloJni_apk = self.device.install_if_needed(HelloJni_APK)
self.device.push_file(self.revent_run_file, self.on_device_run_revent)
self.device.push_file(self.revent_setup_file, self.on_device_setup_revent)