From db5e7dccdb13a463453eb2b592e413b93ac31bd6 Mon Sep 17 00:00:00 2001 From: Joe Bolinger Date: Thu, 11 Nov 2021 17:05:35 -0800 Subject: [PATCH] Add dedicated biometrics sysui thread. Bug: 205875955 Test: manual Change-Id: Ibc3b70a2f7beb99315b10317dc177dbed64bf2fa --- .../biometrics/dagger/BiometricsModule.kt | 49 +++++++++++++++++++ .../systemui/dagger/SystemUIModule.java | 2 + 2 files changed, 51 insertions(+) create mode 100644 packages/SystemUI/src/com/android/systemui/biometrics/dagger/BiometricsModule.kt diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/dagger/BiometricsModule.kt b/packages/SystemUI/src/com/android/systemui/biometrics/dagger/BiometricsModule.kt new file mode 100644 index 0000000000000..b5d81f2539161 --- /dev/null +++ b/packages/SystemUI/src/com/android/systemui/biometrics/dagger/BiometricsModule.kt @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2021 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.systemui.biometrics.dagger + +import com.android.systemui.dagger.SysUISingleton +import com.android.systemui.util.concurrency.ThreadFactory +import dagger.Module +import dagger.Provides +import java.util.concurrent.Executor +import javax.inject.Qualifier + +/** + * Dagger module for all things biometric. + */ +@Module +object BiometricsModule { + + /** Background [Executor] for HAL related operations. */ + @Provides + @SysUISingleton + @JvmStatic + @BiometricsBackground + fun providesPluginExecutor(threadFactory: ThreadFactory): Executor = + threadFactory.buildExecutorOnNewThread("biometrics") +} + +/** + * Background executor for HAL operations that are latency sensitive but too + * slow to run on the main thread. Prefer the shared executors, such as + * [com.android.systemui.dagger.qualifiers.Background] when a HAL is not directly involved. + */ +@Qualifier +@MustBeDocumented +@Retention(AnnotationRetention.RUNTIME) +annotation class BiometricsBackground diff --git a/packages/SystemUI/src/com/android/systemui/dagger/SystemUIModule.java b/packages/SystemUI/src/com/android/systemui/dagger/SystemUIModule.java index 3c867603546a6..bf8389e131344 100644 --- a/packages/SystemUI/src/com/android/systemui/dagger/SystemUIModule.java +++ b/packages/SystemUI/src/com/android/systemui/dagger/SystemUIModule.java @@ -30,6 +30,7 @@ import com.android.systemui.SystemUIFactory; import com.android.systemui.appops.dagger.AppOpsModule; import com.android.systemui.assist.AssistModule; import com.android.systemui.biometrics.UdfpsHbmProvider; +import com.android.systemui.biometrics.dagger.BiometricsModule; import com.android.systemui.classifier.FalsingModule; import com.android.systemui.communal.dagger.CommunalModule; import com.android.systemui.controls.dagger.ControlsModule; @@ -103,6 +104,7 @@ import dagger.Provides; @Module(includes = { AppOpsModule.class, AssistModule.class, + BiometricsModule.class, ClockModule.class, CommunalModule.class, DreamModule.class,