исправление патча package_name

This commit is contained in:
2025-09-01 10:51:26 +03:00
9 changed files with 203 additions and 32 deletions
+33
View File
@@ -0,0 +1,33 @@
"""Disable ad banners"""
priority = 0
from utils.smali_parser import (
find_smali_method_end,
find_smali_method_start,
get_smali_lines,
replace_smali_method_body,
)
replace = """ .locals 0
const/4 p0, 0x1
return p0
"""
def apply(config) -> bool:
path = "./decompiled/smali_classes2/com/swiftsoft/anixartd/Prefs.smali"
lines = get_smali_lines(path)
for index, line in enumerate(lines):
if line.find("IS_SPONSOR") >= 0:
method_start = find_smali_method_start(lines, index)
method_end = find_smali_method_end(lines, index)
new_content = replace_smali_method_body(
lines, method_start, method_end, replace
)
with open(path, "w", encoding="utf-8") as file:
file.writelines(new_content)
return True
+39
View File
@@ -0,0 +1,39 @@
"""Remove beta banner"""
priority = 0
import os
from tqdm import tqdm
from lxml import etree
from typing import TypedDict
def apply(config) -> bool:
attributes = [
"paddingTop",
"paddingBottom",
"paddingStart",
"paddingEnd",
"layout_width",
"layout_height",
"layout_marginTop",
"layout_marginBottom",
"layout_marginStart",
"layout_marginEnd",
]
beta_banner_xml = "./decompiled/res/layout/item_beta.xml"
if os.path.exists(beta_banner_xml):
parser = etree.XMLParser(remove_blank_text=True)
tree = etree.parse(beta_banner_xml, parser)
root = tree.getroot()
for attr in attributes:
# tqdm.write(f"set {attr} = 0.0dip")
root.set(f"{{{config["xml_ns"]['android']}}}{attr}", "0.0dip")
tree.write(
beta_banner_xml, pretty_print=True, xml_declaration=True, encoding="utf-8"
)
return True
+27 -27
View File
@@ -35,20 +35,32 @@ def apply(config: dict) -> bool:
except:
pass
rename_dir(
"./decompiled/smali/com/swiftsoft/anixartd",
os.path.join(
"./decompiled", "smali", config["new_package_name"].replace(".", "/")
),
)
rename_dir(
"./decompiled/smali_classes2/com/swiftsoft/anixartd",
os.path.join(
"./decompiled",
"smali_classes2",
config["new_package_name"].replace(".", "/"),
),
)
if os.path.exists("./decompiled/smali/com/swiftsoft/anixartd"):
rename_dir(
"./decompiled/smali/com/swiftsoft/anixartd",
os.path.join(
"./decompiled", "smali", config["new_package_name"].replace(".", "/")
),
)
if os.path.exists("./decompiled/smali_classes2/com/swiftsoft/anixartd"):
rename_dir(
"./decompiled/smali_classes2/com/swiftsoft/anixartd",
os.path.join(
"./decompiled",
"smali_classes2",
config["new_package_name"].replace(".", "/"),
),
)
if os.path.exists("./decompiled/smali_classes4/com/swiftsoft"):
rename_dir(
"./decompiled/smali_classes4/com/swiftsoft",
os.path.join(
"./decompiled",
"smali_classes4",
"/".join(config["new_package_name"].split(".")[:-1]),
),
)
# rename_dir(
# "./decompiled/smali_classes3/com/swiftsoft/anixartd",
# os.path.join(
@@ -57,17 +69,7 @@ def apply(config: dict) -> bool:
# 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)
@@ -77,7 +79,7 @@ def apply(config: dict) -> bool:
with open(file_path, "r", encoding="utf-8") as file:
file_contents = file.read()
new_contents = new_contents.replace(
new_contents = file_contents.replace(
"com/swiftsoft",
"/".join(config["new_package_name"].split(".")[:-1]),
)
@@ -86,8 +88,6 @@ def apply(config: dict) -> bool:
except:
pass
os.rmdir("./decompiled/smali_classes2/com/swiftsoft")
return True