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

Commit bebd1ded authored by Beverly's avatar Beverly Committed by Beverly Tai
Browse files

Keyguard Wallet activity can request udfps

- Setup ability to request udfps from a SystemUI activity occluding the
keyguard
- Hookup keyguard wallet activity to request udfps
- Update UdfpsKeyguardView logic so that the udfps icon won't show if
the bouncer is visible. Add check for bouncer visibility to check
whether the bouncer view is visible - sometimes the bouncer expansion
can report visible even though the view itself is not visibile.

Test: atest SystemUITest
Bug: 183024921

Change-Id: I2aa922149586a8a6319e884442c21b74607e5017
parent 48a3676a
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -45,7 +45,7 @@ abstract class UdfpsAnimationViewController<T extends UdfpsAnimationView>
    @NonNull final StatusBar mStatusBar;
    @NonNull final StatusBar mStatusBar;
    @NonNull final DumpManager mDumpManger;
    @NonNull final DumpManager mDumpManger;


    private boolean mNotificationShadeExpanded;
    boolean mNotificationShadeExpanded;


    protected UdfpsAnimationViewController(
    protected UdfpsAnimationViewController(
            T view,
            T view,
+30 −11
Original line number Original line Diff line number Diff line
@@ -40,12 +40,14 @@ import com.android.systemui.statusbar.StatusBarState;
public class UdfpsKeyguardView extends UdfpsAnimationView {
public class UdfpsKeyguardView extends UdfpsAnimationView {
    private final UdfpsKeyguardDrawable mFingerprintDrawable;
    private final UdfpsKeyguardDrawable mFingerprintDrawable;
    private ImageView mFingerprintView;
    private ImageView mFingerprintView;
    private int mWallpaperTexColor;
    private int mWallpaperTextColor;
    private int mStatusBarState;
    private int mStatusBarState;


    // used when highlighting fp icon:
    // used when highlighting fp icon:
    private int mTextColorPrimary;
    private int mTextColorPrimary;
    private ImageView mBgProtection;
    private ImageView mBgProtection;
    boolean mUdfpsRequested;
    int mUdfpsRequestedColor;


    private AnimatorSet mAnimatorSet;
    private AnimatorSet mAnimatorSet;
    private int mAlpha; // 0-255
    private int mAlpha; // 0-255
@@ -63,10 +65,11 @@ public class UdfpsKeyguardView extends UdfpsAnimationView {


        mBgProtection = findViewById(R.id.udfps_keyguard_fp_bg);
        mBgProtection = findViewById(R.id.udfps_keyguard_fp_bg);


        mWallpaperTexColor = Utils.getColorAttrDefaultColor(mContext,
        mWallpaperTextColor = Utils.getColorAttrDefaultColor(mContext,
                R.attr.wallpaperTextColorAccent);
                R.attr.wallpaperTextColorAccent);
        mTextColorPrimary = Utils.getColorAttrDefaultColor(mContext,
        mTextColorPrimary = Utils.getColorAttrDefaultColor(mContext,
                android.R.attr.textColorPrimary);
                android.R.attr.textColorPrimary);
        mUdfpsRequested = false;
    }
    }


    @Override
    @Override
@@ -90,11 +93,31 @@ public class UdfpsKeyguardView extends UdfpsAnimationView {
        return true;
        return true;
    }
    }


    void requestUdfps(boolean request, int color) {
        if (request) {
            mUdfpsRequestedColor = color;
        } else {
            mUdfpsRequestedColor = -1;
        }
        mUdfpsRequested = request;
        updateColor();
    }

    void setStatusBarState(int statusBarState) {
    void setStatusBarState(int statusBarState) {
        mStatusBarState = statusBarState;
        mStatusBarState = statusBarState;
        if (!isShadeLocked()) {
        updateColor();
    }

    void updateColor() {
        mFingerprintView.setAlpha(1f);
        mFingerprintView.setAlpha(1f);
            mFingerprintDrawable.setLockScreenColor(mWallpaperTexColor);
        mFingerprintDrawable.setLockScreenColor(getColor());
    }

    private int getColor() {
        if (mUdfpsRequested && mUdfpsRequestedColor != -1) {
            return mUdfpsRequestedColor;
        } else {
            return mWallpaperTextColor;
        }
        }
    }
    }


@@ -142,7 +165,7 @@ public class UdfpsKeyguardView extends UdfpsAnimationView {
        } else {
        } else {
            // update icon color
            // update icon color
            fpIconAnim = new ValueAnimator();
            fpIconAnim = new ValueAnimator();
            fpIconAnim.setIntValues(mWallpaperTexColor, mTextColorPrimary);
            fpIconAnim.setIntValues(getColor(), mTextColorPrimary);
            fpIconAnim.setEvaluator(new ArgbEvaluator());
            fpIconAnim.setEvaluator(new ArgbEvaluator());
            fpIconAnim.addUpdateListener(valueAnimator -> mFingerprintDrawable.setLockScreenColor(
            fpIconAnim.addUpdateListener(valueAnimator -> mFingerprintDrawable.setLockScreenColor(
                    (Integer) valueAnimator.getAnimatedValue()));
                    (Integer) valueAnimator.getAnimatedValue()));
@@ -170,10 +193,6 @@ public class UdfpsKeyguardView extends UdfpsAnimationView {
        return mStatusBarState == StatusBarState.SHADE_LOCKED;
        return mStatusBarState == StatusBarState.SHADE_LOCKED;
    }
    }


    boolean isHome() {
        return mStatusBarState == StatusBarState.SHADE;
    }

    /**
    /**
     * Animates out the bg protection circle behind the fp icon to unhighlight the icon.
     * Animates out the bg protection circle behind the fp icon to unhighlight the icon.
     */
     */
@@ -193,7 +212,7 @@ public class UdfpsKeyguardView extends UdfpsAnimationView {
        } else {
        } else {
            // update icon color
            // update icon color
            fpIconAnim = new ValueAnimator();
            fpIconAnim = new ValueAnimator();
            fpIconAnim.setIntValues(mTextColorPrimary, mWallpaperTexColor);
            fpIconAnim.setIntValues(mTextColorPrimary, getColor());
            fpIconAnim.setEvaluator(new ArgbEvaluator());
            fpIconAnim.setEvaluator(new ArgbEvaluator());
            fpIconAnim.addUpdateListener(valueAnimator -> mFingerprintDrawable.setLockScreenColor(
            fpIconAnim.addUpdateListener(valueAnimator -> mFingerprintDrawable.setLockScreenColor(
                    (Integer) valueAnimator.getAnimatedValue()));
                    (Integer) valueAnimator.getAnimatedValue()));
+28 −1
Original line number Original line Diff line number Diff line
@@ -57,6 +57,7 @@ public class UdfpsKeyguardViewController extends UdfpsAnimationViewController<Ud


    @Nullable private Runnable mCancelRunnable;
    @Nullable private Runnable mCancelRunnable;
    private boolean mShowingUdfpsBouncer;
    private boolean mShowingUdfpsBouncer;
    private boolean mUdfpsRequested;
    private boolean mQsExpanded;
    private boolean mQsExpanded;
    private boolean mFaceDetectRunning;
    private boolean mFaceDetectRunning;
    private boolean mHintShown;
    private boolean mHintShown;
@@ -70,6 +71,7 @@ public class UdfpsKeyguardViewController extends UdfpsAnimationViewController<Ud
     * {@link KeyguardBouncer#EXPANSION_HIDDEN} (1f)
     * {@link KeyguardBouncer#EXPANSION_HIDDEN} (1f)
     */
     */
    private float mInputBouncerHiddenAmount;
    private float mInputBouncerHiddenAmount;
    private boolean mIsBouncerVisible;


    protected UdfpsKeyguardViewController(
    protected UdfpsKeyguardViewController(
            @NonNull UdfpsKeyguardView view,
            @NonNull UdfpsKeyguardView view,
@@ -105,6 +107,7 @@ public class UdfpsKeyguardViewController extends UdfpsAnimationViewController<Ud
        mStateListener.onDozeAmountChanged(dozeAmount, dozeAmount);
        mStateListener.onDozeAmountChanged(dozeAmount, dozeAmount);
        mStatusBarStateController.addCallback(mStateListener);
        mStatusBarStateController.addCallback(mStateListener);


        mUdfpsRequested = false;
        mStatusBarState = mStatusBarStateController.getState();
        mStatusBarState = mStatusBarStateController.getState();
        mQsExpanded = mKeyguardViewManager.isQsExpanded();
        mQsExpanded = mKeyguardViewManager.isQsExpanded();
        mKeyguardIsVisible = mKeyguardUpdateMonitor.isKeyguardVisible();
        mKeyguardIsVisible = mKeyguardUpdateMonitor.isKeyguardVisible();
@@ -113,6 +116,7 @@ public class UdfpsKeyguardViewController extends UdfpsAnimationViewController<Ud
        updatePauseAuth();
        updatePauseAuth();


        mKeyguardViewManager.setAlternateAuthInterceptor(mAlternateAuthInterceptor);
        mKeyguardViewManager.setAlternateAuthInterceptor(mAlternateAuthInterceptor);
        mIsBouncerVisible = mKeyguardViewManager.bouncerIsOrWillBeShowing();
    }
    }


    @Override
    @Override
@@ -137,11 +141,15 @@ public class UdfpsKeyguardViewController extends UdfpsAnimationViewController<Ud
        pw.println("mShowingUdfpsBouncer=" + mShowingUdfpsBouncer);
        pw.println("mShowingUdfpsBouncer=" + mShowingUdfpsBouncer);
        pw.println("mFaceDetectRunning=" + mFaceDetectRunning);
        pw.println("mFaceDetectRunning=" + mFaceDetectRunning);
        pw.println("mTransitioningFromHomeToKeyguard=" + mTransitioningFromHome);
        pw.println("mTransitioningFromHomeToKeyguard=" + mTransitioningFromHome);
        pw.println("mStatusBarState" + StatusBarState.toShortString(mStatusBarState));
        pw.println("mStatusBarState=" + StatusBarState.toShortString(mStatusBarState));
        pw.println("mQsExpanded=" + mQsExpanded);
        pw.println("mQsExpanded=" + mQsExpanded);
        pw.println("mKeyguardVisible=" + mKeyguardIsVisible);
        pw.println("mKeyguardVisible=" + mKeyguardIsVisible);
        pw.println("mIsBouncerVisible=" + mIsBouncerVisible);
        pw.println("mInputBouncerHiddenAmount=" + mInputBouncerHiddenAmount);
        pw.println("mInputBouncerHiddenAmount=" + mInputBouncerHiddenAmount);
        pw.println("mAlpha=" + mView.getAlpha());
        pw.println("mAlpha=" + mView.getAlpha());
        pw.println("mUdfpsRequested=" + mUdfpsRequested);
        pw.println("mView.mUdfpsRequested=" + mView.mUdfpsRequested);
        pw.println("mView.mUdfpsRequestedColor=" + mView.mUdfpsRequestedColor);
    }
    }


    /**
    /**
@@ -173,6 +181,12 @@ public class UdfpsKeyguardViewController extends UdfpsAnimationViewController<Ud
            return false;
            return false;
        }
        }


        if (mUdfpsRequested && !mNotificationShadeExpanded
                && (!mIsBouncerVisible
                || mInputBouncerHiddenAmount != KeyguardBouncer.EXPANSION_VISIBLE)) {
            return false;
        }

        if (mStatusBarState != KEYGUARD) {
        if (mStatusBarState != KEYGUARD) {
            return true;
            return true;
        }
        }
@@ -332,6 +346,13 @@ public class UdfpsKeyguardViewController extends UdfpsAnimationViewController<Ud
                    return mShowingUdfpsBouncer;
                    return mShowingUdfpsBouncer;
                }
                }


                @Override
                public void requestUdfps(boolean request, int color) {
                    mUdfpsRequested = request;
                    mView.requestUdfps(request, color);
                    updatePauseAuth();
                }

                @Override
                @Override
                public boolean isAnimating() {
                public boolean isAnimating() {
                    return mView.isAnimating();
                    return mView.isAnimating();
@@ -355,6 +376,12 @@ public class UdfpsKeyguardViewController extends UdfpsAnimationViewController<Ud
                    updatePauseAuth();
                    updatePauseAuth();
                }
                }


                @Override
                public void onBouncerVisibilityChanged() {
                    mIsBouncerVisible = mKeyguardViewManager.bouncerIsOrWillBeShowing();
                    updatePauseAuth();
                }

                @Override
                @Override
                public void dump(PrintWriter pw) {
                public void dump(PrintWriter pw) {
                    pw.println(getTag());
                    pw.println(getTag());
+24 −6
Original line number Original line Diff line number Diff line
@@ -220,17 +220,22 @@ public class KeyguardBouncer {
     */
     */
    private void onFullyHidden() {
    private void onFullyHidden() {
        cancelShowRunnable();
        cancelShowRunnable();
        if (mRoot != null) {
        setVisibility(View.INVISIBLE);
            mRoot.setVisibility(View.INVISIBLE);
        }
        mFalsingCollector.onBouncerHidden();
        mFalsingCollector.onBouncerHidden();
        DejankUtils.postAfterTraversal(mResetRunnable);
        DejankUtils.postAfterTraversal(mResetRunnable);
    }
    }


    private void setVisibility(@View.Visibility int visibility) {
        if (mRoot != null) {
            mRoot.setVisibility(visibility);
            dispatchVisibilityChanged();
        }
    }

    private final Runnable mShowRunnable = new Runnable() {
    private final Runnable mShowRunnable = new Runnable() {
        @Override
        @Override
        public void run() {
        public void run() {
            mRoot.setVisibility(View.VISIBLE);
            setVisibility(View.VISIBLE);
            showPromptReason(mBouncerPromptReason);
            showPromptReason(mBouncerPromptReason);
            final CharSequence customMessage = mCallback.consumeCustomMessage();
            final CharSequence customMessage = mCallback.consumeCustomMessage();
            if (customMessage != null) {
            if (customMessage != null) {
@@ -299,7 +304,7 @@ public class KeyguardBouncer {
        }
        }
        mIsAnimatingAway = false;
        mIsAnimatingAway = false;
        if (mRoot != null) {
        if (mRoot != null) {
            mRoot.setVisibility(View.INVISIBLE);
            setVisibility(View.INVISIBLE);
            if (destroyView) {
            if (destroyView) {


                // We have a ViewFlipper that unregisters a broadcast when being detached, which may
                // We have a ViewFlipper that unregisters a broadcast when being detached, which may
@@ -436,7 +441,7 @@ public class KeyguardBouncer {
        mContainer.addView(mRoot, mContainer.getChildCount());
        mContainer.addView(mRoot, mContainer.getChildCount());
        mStatusBarHeight = mRoot.getResources().getDimensionPixelOffset(
        mStatusBarHeight = mRoot.getResources().getDimensionPixelOffset(
                com.android.systemui.R.dimen.status_bar_height);
                com.android.systemui.R.dimen.status_bar_height);
        mRoot.setVisibility(View.INVISIBLE);
        setVisibility(View.INVISIBLE);


        final WindowInsets rootInsets = mRoot.getRootWindowInsets();
        final WindowInsets rootInsets = mRoot.getRootWindowInsets();
        if (rootInsets != null) {
        if (rootInsets != null) {
@@ -533,6 +538,12 @@ public class KeyguardBouncer {
        }
        }
    }
    }


    private void dispatchVisibilityChanged() {
        for (BouncerExpansionCallback callback : mExpansionCallbacks) {
            callback.onVisibilityChanged(mRoot.getVisibility() == View.VISIBLE);
        }
    }

    /**
    /**
     * Apply keyguard configuration from the currently active resources. This can be called when the
     * Apply keyguard configuration from the currently active resources. This can be called when the
     * device configuration changes, to re-apply some resources that are qualified on the device
     * device configuration changes, to re-apply some resources that are qualified on the device
@@ -573,6 +584,13 @@ public class KeyguardBouncer {
         * to 1f {@link KeyguardBouncer#EXPANSION_HIDDEN} when fully hidden
         * to 1f {@link KeyguardBouncer#EXPANSION_HIDDEN} when fully hidden
         */
         */
        default void onExpansionChanged(float bouncerHideAmount) {}
        default void onExpansionChanged(float bouncerHideAmount) {}

        /**
         * Invoked when visibility of KeyguardBouncer has changed.
         * Note the bouncer expansion can be {@link KeyguardBouncer#EXPANSION_VISIBLE}, but the
         * view's visibility can be {@link View.INVISIBLE}.
         */
        default void onVisibilityChanged(boolean isVisible) {}
    }
    }


    /** Create a {@link KeyguardBouncer} once a container and bouncer callback are available. */
    /** Create a {@link KeyguardBouncer} once a container and bouncer callback are available. */
+33 −0
Original line number Original line Diff line number Diff line
@@ -129,6 +129,13 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
            }
            }
            updateStates();
            updateStates();
        }
        }

        @Override
        public void onVisibilityChanged(boolean isVisible) {
            if (mAlternateAuthInterceptor != null) {
                mAlternateAuthInterceptor.onBouncerVisibilityChanged();
            }
        }
    };
    };
    private final DockManager.DockEventListener mDockEventListener =
    private final DockManager.DockEventListener mDockEventListener =
            new DockManager.DockEventListener() {
            new DockManager.DockEventListener() {
@@ -1125,6 +1132,18 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
        }
        }
    }
    }


    /**
     * Request to show the udfps affordance in a particular color. This can be used if an
     * occluding app on the keyguard would like to request udfps.  This method does nothing if
     * {@link KeyguardUpdateMonitor#shouldListenForFingerprint} is false.
     */
    public void requestUdfps(boolean request, int color) {
        if (mAlternateAuthInterceptor == null) {
            return;
        }
        mAlternateAuthInterceptor.requestUdfps(request, color);
    }

    /**
    /**
     * Delegate used to send show/reset events to an alternate authentication method instead of the
     * Delegate used to send show/reset events to an alternate authentication method instead of the
     * regular pin/pattern/password bouncer.
     * regular pin/pattern/password bouncer.
@@ -1174,5 +1193,19 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
         */
         */
        void setBouncerExpansionChanged(float expansion);
        void setBouncerExpansionChanged(float expansion);


        /**
         *  called when the bouncer view visibility has changed.
         */
        void onBouncerVisibilityChanged();

        /**
         * Use when an app occluding the keyguard would like to give the user ability to
         * unlock the device using udfps.
         *
         * @param color of the udfps icon. should have proper contrast with its background. only
         *              used if requestUdfps = true
         */
        void requestUdfps(boolean requestUdfps, int color);

    }
    }
}
}
 No newline at end of file
Loading