def __init__(self, device, platform, version=None, **kwargs): self.relay = Relayed_device(kb_relay_port=device['kb']['relay_tty'], kb_port=device['kb']['kb_tty']) self.kb_device_port = device['kb']['port'] self.platform = platform self.version = version base_step.__init__(self, **kwargs)
class perform_startup_wizard(base_step): def __init__(self, device, platform, version=None, **kwargs): self.relay = Relayed_device(kb_relay_port=device['kb']['relay_tty'], kb_port=device['kb']['kb_tty']) self.kb_device_port = device['kb']['port'] self.platform = platform self.version = version base_step.__init__(self, **kwargs) def do(self): print "Trying to activate kb, platform - ", str(self.platform) time.sleep(10) self.relay.try_activate_kb(self.kb_device_port) time.sleep(5) print "Should be activated" # welcome screen if self.platform == "ECS28A": keys = ['<enter>', '<tab>', '<enter>'] else: keys = ['<enter>', '<tab>', '<enter>'] # wifi keys += ['<tab>', '<tab>', '<enter>', '<tab>', '<enter>'] # date&time keys += ['<tab>', '<tab>', '<enter>'] # name keys += ['<tab>', '<tab>', '<tab>', '<tab>', '<enter>'] # protect your phone keys += [ '<tab>', '<tab>', '<tab>', '<tab>', '<enter>', '<tab>', '<enter>' ] # google services if self.platform == "ECS28A": keys += [ '<tab>', '<tab>', '<tab>', '<tab>', '<tab>', '<enter>', '<tab>', '<tab>', '<enter>' ] else: keys += [ '<tab>', '<tab>', '<tab>', '<tab>', '<tab>', '<tab>', '<enter>', '<tab>', '<tab>', '<enter>' ] # allow keys += ['<tab>', '<enter>'] for key in keys: print key self.relay.send_to_kb(key) time.sleep(2) time.sleep(2) # got it self.relay.send_to_kb('<enter>') self.relay.try_deactivate_kb() self.relay.close() def check_condition(self): return True
def prepare_for_next_run(suite): devices = [device for device in all_devices] print "Start preparing for the next {0} run".format(suite.upper()) if len(devices) > 0: for device in devices: serial = device["serial"] print "Prepare device {0} for next build.".format(device) print "Will try to use adb connection to shutdown/put the device into sleep mode" if local_utils.has_adb_serial(serial = serial): if shutdown_to_charge: print "[ {0} ]: Shutdown device to charge".format(serial) local_steps.command(command = "adb -s {0} shell reboot -p".format(serial))() time.sleep(5) print "[ {0} ]: Shutdown - Done!".format(serial) else: print "[ {0} ]: Put device into sleep mode".format(serial) adb_steps.put_device_into_sleep_mode(serial = serial)() print "[ {0} ]: Sleep - Done!".format(serial) else: print "[ {0} ]: does not have adb connection!!!".format(serial) print "[ {0} ]: Try to use relay to shutdown the devices".format(serial) try: my_relay = Relayed_device(relay_port = device["relay"]["tty"], power_port = device["relay"]["power_port"], v_up_port = device["relay"]["v_up_port"], v_down_port = device["relay"]["v_down_port"]) my_relay.power_on() my_relay.power_off() my_relay.close() except Exception, e: print "{0} devivice has no relay - {1}!!!".format(serial, e.message)
def __init__(self, device, platform="ECS27B", **kwargs): self.relay = Relayed_device(kb_relay_port=device['kb']['relay_tty'], kb_port=device['kb']['kb_tty']) self.touch_relay = Relayed_device( relay_port=device["relay"]["tty"], power_port=device["relay"]["power_port"], v_up_port=device["relay"]["v_up_port"], v_down_port=device["relay"]["v_down_port"], always_allow_port=device["relay"]["always_allow_port"], allow_ok_port=device["relay"]["allow_ok_port"], ) self.kb_device_port = device['kb']['port'] self.device = device self.allowed = False self.platform = platform base_step.__init__(self, **kwargs)
def do(self): screen_log = local_steps.create_screen(screen_name=self.screen_name, with_log=True)() grep_for = [ "Phone Flash Tool exited with code ", "Platform Flash Tool exited with code " ] pft_screen_command(serial=self.serial, device=self.device, screen_name=self.screen_name, screen_log=screen_log, flash_xml_path=self.flash_xml_path, user_build=self.user_build, user_signed=self.user_signed, timeout=self.timeout, grep_for=grep_for, update=self.update)() if self.usb_debugging: iterations = 2 for i in range(iterations): try: local_steps.wait_for_adb(serial=self.serial, timeout=300)() break except Exception, e: print "{0}/{1} interation({2}): adb is not enabled on "\ "{3} after 300 seconds.".format(i + 1, iterations, e.message, self.serial) try: my_relay = Relayed_device( relay_port=self.device["relay"]["tty"], power_port=self.device["relay"]["power_port"], v_up_port=self.device["relay"]["v_up_port"], v_down_port=self.device["relay"]["v_down_port"]) my_relay.relay_reboot() except Exception, e: print "Serial {0} has no relay connection: {1}".format( self.serial, e.message) raise e
def __init__(self, **kwargs): base_step.__init__(self, **kwargs) self.relay = Relayed_device( # "RLY08B" or "URMC32" relay_type=kwargs["relay_type"], # COM port used for communication. Ex: "/dev/ttyACM0" relay_port=kwargs["relay_port"] if "relay_port" in kwargs else None, # number of the relay connected to POWER button power_port=kwargs["power_port"] if "power_port" in kwargs else None, # number of the relay connected to VOL UP button v_up_port=kwargs["v_up_port"] if "v_up_port" in kwargs else None, # number of the relay connected to VOL DOWN button v_down_port=kwargs["v_down_port"] if "v_down_port" in kwargs else None, # number of the relay used to cut VC+ of the USB cable connected to the device USB_VC_cut_port=kwargs["USB_VC_cut_port"] if "USB_VC_cut_port" in kwargs else None)
class first_boot_no_wizard(base_step): def __init__(self, device, **kwargs): self.relay = Relayed_device(kb_relay_port=device['kb']['relay_tty'], kb_port=device['kb']['kb_tty']) self.kb_device_port = device['kb']['port'] base_step.__init__(self, **kwargs) def do(self): self.relay.try_activate_kb(self.kb_device_port) # allow keys += ['<tab>', '<enter>'] # got it keys += ['<enter>', '<enter>'] for key in keys: self.relay.send_to_kb(key) time.sleep(0.5) self.relay.try_deactivate_kb() self.relay.close() def check_condition(self): return True
s = d["serial"] print "Prepare device " + str(s) + " for next build." print "Will try to use adb connection to shutdown/put to sleep the device" if local_utils.has_adb_serial(serial=s): adb_steps.enable_uiautomator_service(serial=s, timeout=120)() if shutdown_to_charge: print str(s) + ": Shutdown device to charge" local_steps.command(command="adb -s " + str(s) + " shell reboot -p")() time.sleep(5) print str(s) + ": Shutdown - Done!" else: print str(s) + ": Put device to sleep" adb_steps.put_device_into_sleep_mode(serial=s)() print str(s) + ": Sleep - Done!" else: print str(s) + ": does not have adb connection!!!" print str(s) + ": Try to use relay to shutdown the devices" try: my_relay = Relayed_device(relay_port=d["relay"]["tty"], power_port=d["relay"]["power_port"], v_up_port=d["relay"]["v_up_port"], v_down_port=d["relay"]["v_down_port"]) my_relay.power_on() my_relay.power_off() my_relay.close() except Exception, e: print "NO relay!!!" print e.message ########################################################################
def __init__(self, device, **kwargs): self.relay = Relayed_device(kb_relay_port=device['kb']['relay_tty'], kb_port=device['kb']['kb_tty']) self.kb_device_port = device['kb']['port'] base_step.__init__(self, **kwargs)
class enable_usb_debugging(base_step): def __init__(self, device, platform="ECS27B", **kwargs): self.relay = Relayed_device(kb_relay_port=device['kb']['relay_tty'], kb_port=device['kb']['kb_tty']) self.touch_relay = Relayed_device( relay_port=device["relay"]["tty"], power_port=device["relay"]["power_port"], v_up_port=device["relay"]["v_up_port"], v_down_port=device["relay"]["v_down_port"], always_allow_port=device["relay"]["always_allow_port"], allow_ok_port=device["relay"]["allow_ok_port"], ) self.kb_device_port = device['kb']['port'] self.device = device self.allowed = False self.platform = platform base_step.__init__(self, **kwargs) def do(self): print self.platform time.sleep(5) self.relay.try_activate_kb(self.kb_device_port) time.sleep(5) if self.platform == "ECS28A": # about app button keys = [ '<tab>', '<tab>', '<tab>', '<tab>', '<tab>', '<tab>', '<tab>', '<tab>', '<enter>' ] # setting keys += [ '<downarrow>', '<downarrow>', '<downarrow>', '<downarrow>', '<rarrow>', '<rarrow>' ] keys += [ '<rarrow>', '<rarrow>', '<rarrow>', '<rarrow>', '<rarrow>', '<enter>' ] # about phone keys += [ '<downarrow>', '<downarrow>', '<downarrow>', '<downarrow>', '<downarrow>' ] keys += [ '<downarrow>', '<downarrow>', '<downarrow>', '<downarrow>', '<downarrow>', '<enter>' ] # enable dev_options keys += [ '<downarrow>', '<downarrow>', '<downarrow>', '<downarrow>', '<downarrow>', '<downarrow>' ] keys += [ '<enter>', '<enter>', '<enter>', '<enter>', '<enter>', '<enter>', '<enter>', '<esc>' ] # dev options keys += ['<uparrow>', '<larrow>', '<enter>'] # enable_usb_debugging keys += [ '<downarrow>', '<downarrow>', '<downarrow>', '<downarrow>', '<downarrow>' ] keys += ['<downarrow>', '<downarrow>', 'downarrow'] keys += ['<enter>', '<tab>', '<enter>'] # home keys += ['<esc>', '<esc>', '<esc>'] else: # all app button keys = [ '<uparrow>', '<uparrow>', '<downarrow>', '<downarrow>', '<enter>' ] # setting keys += [ '<downarrow>', '<downarrow>', '<downarrow>', '<downarrow>', '<downarrow>', '<enter>' ] # about phone keys += [ '<downarrow>', '<downarrow>', '<downarrow>', '<downarrow>', '<downarrow>' ] keys += [ '<downarrow>', '<downarrow>', '<downarrow>', '<downarrow>', '<downarrow>', '<enter>' ] # enable dev_options keys += [ '<downarrow>', '<downarrow>', '<downarrow>', '<downarrow>', '<downarrow>', '<downarrow>' ] keys += [ '<enter>', '<enter>', '<enter>', '<enter>', '<enter>', '<enter>', '<enter>', '<esc>' ] # dev options keys += [ '<downarrow>', '<downarrow>', '<downarrow>', '<downarrow>', '<downarrow>' ] keys += [ '<downarrow>', '<downarrow>', '<downarrow>', '<downarrow>', '<downarrow>', '<enter>' ] # enable_usb_debugging keys += [ '<downarrow>', '<downarrow>', '<downarrow>', '<downarrow>', '<downarrow>' ] keys += ['<downarrow>', '<downarrow>'] keys += ['<enter>', '<tab>', '<enter>'] # home keys += ['<esc>', '<esc>', '<esc>'] for key in keys: print key self.relay.send_to_kb(key) time.sleep(1) self.relay.try_deactivate_kb() time.sleep(5) # Allow USB debugging -- checkbox + OK # Trying 5 times and then exit with error for t in range(5): try: print "Try to check always allow and touch OK - ", str(t + 1) self.touch_relay.allow_usb_debugging() time.sleep(5) self.relay.try_activate_kb(self.kb_device_port) time.sleep(5) self.relay.try_deactivate_kb() time.sleep(5) local_steps.wait_for_adb(serial=self.device["serial"], timeout=10)() print "Success" self.allowed = True break except FailedError: print "Failed" pass self.relay.close() self.touch_relay.close() def check_condition(self): return self.allowed
def do(self): cmd_header = "screen -x {0} -p0 -X stuff '".format(self.screen_name) enter = "\r'" local_steps.command(command="{0}{1}{2}".format( cmd_header, self.screen_command, enter))() if not self.user_build or self.user_signed or self.update: return waiting = 0 unlock_grep = "\"oem\" \"unlock\"` command" print "{0}: Waiting unlock command".format(self.serial) while waiting < self.timeout / 8: cat_grep_cmd = "tail -n 10 {0} | grep '{1}'".format( self.screen_log, unlock_grep) stdout, stderr = self.local_connection.run_cmd( command=cat_grep_cmd) if unlock_grep in stdout: time.sleep(30) my_relay = Relayed_device( relay_port=self.device["relay"]["tty"], power_port=self.device["relay"]["power_port"], v_up_port=self.device["relay"]["v_up_port"], v_down_port=self.device["relay"]["v_down_port"]) my_relay.press_volume_up() my_relay.press_power() my_relay.close() break waiting += 2 time.sleep(2) unlock_grep = "\"oem\" \"unlock\"` failed" while waiting < 30: cat_grep_cmd = "tail -n 10 {0} | grep '{1}'".format( self.screen_log, unlock_grep) stdout, stderr = self.local_connection.run_cmd( command=cat_grep_cmd) if unlock_grep in stdout: print "{0}: Unlock command failed".format(self.serial) print "{0}: The device is not OEM enabled!!!!!".format( self.serial) sys.exit(0) waiting += 2 time.sleep(2) waiting = 0 lock_grep = "\"oem\" \"lock\"` command" print "{0}: Waiting lock command".format(self.serial) while waiting < self.timeout * 6 / 8: cat_grep_cmd = "tail -n 10 {0} | grep '{1}'".format( self.screen_log, lock_grep) stdout, stderr = self.local_connection.run_cmd( command=cat_grep_cmd) if lock_grep in stdout: time.sleep(30) my_relay = Relayed_device( relay_port=self.device["relay"]["tty"], power_port=self.device["relay"]["power_port"], v_up_port=self.device["relay"]["v_up_port"], v_down_port=self.device["relay"]["v_down_port"]) my_relay.press_volume_up() my_relay.press_power() my_relay.close() break waiting += 2 time.sleep(2)
try: adb_steps.wait_for_ui(serial=self.serial, timeout=900)() print "{0}: Perform factory reset".format(self.serial) factory_reset(serial=self.serial)() time.sleep(120) local_steps.wait_for_adb(serial=self.serial, timeout=120)() print "{0}: Factory reset - Done!".format(self.serial) break except Exception, e: print e.message try: my_relay = Relayed_device( relay_port=self.device["relay"]["tty"], power_port=self.device["relay"]["power_port"], v_up_port=self.device["relay"]["v_up_port"], v_down_port=self.device["relay"] ["v_down_port"]) my_relay.relay_reboot() except Exception, e: print e.message raise e else: adb_steps.wait_for_ui(serial=self.serial, timeout=900)() print "{0}: Perform factory reset".format(self.serial) factory_reset(serial=self.serial)() time.sleep(120) local_steps.wait_for_adb(serial=self.serial, timeout=120)() print "{0}: Factory reset - Done!".format(self.serial) time.sleep(60) else: