Thursday, March 31, 2022

My own logics Development for different requirements. Please Don't open it

=================================================================

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) 

=================================================================


Wednesday, March 2, 2022

General Device/other issues we are facing in real time - How to overcome with solution

Device side issues: 

In the command prompt, if you type "adb devices -l" command then some of the devices may be displayed as unauthorized

List of devices attached

213495xxxxxx0092         unauthorized

solution:  In mobile go to settings then enable user debugging mode properly then try the command.

adb devices -l

List of devices attached

21349xxxxxxx092         device product: Product_Name model: model name device: device_name

======================================================================

Memory-related issues in machines:

Most of the time when we are running automation scripts we will get error messages like:"no space left on device"

solution:   We have to clean up the memory (by deleting dockers, containers, and temporary files) and also used below command 

docker system prune -a   ==> It will clear space on your device by doing the following tasks 

     This command will remove: 

            - all stopped containers

            - all networks not used by at least one container

            - all images without at least one container associated with them

            - all build cache


Note: Every time, before running long-run automation scripts, make sure that machine memory will be sufficient or not? 

======================================================================