fix of by one in static values generation

This commit is contained in:
Jean-Marie Mineau 2024-02-07 10:35:38 +01:00
parent fcfe2dc6e9
commit e0f348aecc
Signed by: histausse
GPG key ID: B66AEEDA9B645AD2
2 changed files with 19 additions and 7 deletions

20
test.py
View file

@ -67,12 +67,13 @@ classes = list(
IdType("Lcom/example/testapplication/ui/home/HomeViewModel;"),
IdType("Landroidx/navigation/NavDeepLink$Builder;"),
IdType("Landroidx/constraintlayout/core/widgets/ConstraintWidget$1;"),
IdType("Landroidx/appcompat/app/ActionBar;"),
],
apk.classes.keys(),
)
)
for cls in classes:
apk.remove_class(cls)
# for cls in classes:
# apk.remove_class(cls)
print("[+] Recompile")
@ -94,9 +95,13 @@ for dex in dex_raw:
# apksigner=Path.home() / "Android" / "Sdk" / "build-tools" / "34.0.0" / "apksigner",
# )
last_id = None
MAX_REQ = 1
def cmp(a, b, req=0):
if req > 6:
if req > MAX_REQ:
return
if type(a) == dict:
cmp_dict(a, b, req)
@ -116,10 +121,15 @@ def nice_bool(b) -> str:
def cmp_other(a, b, req=0):
ident = " " * req
for f in dir(a):
if getattr(getattr(a, f), "__call__", None) is None:
if getattr(getattr(a, f), "__call__", None) is None and (
len(f) < 2 or f[:2] != "__"
):
eq = getattr(a, f) == getattr(b, f)
print(f"{f'{ident}{f}: ':<150}{nice_bool(eq)}")
if not eq:
if "descriptor" in dir(a):
global last_id
last_id = a.descriptor
cmp(getattr(a, f), getattr(b, f), req + 1)
@ -133,6 +143,8 @@ def cmp_dict(a, b, req=0):
eq = a[key] == b[key]
print(f"{f'{ident}{str(key)}: ':<150}{nice_bool(eq)}")
if not eq:
global last_id
last_id = a.descriptor
cmp(a[key], b[key], req + 1)