Merge "Launch coroutines in the repository only if the refactor flag is enabled" into udc-dev

This commit is contained in:
Chandru S
2023-04-29 00:03:12 +00:00
committed by Android (Google) Code Review
5 changed files with 72 additions and 27 deletions

View File

@@ -4379,9 +4379,11 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
*/
public void startBiometricWatchdog() {
if (mFaceManager != null && !isFaceAuthInteractorEnabled()) {
mLogger.scheduleWatchdog("face");
mFaceManager.scheduleWatchdog();
}
if (mFpm != null) {
mLogger.scheduleWatchdog("fingerprint");
mFpm.scheduleWatchdog();
}
}

View File

@@ -67,8 +67,10 @@ constructor(@KeyguardUpdateMonitorLog private val logBuffer: LogBuffer) {
"ActiveUnlock",
DEBUG,
{ int1 = wakeReason },
{ "Skip requesting active unlock from wake reason that doesn't trigger face auth" +
" reason=${PowerManager.wakeReasonToString(int1)}" }
{
"Skip requesting active unlock from wake reason that doesn't trigger face auth" +
" reason=${PowerManager.wakeReasonToString(int1)}"
}
)
}
@@ -207,17 +209,27 @@ constructor(@KeyguardUpdateMonitorLog private val logBuffer: LogBuffer) {
}
fun logFaceDetected(userId: Int, isStrongBiometric: Boolean) {
logBuffer.log(TAG, DEBUG, {
int1 = userId
bool1 = isStrongBiometric
}, {"Face detected: userId: $int1, isStrongBiometric: $bool1"})
logBuffer.log(
TAG,
DEBUG,
{
int1 = userId
bool1 = isStrongBiometric
},
{ "Face detected: userId: $int1, isStrongBiometric: $bool1" }
)
}
fun logFingerprintDetected(userId: Int, isStrongBiometric: Boolean) {
logBuffer.log(TAG, DEBUG, {
int1 = userId
bool1 = isStrongBiometric
}, {"Fingerprint detected: userId: $int1, isStrongBiometric: $bool1"})
logBuffer.log(
TAG,
DEBUG,
{
int1 = userId
bool1 = isStrongBiometric
},
{ "Fingerprint detected: userId: $int1, isStrongBiometric: $bool1" }
)
}
fun logFingerprintError(msgId: Int, originalErrMsg: String) {
@@ -669,13 +681,10 @@ constructor(@KeyguardUpdateMonitorLog private val logBuffer: LogBuffer) {
}
fun logHandleBatteryUpdate(isInteresting: Boolean) {
logBuffer.log(
TAG,
DEBUG,
{
bool1 = isInteresting
},
{ "handleBatteryUpdate: $bool1" }
)
logBuffer.log(TAG, DEBUG, { bool1 = isInteresting }, { "handleBatteryUpdate: $bool1" })
}
fun scheduleWatchdog(@CompileTimeConstant watchdogType: String) {
logBuffer.log(TAG, DEBUG, "Scheduling biometric watchdog for $watchdogType")
}
}

View File

@@ -32,6 +32,8 @@ import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.qualifiers.Application
import com.android.systemui.dagger.qualifiers.Main
import com.android.systemui.dump.DumpManager
import com.android.systemui.flags.FeatureFlags
import com.android.systemui.flags.Flags
import com.android.systemui.keyguard.domain.interactor.AlternateBouncerInteractor
import com.android.systemui.keyguard.domain.interactor.KeyguardInteractor
import com.android.systemui.keyguard.domain.interactor.KeyguardTransitionInteractor
@@ -42,6 +44,7 @@ import com.android.systemui.keyguard.shared.model.ErrorAuthenticationStatus
import com.android.systemui.keyguard.shared.model.FailedAuthenticationStatus
import com.android.systemui.keyguard.shared.model.HelpAuthenticationStatus
import com.android.systemui.keyguard.shared.model.SuccessAuthenticationStatus
import com.android.systemui.keyguard.shared.model.TransitionState
import com.android.systemui.keyguard.shared.model.WakefulnessModel
import com.android.systemui.log.FaceAuthenticationLogger
import com.android.systemui.log.SessionTracker
@@ -63,6 +66,7 @@ import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.filter
import kotlinx.coroutines.flow.filterNotNull
import kotlinx.coroutines.flow.flowOf
import kotlinx.coroutines.flow.launchIn
@@ -135,6 +139,7 @@ constructor(
@FaceDetectTableLog private val faceDetectLog: TableLogBuffer,
@FaceAuthTableLog private val faceAuthLog: TableLogBuffer,
private val keyguardTransitionInteractor: KeyguardTransitionInteractor,
private val featureFlags: FeatureFlags,
dumpManager: DumpManager,
) : DeviceEntryFaceAuthRepository, Dumpable {
private var authCancellationSignal: CancellationSignal? = null
@@ -212,15 +217,21 @@ constructor(
.collect(Collectors.toSet())
dumpManager.registerCriticalDumpable("DeviceEntryFaceAuthRepositoryImpl", this)
observeFaceAuthGatingChecks()
observeFaceDetectGatingChecks()
observeFaceAuthResettingConditions()
listenForSchedulingWatchdog()
if (featureFlags.isEnabled(Flags.FACE_AUTH_REFACTOR)) {
observeFaceAuthGatingChecks()
observeFaceDetectGatingChecks()
observeFaceAuthResettingConditions()
listenForSchedulingWatchdog()
}
}
private fun listenForSchedulingWatchdog() {
keyguardTransitionInteractor.anyStateToGoneTransition
.onEach { faceManager?.scheduleWatchdog() }
.filter { it.transitionState == TransitionState.FINISHED }
.onEach {
faceAuthLogger.watchdogScheduled()
faceManager?.scheduleWatchdog()
}
.launchIn(applicationScope)
}

View File

@@ -261,4 +261,8 @@ constructor(
{ "Attempting face auth again because of HW error: retry attempt $int1" }
)
}
fun watchdogScheduled() {
logBuffer.log(TAG, DEBUG, "FaceManager Biometric watchdog scheduled.")
}
}

