feat(discord): add opt-in mobile rich presence with track artwork

This commit is contained in:
zarzet committed 2026-10-03 02:14:11 +07:00
1 parent bbe2caa754
commit 0b2cf0e4e5
40 files changed
+1839 -18

No files matched your search

+8 -5
View File
@@ -15,7 +15,7 @@ ABI_LAYOUT = {
"armeabi-v7a": (1, 40),
}
CORE_LIBRARIES = ("libapp.so", "libflutter.so")
REMOVED_LIBRARIES = ("libspotiflac_discord.so", "libdiscord_partner_sdk.so")
DISCORD_LIBRARIES = ("libspotiflac_discord.so", "libdiscord_partner_sdk.so")
class AuditError(Exception):
@@ -107,7 +107,7 @@ def check_backend_markers(
raise AuditError("Go APK contains forbidden libspotiflac_mobile.so")
def audit(path: Path, backend: str, abis: Sequence[str]) -> str:
def audit(path: Path, backend: str, abis: Sequence[str], discord_sdk: bool = False) -> str:
if not path.is_file():
raise AuditError("APK is not a regular file: " + str(path))
digest = artifact_sha256(path)
@@ -116,8 +116,8 @@ def audit(path: Path, backend: str, abis: Sequence[str]) -> str:
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 not discord_sdk and name.rsplit("/", 1)[-1] == "libdiscord_partner_sdk.so":
raise AuditError("APK unexpectedly contains Discord 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)
@@ -128,6 +128,8 @@ def audit(path: Path, backend: str, abis: Sequence[str]) -> str:
libraries = CORE_LIBRARIES + (backend_library,)
if backend == "rust":
libraries += ("libjnidispatch.so",)
if discord_sdk:
libraries += DISCORD_LIBRARIES
for abi in abis:
for library in libraries:
entry_path = f"lib/{abi}/{library}"
@@ -144,6 +146,7 @@ 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("--discord-sdk", action="store_true", help="require Discord SDK and bridge in every ABI")
return parser
@@ -151,7 +154,7 @@ 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)
digest = audit(args.apk, args.backend, abis, args.discord_sdk)
except (AuditError, OSError) as exc:
print("error: " + str(exc), file=sys.stderr)
return 1