diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java b/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java index 518baec6b089e..8f03eede1b1eb 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java @@ -4543,13 +4543,18 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab * Cancels all operations in the scheduler if it is hung for 10 seconds. */ public void startBiometricWatchdog() { - if (mFaceManager != null && !isFaceAuthInteractorEnabled()) { - mLogger.scheduleWatchdog("face"); - mFaceManager.scheduleWatchdog(); - } - if (mFpm != null) { - mLogger.scheduleWatchdog("fingerprint"); - mFpm.scheduleWatchdog(); - } + final boolean isFaceAuthInteractorEnabled = isFaceAuthInteractorEnabled(); + mBackgroundExecutor.execute(() -> { + Trace.beginSection("#startBiometricWatchdog"); + if (mFaceManager != null && !isFaceAuthInteractorEnabled) { + mLogger.scheduleWatchdog("face"); + mFaceManager.scheduleWatchdog(); + } + if (mFpm != null) { + mLogger.scheduleWatchdog("fingerprint"); + mFpm.scheduleWatchdog(); + } + Trace.endSection(); + }); } } diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/data/repository/DeviceEntryFaceAuthRepository.kt b/packages/SystemUI/src/com/android/systemui/keyguard/data/repository/DeviceEntryFaceAuthRepository.kt index 3d8f6fd40e6b4..a3d1abedcc2cb 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/data/repository/DeviceEntryFaceAuthRepository.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/data/repository/DeviceEntryFaceAuthRepository.kt @@ -31,6 +31,7 @@ import com.android.systemui.common.coroutine.ChannelExt.trySendWithFailureLoggin import com.android.systemui.common.coroutine.ConflatedCallbackFlow.conflatedCallbackFlow import com.android.systemui.dagger.SysUISingleton import com.android.systemui.dagger.qualifiers.Application +import com.android.systemui.dagger.qualifiers.Background import com.android.systemui.dagger.qualifiers.Main import com.android.systemui.dump.DumpManager import com.android.systemui.flags.FeatureFlags @@ -126,6 +127,7 @@ constructor( private val keyguardBypassController: KeyguardBypassController? = null, @Application private val applicationScope: CoroutineScope, @Main private val mainDispatcher: CoroutineDispatcher, + @Background private val backgroundDispatcher: CoroutineDispatcher, private val sessionTracker: SessionTracker, private val uiEventsLogger: UiEventLogger, private val faceAuthLogger: FaceAuthenticationLogger, @@ -228,8 +230,12 @@ constructor( keyguardTransitionInteractor.anyStateToGoneTransition .filter { it.transitionState == TransitionState.FINISHED } .onEach { - faceAuthLogger.watchdogScheduled() - faceManager?.scheduleWatchdog() + // We deliberately want to run this in background because scheduleWatchdog does + // a Binder IPC. + withContext(backgroundDispatcher) { + faceAuthLogger.watchdogScheduled() + faceManager?.scheduleWatchdog() + } } .launchIn(applicationScope) } diff --git a/packages/SystemUI/tests/src/com/android/systemui/keyguard/data/repository/DeviceEntryFaceAuthRepositoryTest.kt b/packages/SystemUI/tests/src/com/android/systemui/keyguard/data/repository/DeviceEntryFaceAuthRepositoryTest.kt index d62db5d1b8903..020c0b22ba27d 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/keyguard/data/repository/DeviceEntryFaceAuthRepositoryTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/keyguard/data/repository/DeviceEntryFaceAuthRepositoryTest.kt @@ -228,6 +228,7 @@ class DeviceEntryFaceAuthRepositoryTest : SysuiTestCase() { bypassControllerOverride, testScope.backgroundScope, testDispatcher, + testDispatcher, sessionTracker, uiEventLogger, FaceAuthenticationLogger(logcatLogBuffer("DeviceEntryFaceAuthRepositoryLog")),