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
This commit is contained in:
Jernej Virag
2023-07-05 14:06:03 +02:00
parent fb2767b40d
commit cc75da7098
3 changed files with 22 additions and 10 deletions

View File

@@ -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();
});
}
}

View File

@@ -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)
}

View File

@@ -228,6 +228,7 @@ class DeviceEntryFaceAuthRepositoryTest : SysuiTestCase() {
bypassControllerOverride,
testScope.backgroundScope,
testDispatcher,
testDispatcher,
sessionTracker,
uiEventLogger,
FaceAuthenticationLogger(logcatLogBuffer("DeviceEntryFaceAuthRepositoryLog")),