=================================================================
write the logic for Image flashing:
import subprocess , time
def is_gki_image_flashed(devi_id):
uname = run_adb_command("adb shell uname -r")
print uname[0], len(uname[0])
length = len(uname[0])
if str == type(uname[0]):
if length>18:
return True
else:
return False
def gki_image_flashing(device_id,local_image_path,Remote_image_path,image_file_name,otp_file_name=None):
"""
this function will perform GKI image flashing with OTP & without OTP
"""
#shutil.copyfile(Remote_image_path, local_image_path)
if otp_file_name == None:
run_adb_command("adb -s "+device_id+" reboot bootloader")
time.sleep(10)
print("device went to fastboot mode")
outcome = subprocesscheck_output(["fastboot", "devices"])
if device_id in outcome:
run_adb_command("fastboot oem allow_unlock")
run_adb_command("fastboot oem unlock_all")
Image_file = local_image_path+"\\"+image_file_name
cmd = "fastboot flash boot "+Image_file
print(cmd, "command to be executed")
run_adb_command(cmd)
run_adb_command("fastboot -s "+device_id+" erase userdata")
time.sleep(60)
run_adb_command("fastboot -s "+device_id+" reboot")
time.sleep(90)
if check_adb_connection_status(device_id):
Flash_status = is_gki_image_flashed(device_id)
if Flash_status == True:
log_message("GKI Image is flashed on", device_id)
else:
log_message("GKI Image is not flashed on", device_id)
else:
run_adb_command("adb -s "+device_id+" reboot bootloader")
time.sleep(10)
print("device went to fastboot mode")
outcome = subprocess.check_output(["fastboot", "devices"])
if device_id in outcome:
run_adb_command("fastboot oem allow_unlock")
run_adb_command("fastboot flash otp "+otp_file_name) # Need to provide otp file name along with path
run_adb_command("fastboot oem unlock_all")
Image_file = local_image_path+"\\"+image_file_name
cmd = "fastboot flash boot "+Image_file
run_adb_command(cmd)
run_adb_command("fastboot -s "+device_id+" erase userdata")
time.sleep(60)
run_adb_command("fastboot -s "+device_id+" reboot")
time.sleep(90)
if check_adb_connection_status(device_id):
Flash_status = is_gki_image_flashed(device_id)
if Flash_status == True:
log_message("GKI Image is flashed on", device_id)
else:
log_message("GKI Image is not flashed on", device_id)
=================================================================