fix(camera): isolate first callback session in code7 probe

This commit is contained in:
zenord
2026-10-14 14:06:06 +08:00
parent 7eb7d5f1bc
commit 3371997252
11 changed files with 198 additions and 14 deletions
+2 -2
View File
@@ -37,8 +37,8 @@ android {
applicationId 'com.gorios.lanvoice.cameraprobe'
minSdk 26
targetSdk 34
versionCode 6
versionName 'camera-probe-0.1.5'
versionCode 7
versionName 'camera-probe-0.1.6'
ndk { abiFilters 'arm64-v8a' }
}
compileOptions { sourceCompatibility JavaVersion.VERSION_17; targetCompatibility JavaVersion.VERSION_17 }
@@ -19,7 +19,7 @@ class CameraProbeLauncherActivity: ComponentActivity() {
private var foreground=false
private var pending=false
private var permissionPending by mutableStateOf(false)
private var status by mutableStateOf("点击后对照1920×1080 NV21固定30fps的纯预览及帧回调,结束自动发送报告。")
private var status by mutableStateOf("点击后只检查1920×1080 NV21固定30fps帧回调,作为本轮首个且唯一相机会话,结束自动发送报告。上一轮关闭超时时,请重启设备后直接运行此项。")
private val permission=registerForActivityResult(ActivityResultContracts.RequestPermission()) { granted ->
permissionPending=false
if(granted && pending) startIfReady()
@@ -23,7 +23,7 @@ import com.gorios.lanvoice.expression.*
/** The foreground UI/report owner never calls a native camera API. A private bound worker
* runs one configuration, then must demonstrably exit before the next owner is launched. */
class IsolatedCameraDiagnosticsActivity : ComponentActivity() {
private val plannedModes = IsolatedProbeSuite.SYSTEM_PARAMETER_ORDER
private val plannedModes = IsolatedProbeSuite.SINGLE_CALLBACK_ORDER
private val suite = IsolatedProbeSuite(SystemClock.elapsedRealtime(), requireAvailability = true,
modes = plannedModes, availabilityLimitMs = IsolatedProbeSuite.SYSTEM_AVAILABILITY_LIMIT_MS)
private val main = Handler(Looper.getMainLooper())
@@ -92,8 +92,8 @@ class IsolatedCameraDiagnosticsActivity : ComponentActivity() {
setContent { MaterialTheme {
Column(Modifier.fillMaxSize().windowInsetsPadding(WindowInsets.safeDrawing)
.verticalScroll(rememberScrollState()).padding(16.dp)) {
Text("前置相机系统参数对照", style = MaterialTheme.typography.titleLarge)
Text("按提供参数检查两项:1920×1080、NV21、固定30fps,先纯预览,再计帧回调。只通过FPS区间API设置帧率,参数需设备支持且读回一致。每项采样5秒、关闭等2秒,相机可用最多等15秒;不保存画面、不收音。")
Text("前置相机首会话采集检查", style = MaterialTheme.typography.titleLarge)
Text("只运行一项帧回调:1920×1080、NV21、固定30fps。没有前置纯预览测试,只通过FPS区间API设置帧率,参数需支持且读回一致。采样5秒、关闭等2秒,相机可用最多等15秒;不保存画面、不收音。")
AndroidView(factory = { context -> SurfaceView(context).apply {
holder.addCallback(object : SurfaceHolder.Callback {
override fun surfaceCreated(h: SurfaceHolder) { this@IsolatedCameraDiagnosticsActivity.holder = h }
@@ -122,7 +122,7 @@ class IsolatedCameraDiagnosticsActivity : ComponentActivity() {
if (receipt == "发送失败") TextButton(onClick = ::sendReport) { Text("重发报告") }
TextButton(onClick = { dispatch(suite.cancel(now())) }) { Text("停止诊断并发送") }
TextButton(onClick = { dispatch(suite.cancel(now())); finish() }) { Text("返回") }
Text("纯预览不采样像素,帧0不能证明无画面。相同预览参数不等于复现系统相机的三个输出流;本次失败不能证明全部第三方应用被限制。报告分别记录运行、出帧和关闭状态。")
Text("首项仅表示本轮没有先运行其他配置,不证明驱动已恢复。报告分别记录参数、出帧、原生关闭和进程退出;本次失败不能证明全部第三方应用被限制。")
}
} }
availabilityMonitor = ProbeAvailabilityMonitor(this) { epoch, state -> main.post {
@@ -28,6 +28,8 @@ class IsolatedProbeSuite(private val seed: Long = 0, private val requireAvailabi
// Avoid putting the known default-preview stopPreview stall before all other probes.
val RECOMMENDED_ORDER = CameraProbeMode.STANDARD_MODES.filter { it != CameraProbeMode.CAMERA1_DEFAULT_PREVIEW } + CameraProbeMode.CAMERA1_DEFAULT_PREVIEW
val SYSTEM_PARAMETER_ORDER = listOf(CameraProbeMode.CAMERA1_SYSTEM_1080_PREVIEW,CameraProbeMode.CAMERA1_SYSTEM_1080_CALLBACK)
// No earlier preview/close in this suite may affect the callback comparison.
val SINGLE_CALLBACK_ORDER = listOf(CameraProbeMode.CAMERA1_SYSTEM_1080_CALLBACK)
}
init {
require(modes.isNotEmpty() && modes.size <= CameraProbeMode.entries.size && modes.distinct().size == modes.size)