From 3458aa038a2dbba00d6237bbc327f299cfe7728c Mon Sep 17 00:00:00 2001 From: Bing Date: Mon, 15 Apr 2024 08:47:50 -0400 Subject: [PATCH] - Bugfix: #192 - Failed to process Android 15 beta firmware. --- build-on-mac.spec | 2 +- build.sh | 2 +- constants.py | 2 +- modules.py | 7 ++++++- runtime.py | 20 ++++++++++++-------- windows-metadata.yaml | 2 +- windows-version-info.txt | 8 ++++---- 7 files changed, 26 insertions(+), 17 deletions(-) diff --git a/build-on-mac.spec b/build-on-mac.spec index 3e59f0b..b0a630f 100644 --- a/build-on-mac.spec +++ b/build-on-mac.spec @@ -28,6 +28,6 @@ exe = EXE(pyz, icon='images/icon-dark-256.icns') app = BUNDLE(exe, name='PixelFlasher.app', - version='6.9.2.0', + version='6.9.2.1', icon='./images/icon-dark-256.icns', bundle_identifier='com.badabing.pixelflasher') diff --git a/build.sh b/build.sh index d9e68f7..fe0c8be 100755 --- a/build.sh +++ b/build.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash rm -rf build dist -VERSION=6.9.2.0 +VERSION=6.9.2.1 NAME="PixelFlasher" DIST_NAME="PixelFlasher" diff --git a/constants.py b/constants.py index d13dd1f..02f493f 100644 --- a/constants.py +++ b/constants.py @@ -2,7 +2,7 @@ APPNAME = 'PixelFlasher' CONFIG_FILE_NAME = 'PixelFlasher.json' -VERSION = '6.9.2.0' +VERSION = '6.9.2.1' SDKVERSION = '33.0.3' MAIN_WIDTH = 1400 MAIN_HEIGHT = 1040 diff --git a/modules.py b/modules.py index a0560a0..b5f1b3c 100644 --- a/modules.py +++ b/modules.py @@ -2448,6 +2448,11 @@ def patch_apatch_script(patch_method="app"): print(f"With APatch patching, the boot.img will be used, instead of init_boot.img, however we need ramdisk from init_boot.img") init_boot_path = boot_path boot_path = boot_path.replace("init_boot.img", "boot.img") + if not os.path.exists(boot_path): + print(f"\n❌ {datetime.now():%Y-%m-%d %H:%M:%S} ERROR: boot.img file [{boot_path}] is not found.") + puml("#red:ERROR: boot.img file [{boot_path}] is not found;\n") + print("Aborting ...\n}\n") + return -1 stock_init_sha1 = sha1(init_boot_path)[:8] stock_sha1 = sha1(boot_path)[:8] print(f"Using boot.img for APatch patching with SHA1 of {stock_sha1}") @@ -4090,7 +4095,7 @@ def flash_phone(self): os.chdir(package_dir_full) theCmd = f"\"{theCmd}\"" debug(theCmd) - res = run_shell2(theCmd) + res = run_shell2(theCmd, env=get_env_variables()) if res.returncode != 0: print(f"\n❌ {datetime.now():%Y-%m-%d %H:%M:%S} ERROR: Encountered an error while running flash script.") print(f"theCmd: {theCmd}") diff --git a/runtime.py b/runtime.py index 04ce46b..b1163dd 100644 --- a/runtime.py +++ b/runtime.py @@ -3515,22 +3515,27 @@ def run_shell2(cmd, timeout=None, detached=False, directory=None, encoding='ISO- "stderr": subprocess.STDOUT, "encoding": encoding, "errors": "replace", - "cwd": directory, "start_new_session": detached, - "creationflags": creationflags } if env is not None: proc_args["env"] = env + if creationflags is not None: + proc_args["creationflags"] = creationflags + if directory is not None: + proc_args["cwd"] = directory proc = subprocess.Popen(**proc_args) def read_output(): + print start_time = time.time() + output = [] while True: line = proc.stdout.readline() wx.YieldIfNeeded() if line.strip() != "": print(line.strip()) + output.append(line.strip()) if not line: break if timeout is not None and time.time() - start_time > timeout: @@ -3538,14 +3543,13 @@ def read_output(): print(f"\n❌ {datetime.now():%Y-%m-%d %H:%M:%S} ERROR: Command {cmd} timed out after {timeout} seconds") puml("#red:Command timed out;\n", True) puml(f"note right\nCommand {cmd} timed out after {timeout} seconds\nend note\n") - return subprocess.CompletedProcess(args=cmd, returncode=-1, stdout='', stderr='') - - if detached: - threading.Thread(target=read_output, daemon=True).start() - else: - read_output() + return subprocess.CompletedProcess(args=cmd, returncode=-1, stdout='\n'.join(output), stderr='') + threading.Thread(target=read_output, daemon=True).start() + if not detached: + proc.wait() return proc + except Exception as e: print(f"\n❌ {datetime.now():%Y-%m-%d %H:%M:%S} ERROR: Encountered an error while executing run_shell2 {cmd}") traceback.print_exc() diff --git a/windows-metadata.yaml b/windows-metadata.yaml index e83666c..4b49624 100644 --- a/windows-metadata.yaml +++ b/windows-metadata.yaml @@ -1,6 +1,6 @@ # https://github.com/DudeNr33/pyinstaller-versionfile # create-version-file windows-metadata.yaml --outfile windows-version-info.txt -Version: 6.9.2.0 +Version: 6.9.2.1 FileDescription: PixelFlasher InternalName: PixelFlasher OriginalFilename: PixelFlasher.exe diff --git a/windows-version-info.txt b/windows-version-info.txt index 1373583..46e688f 100644 --- a/windows-version-info.txt +++ b/windows-version-info.txt @@ -7,8 +7,8 @@ VSVersionInfo( ffi=FixedFileInfo( # filevers and prodvers should be always a tuple with four items: (1, 2, 3, 4) # Set not needed items to zero 0. Must always contain 4 elements. - filevers=(6,9,2,0), - prodvers=(6,9,2,0), + filevers=(6,9,2,1), + prodvers=(6,9,2,1), # Contains a bitmask that specifies the valid bits 'flags'r mask=0x3f, # Contains a bitmask that specifies the Boolean attributes of the file. @@ -32,12 +32,12 @@ VSVersionInfo( u'040904B0', [StringStruct(u'CompanyName', u''), StringStruct(u'FileDescription', u'PixelFlasher'), - StringStruct(u'FileVersion', u'6.9.2.0'), + StringStruct(u'FileVersion', u'6.9.2.1'), StringStruct(u'InternalName', u'PixelFlasher'), StringStruct(u'LegalCopyright', u''), StringStruct(u'OriginalFilename', u'PixelFlasher.exe'), StringStruct(u'ProductName', u'PixelFlasher'), - StringStruct(u'ProductVersion', u'6.9.2.0')]) + StringStruct(u'ProductVersion', u'6.9.2.1')]) ]), VarFileInfo([VarStruct(u'Translation', [1033, 1200])]) ]