Files
podlite/tools/check_dex.py
T
XoséandClaude Opus 5.5 666a7eb8cd Podlite 1.12: a build for Android 4.1 (Xperia J) with ExoPlayer, speed and skip silences
- One build per Android level, as in Tenda and Plexamp Lite: build/Podlite.apk (Android 2.2+, versionCode 1308) and
  build/Podlite-api16.apk (Android 4.1+, 1316), from shared src/ plus platform/api8 or platform/api16; build.sh now
  runs on the local toolchain (aapt2, dx or R8, signapk.py; the JKS key converted for the run).
- Android 4.1 build: ExoPlayer 2.18.7 behind an Engine interface, with playback speed (player header) and skipping
  silences (Settings), a 3-minute buffer and MediaPlayer as fallback for audio it can't decode; a notification and
  lock screen with the cover and buttons; Holo; a menu button on phones without a Menu key; metered networks for
  "download on Wi-Fi only".
- Both builds: tlskit's Http.abort fix (a finished response's pooled connection is no longer closed under a later
  request); the lock screen's and newer headsets' play/pause keys.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-01 21:56:18 +01:00

29 lines
1.2 KiB
Python

#!/usr/bin/env python3
"""Checks the dex inside an APK the way Dalvik's dexopt does at install time: format version,
size, Adler-32, SHA-1, no post-035 sections. usage: check_dex.py app.apk"""
import hashlib
import struct
import sys
import zipfile
import zlib
d = zipfile.ZipFile(sys.argv[1]).read("classes.dex")
problems = []
if d[:8] != b"dex\n035\x00":
problems.append("dex version %r (Android 2.3 needs 035)" % d[:8])
if struct.unpack("<I", d[32:36])[0] != len(d):
problems.append("file_size field wrong")
if zlib.adler32(d[12:]) & 0xFFFFFFFF != struct.unpack("<I", d[8:12])[0]:
problems.append("Adler-32 checksum wrong")
if hashlib.sha1(d[32:]).digest() != d[12:32]:
problems.append("SHA-1 signature wrong")
map_off = struct.unpack("<I", d[52:56])[0]
for i in range(struct.unpack("<I", d[map_off:map_off + 4])[0]):
t = struct.unpack("<H", d[map_off + 4 + i * 12:map_off + 6 + i * 12])[0]
if t in (7, 8):
problems.append("contains call_site/method_handle sections (needs Android 8+)")
for p in problems:
print("DEX PROBLEM:", p)
print("classes.dex: %d bytes, %s" % (len(d), "OK" if not problems else "REJECTED"))
sys.exit(1 if problems else 0)