View File

@@ -54,6 +54,7 @@ import com.android.systemui.keyguard.shared.model.ErrorAuthenticationStatus
import com.android.systemui.keyguard.shared.model.HelpAuthenticationStatus
import com.android.systemui.keyguard.shared.model.KeyguardState
import com.android.systemui.keyguard.shared.model.SuccessAuthenticationStatus
import com.android.systemui.keyguard.shared.model.TransitionState
import com.android.systemui.keyguard.shared.model.TransitionStep
import com.android.systemui.keyguard.shared.model.WakeSleepReason
import com.android.systemui.keyguard.shared.model.WakefulnessModel
@@ -234,6 +235,7 @@ class DeviceEntryFaceAuthRepositoryTest : SysuiTestCase() {
faceDetectBuffer,
faceAuthBuffer,
keyguardTransitionInteractor,
featureFlags,
dumpManager,
)
}
@@ -612,6 +614,7 @@ class DeviceEntryFaceAuthRepositoryTest : SysuiTestCase() {
authStatus()
detectStatus()
authRunning()
bypassEnabled()
lockedOut()
canFaceAuthRun()
authenticated()
@@ -847,7 +850,11 @@ class DeviceEntryFaceAuthRepositoryTest : SysuiTestCase() {
fun schedulesFaceManagerWatchdogWhenKeyguardIsGoneFromDozing() =
testScope.runTest {
keyguardTransitionRepository.sendTransitionStep(
TransitionStep(from = KeyguardState.DOZING, to = KeyguardState.GONE)
TransitionStep(
from = KeyguardState.DOZING,
to = KeyguardState.GONE,
transitionState = TransitionState.FINISHED
)
)
runCurrent()
@@ -858,7 +865,11 @@ class DeviceEntryFaceAuthRepositoryTest : SysuiTestCase() {
fun schedulesFaceManagerWatchdogWhenKeyguardIsGoneFromAod() =
testScope.runTest {
keyguardTransitionRepository.sendTransitionStep(
TransitionStep(from = KeyguardState.AOD, to = KeyguardState.GONE)
TransitionStep(
from = KeyguardState.AOD,
to = KeyguardState.GONE,
transitionState = TransitionState.FINISHED
)
)
runCurrent()
@@ -869,7 +880,11 @@ class DeviceEntryFaceAuthRepositoryTest : SysuiTestCase() {
fun schedulesFaceManagerWatchdogWhenKeyguardIsGoneFromLockscreen() =
testScope.runTest {
keyguardTransitionRepository.sendTransitionStep(
TransitionStep(from = KeyguardState.LOCKSCREEN, to = KeyguardState.GONE)
TransitionStep(
from = KeyguardState.LOCKSCREEN,
to = KeyguardState.GONE,
transitionState = TransitionState.FINISHED
)
)
runCurrent()
@@ -880,7 +895,11 @@ class DeviceEntryFaceAuthRepositoryTest : SysuiTestCase() {
fun schedulesFaceManagerWatchdogWhenKeyguardIsGoneFromBouncer() =
testScope.runTest {
keyguardTransitionRepository.sendTransitionStep(
TransitionStep(from = KeyguardState.PRIMARY_BOUNCER, to = KeyguardState.GONE)
TransitionStep(
from = KeyguardState.PRIMARY_BOUNCER,
to = KeyguardState.GONE,
transitionState = TransitionState.FINISHED
)
)
runCurrent()