Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ea90f3d6 authored by Chandru S's avatar Chandru S Committed by Android (Google) Code Review
Browse files

Merge "Create cancellation signal closer to where face detection runs" into main

parents 752f215f cec525e8
Loading
Loading
Loading
Loading
+10 −8
Original line number Original line Diff line number Diff line
@@ -626,19 +626,21 @@ constructor(
            faceAuthLogger.skippingDetection(_isAuthRunning.value, detectCancellationSignal != null)
            faceAuthLogger.skippingDetection(_isAuthRunning.value, detectCancellationSignal != null)
            return
            return
        }
        }
        detectCancellationSignal?.cancel()
        detectCancellationSignal = CancellationSignal()
        withContext(mainDispatcher) {
        withContext(mainDispatcher) {
            // We always want to invoke face detect in the main thread.
            // We always want to invoke face detect in the main thread.
            faceAuthLogger.faceDetectionStarted()
            faceAuthLogger.faceDetectionStarted()
            detectCancellationSignal?.cancel()
            detectCancellationSignal = CancellationSignal()
            detectCancellationSignal?.let {
                faceManager?.detectFace(
                faceManager?.detectFace(
                checkNotNull(detectCancellationSignal),
                    it,
                    detectionCallback,
                    detectionCallback,
                    SysUiFaceAuthenticateOptions(currentUserId, uiEvent, uiEvent.extraInfo)
                    SysUiFaceAuthenticateOptions(currentUserId, uiEvent, uiEvent.extraInfo)
                        .toFaceAuthenticateOptions()
                        .toFaceAuthenticateOptions()
                )
                )
            }
            }
        }
        }
    }


    private val currentUserId: Int
    private val currentUserId: Int
        get() = userRepository.getSelectedUserInfo().id
        get() = userRepository.getSelectedUserInfo().id