fix(camera): verify system preview parameters in isolated code5 probe

This commit is contained in:
zenord
2026-10-14 13:13:08 +08:00
parent 14f1194a95
commit 57f8763df2
14 changed files with 400 additions and 43 deletions
+1
View File
@@ -20,3 +20,4 @@ with tempfile.TemporaryDirectory(prefix='camera-controller-check-') as folder:
subprocess.run([ns['JAVA'],'-cp',folder+':'+ns['cp'],'CameraProbeCheckKt'],check=True,cwd=ROOT,timeout=30)
subprocess.run([ns['JAVA'],'-cp',folder+':'+ns['cp'],'IsolatedProbeSuiteCheckKt'],check=True,cwd=ROOT,timeout=30)
subprocess.run([ns['JAVA'],'-cp',folder+':'+ns['cp'],'ProbeRecoveryCheckKt'],check=True,cwd=ROOT,timeout=30)
subprocess.run([ns['JAVA'],'-cp',folder+':'+ns['cp'],'SystemParameterCheckKt'],check=True,cwd=ROOT,timeout=30)
+12 -6
View File
@@ -16,16 +16,22 @@ def clock(v,ms=False):
return datetime.datetime.fromtimestamp(v/1000 if ms else v,zoneinfo.ZoneInfo('Asia/Shanghai')).isoformat()
reportdata=get('debug/report');reports=reportdata.get('reports',[])
rows=[]
allowed={'mode','failure','started_ms','finished_ms','bound_ms','open_ms','surface_provided_ms','surface_ack_ms','surface_result_code','surface_created','surface_released','first_frame_ms','frames','analysis_returned','capture_completed','capture_failed','width','height','callback_bytes','native_state','session_failure','close_started_ms','close_returned_ms','closed_ms','close_confirmed','provided_surfaces','acknowledged_surfaces','native_operation','native_call_state','native_call_started_ms','native_call_returned_ms','initial_failure','frame_observation','worker_pid','process_stop_required','process_exit_confirmed','surface_valid_before_attach','surface_valid_before_start','surface_creating_at_attach','surface_width','surface_height','attempted','preflight_availability','availability_wait_ms','previous_close_unconfirmed','surface_preparation','surface_requested_width','surface_requested_height','surface_ready_ms','first_exception_operation','first_exception_kind','session_error_code','camera_error_code'}
allowed={'mode','failure','started_ms','finished_ms','bound_ms','open_ms','surface_provided_ms','surface_ack_ms','surface_result_code','surface_created','surface_released','first_frame_ms','frames','analysis_returned','capture_completed','capture_failed','width','height','callback_bytes','native_state','session_failure','close_started_ms','close_returned_ms','closed_ms','close_confirmed','provided_surfaces','acknowledged_surfaces','native_operation','native_call_state','native_call_started_ms','native_call_returned_ms','initial_failure','frame_observation','worker_pid','process_stop_required','process_exit_confirmed','surface_valid_before_attach','surface_valid_before_start','surface_creating_at_attach','surface_width','surface_height','attempted','preflight_availability','availability_wait_ms','previous_close_unconfirmed','surface_preparation','surface_requested_width','surface_requested_height','surface_ready_ms','first_exception_operation','first_exception_kind','session_error_code','camera_error_code','requested_preview_format','requested_fps_min_milli','requested_fps_max_milli','actual_preview_format','actual_fps_min_milli','actual_fps_max_milli','actual_preview_frame_rate','parameter_readback_verified','system_parameters_matched','supported_fixed_30_fps','fps_ranges_truncated'}
tracekeys={'available','latch_started','latch_completed','first_available_ms','latch_started_ms','latch_completed_ms','worker_heartbeat_ms','result_acks','result_code','consumer_closed'}
def safe(v):return isinstance(v,(int,float,bool)) or isinstance(v,str) and bool(re.fullmatch('[a-zA-Z0-9_]{1,48}',v))
def version(v):return v if isinstance(v,str) and re.fullmatch(r'(?:camera-probe-)?[0-9]{1,3}(?:\.[0-9]{1,3}){1,3}',v) else None
for wrap in reports[-10:]:
r=wrap.get('report',{});p=r.get('camera_probe',{})
row={'received_shanghai':clock(wrap.get('received_at')),'report_shanghai':clock(r.get('timestamp'),True),'version_code':r.get('version_code'),'app_version':r.get('app_version'),'mode':r.get('avatar_runtime',{}).get('mode'),'camera_probe':{}}
for k in ('stage','entry_failure','max_tests','run_limit_ms','close_limit_ms','process_isolated','process_exit_limit_ms','availability_limit_ms'):
code=r.get('version_code');mode=r.get('avatar_runtime',{}).get('mode')
row={'received_shanghai':clock(wrap.get('received_at')),'report_shanghai':clock(r.get('timestamp'),True),'version_code':code if isinstance(code,int) and not isinstance(code,bool) and 0<=code<=2147483647 else None,'app_version':version(r.get('app_version')),'mode':mode if safe(mode) else None,'camera_probe':{}}
for k in ('stage','entry_failure','max_tests','run_limit_ms','close_limit_ms','process_isolated','process_exit_limit_ms','availability_limit_ms','result_count','attempted_count','not_attempted_count','system_parameter_finding','profile_source','system_three_streams_reproduced','universal_third_party_restriction_confirmed'):
if safe(p.get(k)):row['camera_probe'][k]=p[k]
row['camera_probe']['results']=[dict({k:v for k,v in x.items() if k in allowed and safe(v)},preview_trace={k:v for k,v in x.get('preview_trace',{}).items() if k in tracekeys and safe(v)}) for x in p.get('results',[])[:7]]
if r.get('version_code') in (28,29,3,4):
row['camera_probe']['results']=[dict({k:v for k,v in x.items() if k in allowed and safe(v)},preview_trace={k:v for k,v in x.get('preview_trace',{}).items() if k in tracekeys and safe(v)}) for x in p.get('results',[])[:9]]
if isinstance(p.get('planned_modes'),list):row['camera_probe']['planned_modes']=[m for m in p['planned_modes'][:9] if isinstance(m,str) and safe(m)]
for item,rawitem in zip(row['camera_probe']['results'],p.get('results',[])[:9]):
ranges=rawitem.get('supported_fps_ranges_milli',[])
if isinstance(ranges,list):item['supported_fps_ranges_milli']=[v for v in ranges[:16] if isinstance(v,list) and len(v)==2 and all(isinstance(n,int) and not isinstance(n,bool) and 0<=n<=240000 for n in v) and v[0]<=v[1]]
if r.get('version_code') in (28,29,3,4,5):
row['events']=[]
for e in r.get('logs',[]):
msg=e.get('msg','')
@@ -39,7 +45,7 @@ for e in log.get('entries',[]):
msg=e.get('message',e.get('msg',''))
if 'camera_probe ' not in msg:continue
tokens=dict(re.findall(r'(event|mode|elapsed_ms|frames|native|failure|operation|call_state)=([a-zA-Z0-9_\-]+)',msg))
events.append({'ts':e.get('ts'),**tokens})
events.append({'ts':e.get('ts') if isinstance(e.get('ts'),(int,float)) else None,**tokens})
print(json.dumps({'reports':rows,'recent_probe_events':events[-40:]},ensure_ascii=False,indent=2))
"""
+10 -8
View File
@@ -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='4'",
"versionName='camera-probe-0.1.3'", "sdkVersion:'26'", "targetSdkVersion:'34'"):
for value in ("name='com.gorios.lanvoice.cameraprobe'", "versionCode='5'",
"versionName='camera-probe-0.1.4'", "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',
@@ -56,6 +56,8 @@ def verify(apk):
'lib/arm64-v8a/libimage_processing_util_jni.so',
'lib/arm64-v8a/libsurface_util_jni.so'}, 'unexpected native dependency')
dex = b''.join(archive.read(n) for n in paths if re.fullmatch(r'classes\d*\.dex', n))
for mode in ('CAMERA1_SYSTEM_1080_PREVIEW','CAMERA1_SYSTEM_1080_CALLBACK'):
require(mode.encode() in dex, 'system-parameter mode missing: '+mode)
for klass in ('MainActivity', 'VoiceSession', 'ExpressionCameraManager',
'ContinuousBodyRenderer', 'EmotionActionAvatarView'):
require(('Lcom/gorios/lanvoice/'+klass+';').encode() not in dex and
@@ -82,13 +84,13 @@ def verify(apk):
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')
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.3',
'version_code': 4, 'min_sdk': 26, 'target_sdk': 34, 'certificate_sha256': CERT,
return {'package': 'com.gorios.lanvoice.cameraprobe', 'version_name': 'camera-probe-0.1.4',
'version_code': 5, 'min_sdk': 26, 'target_sdk': 34, 'certificate_sha256': CERT,
'abi': 'arm64-v8a', 'assets': 0, 'microphone_permission': False,
'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, 'availability_limit_ms': 5000, 'surface_resize_handshake': True,
'availability_is_streaming_proof': False, 'default_preview_last': True, 'device': 'not_run'}
'camera_tests': 2, 'planned_modes': ['camera1_system_1080_preview','camera1_system_1080_callback'], 'requested_preview': {'width':1920,'height':1080,'format':'nv21','fps_min_milli':30000,'fps_max_milli':30000}, 'process_isolated': True,
'run_limit_ms': 5000, 'close_limit_ms': 2000, 'process_exit_limit_ms': 4000, 'availability_limit_ms': 15000, 'surface_resize_handshake': True,
'availability_is_streaming_proof': False, 'system_three_streams_reproduced': False, 'universal_third_party_restriction_confirmed': False, 'device': 'not_run'}
def main():
parser = argparse.ArgumentParser(description=__doc__)
@@ -101,7 +103,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-v013-code4-debug.apk'
artifact = ROOT/'artifacts/lan-voice-camera-probe-v014-code5-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)