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

Commit 351107ec authored by Ilya Matyukhin's avatar Ilya Matyukhin
Browse files

Make UdfpsHbmCallback a dependency of UdfpsController

Bug: 187732246
Test: atest UdfpsControllerGoogle
Change-Id: I1aead35213de9491538b6eaf5d4a45be569ecab8
parent dd3707ad
Loading
Loading
Loading
Loading
+2 −2
Original line number Original line Diff line number Diff line
@@ -35,7 +35,7 @@ oneway interface IUdfpsHbmListener {
     * UdfpsController will call this method when the HBM is enabled.
     * UdfpsController will call this method when the HBM is enabled.
     *
     *
     * @param hbmType The type of HBM that was enabled. See
     * @param hbmType The type of HBM that was enabled. See
     *        {@link com.android.systemui.biometrics.HbmTypes}.
     *        {@link com.android.systemui.biometrics.UdfpsHbmTypes}.
     * @param displayId The displayId for which the HBM is enabled. See
     * @param displayId The displayId for which the HBM is enabled. See
     *        {@link android.view.Display#getDisplayId()}.
     *        {@link android.view.Display#getDisplayId()}.
     */
     */
@@ -45,7 +45,7 @@ oneway interface IUdfpsHbmListener {
     * UdfpsController will call this method when the HBM is disabled.
     * UdfpsController will call this method when the HBM is disabled.
     *
     *
     * @param hbmType The type of HBM that was disabled. See
     * @param hbmType The type of HBM that was disabled. See
     *        {@link com.android.systemui.biometrics.HbmTypes}.
     *        {@link com.android.systemui.biometrics.UdfpsHbmTypes}.
     * @param displayId The displayId for which the HBM is disabled. See
     * @param displayId The displayId for which the HBM is disabled. See
     *        {@link android.view.Display#getDisplayId()}.
     *        {@link android.view.Display#getDisplayId()}.
     */
     */
+8 −15
Original line number Original line Diff line number Diff line
@@ -59,7 +59,6 @@ import android.view.accessibility.AccessibilityManager;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.annotations.VisibleForTesting;
import com.android.keyguard.KeyguardUpdateMonitor;
import com.android.keyguard.KeyguardUpdateMonitor;
import com.android.systemui.R;
import com.android.systemui.R;
import com.android.systemui.biometrics.HbmTypes.HbmType;
import com.android.systemui.dagger.SysUISingleton;
import com.android.systemui.dagger.SysUISingleton;
import com.android.systemui.dagger.qualifiers.Main;
import com.android.systemui.dagger.qualifiers.Main;
import com.android.systemui.doze.DozeReceiver;
import com.android.systemui.doze.DozeReceiver;
@@ -72,6 +71,8 @@ import com.android.systemui.statusbar.phone.StatusBar;
import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager;
import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager;
import com.android.systemui.util.concurrency.DelayableExecutor;
import com.android.systemui.util.concurrency.DelayableExecutor;


import java.util.Optional;

import javax.inject.Inject;
import javax.inject.Inject;


/**
/**
@@ -87,7 +88,7 @@ import javax.inject.Inject;
 */
 */
@SuppressWarnings("deprecation")
@SuppressWarnings("deprecation")
@SysUISingleton
@SysUISingleton
public class UdfpsController implements DozeReceiver, HbmCallback {
public class UdfpsController implements DozeReceiver {
    private static final String TAG = "UdfpsController";
    private static final String TAG = "UdfpsController";
    private static final long AOD_INTERRUPT_TIMEOUT_MILLIS = 1000;
    private static final long AOD_INTERRUPT_TIMEOUT_MILLIS = 1000;


@@ -110,6 +111,7 @@ public class UdfpsController implements DozeReceiver, HbmCallback {
    @NonNull private final FalsingManager mFalsingManager;
    @NonNull private final FalsingManager mFalsingManager;
    @NonNull private final PowerManager mPowerManager;
    @NonNull private final PowerManager mPowerManager;
    @NonNull private final AccessibilityManager mAccessibilityManager;
    @NonNull private final AccessibilityManager mAccessibilityManager;
    @Nullable private final UdfpsHbmCallback mHbmCallback;
    // Currently the UdfpsController supports a single UDFPS sensor. If devices have multiple
    // Currently the UdfpsController supports a single UDFPS sensor. If devices have multiple
    // sensors, this, in addition to a lot of the code here, will be updated.
    // sensors, this, in addition to a lot of the code here, will be updated.
    @VisibleForTesting final FingerprintSensorPropertiesInternal mSensorProps;
    @VisibleForTesting final FingerprintSensorPropertiesInternal mSensorProps;
@@ -466,7 +468,8 @@ public class UdfpsController implements DozeReceiver, HbmCallback {
            @NonNull PowerManager powerManager,
            @NonNull PowerManager powerManager,
            @NonNull AccessibilityManager accessibilityManager,
            @NonNull AccessibilityManager accessibilityManager,
            @NonNull ScreenLifecycle screenLifecycle,
            @NonNull ScreenLifecycle screenLifecycle,
            @Nullable Vibrator vibrator) {
            @Nullable Vibrator vibrator,
            @NonNull Optional<UdfpsHbmCallback> hbmCallback) {
        mContext = context;
        mContext = context;
        // TODO (b/185124905): inject main handler and vibrator once done prototyping
        // TODO (b/185124905): inject main handler and vibrator once done prototyping
        mMainHandler = new Handler(Looper.getMainLooper());
        mMainHandler = new Handler(Looper.getMainLooper());
@@ -486,6 +489,7 @@ public class UdfpsController implements DozeReceiver, HbmCallback {
        mFalsingManager = falsingManager;
        mFalsingManager = falsingManager;
        mPowerManager = powerManager;
        mPowerManager = powerManager;
        mAccessibilityManager = accessibilityManager;
        mAccessibilityManager = accessibilityManager;
        mHbmCallback = hbmCallback.orElse(null);
        screenLifecycle.addObserver(mScreenObserver);
        screenLifecycle.addObserver(mScreenObserver);
        mScreenOn = screenLifecycle.getScreenState() == ScreenLifecycle.SCREEN_ON;
        mScreenOn = screenLifecycle.getScreenState() == ScreenLifecycle.SCREEN_ON;


@@ -619,7 +623,7 @@ public class UdfpsController implements DozeReceiver, HbmCallback {
                    Log.v(TAG, "showUdfpsOverlay | adding window reason=" + reason);
                    Log.v(TAG, "showUdfpsOverlay | adding window reason=" + reason);
                    mView = (UdfpsView) mInflater.inflate(R.layout.udfps_view, null, false);
                    mView = (UdfpsView) mInflater.inflate(R.layout.udfps_view, null, false);
                    mView.setSensorProperties(mSensorProps);
                    mView.setSensorProperties(mSensorProps);
                    mView.setHbmCallback(this);
                    mView.setHbmCallback(mHbmCallback);
                    UdfpsAnimationViewController animation = inflateUdfpsAnimation(reason);
                    UdfpsAnimationViewController animation = inflateUdfpsAnimation(reason);
                    animation.init();
                    animation.init();
                    mView.setAnimationViewController(animation);
                    mView.setAnimationViewController(animation);
@@ -791,17 +795,6 @@ public class UdfpsController implements DozeReceiver, HbmCallback {
        mView.stopIllumination();
        mView.stopIllumination();
    }
    }


    @Override
    public void enableHbm(@HbmType int hbmType, @Nullable Surface surface) {
        // Do nothing. This method can be implemented for devices that require the high-brightness
        // mode for fingerprint illumination.
    }

    @Override
    public void disableHbm(@HbmType int hbmType, @Nullable Surface surface) {
        // Do nothing. This method can be implemented for devices that require the high-brightness
        // mode for fingerprint illumination.
    }


    private VibrationEffect getVibration(String effect, VibrationEffect defaultEffect) {
    private VibrationEffect getVibration(String effect, VibrationEffect defaultEffect) {
        if (TextUtils.isEmpty(effect)) {
        if (TextUtils.isEmpty(effect)) {
+4 −4
Original line number Original line Diff line number Diff line
@@ -19,18 +19,18 @@ package com.android.systemui.biometrics;
import android.annotation.Nullable;
import android.annotation.Nullable;
import android.view.Surface;
import android.view.Surface;


import com.android.systemui.biometrics.HbmTypes.HbmType;
import com.android.systemui.biometrics.UdfpsHbmTypes.HbmType;


/**
/**
 * Interface for controlling the high-brightness mode (HBM). UdfpsView can use this callback to
 * Interface for controlling the high-brightness mode (HBM). UdfpsView can use this callback to
 * enable the HBM while showing the fingerprint illumination, and to disable the HBM after the
 * enable the HBM while showing the fingerprint illumination, and to disable the HBM after the
 * illumination is no longer necessary.
 * illumination is no longer necessary.
 */
 */
public interface HbmCallback {
public interface UdfpsHbmCallback {
    /**
    /**
     * UdfpsView will call this to enable the HBM when the fingerprint illumination is needed.
     * UdfpsView will call this to enable the HBM when the fingerprint illumination is needed.
     *
     *
     * @param hbmType The type of HBM that should be enabled. See {@link HbmTypes}.
     * @param hbmType The type of HBM that should be enabled. See {@link UdfpsHbmTypes}.
     * @param surface The surface for which the HBM is requested, in case the HBM implementation
     * @param surface The surface for which the HBM is requested, in case the HBM implementation
     *                needs to set special surface flags to enable the HBM. Can be null.
     *                needs to set special surface flags to enable the HBM. Can be null.
     */
     */
@@ -39,7 +39,7 @@ public interface HbmCallback {
    /**
    /**
     * UdfpsView will call this to disable the HBM when the illumination is not longer needed.
     * UdfpsView will call this to disable the HBM when the illumination is not longer needed.
     *
     *
     * @param hbmType The type of HBM that should be disabled. See {@link HbmTypes}.
     * @param hbmType The type of HBM that should be disabled. See {@link UdfpsHbmTypes}.
     * @param surface The surface for which the HBM is requested, in case the HBM implementation
     * @param surface The surface for which the HBM is requested, in case the HBM implementation
     *                needs to unset special surface flags to disable the HBM. Can be null.
     *                needs to unset special surface flags to disable the HBM. Can be null.
     */
     */
+1 −1
Original line number Original line Diff line number Diff line
@@ -25,7 +25,7 @@ import java.lang.annotation.RetentionPolicy;
/**
/**
 * Different high-brightness mode (HBM) types that are relevant to this package.
 * Different high-brightness mode (HBM) types that are relevant to this package.
 */
 */
public final class HbmTypes {
public final class UdfpsHbmTypes {
    /** HBM that applies to the whole screen. */
    /** HBM that applies to the whole screen. */
    public static final int GLOBAL_HBM = IUdfpsHbmListener.GLOBAL_HBM;
    public static final int GLOBAL_HBM = IUdfpsHbmListener.GLOBAL_HBM;


+1 −1
Original line number Original line Diff line number Diff line
@@ -26,7 +26,7 @@ interface UdfpsIlluminator {
    /**
    /**
     * @param callback Invoked when HBM should be enabled or disabled.
     * @param callback Invoked when HBM should be enabled or disabled.
     */
     */
    void setHbmCallback(@Nullable HbmCallback callback);
    void setHbmCallback(@Nullable UdfpsHbmCallback callback);


    /**
    /**
     * Invoked when illumination should start.
     * Invoked when illumination should start.
Loading