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
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user