示例#1
0
    def do(self):
        if local_utils.has_fastboot_serial(serial=self.serial):
            fastboot_steps.continue_to_adb(serial=self.serial, blocking=True)()

        local_steps.wait_for_adb(serial=self.serial, blocking=True)()

        adb_steps.wait_for_ui(serial=self.serial, pin=self.pin,
                              blocking=True)()

        adb_steps.command(serial=self.serial,
                          command="svc power stayon true")()

        ui_steps.remove_pin_screen_lock(serial=self.serial,
                                        pin=self.pin,
                                        blocking=True)()

        if self.set_screen_lock:
            ui_steps.set_pin_screen_lock(
                serial=self.serial,
                dut_pin=self.pin,
                require_pin_to_start_device=self.require_pin_to_start_device,
                blocking=True)()

        if self.set_wifi:
            wifi_steps.remove_network(serial=self.serial,
                                      ap_name=self.ap_name)()
            wifi_steps.connect_with_password(serial=self.serial,
                                             ap_name=self.ap_name,
                                             password=self.ap_password,
                                             blocking=True)()
        ui_steps.press_home(serial=self.serial)()
def adb_command_process_exists(serial=None, strpro="com.google.android.setupwizard"):
    local_steps.command("adb -s {} reboot".format(serial))()
    local_steps.wait_for_adb(timeout=300, serial=serial)()
    time.sleep(10)
    adb_command = "adb shell ps | grep \"" + strpro + "\""
    return_result = subprocess.Popen(
        adb_command, stdout=subprocess.PIPE, shell=True).stdout.readline()
    if return_result != "":
        return True
    return False
示例#3
0
def flash_bxt_m_fused(eb_user_patch_flashfiles_zip_name=None,
                      eb_userdebug_patch_flashfiles_zip_name=None,
                      support_flash=False,
                      serial=None):
    unpack_the_zip(file_name="./temp/image/eb/userdebug/" +
                   eb_userdebug_patch_flashfiles_zip_name,
                   temp_path=r"./temp/image/eb/userdebug/flashfiles")
    unpack_the_zip(file_name="./temp/image/eb/user/" +
                   eb_user_patch_flashfiles_zip_name,
                   temp_path=r"./temp/image/eb/user/flashfiles")
    os.system(
        "cp -f ./temp/image/eb/userdebug/flashfiles/boot.img ./temp/image/eb/user/flashfiles"
    )
    if support_flash:
        os.system(
            "cp -f ./temp/image/eb/userdebug/flashfiles/ifwi_gr_mrb_b1.bin ./temp/image/eb/user/flashfiles"
        )
    make_the_zip(dir_name="./temp/image/eb/user/flashfiles/",
                 file_name="./temp/image/eb/flashfiles.zip")

    flash_bxt(flash_ioc="True",
              flash_ifwi="False",
              flash_android="True",
              zip_file="./temp/image/eb/flashfiles.zip",
              serial=serial,
              sleep_time=30,
              wait_for_adb=False)
    flash_bxt(flash_ioc="False",
              flash_ifwi="True",
              flash_android="False",
              zip_file="./temp/image/eb/flashfiles.zip",
              serial=serial,
              sleep_time=30,
              wait_for_adb=False)
    to_fastboot_by_script(serial=serial)
    time.sleep(30)
    local_steps.wait_for_fastboot(timeout=300, serial=serial)()
    os.system("fastboot reboot > /dev/null 2>&1")
    time.sleep(120)

    push_uiautomator_jar(serial=serial)
    d = Device(serial)
    time.sleep(5)
    if d(text="To start Android, enter your password").exists:
        d(resourceId="com.android.settings:id/passwordEntry").click.wait()
        time.sleep(5)
        os.system("adb -s {0} shell input text 1234".format(serial))
        time.sleep(5)
        os.system("adb -s {0} shell input keyevent 66".format(serial))
        time.sleep(5)
    if d(text="Decryption unsuccessful").exists:
        d(text="Reset phone").click.wait()
        time.sleep(120)
    local_steps.wait_for_adb(timeout=300, serial=serial)()
