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

Commit 5ac29cb6 authored by LuK1337's avatar LuK1337
Browse files

udfps: Implement default udfps hbm provider

This should let us choose between multiple UdfpsHbmProvider
implementations.

Change-Id: I9b93e32644feaf1398cdac69e9696d8ec195f246
parent 30220dad
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -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);
+3 −0
Original line number Diff line number Diff line
@@ -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>
+32 −0
Original line number Diff line number Diff line
/*
 * 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()
    }
}
+2 −2
Original line number Diff line number Diff line
@@ -523,7 +523,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,
@@ -551,7 +551,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;
        mOrientationListener = new BiometricOrientationEventListener(
+12 −2
Original line number Diff line number Diff line
@@ -78,6 +78,7 @@ import com.android.systemui.util.time.SystemClockImpl;
import com.android.systemui.volume.dagger.VolumeModule;
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;
@@ -160,8 +161,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