diff options
| -rw-r--r-- | packages/SystemUI/src/com/android/keyguard/DisabledUdfpsController.java | 26 | ||||
| -rw-r--r-- | packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java | 34 |
2 files changed, 45 insertions, 15 deletions
diff --git a/packages/SystemUI/src/com/android/keyguard/DisabledUdfpsController.java b/packages/SystemUI/src/com/android/keyguard/DisabledUdfpsController.java index f01b67b7b5c2..945c9c499401 100644 --- a/packages/SystemUI/src/com/android/keyguard/DisabledUdfpsController.java +++ b/packages/SystemUI/src/com/android/keyguard/DisabledUdfpsController.java @@ -20,6 +20,7 @@ import static android.hardware.biometrics.BiometricSourceType.FINGERPRINT; import android.hardware.biometrics.BiometricSourceType; import android.view.View; +import android.view.ViewGroup; import androidx.annotation.NonNull; @@ -73,13 +74,15 @@ public class DisabledUdfpsController extends ViewController<DisabledUdfpsView> i @Override protected void onViewAttached() { - mKeyguardUpdateMonitor.registerCallback(mKeyguardUpdateMonitorCallback); mIsBouncerShowing = mKeyguardViewController.isBouncerShowing(); - - mStatusBarStateController.addCallback(mStatusBarStateListener); mIsKeyguardShowing = mStatusBarStateController.getState() == StatusBarState.KEYGUARD; mIsDozing = mStatusBarStateController.isDozing(); + mRunningFPS = mKeyguardUpdateMonitor.isFingerprintDetectionRunning(); mAuthenticated = false; + updateButtonVisibility(); + + mKeyguardUpdateMonitor.registerCallback(mKeyguardUpdateMonitorCallback); + mStatusBarStateController.addCallback(mStatusBarStateListener); } @Override @@ -88,6 +91,15 @@ public class DisabledUdfpsController extends ViewController<DisabledUdfpsView> i mStatusBarStateController.removeCallback(mStatusBarStateListener); } + /** + * Call when this controller is no longer needed. This will remove the view from its parent. + */ + public void destroy() { + if (mView != null && mView.getParent() != null) { + ((ViewGroup) mView.getParent()).removeView(mView); + } + } + private void updateButtonVisibility() { mShowButton = !mAuthenticated && !mIsDozing && mIsKeyguardShowing && !mIsBouncerShowing && !mRunningFPS; @@ -143,6 +155,14 @@ public class DisabledUdfpsController extends ViewController<DisabledUdfpsView> i public void onBiometricRunningStateChanged(boolean running, BiometricSourceType biometricSourceType) { mRunningFPS = running && biometricSourceType == FINGERPRINT; + mAuthenticated &= !mRunningFPS; + updateButtonVisibility(); + } + + @Override + public void onBiometricAuthenticated(int userId, + BiometricSourceType biometricSourceType, boolean isStrongBiometric) { + mAuthenticated = true; updateButtonVisibility(); } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java index 615ff79feb1e..6940050f754b 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java @@ -281,18 +281,8 @@ public class NotificationPanelViewController extends PanelViewController { @Override public void onKeyguardVisibilityChanged(boolean showing) { - if (mDisabledUdfpsController == null - && mAuthController.getUdfpsRegion() != null - && mAuthController.isUdfpsEnrolled( - KeyguardUpdateMonitor.getCurrentUser())) { - mLayoutInflater.inflate(R.layout.disabled_udfps_view, mView); - mDisabledUdfpsController = new DisabledUdfpsController( - mView.findViewById(R.id.disabled_udfps_view), - mStatusBarStateController, - mUpdateMonitor, - mAuthController, - mStatusBarKeyguardViewManager); - mDisabledUdfpsController.init(); + if (showing) { + updateDisabledUdfpsController(); } } }; @@ -3561,6 +3551,25 @@ public class NotificationPanelViewController extends PanelViewController { } } + private void updateDisabledUdfpsController() { + final boolean udfpsEnrolled = mAuthController.getUdfpsRegion() != null + && mAuthController.isUdfpsEnrolled( + KeyguardUpdateMonitor.getCurrentUser()); + if (mDisabledUdfpsController == null && udfpsEnrolled) { + mLayoutInflater.inflate(R.layout.disabled_udfps_view, mView); + mDisabledUdfpsController = new DisabledUdfpsController( + mView.findViewById(R.id.disabled_udfps_view), + mStatusBarStateController, + mUpdateMonitor, + mAuthController, + mStatusBarKeyguardViewManager); + mDisabledUdfpsController.init(); + } else if (mDisabledUdfpsController != null && !udfpsEnrolled) { + mDisabledUdfpsController.destroy(); + mDisabledUdfpsController = null; + } + } + private class OnHeightChangedListener implements ExpandableView.OnHeightChangedListener { @Override public void onHeightChanged(ExpandableView view, boolean needsAnimation) { @@ -3980,6 +3989,7 @@ public class NotificationPanelViewController extends PanelViewController { FragmentHostManager.get(mView).addTagListener(QS.TAG, mFragmentListener); mStatusBarStateController.addCallback(mStatusBarStateListener); mConfigurationController.addCallback(mConfigurationListener); + updateDisabledUdfpsController(); mUpdateMonitor.registerCallback(mKeyguardUpdateCallback); // Theme might have changed between inflating this view and attaching it to the // window, so |