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

Commit 59707e21 authored by Kevin Chyn's avatar Kevin Chyn
Browse files

Plumb UDFPS overlay "show reason" from FingerprintService to SysUI

Enables SysUI to draw enroll/auth-specific affordances

If the UI diverges, we can consider enroll or auth specific
UdfpsView subclasses(?) but currently enrollment just shows
an extra circle.

Fixes: 177275693
Test: atest com.android.systemui.biometrics

Change-Id: I5b2aaf00c55279a81348ec7a5dc387b6e62751c0
parent 5d0b5275
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -20,8 +20,12 @@ package android.hardware.fingerprint;
 * @hide
 */
oneway interface IUdfpsOverlayController {
    const int REASON_UNKNOWN = 0;
    const int REASON_ENROLL = 1;
    const int REASON_AUTH = 2;

    // Shows the overlay.
    void showUdfpsOverlay(int sensorId);
    void showUdfpsOverlay(int sensorId, int reason);

    // Hides the overlay.
    void hideUdfpsOverlay(int sensorId);
+3 −0
Original line number Diff line number Diff line
@@ -77,6 +77,9 @@
    <color name="biometric_dialog_accent">#ff80cbc4</color> <!-- light teal -->
    <color name="biometric_dialog_error">#fff28b82</color> <!-- red 300 -->

    <!-- UDFPS colors -->
    <color name="udfps_enroll_icon">#ffffff</color> <!-- 100% white -->

    <color name="GM2_green_500">#FF41Af6A</color>
    <color name="GM2_blue_500">#5195EA</color>
    <color name="GM2_red_500">#E25142</color>
+3 −0
Original line number Diff line number Diff line
@@ -178,6 +178,9 @@
    <color name="biometric_dialog_accent">#ff008577</color>                 <!-- dark teal -->
    <color name="biometric_dialog_error">#ffd93025</color>                  <!-- red 600 -->

    <!-- UDFPS colors -->
    <color name="udfps_enroll_icon">#000000</color> <!-- 100% black -->

    <!-- Logout button -->
    <color name="logout_button_bg_color">#ccffffff</color>

+6 −4
Original line number Diff line number Diff line
@@ -546,6 +546,12 @@ public class AuthController extends SystemUI implements CommandQueue.Callbacks,
    protected void onConfigurationChanged(Configuration newConfig) {
        super.onConfigurationChanged(newConfig);

        // UdfpsController is not BiometricPrompt-specific. It can be active for keyguard or
        // enrollment.
        if (mUdfpsController != null) {
            mUdfpsController.onConfigurationChanged();
        }

        // Save the state of the current dialog (buttons showing, etc)
        if (mCurrentDialog != null) {
            final Bundle savedState = new Bundle();
@@ -567,10 +573,6 @@ public class AuthController extends SystemUI implements CommandQueue.Callbacks,
                    promptInfo.setAuthenticators(Authenticators.DEVICE_CREDENTIAL);
                }

                if (mUdfpsController != null) {
                    mUdfpsController.onConfigurationChanged();
                }

                showDialog(mCurrentDialogArgs, true /* skipAnimation */, savedState);
            }
        }
+22 −8
Original line number Diff line number Diff line
@@ -108,6 +108,8 @@ class UdfpsController implements DozeReceiver {
    private boolean mIsOverlayShowing;
    // Indicates whether the overlay has been requested.
    private boolean mIsOverlayRequested;
    // Reason the overlay has been requested. See IUdfpsOverlayController for definitions.
    private int mRequestReason;

    // The fingerprint AOD trigger doesn't provide an ACTION_UP/ACTION_CANCEL event to tell us when
    // to turn off high brightness mode. To get around this limitation, the state of the AOD
@@ -118,13 +120,13 @@ class UdfpsController implements DozeReceiver {

    public class UdfpsOverlayController extends IUdfpsOverlayController.Stub {
        @Override
        public void showUdfpsOverlay(int sensorId) {
            UdfpsController.this.setShowOverlay(true);
        public void showUdfpsOverlay(int sensorId, int reason) {
            UdfpsController.this.showOverlay(reason);
        }

        @Override
        public void hideUdfpsOverlay(int sensorId) {
            UdfpsController.this.setShowOverlay(false);
            UdfpsController.this.hideOverlay();
        }

        @Override
@@ -285,17 +287,27 @@ class UdfpsController implements DozeReceiver {
        return mView.getSensorRect();
    }

    private void setShowOverlay(boolean show) {
        if (show == mIsOverlayRequested) {
    private void showOverlay(int reason) {
        if (mIsOverlayRequested) {
            return;
        }
        mIsOverlayRequested = true;
        mRequestReason = reason;
        updateOverlay();
    }

    private void hideOverlay() {
        if (!mIsOverlayRequested) {
            return;
        }
        mIsOverlayRequested = show;
        mIsOverlayRequested = false;
        mRequestReason = IUdfpsOverlayController.REASON_UNKNOWN;
        updateOverlay();
    }

    private void updateOverlay() {
        if (mIsOverlayRequested) {
            showUdfpsOverlay();
            showUdfpsOverlay(mRequestReason);
        } else {
            hideUdfpsOverlay();
        }
@@ -323,11 +335,12 @@ class UdfpsController implements DozeReceiver {
        updateOverlay();
    }

    private void showUdfpsOverlay() {
    private void showUdfpsOverlay(int reason) {
        mFgExecutor.execute(() -> {
            if (!mIsOverlayShowing) {
                try {
                    Log.v(TAG, "showUdfpsOverlay | adding window");
                    mView.setShowReason(reason);
                    mWindowManager.addView(mView, computeLayoutParams());
                    mIsOverlayShowing = true;
                    mView.setOnTouchListener(mOnTouchListener);
@@ -344,6 +357,7 @@ class UdfpsController implements DozeReceiver {
        mFgExecutor.execute(() -> {
            if (mIsOverlayShowing) {
                Log.v(TAG, "hideUdfpsOverlay | removing window");
                mView.setShowReason(IUdfpsOverlayController.REASON_UNKNOWN);
                mView.setOnTouchListener(null);
                // Reset the controller back to its starting state.
                onFingerUp();
Loading