示例#4
0
def flash_bxt(flash_ioc="True",
              flash_ifwi="True",
              flash_android="True",
              zip_file=None,
              serial=None,
              sleep_time=120,
              wait_for_adb=True):
    debugcard_port_list = get_debugcard_port(serial=serial)
    os.system("sudo python ./temp/files/flash/flash_image.py --flash_ioc=\"{0}\" --flash_ifwi=\"{1}\" --flash_android=\"{2}\" --zip_file=\"{3}\" --port=\"{4}\""\
                .format(flash_ioc, flash_ifwi, flash_android, zip_file, debugcard_port_list[-2]))
    time.sleep(sleep_time)
    if wait_for_adb:
        local_steps.wait_for_adb(timeout=300, serial=serial)()
示例#5
0
    def do(self):
        # Long press on power button
        self.relay.long_press_power()

        # Long press on power to enable reboot safe mode prompt and select OK
        ui_steps.long_click(
            serial=self.serial,
            view_to_find={"resourceId": "android:id/contentPanel"},
            view_to_check={"text": "Reboot to safe mode"})()
        ui_steps.click_button(serial=self.serial, view_to_find={"text":
                                                                "OK"})()

        # Wait for the device to reboot
        local_steps.wait_until_disconnected(serial=self.serial)()
        local_steps.wait_for_adb(serial=self.serial)()
        adb_steps.wait_for_ui(serial=self.serial)()
def flash_android_os(platform, zip_file, relay_port, serial, flash_ioc="True", flash_ifwi="True",
                     flash_android="True", image_type="userdebug", sleep_time=120, wait_for_adb=True):
    if platform == "bxt":
        flash_script_name = "flash_bxt.py"
    if platform == "acrn":
        flash_script_name = "flash_acrn.py"
    debugcard_port_list = get_debugcard_port(serial=serial)
    arduino_port_list = get_arduino_port(serial=serial)
    os.system("sudo python ./temp/files/flash/{0} --flash_ioc=\"{1}\" --flash_ifwi=\"{2}\""
              " --flash_android=\"{3}\" --zip_file=\"{4}\" --debugcard_port=\"{5}\""
              " --relay_port=\"{6}\" --image_type=\"{7}\" --arduino_port=\"{8}\""
              .format(flash_script_name, flash_ioc, flash_ifwi, flash_android, zip_file,
                      debugcard_port_list[-2], relay_port, image_type, arduino_port_list[0]))
    time.sleep(sleep_time)
    if wait_for_adb:
        local_steps.wait_for_adb(timeout=300, serial=serial)()
示例#7
0
    def do(self):
        print "{0}: {1}".format(self.serial, self.img_path)
        ################################################################################
        # Device has to be in fastboot
        #   - if already in fastboot, do nothing
        #   - if it has adb, reboot in fastboot via adb
        #   - for any other state:
        #       * force poweroff via relay
        #       * boot in fastboot via relay (poweron & volume down)
        ################################################################################
        print "{0}: reboot to fastboot".format(self.serial)
        if local_utils.has_fastboot_serial(self.serial):
            pass
        elif local_utils.has_adb_serial(self.serial):
            adb_steps.reboot(serial=self.serial, command="fastboot")()
        else:
            ############################################################################
            # device file should be made dynamic to support multiple relays
            ############################################################################
            print "{0}: Relay needed!!!!!!!!".format(self.serial)
            my_relay = Relay(port=self.device["relay"]["tty"])
            my_relay.power_on(self.device["relay"]["v_up_port"])
            my_relay.power_on(self.device["relay"]["power_port"])
            my_relay.close()
        print "{0}: Done rebooting for fastboot!".format(self.serial)

        print "{0}: Wait for fastboot".format(self.serial)
        local_steps.wait_for_fastboot(serial=self.serial, timeout=100)()
        print "{0}: Done waiting for fastboot!".format(self.serial)
        old_folder, err = local_steps.command("pwd")()

        local_steps.change_dir(new_folder=self.img_path)()
        print "{0}: Wait for flash-all.sh".format(self.serial)
        #TODO: add stdout_gprep for flash-all.sh
        sout, serr = local_steps.command(
            command="./flash-all.sh -s {0}".format(self.serial))()
        print "{0}: Done! Image flashed".format(self.serial)
        print "{0}: Wait for adb".format(self.serial)

        local_steps.wait_for_adb(serial=self.serial, timeout=720)()
        print "{0}: Done! adb connected".format(self.serial)
        local_steps.change_dir(new_folder=old_folder.strip())()
