forked from anixart-mod/patcher
добавление вспомогательных функций, исправление добавления всплывающего окна первого запуска
This commit is contained in:
+39
-1
@@ -1,13 +1,16 @@
|
||||
"""Change package name of apk"""
|
||||
|
||||
priority = -1
|
||||
from tqdm import tqdm
|
||||
|
||||
import os
|
||||
|
||||
|
||||
def rename_dir(src, dst):
|
||||
os.makedirs(os.path.dirname(dst), exist_ok=True)
|
||||
os.rename(src, dst)
|
||||
|
||||
|
||||
def apply(config: dict) -> bool:
|
||||
assert config["new_package_name"] is not None, "new_package_name is not configured"
|
||||
|
||||
@@ -27,7 +30,6 @@ def apply(config: dict) -> bool:
|
||||
"com/swiftsoft/anixartd",
|
||||
config["new_package_name"].replace(".", "/"),
|
||||
)
|
||||
|
||||
with open(file_path, "w", encoding="utf-8") as file:
|
||||
file.write(new_contents)
|
||||
except:
|
||||
@@ -47,6 +49,42 @@ def apply(config: dict) -> bool:
|
||||
config["new_package_name"].replace(".", "/"),
|
||||
),
|
||||
)
|
||||
# rename_dir(
|
||||
# "./decompiled/smali_classes3/com/swiftsoft/anixartd",
|
||||
# os.path.join(
|
||||
# "./decompiled",
|
||||
# "smali_classes3",
|
||||
# config["new_package_name"].replace(".", "/"),
|
||||
# ),
|
||||
# )
|
||||
if not os.path.exists("./decompiled/smali_classes4/"):
|
||||
return True
|
||||
|
||||
rename_dir(
|
||||
"./decompiled/smali_classes4/com/swiftsoft/anixartd",
|
||||
os.path.join(
|
||||
"./decompiled",
|
||||
"smali_classes4",
|
||||
config["new_package_name"].replace(".", "/"),
|
||||
),
|
||||
)
|
||||
for root, dirs, files in os.walk("./decompiled/smali_classes4/"):
|
||||
for filename in files:
|
||||
file_path = os.path.join(root, filename)
|
||||
|
||||
if os.path.isfile(file_path):
|
||||
try:
|
||||
with open(file_path, "r", encoding="utf-8") as file:
|
||||
file_contents = file.read()
|
||||
|
||||
new_contents = new_contents.replace(
|
||||
"com/swiftsoft",
|
||||
"/".join(config["new_package_name"].split(".")[:-1]),
|
||||
)
|
||||
with open(file_path, "w", encoding="utf-8") as file:
|
||||
file.write(new_contents)
|
||||
except:
|
||||
pass
|
||||
|
||||
os.rmdir("./decompiled/smali_classes2/com/swiftsoft")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user