# -*- coding: utf-8 -*-
import subprocess
import zipfile
from pathlib import Path

split_apk = Path(__file__).resolve().parent.parent / "extracted" / "native" / "split_arm64.apk"
base_apk = Path(__file__).resolve().parent.parent / "apks" / "seabank_ph_base.apk"
DEXDUMP = Path(r"C:\Users\Administrator\AppData\Local\Android\Sdk\build-tools\37.0.0\dexdump.exe")
apk = base_apk if base_apk.exists() else None
if apk is None:
    # use device base if needed - skip
    import sys
    print("no base apk")
    sys.exit(0)
with zipfile.ZipFile(str(apk)) as zf:
    tmp = Path(__file__).resolve().parent.parent / "tmp" / "tmp11.dex"
    tmp.write_bytes(zf.read("classes11.dex"))
out = subprocess.check_output([str(DEXDUMP), "-d", str(tmp)], universal_newlines=True, errors="replace")
for line in out.splitlines():
    if "0x0101" in line or "NATIVE" in line:
        print(line.strip())
