diff --git a/tests/apk_fixtures.py b/tests/apk_fixtures.py new file mode 100644 index 0000000..20cf7bf --- /dev/null +++ b/tests/apk_fixtures.py @@ -0,0 +1,87 @@ +"""Small APKs built in memory (binary manifest plus resource table), for test_frame_apk +and the end-to-end tests. Deliberately doesn't import sandbox: tests/e2e runs in a +throwaway container and keeps its real home, which sandbox would move.""" +import io +import os +import struct +import sys +import zipfile + +sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), 'ui')) +import frame_apk # noqa: E402 + + +def pool(strings, utf8=False): + """A ResStringPool chunk.""" + data, offsets = b'', [] + for s in strings: + offsets.append(len(data)) + if utf8: + b = s.encode() + data += bytes([len(s), len(b)]) + b + b'\0' + else: + data += struct.pack('. + + package_raw=False drops the package's raw string (as some repackers do); + foreign_label adds a non-android `label` attribute after android:label. + """ + strings = ['label', 'icon', 'versionName', 'minSdkVersion', 'package', 'manifest', 'uses-sdk', + 'application', package, 'junk', 'label', 'versionCode'] # the second 'label' has no android id + resmap = struct.pack('<4I', 0x01010001, 0x01010002, 0x0101021c, 0x0101020c) + resmap = struct.pack('. - - package_raw=False drops the package's raw string (as some repackers do); - foreign_label adds a non-android `label` attribute after android:label. - """ - strings = ['label', 'icon', 'versionName', 'minSdkVersion', 'package', 'manifest', 'uses-sdk', - 'application', package, 'junk', 'label', 'versionCode'] # the second 'label' has no android id - resmap = struct.pack('<4I', 0x01010001, 0x01010002, 0x0101021c, 0x0101020c) - resmap = struct.pack('