Merge "Keyguard Wallet activity can request udfps" into sc-dev

This commit is contained in:
Beverly Tai
2021-05-06 11:41:17 +00:00
committed by Android (Google) Code Review
6 changed files with 129 additions and 20 deletions

View File

@@ -45,7 +45,7 @@ abstract class UdfpsAnimationViewController<T extends UdfpsAnimationView>
@NonNull final StatusBar mStatusBar;
@NonNull final DumpManager mDumpManger;
private boolean mNotificationShadeExpanded;
boolean mNotificationShadeExpanded;
protected UdfpsAnimationViewController(
T view,

View File

@@ -40,12 +40,14 @@ import com.android.systemui.statusbar.StatusBarState;
public class UdfpsKeyguardView extends UdfpsAnimationView {
private final UdfpsKeyguardDrawable mFingerprintDrawable;
private ImageView mFingerprintView;
private int mWallpaperTexColor;
private int mWallpaperTextColor;
private int mStatusBarState;
// used when highlighting fp icon:
private int mTextColorPrimary;
private ImageView mBgProtection;
boolean mUdfpsRequested;
int mUdfpsRequestedColor;
private AnimatorSet mAnimatorSet;
private int mAlpha; // 0-255
@@ -63,10 +65,11 @@ public class UdfpsKeyguardView extends UdfpsAnimationView {
mBgProtection = findViewById(R.id.udfps_keyguard_fp_bg);
mWallpaperTexColor = Utils.getColorAttrDefaultColor(mContext,
mWallpaperTextColor = Utils.getColorAttrDefaultColor(mContext,
R.attr.wallpaperTextColorAccent);
mTextColorPrimary = Utils.getColorAttrDefaultColor(mContext,
android.R.attr.textColorPrimary);
mUdfpsRequested = false;
}
@Override
@@ -90,11 +93,31 @@ public class UdfpsKeyguardView extends UdfpsAnimationView {
return true;
}
void requestUdfps(boolean request, int color) {
if (request) {
mUdfpsRequestedColor = color;
} else {
mUdfpsRequestedColor = -1;
}
mUdfpsRequested = request;
updateColor();
}
void setStatusBarState(int statusBarState) {
mStatusBarState = statusBarState;
if (!isShadeLocked()) {
mFingerprintView.setAlpha(1f);
mFingerprintDrawable.setLockScreenColor(mWallpaperTexColor);
updateColor();
}
void updateColor() {
mFingerprintView.setAlpha(1f);
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 {
// update icon color
fpIconAnim = new ValueAnimator();
fpIconAnim.setIntValues(mWallpaperTexColor, mTextColorPrimary);
fpIconAnim.setIntValues(getColor(), mTextColorPrimary);
fpIconAnim.setEvaluator(new ArgbEvaluator());
fpIconAnim.addUpdateListener(valueAnimator -> mFingerprintDrawable.setLockScreenColor(
(Integer) valueAnimator.getAnimatedValue()));
@@ -170,10 +193,6 @@ public class UdfpsKeyguardView extends UdfpsAnimationView {
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.
*/
@@ -193,7 +212,7 @@ public class UdfpsKeyguardView extends UdfpsAnimationView {
} else {
// update icon color
fpIconAnim = new ValueAnimator();
fpIconAnim.setIntValues(mTextColorPrimary, mWallpaperTexColor);
fpIconAnim.setIntValues(mTextColorPrimary, getColor());
fpIconAnim.setEvaluator(new ArgbEvaluator());
fpIconAnim.addUpdateListener(valueAnimator -> mFingerprintDrawable.setLockScreenColor(
(Integer) valueAnimator.getAnimatedValue()));

View File

@@ -57,6 +57,7 @@ public class UdfpsKeyguardViewController extends UdfpsAnimationViewController<Ud
@Nullable private Runnable mCancelRunnable;
private boolean mShowingUdfpsBouncer;
private boolean mUdfpsRequested;
private boolean mQsExpanded;
private boolean mFaceDetectRunning;
private boolean mHintShown;
@@ -70,6 +71,7 @@ public class UdfpsKeyguardViewController extends UdfpsAnimationViewController<Ud
* {@link KeyguardBouncer#EXPANSION_HIDDEN} (1f)
*/
private float mInputBouncerHiddenAmount;
private boolean mIsBouncerVisible;
protected UdfpsKeyguardViewController(
@NonNull UdfpsKeyguardView view,
@@ -105,6 +107,7 @@ public class UdfpsKeyguardViewController extends UdfpsAnimationViewController<Ud
mStateListener.onDozeAmountChanged(dozeAmount, dozeAmount);
mStatusBarStateController.addCallback(mStateListener);
mUdfpsRequested = false;
mStatusBarState = mStatusBarStateController.getState();
mQsExpanded = mKeyguardViewManager.isQsExpanded();
mKeyguardIsVisible = mKeyguardUpdateMonitor.isKeyguardVisible();
@@ -113,6 +116,7 @@ public class UdfpsKeyguardViewController extends UdfpsAnimationViewController<Ud
updatePauseAuth();
mKeyguardViewManager.setAlternateAuthInterceptor(mAlternateAuthInterceptor);
mIsBouncerVisible = mKeyguardViewManager.bouncerIsOrWillBeShowing();
}
@Override
@@ -137,11 +141,15 @@ public class UdfpsKeyguardViewController extends UdfpsAnimationViewController<Ud
pw.println("mShowingUdfpsBouncer=" + mShowingUdfpsBouncer);
pw.println("mFaceDetectRunning=" + mFaceDetectRunning);
pw.println("mTransitioningFromHomeToKeyguard=" + mTransitioningFromHome);
pw.println("mStatusBarState" + StatusBarState.toShortString(mStatusBarState));
pw.println("mStatusBarState=" + StatusBarState.toShortString(mStatusBarState));
pw.println("mQsExpanded=" + mQsExpanded);
pw.println("mKeyguardVisible=" + mKeyguardIsVisible);
pw.println("mIsBouncerVisible=" + mIsBouncerVisible);
pw.println("mInputBouncerHiddenAmount=" + mInputBouncerHiddenAmount);
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;
}
if (mUdfpsRequested && !mNotificationShadeExpanded
&& (!mIsBouncerVisible
|| mInputBouncerHiddenAmount != KeyguardBouncer.EXPANSION_VISIBLE)) {
return false;
}
if (mStatusBarState != KEYGUARD) {
return true;
}
@@ -332,6 +346,13 @@ public class UdfpsKeyguardViewController extends UdfpsAnimationViewController<Ud
return mShowingUdfpsBouncer;
}
@Override
public void requestUdfps(boolean request, int color) {
mUdfpsRequested = request;
mView.requestUdfps(request, color);
updatePauseAuth();
}
@Override
public boolean isAnimating() {
return mView.isAnimating();
@@ -355,6 +376,12 @@ public class UdfpsKeyguardViewController extends UdfpsAnimationViewController<Ud
updatePauseAuth();
}
@Override
public void onBouncerVisibilityChanged() {
mIsBouncerVisible = mKeyguardViewManager.bouncerIsOrWillBeShowing();
updatePauseAuth();
}
@Override
public void dump(PrintWriter pw) {
pw.println(getTag());

View File

@@ -220,17 +220,22 @@ public class KeyguardBouncer {
*/
private void onFullyHidden() {
cancelShowRunnable();
if (mRoot != null) {
mRoot.setVisibility(View.INVISIBLE);
}
setVisibility(View.INVISIBLE);
mFalsingCollector.onBouncerHidden();
DejankUtils.postAfterTraversal(mResetRunnable);
}
private void setVisibility(@View.Visibility int visibility) {
if (mRoot != null) {
mRoot.setVisibility(visibility);
dispatchVisibilityChanged();
}
}
private final Runnable mShowRunnable = new Runnable() {
@Override
public void run() {
mRoot.setVisibility(View.VISIBLE);
setVisibility(View.VISIBLE);
showPromptReason(mBouncerPromptReason);
final CharSequence customMessage = mCallback.consumeCustomMessage();
if (customMessage != null) {
@@ -299,7 +304,7 @@ public class KeyguardBouncer {
}
mIsAnimatingAway = false;
if (mRoot != null) {
mRoot.setVisibility(View.INVISIBLE);
setVisibility(View.INVISIBLE);
if (destroyView) {
// 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());
mStatusBarHeight = mRoot.getResources().getDimensionPixelOffset(
com.android.systemui.R.dimen.status_bar_height);
mRoot.setVisibility(View.INVISIBLE);
setVisibility(View.INVISIBLE);
final WindowInsets rootInsets = mRoot.getRootWindowInsets();
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
* 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
*/
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. */

View File

@@ -129,6 +129,13 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
}
updateStates();
}
@Override
public void onVisibilityChanged(boolean isVisible) {
if (mAlternateAuthInterceptor != null) {
mAlternateAuthInterceptor.onBouncerVisibilityChanged();
}
}
};
private final DockManager.DockEventListener mDockEventListener =
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
* regular pin/pattern/password bouncer.
@@ -1174,5 +1193,19 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
*/
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);
}
}

View File

@@ -16,6 +16,7 @@
package com.android.systemui.wallet.ui;
import android.graphics.Color;
import android.os.Bundle;
import android.os.Handler;
import android.service.quickaccesswallet.QuickAccessWalletClient;
@@ -34,6 +35,7 @@ import com.android.systemui.plugins.ActivityStarter;
import com.android.systemui.plugins.FalsingManager;
import com.android.systemui.settings.UserTracker;
import com.android.systemui.statusbar.phone.KeyguardDismissUtil;
import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager;
import com.android.systemui.statusbar.policy.KeyguardStateController;
import com.android.systemui.util.LifecycleActivity;
@@ -54,6 +56,7 @@ public class WalletActivity extends LifecycleActivity {
private final Handler mHandler;
private final FalsingManager mFalsingManager;
private final UserTracker mUserTracker;
private final StatusBarKeyguardViewManager mKeyguardViewManager;
private WalletScreenController mWalletScreenController;
@Inject
@@ -65,7 +68,8 @@ public class WalletActivity extends LifecycleActivity {
@Background Executor executor,
@Main Handler handler,
FalsingManager falsingManager,
UserTracker userTracker) {
UserTracker userTracker,
StatusBarKeyguardViewManager keyguardViewManager) {
mQuickAccessWalletClient = quickAccessWalletClient;
mKeyguardStateController = keyguardStateController;
mKeyguardDismissUtil = keyguardDismissUtil;
@@ -74,6 +78,7 @@ public class WalletActivity extends LifecycleActivity {
mHandler = handler;
mFalsingManager = falsingManager;
mUserTracker = userTracker;
mKeyguardViewManager = keyguardViewManager;
}
@Override
@@ -136,6 +141,13 @@ public class WalletActivity extends LifecycleActivity {
protected void onResume() {
super.onResume();
mWalletScreenController.queryWalletCards();
mKeyguardViewManager.requestUdfps(true, Color.BLACK);
}
@Override
protected void onPause() {
super.onPause();
mKeyguardViewManager.requestUdfps(false, -1);
}
@Override