Merge "resetFgsRestrictionLocked() must be called AFTER logFGSStateChangeLocked()." into sc-dev
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardPinBasedInputView.java b/packages/SystemUI/src/com/android/keyguard/KeyguardPinBasedInputView.java
index c95101e..0b8868f 100644
--- a/packages/SystemUI/src/com/android/keyguard/KeyguardPinBasedInputView.java
+++ b/packages/SystemUI/src/com/android/keyguard/KeyguardPinBasedInputView.java
@@ -62,10 +62,9 @@
 
     @Override
     protected void setPasswordEntryEnabled(boolean enabled) {
-        boolean wasEnabled = mPasswordEntry.isEnabled();
         mPasswordEntry.setEnabled(enabled);
         mOkButton.setEnabled(enabled);
-        if (enabled && !wasEnabled && !mPasswordEntry.hasFocus()) {
+        if (enabled && !mPasswordEntry.hasFocus()) {
             mPasswordEntry.requestFocus();
         }
     }
diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsHbmProvider.java b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsHbmProvider.java
index 52141c0..da24a8f 100644
--- a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsHbmProvider.java
+++ b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsHbmProvider.java
@@ -31,8 +31,10 @@
     /**
      * UdfpsView will call this to enable the HBM when the fingerprint illumination is needed.
      *
-     * The call must be made from the UI thread. The callback, if provided, will also be invoked
-     * from the UI thread.
+     * This method is a no-op when some type of HBM is already enabled.
+     *
+     * This method must be called from the UI thread. The callback, if provided, will also be
+     * invoked from the UI thread.
      *
      * @param hbmType The type of HBM that should be enabled. See {@link UdfpsHbmTypes}.
      * @param surface The surface for which the HBM is requested, in case the HBM implementation
@@ -45,14 +47,14 @@
     /**
      * UdfpsView will call this to disable the HBM when the illumination is not longer needed.
      *
+     * This method is a no-op when HBM is already disabled. If HBM is enabled, this method will
+     * disable HBM for the {@code hbmType} and {@code surface} that were provided to the
+     * corresponding {@link #enableHbm(int, Surface, Runnable)}.
+     *
      * The call must be made from the UI thread. The callback, if provided, will also be invoked
      * from the UI thread.
      *
-     * @param hbmType The type of HBM that should be disabled. See {@link UdfpsHbmTypes}.
-     * @param surface The surface for which the HBM is requested, in case the HBM implementation
-     *                needs to unset special surface flags to disable the HBM. Can be null.
      * @param onHbmDisabled A runnable that will be executed once HBM is disabled.
      */
-    void disableHbm(@HbmType int hbmType, @Nullable Surface surface,
-            @Nullable Runnable onHbmDisabled);
+    void disableHbm(@Nullable Runnable onHbmDisabled);
 }
diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsSurfaceView.java b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsSurfaceView.java
index 86e3ae6..6a6f57a 100644
--- a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsSurfaceView.java
+++ b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsSurfaceView.java
@@ -124,8 +124,9 @@
     @Override
     public void stopIllumination() {
         if (mHbmProvider != null) {
-            final Runnable onHbmDisabled = this::invalidate;
-            mHbmProvider.disableHbm(mHbmType, mHolder.getSurface(), onHbmDisabled);
+            final Runnable onHbmDisabled =
+                    (mHbmType == UdfpsHbmTypes.GLOBAL_HBM) ? this::invalidate : null;
+            mHbmProvider.disableHbm(onHbmDisabled);
         } else {
             Log.e(TAG, "stopIllumination | mHbmProvider is null");
         }