mirror of
https://github.com/zarzet/SpotiFLAC-Mobile.git
synced 2026-09-30 13:19:44 +02:00
refactor(discord): remove rich presence and bundled SDK
Remove the presence setting, platform bridge, SDK archive, and SDK preparation from local and CI builds. Reject leftover Discord native libraries in release APK audits.
This commit is contained in:
1 parent
863d1536dd
commit
728d179d69
43 files changed
+37
-1171
No files matched your search
@@ -15,11 +15,7 @@ ABI_LAYOUT = {
|
||||
"armeabi-v7a": (1, 40),
|
||||
}
|
||||
CORE_LIBRARIES = ("libapp.so", "libflutter.so")
|
||||
DISCORD_LIBRARIES = ("libspotiflac_discord.so", "libdiscord_partner_sdk.so")
|
||||
DISCORD_CLASSES = (
|
||||
b"Lcom/zarz/spotiflac/discord/DiscordNative;",
|
||||
b"Lcom/discord/socialsdk/DiscordSocialSdkInit;",
|
||||
)
|
||||
REMOVED_LIBRARIES = ("libspotiflac_discord.so", "libdiscord_partner_sdk.so")
|
||||
|
||||
|
||||
class AuditError(Exception):
|
||||
@@ -111,21 +107,7 @@ def check_backend_markers(
|
||||
raise AuditError("Go APK contains forbidden libspotiflac_mobile.so")
|
||||
|
||||
|
||||
def check_discord(zf: zipfile.ZipFile, infos: Sequence[zipfile.ZipInfo]) -> None:
|
||||
notices = required_entry(infos, "assets/discord-sdk-notices.txt")
|
||||
if not zf.read(notices).strip():
|
||||
raise AuditError("Discord SDK notices are empty")
|
||||
missing = set(DISCORD_CLASSES)
|
||||
for info in infos:
|
||||
if info.filename.endswith(".dex"):
|
||||
data = zf.read(info)
|
||||
missing = {marker for marker in missing if marker not in data}
|
||||
if missing:
|
||||
raise AuditError("Discord JNI/SDK classes missing from DEX: " +
|
||||
", ".join(sorted(marker.decode() for marker in missing)))
|
||||
|
||||
|
||||
def audit(path: Path, backend: str, abis: Sequence[str], require_discord: bool = False) -> str:
|
||||
def audit(path: Path, backend: str, abis: Sequence[str]) -> str:
|
||||
if not path.is_file():
|
||||
raise AuditError("APK is not a regular file: " + str(path))
|
||||
digest = artifact_sha256(path)
|
||||
@@ -133,6 +115,9 @@ def audit(path: Path, backend: str, abis: Sequence[str], require_discord: bool =
|
||||
with zipfile.ZipFile(path, "r") as zf:
|
||||
infos = zf.infolist()
|
||||
names = [info.filename for info in infos]
|
||||
for name in names:
|
||||
if name.rsplit("/", 1)[-1] in REMOVED_LIBRARIES:
|
||||
raise AuditError("APK contains removed SDK library: " + name)
|
||||
if "assets/flutter_assets/kernel_blob.bin" in names:
|
||||
raise AuditError("debug APK contains assets/flutter_assets/kernel_blob.bin")
|
||||
check_abi_directories(names, abis)
|
||||
@@ -143,9 +128,6 @@ def audit(path: Path, backend: str, abis: Sequence[str], require_discord: bool =
|
||||
libraries = CORE_LIBRARIES + (backend_library,)
|
||||
if backend == "rust":
|
||||
libraries += ("libjnidispatch.so",)
|
||||
if require_discord:
|
||||
check_discord(zf, infos)
|
||||
libraries += DISCORD_LIBRARIES
|
||||
for abi in abis:
|
||||
for library in libraries:
|
||||
entry_path = f"lib/{abi}/{library}"
|
||||
@@ -162,8 +144,6 @@ def make_parser() -> argparse.ArgumentParser:
|
||||
parser.add_argument("apk", type=Path, help="release APK to audit")
|
||||
parser.add_argument("--backend", choices=("rust", "go"), required=True)
|
||||
parser.add_argument("--abis", required=True, metavar="ABI[,ABI...]", help="expected APK ABIs")
|
||||
parser.add_argument("--require-discord", action="store_true",
|
||||
help="require Discord JNI/SDK libraries, classes and notices")
|
||||
return parser
|
||||
|
||||
|
||||
@@ -171,12 +151,11 @@ def main(argv: Sequence[str] = None) -> int:
|
||||
args = make_parser().parse_args(argv)
|
||||
try:
|
||||
abis = parse_abis(args.abis)
|
||||
digest = audit(args.apk, args.backend, abis, args.require_discord)
|
||||
digest = audit(args.apk, args.backend, abis)
|
||||
except (AuditError, OSError) as exc:
|
||||
print("error: " + str(exc), file=sys.stderr)
|
||||
return 1
|
||||
print(f"OK sha256={digest} backend={args.backend} abis={','.join(abis)} "
|
||||
f"discord={'required' if args.require_discord else 'optional'}")
|
||||
print(f"OK sha256={digest} backend={args.backend} abis={','.join(abis)}")
|
||||
return 0
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user