fix(camera): isolate stalled diagnostic modes and gate preview surfaces
This commit is contained in:
@@ -32,8 +32,8 @@ def digest(path):
|
||||
|
||||
def verify(apk):
|
||||
badge = subprocess.check_output([str(TOOLS/'aapt'), 'dump', 'badging', str(apk)], text=True)
|
||||
for value in ("name='com.gorios.lanvoice.cameraprobe'", "versionCode='2'",
|
||||
"versionName='camera-probe-0.1.1'", "sdkVersion:'26'", "targetSdkVersion:'34'"):
|
||||
for value in ("name='com.gorios.lanvoice.cameraprobe'", "versionCode='3'",
|
||||
"versionName='camera-probe-0.1.2'", "sdkVersion:'26'", "targetSdkVersion:'34'"):
|
||||
require(value in badge, 'APK metadata: '+value)
|
||||
permissions = set(re.findall(r"^uses-permission: name='([^']+)'", badge, re.M))
|
||||
require(permissions == {'android.permission.CAMERA', 'android.permission.INTERNET',
|
||||
@@ -41,6 +41,11 @@ def verify(apk):
|
||||
'unexpected permissions')
|
||||
native = re.search(r'^native-code: (.+)$', badge, re.M)
|
||||
require(native is not None and native[1].strip() == "'arm64-v8a'", 'unexpected native ABI')
|
||||
manifest = subprocess.check_output([str(TOOLS/'aapt'), 'dump', 'xmltree', str(apk), 'AndroidManifest.xml'], text=True)
|
||||
services = re.findall(r'^ E: service .*?(?=^ E:|\Z)', manifest, re.M | re.S)
|
||||
worker = next((s for s in services if '"com.gorios.lanvoice.CameraProbeWorkerService"' in s), '')
|
||||
require('android:exported(0x01010010)=(type 0x12)0x0' in worker and
|
||||
'android:process(0x01010011)=":camera_probe_worker"' in worker, 'worker not privately process-isolated in actual APK')
|
||||
cert = subprocess.check_output([str(TOOLS/'apksigner'), 'verify', '--verbose', '--print-certs', str(apk)], text=True)
|
||||
require(re.search(r'Signer #1 certificate SHA-256 digest: (\w+)', cert)[1] == CERT, 'debug certificate drift')
|
||||
with zipfile.ZipFile(apk) as archive:
|
||||
@@ -60,6 +65,9 @@ def verify(apk):
|
||||
require(b'Lcom/google/mediapipe/' not in dex, 'face model dependency included')
|
||||
for klass in ('Lcom/gorios/lanvoice/CameraDiagnosticsActivity;',
|
||||
'Lcom/gorios/lanvoice/CameraProbeLauncherActivity;',
|
||||
'Lcom/gorios/lanvoice/IsolatedCameraDiagnosticsActivity;',
|
||||
'Lcom/gorios/lanvoice/CameraProbeWorkerService;',
|
||||
'Lcom/gorios/lanvoice/IsolatedProbeSuite;',
|
||||
'Lcom/gorios/lanvoice/expression/CameraProbeController;',
|
||||
'Lcom/gorios/lanvoice/diag/DiagnosticReportUpload;'):
|
||||
require(klass.encode() in dex, 'missing production diagnostic component: '+klass)
|
||||
@@ -72,10 +80,13 @@ def verify(apk):
|
||||
sources[name] = digest(source)
|
||||
trust = ROOT/'camera-probe/build/generated/cameraTrust/res/raw/gateway_cert.pem'
|
||||
require(trust.read_bytes() == (ROOT/'app/src/main/res/raw/gateway_cert.pem').read_bytes(), 'gateway trust drift')
|
||||
return {'package': 'com.gorios.lanvoice.cameraprobe', 'version_name': 'camera-probe-0.1.1',
|
||||
'version_code': 2, 'min_sdk': 26, 'target_sdk': 34, 'certificate_sha256': CERT,
|
||||
camera_sources = {str(p.relative_to(ROOT)): digest(p) for p in sorted((ROOT/'camera-probe/src').rglob('*')) if p.is_file()}
|
||||
return {'package': 'com.gorios.lanvoice.cameraprobe', 'version_name': 'camera-probe-0.1.2',
|
||||
'version_code': 3, 'min_sdk': 26, 'target_sdk': 34, 'certificate_sha256': CERT,
|
||||
'abi': 'arm64-v8a', 'assets': 0, 'microphone_permission': False,
|
||||
'shared_production_sources': sources, 'camera_tests': 7, 'device': 'not_run'}
|
||||
'shared_production_sources': sources, 'camera_application_sources': camera_sources,
|
||||
'camera_tests': 7, 'process_isolated': True,
|
||||
'run_limit_ms': 5000, 'close_limit_ms': 2000, 'process_exit_limit_ms': 4000, 'device': 'not_run'}
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
@@ -88,7 +99,7 @@ def main():
|
||||
subprocess.run([str(ROOT/'scripts/build.sh'), ':camera-probe:assembleDebug'], cwd=ROOT, check=True)
|
||||
built = ROOT/'camera-probe/build/outputs/apk/debug/camera-probe-debug.apk'
|
||||
report = verify(built)
|
||||
artifact = ROOT/'artifacts/lan-voice-camera-probe-v011-code2-debug.apk'
|
||||
artifact = ROOT/'artifacts/lan-voice-camera-probe-v012-code3-debug.apk'
|
||||
require(not artifact.exists() and not artifact.with_suffix('.apk.sha256').exists(), 'published camera version occupied')
|
||||
with artifact.open('xb') as target, built.open('rb') as source:
|
||||
shutil.copyfileobj(source, target)
|
||||
@@ -106,7 +117,7 @@ def main():
|
||||
http_bytes_verified=True, paid_calls=0, model_calls=0)
|
||||
output.parent.mkdir(parents=True, exist_ok=True)
|
||||
output.write_text(json.dumps(report, indent=2)+'\n')
|
||||
print(json.dumps({k:v for k,v in report.items() if k!='shared_production_sources'}, indent=2))
|
||||
print(json.dumps({k:v for k,v in report.items() if k not in ('shared_production_sources','camera_application_sources')}, indent=2))
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
||||
Reference in New Issue
Block a user