diff --git a/packages/SystemUI/proguard.flags b/packages/SystemUI/proguard.flags index 61147281da6fd09fc1459dd7971c528e73dd55cd..8cb2580aa2108bb13c65adb462af9e0dd303b886 100644 --- a/packages/SystemUI/proguard.flags +++ b/packages/SystemUI/proguard.flags @@ -24,6 +24,9 @@ -keep class com.android.systemui.tv.TvSystemUIFactory -keep class * extends com.android.systemui.SystemUI -keep class * implements com.android.systemui.SystemUI$Injector +-keep class * implements com.android.systemui.biometrics.UdfpsHbmProvider { + public <init>(...); +} -keepclasseswithmembers class * { public <init>(android.content.Context, android.util.AttributeSet); diff --git a/packages/SystemUI/res/values/lmodroid_config.xml b/packages/SystemUI/res/values/lmodroid_config.xml index 94bc27188369a8cf453f6fe3d0b25b3092b18e67..7e78003fb5831a761e1484e90f045d7fd08ddbdf 100644 --- a/packages/SystemUI/res/values/lmodroid_config.xml +++ b/packages/SystemUI/res/values/lmodroid_config.xml @@ -20,4 +20,7 @@ <!-- Color of the UDFPS pressed view --> <color name="config_udfpsColor">#ffffffff</color> + + <!-- Udfps HBM provider class name --> + <string name="config_udfpsHbmProviderComponent">com.android.systemui.biometrics.DummyUdfpsHbmProvider</string> </resources> diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/DummyUdfpsHbmProvider.kt b/packages/SystemUI/src/com/android/systemui/biometrics/DummyUdfpsHbmProvider.kt new file mode 100644 index 0000000000000000000000000000000000000000..a1ec9c2bb76ef35c7c4241b2fc7ae6f932d88379 --- /dev/null +++ b/packages/SystemUI/src/com/android/systemui/biometrics/DummyUdfpsHbmProvider.kt @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2022 The LineageOS 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 + +import android.content.Context +import android.view.Surface + +class DummyUdfpsHbmProvider constructor( + private val context: Context +): UdfpsHbmProvider { + override fun enableHbm(hbmType: Int, surface: Surface?, onHbmEnabled: Runnable?) { + onHbmEnabled?.run() + } + + override fun disableHbm(onHbmDisabled: Runnable?) { + onHbmDisabled?.run() + } +} diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsController.java b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsController.java index 3e9d6b0fa362f912a04f6560799f69d3f283636b..5ef329c457f488613ce9a68d04241ca3968d1cbc 100644 --- a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsController.java +++ b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsController.java @@ -547,7 +547,7 @@ public class UdfpsController implements DozeReceiver { @NonNull ScreenLifecycle screenLifecycle, @Nullable Vibrator vibrator, @NonNull UdfpsHapticsSimulator udfpsHapticsSimulator, - @NonNull Optional<UdfpsHbmProvider> hbmProvider, + @NonNull UdfpsHbmProvider hbmProvider, @NonNull KeyguardStateController keyguardStateController, @NonNull KeyguardBypassController keyguardBypassController, @NonNull DisplayManager displayManager, @@ -576,7 +576,7 @@ public class UdfpsController implements DozeReceiver { mPowerManager = powerManager; mAccessibilityManager = accessibilityManager; mLockscreenShadeTransitionController = lockscreenShadeTransitionController; - mHbmProvider = hbmProvider.orElse(null); + mHbmProvider = hbmProvider; screenLifecycle.addObserver(mScreenObserver); mScreenOn = screenLifecycle.getScreenState() == ScreenLifecycle.SCREEN_ON; mKeyguardBypassController = keyguardBypassController; diff --git a/packages/SystemUI/src/com/android/systemui/dagger/SystemUIModule.java b/packages/SystemUI/src/com/android/systemui/dagger/SystemUIModule.java index 12786f278a1642423c9fc8fe1df770885abd3597..8adaa98e1a13b6a312e13c7a2fce436ed73c0cec 100644 --- a/packages/SystemUI/src/com/android/systemui/dagger/SystemUIModule.java +++ b/packages/SystemUI/src/com/android/systemui/dagger/SystemUIModule.java @@ -83,6 +83,7 @@ import com.android.systemui.util.time.SystemClock; import com.android.systemui.util.time.SystemClockImpl; import com.android.systemui.wallet.dagger.WalletModule; import com.android.systemui.wmshell.BubblesManager; +import com.android.systemui.R; import com.android.wm.shell.bubbles.Bubbles; import java.util.Optional; @@ -175,8 +176,17 @@ public abstract class SystemUIModule { @BindsOptionalOf abstract StatusBar optionalStatusBar(); - @BindsOptionalOf - abstract UdfpsHbmProvider optionalUdfpsHbmProvider(); + @Provides + static UdfpsHbmProvider getUdfpsHbmProvider(Context context) { + String className = context.getString(R.string.config_udfpsHbmProviderComponent); + try { + Class<?> clazz = context.getClassLoader().loadClass(className); + return (UdfpsHbmProvider) clazz.getDeclaredConstructor( + new Class[] { Context.class }).newInstance(context); + } catch (Throwable t) { + throw new RuntimeException("Error loading UdfpsHbmProvider " + className, t); + } + } @SysUISingleton @Binds