示例#8
0
    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
示例#9
0
from testlib.scripts.android.fastboot import fastboot_steps
from testlib.scripts.android.fastboot import fastboot_utils
from testlib.scripts.connections.local import local_steps

##### initialization #####
globals().update(vars(get_args(sys.argv)))

##### test start #####
try:
	os.system("mkdir -p ./temp/files/flash")
	fastboot_utils.download_flash_scripts()

	adb_steps.reboot(command="fastboot", reboot_timeout=300, serial=serial)()
	local_steps.wait_for_fastboot(timeout=300, serial=serial)()
	fastboot_steps.continue_to_adb(serial=serial)()
	local_steps.wait_for_adb(timeout=300, serial=serial)()

	os.system("adb -s {0} shell reboot -p".format(serial))
	time.sleep(30)
	fastboot_utils.to_fastboot_by_script(serial=serial)
	local_steps.wait_for_fastboot(timeout=300, serial=serial)()
	fastboot_steps.continue_to_adb(serial=serial)()
	local_steps.wait_for_adb(timeout=300, serial=serial)()
	os.system("sudo rm -rf ./temp")

except:
	fastboot_utils.to_fastboot_by_script(serial=serial)
	local_steps.wait_for_fastboot(timeout=300, serial=serial)()
	fastboot_steps.continue_to_adb(serial=serial)()
	local_steps.wait_for_adb(timeout=300, serial=serial)()
	os.system("sudo rm -rf ./temp")
ui_steps.close_all_app_from_recent(serial=serial, blocking=True)()
telephony_steps.set_sim_pin(serial=serial,
                            state="ON",
                            pin=sim_pin,
                            blocking=True)()
telephony_steps.check_pin_is_requested(serial=serial,
                                       pin=sim_pin,
                                       blocking=True)()
telephony_steps.enter_pin(serial=serial, pin=sim_pin, blocking=True)()

