mirror of
https://github.com/Radiquum/anixart-patcher.git
synced 2025-09-07 11:43:51 +05:00
fix: app version was not actually changed
This commit is contained in:
parent
79bfd0b8d6
commit
831c2919b8
1 changed files with 39 additions and 0 deletions
|
@ -7,6 +7,7 @@ priority = -98
|
|||
|
||||
# imports
|
||||
## bundled
|
||||
import os
|
||||
from typing import TypedDict
|
||||
|
||||
## installed
|
||||
|
@ -47,4 +48,42 @@ def apply(patch_conf: PatchConfig_ChangeAppVersion) -> bool:
|
|||
) as f:
|
||||
apktool_yaml = yaml.dump(apktool_yaml, f, indent=2, Dumper=yaml.Dumper)
|
||||
|
||||
for root, dirs, files in os.walk(f"{config['folders']['decompiled']}"):
|
||||
if len(files) < 0:
|
||||
continue
|
||||
|
||||
for filename in files:
|
||||
file_path = os.path.join(root, filename)
|
||||
if os.path.isfile(file_path) and filename.endswith(".smali"):
|
||||
file_contents = None
|
||||
with open(file_path, "r", encoding="utf-8") as file:
|
||||
file_contents = file.read()
|
||||
|
||||
if file_contents.find(str(patch_conf["_internal_app_build"])) >= 0 or file_contents.find(
|
||||
hex(patch_conf["_internal_app_build"])
|
||||
) >= 0:
|
||||
file_contents = file_contents.replace(
|
||||
str(patch_conf["_internal_app_build"]),
|
||||
str(patch_conf["version_code"]) or str(patch_conf["_internal_app_build"]),
|
||||
)
|
||||
file_contents = file_contents.replace(
|
||||
hex(patch_conf["_internal_app_build"]),
|
||||
hex(patch_conf["version_code"]) or hex(patch_conf["_internal_app_build"]),
|
||||
)
|
||||
log.debug(f"replaced build number in file: {file_path}")
|
||||
log.debug(f"previous: {patch_conf["_internal_app_build"]} ({hex(patch_conf['_internal_app_build'])})")
|
||||
log.debug(f"replaced: {patch_conf["version_code"]} ({hex(patch_conf['version_code'])})")
|
||||
|
||||
if file_contents.find(patch_conf["_internal_app_version"]) >= 0:
|
||||
file_contents = file_contents.replace(
|
||||
patch_conf["_internal_app_version"],
|
||||
patch_conf["version_name"] or patch_conf["_internal_app_version"],
|
||||
)
|
||||
log.debug(f"replaced version name in file: {file_path}")
|
||||
log.debug(f"previous: {patch_conf["_internal_app_build"]}")
|
||||
log.debug(f"replaced: {patch_conf["version_code"]}")
|
||||
|
||||
with open(file_path, "w", encoding="utf-8") as file:
|
||||
file.write(file_contents)
|
||||
|
||||
return True
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue