From f8afdce2150d1a9d44f293eecba3cc8733756878 Mon Sep 17 00:00:00 2001 From: Kevin Chyn Date: Tue, 28 Sep 2021 13:54:30 -0700 Subject: [PATCH] Ensure face icon controller is deactivated when view is detached Fixes: 197397546 Check AuthBiometricFaceView logs in the below cases: Test: start auth, dismiss while face is scanning Test: start auth, turn off screen while face is scanning Change-Id: I8ed98f80998fce4a1e67e57380ee7f19c811b4d8 --- .../biometrics/AuthBiometricFaceView.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/AuthBiometricFaceView.java b/packages/SystemUI/src/com/android/systemui/biometrics/AuthBiometricFaceView.java index c32c1a2f3e53b..48f6431aec69b 100644 --- a/packages/SystemUI/src/com/android/systemui/biometrics/AuthBiometricFaceView.java +++ b/packages/SystemUI/src/com/android/systemui/biometrics/AuthBiometricFaceView.java @@ -16,7 +16,6 @@ package com.android.systemui.biometrics; -import android.annotation.NonNull; import android.content.Context; import android.graphics.drawable.Animatable2; import android.graphics.drawable.AnimatedVectorDrawable; @@ -30,6 +29,7 @@ import android.view.View; import android.widget.ImageView; import android.widget.TextView; +import androidx.annotation.NonNull; import androidx.annotation.Nullable; import com.android.internal.annotations.VisibleForTesting; @@ -163,6 +163,18 @@ public class AuthBiometricFaceView extends AuthBiometricView { } @Nullable @VisibleForTesting IconController mFaceIconController; + @NonNull private final OnAttachStateChangeListener mOnAttachStateChangeListener = + new OnAttachStateChangeListener() { + @Override + public void onViewAttachedToWindow(View v) { + + } + + @Override + public void onViewDetachedFromWindow(View v) { + mFaceIconController.deactivate(); + } + }; public AuthBiometricFaceView(Context context) { this(context, null); @@ -181,6 +193,8 @@ public class AuthBiometricFaceView extends AuthBiometricView { protected void onFinishInflate() { super.onFinishInflate(); mFaceIconController = new IconController(mContext, mIconView, mIndicatorView); + + addOnAttachStateChangeListener(mOnAttachStateChangeListener); } @Override