#!/usr/bin/env python3 """Check the shipped native ABI, ELF load alignment and APK zip alignment.""" from pathlib import Path import hashlib import json import struct import sys import zipfile def verify(path): with zipfile.ZipFile(path) as archive, open(path, 'rb') as raw: libraries = [i for i in archive.infolist() if i.filename.endswith('.so')] if [i.filename for i in libraries] != ['lib/arm64-v8a/libcrossdesk_android.so']: raise ValueError('APK must contain exactly the arm64 native controller library') library = libraries[0] data = archive.read(library) if data[:6] != b'\x7fELF\x02\x01' or struct.unpack_from('