From bd84c168f4738897f69dc6b72a30bef25f1e8513 Mon Sep 17 00:00:00 2001 From: Selim Cinek Date: Tue, 11 Jun 2019 16:23:23 -0700 Subject: [PATCH] Not bypassing the lockscreen anymore when the user has pulled down Previously we would bypass the lockscreen even if the user has already pulled down. Bug: 134094877 Test: atest SystemUITests Change-Id: Ic86f345a53da83a111ace2ede86648596c3ad982 --- .../phone/BiometricUnlockController.java | 9 +++++++ .../statusbar/phone/HeadsUpManagerPhone.java | 2 -- .../phone/KeyguardBypassController.kt | 27 ++++++++++++++++--- .../phone/BiometricsUnlockControllerTest.java | 1 + .../phone/NotificationPanelViewTest.java | 2 +- 5 files changed, 35 insertions(+), 6 deletions(-) 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 aa78a5d63f7e1..35df7d920e29d 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/BiometricUnlockController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/BiometricUnlockController.java @@ -163,6 +163,7 @@ public class BiometricUnlockController extends KeyguardUpdateMonitorCallback { mHandler = handler; mWakeUpDelay = wakeUpDelay; mKeyguardBypassController = keyguardBypassController; + mKeyguardBypassController.setUnlockController(this); } public void setStatusBarKeyguardViewManager( @@ -234,6 +235,14 @@ public class BiometricUnlockController extends KeyguardUpdateMonitorCallback { } mMetricsLogger.write(new LogMaker(MetricsEvent.BIOMETRIC_AUTH) .setType(MetricsEvent.TYPE_SUCCESS).setSubtype(toSubtype(biometricSourceType))); + boolean unlockAllowed = mKeyguardBypassController.onBiometricAuthenticated( + biometricSourceType); + if (unlockAllowed) { + startWakeAndUnlock(biometricSourceType); + } + } + + private void startWakeAndUnlock(BiometricSourceType biometricSourceType) { startWakeAndUnlock(calculateMode(biometricSourceType)); } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpManagerPhone.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpManagerPhone.java index 9cdb2cdd40735..b6ba3695b7053 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpManagerPhone.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpManagerPhone.java @@ -16,8 +16,6 @@ package com.android.systemui.statusbar.phone; -import static com.android.systemui.util.InjectionInflationController.VIEW_CONTEXT; - import android.annotation.NonNull; import android.annotation.Nullable; import android.content.Context; 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 124206a5a369d..9bbe4bed7c0ee 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBypassController.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBypassController.kt @@ -17,17 +17,22 @@ package com.android.systemui.statusbar.phone import android.content.Context +import android.hardware.biometrics.BiometricSourceType import android.hardware.face.FaceManager import android.provider.Settings import com.android.keyguard.KeyguardUpdateMonitor +import com.android.systemui.plugins.statusbar.StatusBarStateController +import com.android.systemui.statusbar.StatusBarState import com.android.systemui.tuner.TunerService - import javax.inject.Inject import javax.inject.Singleton @Singleton class KeyguardBypassController { + private val unlockMethodCache: UnlockMethodCache + private val statusBarStateController: StatusBarStateController + /** * If face unlock dismisses the lock screen or keeps user on keyguard for the current user. */ @@ -35,11 +40,13 @@ class KeyguardBypassController { get() = field && unlockMethodCache.isUnlockingWithFacePossible private set - private val unlockMethodCache: UnlockMethodCache + lateinit var unlockController: BiometricUnlockController @Inject - constructor(context: Context, tunerService: TunerService) { + constructor(context: Context, tunerService: TunerService, + statusBarStateController: StatusBarStateController) { unlockMethodCache = UnlockMethodCache.getInstance(context) + this.statusBarStateController = statusBarStateController val faceManager = context.getSystemService(FaceManager::class.java) if (faceManager?.isHardwareDetected != true) { return @@ -58,4 +65,18 @@ class KeyguardBypassController { } }, Settings.Secure.FACE_UNLOCK_DISMISSES_KEYGUARD) } + + /** + * Notify that the biometric unlock has happened. + * + * @return false if we can not wake and unlock right now + */ + fun onBiometricAuthenticated(biometricSourceType: BiometricSourceType): Boolean { + if (bypassEnabled && statusBarStateController.state != StatusBarState.KEYGUARD) { + // We're bypassing but not actually on the lockscreen, the user should decide when + // to unlock + return false + } + return true + } } diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/BiometricsUnlockControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/BiometricsUnlockControllerTest.java index eb3f56a19c9e8..3d49d58b4202b 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/BiometricsUnlockControllerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/BiometricsUnlockControllerTest.java @@ -81,6 +81,7 @@ public class BiometricsUnlockControllerTest extends SysuiTestCase { when(mStatusBarKeyguardViewManager.isShowing()).thenReturn(true); when(mUpdateMonitor.isDeviceInteractive()).thenReturn(true); when(mUnlockMethodCache.isUnlockingWithFacePossible()).thenReturn(true); + when(mKeyguardBypassController.onBiometricAuthenticated(any())).thenReturn(true); mContext.addMockSystemService(PowerManager.class, mPowerManager); mDependency.injectTestDependency(NotificationMediaManager.class, mMediaManager); mDependency.injectTestDependency(StatusBarWindowController.class, diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationPanelViewTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationPanelViewTest.java index e92dd4c44e7d0..747411adedcee 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationPanelViewTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationPanelViewTest.java @@ -112,7 +112,7 @@ public class NotificationPanelViewTest extends SysuiTestCase { mDependency.injectMockDependency(ConfigurationController.class); mDependency.injectMockDependency(ZenModeController.class); KeyguardBypassController bypassController = new KeyguardBypassController(mContext, - mock(TunerService.class)); + mock(TunerService.class), mStatusBarStateController); NotificationWakeUpCoordinator coordinator = new NotificationWakeUpCoordinator(mContext, mock(HeadsUpManagerPhone.class),