fix: pair front camera analysis with a local drained preview surface

This commit is contained in:
zenord
2026-10-13 18:54:59 +08:00
parent 4010675f8c
commit 688bb7d6b3
20 changed files with 453 additions and 24 deletions
+6 -3
View File
@@ -2,12 +2,15 @@ package androidx.camera.lifecycle
import androidx.camera.core.*
class ProcessCameraProvider {
val camera=Camera();val bindings=mutableListOf<ImageAnalysis>();val unbound=mutableListOf<ImageAnalysis>()
val previews=mutableListOf<Preview>();val unboundPreviews=mutableListOf<Preview>()
var throwBind=false
fun hasCamera(s: CameraSelector)=true
fun bindToLifecycle(l: androidx.lifecycle.LifecycleOwner,s: CameraSelector,a: ImageAnalysis): Camera {
if(throwBind) {throwBind=false;error("synthetic_bind_error")};bindings+=a;return camera
fun bindToLifecycle(l: androidx.lifecycle.LifecycleOwner,s: CameraSelector,vararg cases: UseCase): Camera {
if(throwBind) {throwBind=false;error("synthetic_bind_error")}
check(cases.size==2 && cases[0] is Preview && cases[1] is ImageAnalysis)
bindings+=cases.filterIsInstance<ImageAnalysis>();previews+=cases.filterIsInstance<Preview>();return camera
}
fun unbind(a: ImageAnalysis) {unbound+=a}
fun unbind(vararg cases: UseCase) {unbound+=cases.filterIsInstance<ImageAnalysis>();unboundPreviews+=cases.filterIsInstance<Preview>()}
class Future(val provider: ProcessCameraProvider) {
fun get()=provider
fun addListener(r: Runnable,e: java.util.concurrent.Executor) {e.execute(r)}