def get_platform_name(serial):
    if serial in local_utils.get_connected_android_devices()["android"]:
        ro_build_version_release = "ro.build.version.release"
        ro_product_device = "ro.product.device"
        build_version_release = os.popen("adb -s {0} shell getprop {1}".format(
            serial, ro_build_version_release)).readlines()
        product_device = os.popen("adb -s {0} shell getprop {1}".format(
            serial, ro_product_device)).readlines()
        if build_version_release[0].strip()[0] == "6":
            return "m_" + product_device[0].strip()
        if build_version_release[0].strip()[0] == "8":
            return "o_" + product_device[0].strip()
        if build_version_release[0].strip()[0] == "9":
            return "p_" + product_device[0].strip()
    if serial in local_utils.get_connected_android_devices()["fastboot"]:
        if not os.path.exists("./temp/files"):
            os.makedirs("./temp/files")
        os.system(
            "fastboot -s {0} getvar product > ./temp/files/product_device.txt 2>&1"
            .format(serial))
        return_result = open("./temp/files/product_device.txt").readlines()
        for line in return_result:
            if "product" in line:
                return line.split(":")[1].strip()
    return None
示例#2
0
    def check_condition(self):
        wait_time = 0
        while self.serial not in local_utils.get_connected_android_devices()["recovery"] and\
              wait_time < self.timeout:
            time.sleep(2)
            wait_time += 2

        return self.serial in local_utils.get_connected_android_devices(
        )["recovery"]
示例#3
0
 def check_condition(self):
     wait_time = 0
     while self.serial not in local_utils.get_connected_android_devices()['android'] and\
           wait_time < self.timeout:
         time.sleep(2)
         wait_time += 2
     if self.wait_ui:
         return adb_steps.wait_for_ui_processes(serial=self.serial)()
     return self.serial in local_utils.get_connected_android_devices(
     )['android']
示例#4
0
def get_platform_name(serial=None):
    if serial in local_utils.get_connected_android_devices()["android"]:
        return_result = os.popen(
            "adb shell getprop ro.product.device").readlines()
        return return_result[0].strip("\r\n")
    if serial in local_utils.get_connected_android_devices()["fastboot"]:
        if not os.path.exists("./temp/files"):
            os.makedirs("./temp/files")
        os.system("fastboot getvar product > ./temp/files/temp.txt 2>&1")
        return_result = open("./temp/files/temp.txt").readlines()
        for line in return_result:
            if "product" in line:
                return line.split(":")[1].strip()
    return None
示例#5
0
 def do(self):
     # hard boot to main OS
     if self.serial not in local_utils.get_connected_android_devices(
     )['android'] or self.force_reboot:
         power_off_device(serial=self.serial,
                          except_charging=True,
                          device_info=self.device_info,
                          **self.kwargs)()
         if self.delay_power_on > 0: time.sleep(self.delay_power_on)
         power_on_device(serial=self.serial,
                         except_charging=True,
                         **self.kwargs)()
示例#6
0
    def check_condition(self):
        wait_time = 0
        if self.option in ["normal_boot", "reboot"]:
            device_state = "android"
        elif self.option == "power_off":
            device_state = "charge_os"
            return True
        elif self.option == "bootloader":
            device_state = "fastboot"
            time.sleep(3)
        elif self.option == "recovery":
            device_state = "recovery"
        else:
            self.set_errorm("", "Invalid menu option {0}".format(self.option))
            return False

        while self.serial not in local_utils.get_connected_android_devices()[device_state] and\
              wait_time < self.timeout:
            time.sleep(2)
            wait_time += 2

        return self.serial in local_utils.get_connected_android_devices(
        )[device_state]
    test_result = False
    diff_cmd = "diff ./temp/image/n/flashfiles/ifwi_gr_mrb_b1.bin ./temp/image/eb/{0}/flashfiles/ifwi_gr_mrb_b1.bin".format(
        flashfiles_type)
    return_result = os.popen(diff_cmd).readlines()
    for line in return_result:
        if "differ" in line: test_result = True
    if not test_result:
        raise Exception("The test result did not achieve the desired results")

    fastboot_utils.make_the_zip(
        dir_name="./temp/image/eb/{0}/flashfiles/".format(flashfiles_type),
        file_name="./temp/image/eb/corrupted_flashfiles.zip")
    fastboot_utils.flash_bxt(
        flash_ioc="False",
        flash_ifwi="True",
        flash_android="False",
        zip_file="./temp/image/eb/corrupted_flashfiles.zip",
        serial=serial,
        sleep_time=60,
        wait_for_adb=False)
    if serial in local_utils.get_connected_android_devices()["android"]:
        raise Exception("The test result did not achieve the desired results")

    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 #####
    fastboot_utils.download_flash_scripts()

    adb_steps.reboot(command="fastboot", reboot_timeout=300, serial=serial)()
    fastboot_steps.corrupt_esp_partition(unlock_dut=True,
                                         lock_dut=False,
                                         reboot=False,
                                         serial=serial)()
    fastboot_utils.flash_bxt(flash_ioc="True",
                             flash_ifwi="True",
                             flash_android="False",
                             zip_file=flash_files,
                             serial=serial,
                             sleep_time=60,
                             wait_for_adb=False)

    if serial in local_utils.get_connected_android_devices()['android']:
        raise Exception("The test result did not achieve the desired results")

    fastboot_utils.to_fastboot_by_script(serial=serial)
    local_steps.wait_for_fastboot(timeout=300, serial=serial)()
    os.system("fastboot reboot > /dev/null 2>&1")
    time.sleep(60)

    if serial not in local_utils.get_connected_android_devices()['fastboot']:
        raise Exception("The test result did not achieve the desired results")

    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)