From bf2bf1bc09fef50cb84ab9c7c5c4096a8e2491d4 Mon Sep 17 00:00:00 2001 From: Kevin Chyn Date: Fri, 25 Oct 2019 11:39:10 -0700 Subject: [PATCH 1/3] Temporarily do not remove biometric view when animating to credential When animating to device credential, the biometric view animates its translation and opacity, then removes itself from the layout. Upon removal, we currently remove all things from the handler. This includes (racily) the callback to display device credential UI. Thus, temporarily do not remove the view. Will fix this properly in a follow-up CL. Test: manual test with BiometricPromptDemo 10+ times Test: atest com.android.systemui.biometrics Bug: 143174046 Change-Id: Ibdf7c17514062a08ff3919fad2c798f9127e4234 --- .../com/android/systemui/biometrics/AuthBiometricView.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/AuthBiometricView.java b/packages/SystemUI/src/com/android/systemui/biometrics/AuthBiometricView.java index d20cd72f07126..d38b31ac9fca6 100644 --- a/packages/SystemUI/src/com/android/systemui/biometrics/AuthBiometricView.java +++ b/packages/SystemUI/src/com/android/systemui/biometrics/AuthBiometricView.java @@ -23,7 +23,6 @@ import android.animation.ValueAnimator; import android.annotation.IntDef; import android.annotation.NonNull; import android.annotation.Nullable; -import android.app.admin.DevicePolicyManager; import android.content.Context; import android.hardware.biometrics.BiometricPrompt; import android.os.Bundle; @@ -33,7 +32,6 @@ import android.text.TextUtils; import android.util.AttributeSet; import android.util.Log; import android.view.View; -import android.view.ViewGroup; import android.view.accessibility.AccessibilityManager; import android.widget.Button; import android.widget.ImageView; @@ -41,7 +39,6 @@ import android.widget.LinearLayout; import android.widget.TextView; import com.android.internal.annotations.VisibleForTesting; -import com.android.internal.widget.LockPatternUtils; import com.android.systemui.R; import java.lang.annotation.Retention; @@ -404,7 +401,7 @@ public abstract class AuthBiometricView extends LinearLayout { public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); if (biometricView.getParent() != null) { - ((ViewGroup) biometricView.getParent()).removeView(biometricView); + // ((ViewGroup) biometricView.getParent()).removeView(biometricView); } mSize = newSize; } From 19ecfcde18976efcad11805128b7cb9f05b566f1 Mon Sep 17 00:00:00 2001 From: Kevin Chyn Date: Fri, 25 Oct 2019 13:59:05 -0700 Subject: [PATCH 2/3] Animate height animator together with the rest of the AnimatorSet The height animator was using the default animation duration, thus ending earlier, causing the invalidateOutline to not be invoked for the remainder of the AnimatorSet's duration. Fixes: 143371342 Test: BiometricPromptDemo, rotate to landscape, tap "Use Pattern" Change-Id: I6a46bb2f596adc20152ed25e95a66410fd57d257 --- .../com/android/systemui/biometrics/AuthPanelController.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/AuthPanelController.java b/packages/SystemUI/src/com/android/systemui/biometrics/AuthPanelController.java index 2b8b586961ffb..4acbadea3a37e 100644 --- a/packages/SystemUI/src/com/android/systemui/biometrics/AuthPanelController.java +++ b/packages/SystemUI/src/com/android/systemui/biometrics/AuthPanelController.java @@ -19,7 +19,6 @@ package com.android.systemui.biometrics; import android.animation.AnimatorSet; import android.animation.ValueAnimator; import android.content.Context; -import android.graphics.Color; import android.graphics.Outline; import android.util.Log; import android.view.View; @@ -142,7 +141,6 @@ public class AuthPanelController extends ViewOutlineProvider { mContentHeight = (int) animation.getAnimatedValue(); mPanelView.invalidateOutline(); }); - heightAnimator.start(); // Animate width ValueAnimator widthAnimator = ValueAnimator.ofInt(mContentWidth, contentWidth); @@ -163,7 +161,8 @@ public class AuthPanelController extends ViewOutlineProvider { AnimatorSet as = new AnimatorSet(); as.setDuration(animateDurationMs); as.setInterpolator(new AccelerateDecelerateInterpolator()); - as.playTogether(cornerAnimator, widthAnimator, marginAnimator, alphaAnimator); + as.playTogether(cornerAnimator, heightAnimator, widthAnimator, marginAnimator, + alphaAnimator); as.start(); } else { From 656a697c6c5fdd42ce91429bf835de262f1db740 Mon Sep 17 00:00:00 2001 From: Kevin Chyn Date: Fri, 25 Oct 2019 14:16:41 -0700 Subject: [PATCH 3/3] Move the animation delay for credential UI up one layer This way we can remove the view and do the appropriate logic that's supposed to happen in onDetachedFromWindow. Fixes: 143174046 Test: atest com.android.systemui.biometrics Test: BiometricPromptDemo, tap "Use password", repeat 10+ times Change-Id: Idd1f2b2bc91fae97d97f7301ee762ed946da9f8f --- .../systemui/biometrics/AuthBiometricView.java | 11 +++-------- .../systemui/biometrics/AuthContainerView.java | 15 +++++++++++---- .../biometrics/AuthBiometricViewTest.java | 5 ----- .../biometrics/AuthContainerViewTest.java | 6 +++++- 4 files changed, 19 insertions(+), 18 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/AuthBiometricView.java b/packages/SystemUI/src/com/android/systemui/biometrics/AuthBiometricView.java index d38b31ac9fca6..f5f1fad71b147 100644 --- a/packages/SystemUI/src/com/android/systemui/biometrics/AuthBiometricView.java +++ b/packages/SystemUI/src/com/android/systemui/biometrics/AuthBiometricView.java @@ -32,6 +32,7 @@ import android.text.TextUtils; import android.util.AttributeSet; import android.util.Log; import android.view.View; +import android.view.ViewGroup; import android.view.accessibility.AccessibilityManager; import android.widget.Button; import android.widget.ImageView; @@ -149,10 +150,6 @@ public abstract class AuthBiometricView extends LinearLayout { public int getMediumToLargeAnimationDurationMs() { return AuthDialog.ANIMATE_MEDIUM_TO_LARGE_DURATION_MS; } - - public int getAnimateCredentialStartDelayMs() { - return AuthDialog.ANIMATE_CREDENTIAL_START_DELAY_MS; - } } private final Injector mInjector; @@ -401,7 +398,7 @@ public abstract class AuthBiometricView extends LinearLayout { public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); if (biometricView.getParent() != null) { - // ((ViewGroup) biometricView.getParent()).removeView(biometricView); + ((ViewGroup) biometricView.getParent()).removeView(biometricView); } mSize = newSize; } @@ -629,9 +626,7 @@ public abstract class AuthBiometricView extends LinearLayout { */ void startTransitionToCredentialUI() { updateSize(AuthDialog.SIZE_LARGE); - mHandler.postDelayed(() -> { - mCallback.onAction(Callback.ACTION_USE_DEVICE_CREDENTIAL); - }, mInjector.getAnimateCredentialStartDelayMs()); + mCallback.onAction(Callback.ACTION_USE_DEVICE_CREDENTIAL); } @Override diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/AuthContainerView.java b/packages/SystemUI/src/com/android/systemui/biometrics/AuthContainerView.java index f1abdb31b5f8e..3948416ff4f7b 100644 --- a/packages/SystemUI/src/com/android/systemui/biometrics/AuthContainerView.java +++ b/packages/SystemUI/src/com/android/systemui/biometrics/AuthContainerView.java @@ -24,13 +24,12 @@ import android.content.Context; import android.graphics.PixelFormat; import android.graphics.PorterDuff; import android.graphics.drawable.Drawable; -import android.hardware.biometrics.Authenticator; import android.hardware.biometrics.BiometricAuthenticator; -import android.hardware.biometrics.BiometricPrompt; import android.os.Binder; import android.os.Bundle; +import android.os.Handler; import android.os.IBinder; -import android.os.UserManager; +import android.os.Looper; import android.util.Log; import android.view.KeyEvent; import android.view.LayoutInflater; @@ -75,6 +74,7 @@ public class AuthContainerView extends LinearLayout @interface ContainerState {} final Config mConfig; + private final Handler mHandler; private final Injector mInjector; private final IBinder mWindowToken = new Binder(); private final WindowManager mWindowManager; @@ -177,6 +177,10 @@ public class AuthContainerView extends LinearLayout View getPanelView(FrameLayout parent) { return parent.findViewById(R.id.panel); } + + int getAnimateCredentialStartDelayMs() { + return AuthDialog.ANIMATE_CREDENTIAL_START_DELAY_MS; + } } @VisibleForTesting @@ -201,7 +205,9 @@ public class AuthContainerView extends LinearLayout break; case AuthBiometricView.Callback.ACTION_USE_DEVICE_CREDENTIAL: mConfig.mCallback.onDeviceCredentialPressed(); - addCredentialView(false /* animatePanel */, true /* animateContents */); + mHandler.postDelayed(() -> { + addCredentialView(false /* animatePanel */, true /* animateContents */); + }, mInjector.getAnimateCredentialStartDelayMs()); break; default: Log.e(TAG, "Unhandled action: " + action); @@ -223,6 +229,7 @@ public class AuthContainerView extends LinearLayout mConfig = config; mInjector = injector; + mHandler = new Handler(Looper.getMainLooper()); mWindowManager = mContext.getSystemService(WindowManager.class); mWakefulnessLifecycle = Dependency.get(WakefulnessLifecycle.class); diff --git a/packages/SystemUI/tests/src/com/android/systemui/biometrics/AuthBiometricViewTest.java b/packages/SystemUI/tests/src/com/android/systemui/biometrics/AuthBiometricViewTest.java index 2c85424bac792..df676376b479c 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/biometrics/AuthBiometricViewTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/biometrics/AuthBiometricViewTest.java @@ -370,11 +370,6 @@ public class AuthBiometricViewTest extends SysuiTestCase { public int getMediumToLargeAnimationDurationMs() { return 0; } - - @Override - public int getAnimateCredentialStartDelayMs() { - return 0; - } } private class TestableBiometricView extends AuthBiometricView { diff --git a/packages/SystemUI/tests/src/com/android/systemui/biometrics/AuthContainerViewTest.java b/packages/SystemUI/tests/src/com/android/systemui/biometrics/AuthContainerViewTest.java index 990f74ae33c85..6e438e8e5772a 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/biometrics/AuthContainerViewTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/biometrics/AuthContainerViewTest.java @@ -16,7 +16,6 @@ package com.android.systemui.biometrics; -import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; @@ -206,5 +205,10 @@ public class AuthContainerViewTest extends SysuiTestCase { public View getPanelView(FrameLayout parent) { return mock(View.class); } + + @Override + public int getAnimateCredentialStartDelayMs() { + return 0; + } } }