fix(camera): verify system preview parameters in isolated code5 probe
This commit is contained in:
@@ -37,8 +37,8 @@ android {
|
||||
applicationId 'com.gorios.lanvoice.cameraprobe'
|
||||
minSdk 26
|
||||
targetSdk 34
|
||||
versionCode 4
|
||||
versionName 'camera-probe-0.1.3'
|
||||
versionCode 5
|
||||
versionName 'camera-probe-0.1.4'
|
||||
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("点击后仅检查前置相机,并自动发送状态报告。")
|
||||
private var status by mutableStateOf("点击后对照1920×1080 NV21固定30fps的纯预览及帧回调,结束自动发送报告。")
|
||||
private val permission=registerForActivityResult(ActivityResultContracts.RequestPermission()) { granted ->
|
||||
permissionPending=false
|
||||
if(granted && pending) startIfReady()
|
||||
|
||||
@@ -23,8 +23,9 @@ 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 suite = IsolatedProbeSuite(SystemClock.elapsedRealtime(), requireAvailability = true,
|
||||
modes = IsolatedProbeSuite.RECOMMENDED_ORDER)
|
||||
modes = plannedModes, availabilityLimitMs = IsolatedProbeSuite.SYSTEM_AVAILABILITY_LIMIT_MS)
|
||||
private val main = Handler(Looper.getMainLooper())
|
||||
private var holder: SurfaceHolder? = null
|
||||
private var foreground = false
|
||||
@@ -91,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("七项自动检查,默认预览放最后。每项采样5秒、关闭等待2秒;下一项等待相机可用最多5秒,不可用记为未测试。仅发送状态,不保存画面、不收音。")
|
||||
Text("前置相机系统参数对照", style = MaterialTheme.typography.titleLarge)
|
||||
Text("按提供参数检查两项:1920×1080、NV21、固定30fps,先纯预览,再计帧回调。参数需设备支持且读回一致。每项采样5秒、关闭等2秒,相机可用最多等15秒;不保存画面、不收音。")
|
||||
AndroidView(factory = { context -> SurfaceView(context).apply {
|
||||
holder.addCallback(object : SurfaceHolder.Callback {
|
||||
override fun surfaceCreated(h: SurfaceHolder) { this@IsolatedCameraDiagnosticsActivity.holder = h }
|
||||
@@ -105,7 +106,7 @@ class IsolatedCameraDiagnosticsActivity : ComponentActivity() {
|
||||
}
|
||||
})
|
||||
} }, modifier = Modifier.fillMaxWidth().height(220.dp))
|
||||
Text("配置 ${rows.size}/7 · " + when (phase) {
|
||||
Text("配置 ${rows.size}/${plannedModes.size} · 已运行${rows.count {it.attempted}} / 未运行${rows.count {!it.attempted}} · " + when (phase) {
|
||||
ProbeIsolationPhase.IDLE, ProbeIsolationPhase.STARTING -> "准备预览与工作进程"
|
||||
ProbeIsolationPhase.WAITING_CAMERA -> "等待系统前置相机可用"
|
||||
ProbeIsolationPhase.RUNNING -> "采样中"
|
||||
@@ -121,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("默认 Camera1 项仅预览、没有图像回调,帧0不能证明无画面。进程退出确认不等于原生关闭成功;报告分别记录。")
|
||||
Text("纯预览不采样像素,帧0不能证明无画面。相同预览参数不等于复现系统相机的三个输出流;本次失败不能证明全部第三方应用被限制。报告分别记录运行、出帧和关闭状态。")
|
||||
}
|
||||
} }
|
||||
availabilityMonitor = ProbeAvailabilityMonitor(this) { epoch, state -> main.post {
|
||||
@@ -257,9 +258,9 @@ class IsolatedCameraDiagnosticsActivity : ComponentActivity() {
|
||||
device = "${Build.MANUFACTURER} ${Build.MODEL}", androidApi = Build.VERSION.SDK_INT,
|
||||
connection = "LOCAL_CAMERA_PROBE", voiceActive = false, phase = "IDLE", aec = "NOT_RUNNING",
|
||||
avatarMode = "camera_probe", cameraGranted = checkSelfPermission(Manifest.permission.CAMERA) == PackageManager.PERMISSION_GRANTED,
|
||||
cameraProbeStage = stage, cameraProbes = suite.results, cameraProbeIsolated = true,
|
||||
cameraProbeStage = stage, cameraProbes = suite.results, cameraProbeModes = plannedModes, cameraProbeIsolated = true,
|
||||
cameraProbeRunLimitMs = IsolatedProbeSuite.RUN_LIMIT_MS.toInt(), cameraProbeCloseLimitMs = IsolatedProbeSuite.CLOSE_LIMIT_MS.toInt(), cameraProbeExitLimitMs = IsolatedProbeSuite.EXIT_LIMIT_MS.toInt(),
|
||||
cameraProbeAvailabilityLimitMs = IsolatedProbeSuite.AVAILABILITY_LIMIT_MS.toInt())
|
||||
cameraProbeAvailabilityLimitMs = IsolatedProbeSuite.SYSTEM_AVAILABILITY_LIMIT_MS.toInt())
|
||||
DiagnosticReportUpload.send(info) { ok -> main.post { sending = false; receipt = if (ok) "已自动发送" else "发送失败" } }
|
||||
}
|
||||
override fun onResume() { super.onResume(); hideSystemBars(window); foreground = true; main.post { startIfReady(); bindIfSurfaceReady() } }
|
||||
|
||||
@@ -14,7 +14,8 @@ sealed interface ProbeIsolationEffect {
|
||||
/** Actual parent watchdog policy. A timeout alone NEVER permits overlapping camera owners.
|
||||
* Native close ACK and confirmed process death are different facts in every result. */
|
||||
class IsolatedProbeSuite(private val seed: Long = 0, private val requireAvailability: Boolean = false,
|
||||
private val modes: List<CameraProbeMode> = CameraProbeMode.entries.toList()) {
|
||||
private val modes: List<CameraProbeMode> = CameraProbeMode.STANDARD_MODES,
|
||||
private val availabilityLimitMs: Long = AVAILABILITY_LIMIT_MS) {
|
||||
companion object {
|
||||
const val START_LIMIT_MS = 4_000L
|
||||
const val RUN_LIMIT_MS = 5_000L
|
||||
@@ -23,10 +24,15 @@ class IsolatedProbeSuite(private val seed: Long = 0, private val requireAvailabi
|
||||
const val SETTLE_MS = 500L
|
||||
const val AVAILABILITY_LIMIT_MS = 5_000L
|
||||
const val AVAILABLE_STABLE_MS = 500L
|
||||
const val SYSTEM_AVAILABILITY_LIMIT_MS = 15_000L
|
||||
// Avoid putting the known default-preview stopPreview stall before all other probes.
|
||||
val RECOMMENDED_ORDER = CameraProbeMode.entries.filter { it != CameraProbeMode.CAMERA1_DEFAULT_PREVIEW } + CameraProbeMode.CAMERA1_DEFAULT_PREVIEW
|
||||
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)
|
||||
}
|
||||
init {
|
||||
require(modes.isNotEmpty() && modes.size <= CameraProbeMode.entries.size && modes.distinct().size == modes.size)
|
||||
require(availabilityLimitMs in AVAILABILITY_LIMIT_MS..SYSTEM_AVAILABILITY_LIMIT_MS)
|
||||
}
|
||||
init { require(modes.isNotEmpty() && modes.size <= 7 && modes.distinct().size == modes.size) }
|
||||
var phase = ProbeIsolationPhase.IDLE; private set
|
||||
var epoch = seed; private set
|
||||
var results: List<CameraProbeResult> = emptyList(); private set
|
||||
@@ -68,7 +74,7 @@ class IsolatedProbeSuite(private val seed: Long = 0, private val requireAvailabi
|
||||
phase = ProbeIsolationPhase.STARTING; since = now
|
||||
return listOf(ProbeIsolationEffect.Start(epoch, checkNotNull(current).mode))
|
||||
}
|
||||
if (availability == ProbeCameraAvailability.NO_FRONT || now - since >= AVAILABILITY_LIMIT_MS) {
|
||||
if (availability == ProbeCameraAvailability.NO_FRONT || now - since >= availabilityLimitMs) {
|
||||
val failure = when (availability) {
|
||||
ProbeCameraAvailability.NO_FRONT -> CameraProbeFailure.NO_FRONT
|
||||
ProbeCameraAvailability.UNAVAILABLE -> CameraProbeFailure.CAMERA_UNAVAILABLE
|
||||
|
||||
Reference in New Issue
Block a user