Avoid unwanted wakeAndUnLock mode for face
Test: press power repeatedly on lock screen
Bug: 132846921
Fixes: 130766403
Bug: 130327302
Change-Id: Ic11914ad220a0c8f81f0d28d5f999fcf970ccdeb
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java b/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java
index 26d3d86..5d1f8b1 100644
--- a/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java
+++ b/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java
@@ -748,6 +748,10 @@
private void handleFaceAuthenticated(int authUserId) {
Trace.beginSection("KeyGuardUpdateMonitor#handlerFaceAuthenticated");
try {
+ if (mGoingToSleep) {
+ Log.d(TAG, "Aborted successful auth because device is going to sleep.");
+ return;
+ }
final int userId;
try {
userId = ActivityManager.getService().getCurrentUser().id;
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/BiometricUnlockController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/BiometricUnlockController.java
index d677952..aa78a5d 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/BiometricUnlockController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/BiometricUnlockController.java
@@ -365,16 +365,23 @@
private int calculateMode(BiometricSourceType biometricSourceType) {
boolean unlockingAllowed = mUpdateMonitor.isUnlockingWithBiometricAllowed();
boolean deviceDreaming = mUpdateMonitor.isDreaming();
- boolean faceStayingOnKeyguard = biometricSourceType == BiometricSourceType.FACE
- && !mKeyguardBypassController.getBypassEnabled();
+ boolean face = biometricSourceType == BiometricSourceType.FACE;
+ boolean faceStayingOnKeyguard = face && !mKeyguardBypassController.getBypassEnabled();
if (!mUpdateMonitor.isDeviceInteractive()) {
if (!mStatusBarKeyguardViewManager.isShowing()) {
return MODE_ONLY_WAKE;
} else if (mDozeScrimController.isPulsing() && unlockingAllowed) {
return faceStayingOnKeyguard ? MODE_NONE : MODE_WAKE_AND_UNLOCK_PULSING;
- } else if (unlockingAllowed || !mUnlockMethodCache.isMethodSecure()) {
+ } else if (!face && (unlockingAllowed || !mUnlockMethodCache.isMethodSecure())) {
return MODE_WAKE_AND_UNLOCK;
+ } else if (face) {
+ if (!(mDozeScrimController.isPulsing() && !unlockingAllowed)) {
+ Log.wtf(TAG, "Face somehow arrived when the device was not interactive");
+ }
+ // We could theoretically return MODE_NONE, but this means that the device
+ // would be not interactive, unlocked, and the user would not see the device state.
+ return MODE_ONLY_WAKE;
} else {
return MODE_SHOW_BOUNCER;
}
@@ -389,6 +396,8 @@
return MODE_DISMISS_BOUNCER;
} else if (unlockingAllowed) {
return faceStayingOnKeyguard ? MODE_ONLY_WAKE : MODE_UNLOCK;
+ } else if (face) {
+ return MODE_NONE;
} else if (!mStatusBarKeyguardViewManager.isBouncerShowing()) {
return MODE_SHOW_BOUNCER;
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBypassController.kt b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBypassController.kt
index c9dd461..124206a 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBypassController.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBypassController.kt
@@ -19,7 +19,6 @@
import android.content.Context
import android.hardware.face.FaceManager
import android.provider.Settings
-import com.android.internal.annotations.VisibleForTesting
import com.android.keyguard.KeyguardUpdateMonitor
import com.android.systemui.tuner.TunerService
@@ -59,10 +58,4 @@
}
}, Settings.Secure.FACE_UNLOCK_DISMISSES_KEYGUARD)
}
-
- @VisibleForTesting
- constructor(bypassEnabled: Boolean, unlockMethodCache: UnlockMethodCache) {
- this.bypassEnabled = bypassEnabled
- this.unlockMethodCache = unlockMethodCache
- }
}