File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed
liveness/src/main/java/com/amplifyframework/ui/liveness/camera Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -50,6 +50,7 @@ import java.util.concurrent.Executors
50
50
import kotlin.coroutines.resume
51
51
import kotlin.coroutines.suspendCoroutine
52
52
import kotlinx.coroutines.MainScope
53
+ import kotlinx.coroutines.delay
53
54
import kotlinx.coroutines.launch
54
55
55
56
internal typealias OnMuxedSegment = (bytes: ByteArray , timestamp: Long ) -> Unit
@@ -137,6 +138,16 @@ internal class LivenessCoordinator(
137
138
private var disconnectEventReceived = false
138
139
139
140
init {
141
+ MainScope ().launch {
142
+ delay(5_000 )
143
+ if (! previewTextureView.hasReceivedUpdate) {
144
+ val faceLivenessException = FaceLivenessDetectionException (
145
+ " The camera failed to open within the allowed time limit." ,
146
+ " Ensure the camera is available to use and that no other apps are using it."
147
+ )
148
+ processSessionError(faceLivenessException, true )
149
+ }
150
+ }
140
151
MainScope ().launch {
141
152
getCameraProvider(context).apply {
142
153
if (lifecycleOwner.lifecycle.currentState != Lifecycle .State .DESTROYED ) {
Original file line number Diff line number Diff line change @@ -31,6 +31,7 @@ internal class PreviewTextureView(
31
31
) : TextureView(context) {
32
32
33
33
private var surface: Surface ? = null
34
+ internal var hasReceivedUpdate = false
34
35
35
36
init {
36
37
surfaceTextureListener = object : SurfaceTextureListener {
@@ -48,7 +49,11 @@ internal class PreviewTextureView(
48
49
}
49
50
}
50
51
51
- override fun onSurfaceTextureUpdated (surfaceTexture : SurfaceTexture ) {}
52
+ override fun onSurfaceTextureUpdated (surfaceTexture : SurfaceTexture ) {
53
+ if (! hasReceivedUpdate) {
54
+ hasReceivedUpdate = true
55
+ }
56
+ }
52
57
53
58
override fun onSurfaceTextureSizeChanged (
54
59
surfaceTexture : SurfaceTexture ,
You can’t perform that action at this time.
0 commit comments