<s> import os <EOL> from time import sleep <EOL> from wlauto import Workload , Parameter <EOL> from wlauto import File <EOL> from wlauto . exceptions import ConfigError <EOL> from wlauto . utils . android import ApkInfo <EOL> class ApkLaunchWorkload ( Workload ) : <EOL> name = '<STR_LIT>' <EOL> description = '''<STR_LIT>''' <EOL> supported_platforms = [ '<STR_LIT>' ] <EOL> parameters = [ <EOL> Parameter ( '<STR_LIT>' , description = '<STR_LIT>' , mandatory = True ) , <EOL> Parameter ( '<STR_LIT>' , kind = bool , default = False , <EOL> description = '<STR_LIT>' ) , <EOL> Parameter ( '<STR_LIT>' , kind = int , default = <NUM_LIT:0> , <EOL> description = '<STR_LIT>' ) <EOL> ] <EOL> def setup ( self , context ) : <EOL> apk_file = context . resolver . get ( File ( self , self . apk_file ) ) <EOL> self . package = ApkInfo ( apk_file ) . package <EOL> self . logger . info ( '<STR_LIT>' . format ( apk_file ) ) <EOL> return self . device . install ( apk_file ) <EOL> def run ( self , context ) : <EOL> self . logger . info ( '<STR_LIT>' . format ( self . package ) ) <EOL> self . device . execute ( '<STR_LIT>' . format ( self . package ) ) <EOL> self . logger . info ( '<STR_LIT>' . format ( self . wait_time_seconds ) ) <EOL> sleep ( self . wait_time_seconds ) <EOL> def update_result ( self , context ) : <EOL> app_is_running = bool ( [ p for p in self . device . ps ( ) if p . name == self . package ] ) <EOL> context . result . add_metric ( '<STR_LIT>' , app_is_running ) <EOL> def teardown ( self , context ) : <EOL> if self . uninstall_required : <EOL> self . logger . info ( '<STR_LIT>' . format ( self . package ) ) <EOL> self . device . execute ( '<STR_LIT>' . format ( self . package ) ) </s>
