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

Commit cc75da70 authored by Jernej Virag's avatar Jernej Virag
Browse files

Issue scheduleWatchdog command on background thread

FaceManager/FingerprintManager#scheduleWatchdog commands do Binder IPC
in fire-and-forget manner. Move them to background thread to avoid
binder jank.

Bug: 279928682
Test: DeviceEntryFaceAuthRepository is covered by passing unit tests.
      Tested face auth change on a cheetah.
Change-Id: I8a0e6578dc871cbb5e08aef9250d174f79c4f765
parent fb2767b4
Loading
Loading
Loading
Loading
+13 −8
Original line number Diff line number Diff line
@@ -4543,7 +4543,10 @@ 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()) {
        final boolean isFaceAuthInteractorEnabled = isFaceAuthInteractorEnabled();
        mBackgroundExecutor.execute(() -> {
            Trace.beginSection("#startBiometricWatchdog");
            if (mFaceManager != null && !isFaceAuthInteractorEnabled) {
                mLogger.scheduleWatchdog("face");
                mFaceManager.scheduleWatchdog();
            }
@@ -4551,5 +4554,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
                mLogger.scheduleWatchdog("fingerprint");
                mFpm.scheduleWatchdog();
            }
            Trace.endSection();
        });
    }
}
+8 −2
Original line number Diff line number Diff line
@@ -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,9 +230,13 @@ constructor(
        keyguardTransitionInteractor.anyStateToGoneTransition
            .filter { it.transitionState == TransitionState.FINISHED }
            .onEach {
                // We deliberately want to run this in background because scheduleWatchdog does
                // a Binder IPC.
                withContext(backgroundDispatcher) {
                    faceAuthLogger.watchdogScheduled()
                    faceManager?.scheduleWatchdog()
                }
            }
            .launchIn(applicationScope)
    }

+1 −0
Original line number Diff line number Diff line
@@ -228,6 +228,7 @@ class DeviceEntryFaceAuthRepositoryTest : SysuiTestCase() {
            bypassControllerOverride,
            testScope.backgroundScope,
            testDispatcher,
            testDispatcher,
            sessionTracker,
            uiEventLogger,
            FaceAuthenticationLogger(logcatLogBuffer("DeviceEntryFaceAuthRepositoryLog")),