for i in range(iterations):
    adb_steps.root_connect_device(serial=serial)()
    adb_steps.command(serial=serial, command="mount -t debugfs none /d")()
    adb_steps.command(serial=serial, command="echo c > /proc/sysrq-trigger")()
    adb_steps.check_device_reboots(serial=serial, reboot_timeout=120)()
    local_steps.wait_for_adb(serial=serial, reboot_timeout=120)()
    adb_steps.wait_for_ui(serial=serial,
                          boot_to_Android=False,
                          sim_pin_enabled=True)()
    telephony_steps.check_pin_is_requested(serial=serial,
                                           enabled_pin=False,
                                           with_reboot=False)()
    telephony_steps.open_messenger(serial=serial)()
    telephony_steps.send_sms(
        number=number,
        content=sms_test_content,
        view_to_check={
            "resourceId":
            "com.google.android.apps.messaging:id/message_status",
            "text": "Sent."
        },
示例#11
0
    def do(self):
        # Create panic
        adb_steps.root_connect_device(serial=self.serial)()
        if self.create_crash_mode == "panic":
            # Using local_steps to run the command because adb_steps.command() does not create kernel panic
            local_steps.command("adb -s {0} shell {1}".format(
                self.serial, self.panic_command))()

            # Wait for the device to disconnect
            local_steps.wait_until_disconnected(serial=self.serial)()
            if self.use_combo_button == False:
                print "======================wait 120s======================="
                time.sleep(120)
        else:
            adb_steps.kill_process(serial=self.serial,
                                   process_name=self.watchdog_process_name,
                                   with_reboot=True,
                                   reboot_timeout=60)()

        # Wait for a device state
        if self.wait_for_state == "fastboot":
            # Set the pass and error messages
            self.set_errorm(
                "", "The device with serial {0} is not in fastboot".format(
                    self.serial))
            self.set_passm("The device with serial {0} is in fastboot".format(
                self.serial))

            # If the expected state is fastboot, we need to press the volume down button after the panic is created
            # This will boot the device in fastboot
            # Create a parallel step
            # use_control_process=False
            psteps = ParallelSteps(use_control_process=False)

            step_id_combo = psteps.add_step(
                local_steps.wait_for_fastboot,
                serial=self.serial,
                timeout=self.wait_for_fastboot_timeout)

            self.relay.relay.on(self.relay.v_down_port)
            time.sleep(self.wait_for_fastboot_timeout - 10)
            self.relay.relay.off(self.relay.v_down_port)

            # Interpret the parallel step result
            psteps.interpret_step(step_id_combo)

        elif self.wait_for_state == "android":
            # Set the pass and error messages
            self.set_errorm(
                "",
                "The device with serial {0} is not in MOS".format(self.serial))
            self.set_passm("The device with serial {0} is in MOS".format(
                self.serial))

            # Wait for adb connection
            local_steps.wait_for_adb(serial=self.serial)()

            # Wait for the UI processes
            adb_steps.wait_for_ui_processes(serial=self.serial)()
        elif self.wait_for_state == "crashmode":
            # Set the pass and  error messages
            self.set_errorm(
                "", "The device with serial {0} is not in crash mode".format(
                    self.serial))
            self.set_passm(
                "The device with serial {0} is in crash mode".format(
                    self.serial))

            # Wait for crashmode
            local_steps.wait_for_crashmode(serial=self.serial, timeout=60)()
示例#12
0
            my_relay.press_power()
            my_relay.close()
            local_steps.command(command="fastboot -s " + s + " oem verified")()
            local_steps.command(command="fastboot -s " + s + " oem lock")()

            time.sleep(3)
            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.press_volume_up()
            my_relay.press_power()
            my_relay.close()
            local_steps.command(command="fastboot -s " + s + " reboot")()
            local_steps.wait_for_adb(serial=s, timeout=500)()
            local_steps.wait_for_ui(serial=s, timeout=900)()
        except:
            print "Workaround could not be performed for " + str(s)
            print traceback.format_exc()
    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!!!"
示例#13
0
##### test start #####
try:
    os.system("mkdir -p ./temp/files/flash")
    fastboot_utils.download_flash_scripts()

    adb_steps.reboot(command="fastboot", reboot_timeout=300, serial=serial)()
    fastboot_steps.unlock_device(serial=serial)()
    fastboot_steps.lock_device(serial=serial)()
    fastboot_steps.reboot_fastboot(serial=serial)()

    fastboot_steps.command(
        command="getvar device-state > ./temp/files/device_state.txt 2>&1",
        serial=serial)()
    device_state = fastboot_utils.get_device_state(
        file_path="./temp/files/device_state.txt")
    if device_state == "unlocked":
        raise Exception("The test result did not achieve the desired results")

    fastboot_steps.continue_to_adb(serial=serial)()
    time.sleep(60)
    local_steps.wait_for_adb(serial=serial, timeout=300)()

    fastboot_utils.flash_bxt(zip_file=flash_files, serial=serial)
    os.system("sudo rm -rf ./temp")

except:
    fastboot_utils.flash_bxt(zip_file=flash_files, serial=serial)
    os.system("sudo rm -rf ./temp")
    raise
##### test end #####
示例#14
0
relay_port = args["relay_port"]
power_port = args["power_port"]

# test start #
try:
    device_state = local_utils.get_device_boot_state(serial=serial)

    if device_state == "fastboot":
        fastboot_steps.continue_to_adb(serial=serial)()
        adb_steps.wait_for_ui_processes(serial=serial)()
    elif device_state == "recovery":
        adb_steps.reboot(serial=serial)()
    elif device_state == "crashmode":
        print "adb -s {} reboot".format(serial)
        local_steps.command("adb -s {} reboot".format(serial))()
        local_steps.wait_for_adb(serial=serial)()
        adb_steps.wait_for_ui_processes(serial=serial)()
    else:
        relay_steps.reboot_main_os(serial=serial,
                                   relay_type=relay_type,
                                   relay_port=relay_port,
                                   power_port=power_port,
                                   wait_ui=True)()

    # Reboot to crashmode
    os.system("adb -s {} reboot crashmode > /dev/null 2>&1".format(serial))
    time.sleep(15)
    local_steps.wait_for_crashmode(serial=serial, timeout=60)()

except:
    raise
示例#15
0
    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()
示例#16
0
                    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
            else:
                local_steps.wait_for_adb(serial=self.serial, timeout=120)()

            if self.update and not self.user_signed:
                for i in range(iterations):
                    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