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 4d4818d51414d73f6d699c3f02d4c87b366fe403..6159f6ca7d1ec6040a00ba8ee25054ce1dcef41c 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/BiometricUnlockController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/BiometricUnlockController.java @@ -39,7 +39,6 @@ import com.android.systemui.keyguard.KeyguardViewMediator; import com.android.systemui.keyguard.ScreenLifecycle; import com.android.systemui.keyguard.WakefulnessLifecycle; import com.android.systemui.statusbar.NotificationMediaManager; -import com.android.systemui.tuner.TunerService; import java.io.PrintWriter; @@ -102,20 +101,10 @@ public class BiometricUnlockController extends KeyguardUpdateMonitorCallback { */ private static final float BIOMETRIC_COLLAPSE_SPEEDUP_FACTOR = 1.1f; - /** - * If face unlock dismisses the lock screen or keeps user on keyguard by default on this device. - */ - private final boolean mFaceDismissesKeyguardByDefault; - - /** - * If face unlock dismisses the lock screen or keeps user on keyguard for the current user. - */ - @VisibleForTesting - protected boolean mFaceDismissesKeyguard; - private final NotificationMediaManager mMediaManager; private final PowerManager mPowerManager; private final Handler mHandler; + private final KeyguardBypassController mKeyguardBypassController; private PowerManager.WakeLock mWakeLock; private final KeyguardUpdateMonitor mUpdateMonitor; private final UnlockMethodCache mUnlockMethodCache; @@ -133,16 +122,6 @@ public class BiometricUnlockController extends KeyguardUpdateMonitorCallback { private boolean mPendingShowBouncer; private boolean mHasScreenTurnedOnSinceAuthenticating; - private final TunerService.Tunable mFaceDismissedKeyguardTunable = new TunerService.Tunable() { - @Override - public void onTuningChanged(String key, String newValue) { - int defaultValue = mFaceDismissesKeyguardByDefault ? 1 : 0; - mFaceDismissesKeyguard = Settings.Secure.getIntForUser(mContext.getContentResolver(), - Settings.Secure.FACE_UNLOCK_DISMISSES_KEYGUARD, - defaultValue, KeyguardUpdateMonitor.getCurrentUser()) != 0; - } - }; - private final MetricsLogger mMetricsLogger = Dependency.get(MetricsLogger.class); public BiometricUnlockController(Context context, @@ -152,12 +131,12 @@ public class BiometricUnlockController extends KeyguardUpdateMonitorCallback { StatusBar statusBar, UnlockMethodCache unlockMethodCache, Handler handler, KeyguardUpdateMonitor keyguardUpdateMonitor, - TunerService tunerService) { + KeyguardBypassController keyguardBypassController) { this(context, dozeScrimController, keyguardViewMediator, scrimController, statusBar, - unlockMethodCache, handler, keyguardUpdateMonitor, tunerService, + unlockMethodCache, handler, keyguardUpdateMonitor, context.getResources() .getInteger(com.android.internal.R.integer.config_wakeUpDelayDoze), - context.getResources().getBoolean(R.bool.config_faceAuthDismissesKeyguard)); + keyguardBypassController); } @VisibleForTesting @@ -168,9 +147,8 @@ public class BiometricUnlockController extends KeyguardUpdateMonitorCallback { StatusBar statusBar, UnlockMethodCache unlockMethodCache, Handler handler, KeyguardUpdateMonitor keyguardUpdateMonitor, - TunerService tunerService, int wakeUpDelay, - boolean faceDismissesKeyguard) { + KeyguardBypassController keyguardBypassController) { mContext = context; mPowerManager = context.getSystemService(PowerManager.class); mUpdateMonitor = keyguardUpdateMonitor; @@ -186,9 +164,7 @@ public class BiometricUnlockController extends KeyguardUpdateMonitorCallback { mUnlockMethodCache = unlockMethodCache; mHandler = handler; mWakeUpDelay = wakeUpDelay; - mFaceDismissesKeyguardByDefault = faceDismissesKeyguard; - tunerService.addTunable(mFaceDismissedKeyguardTunable, - Settings.Secure.FACE_UNLOCK_DISMISSES_KEYGUARD); + mKeyguardBypassController = keyguardBypassController; } public void setStatusBarKeyguardViewManager( @@ -392,7 +368,7 @@ public class BiometricUnlockController extends KeyguardUpdateMonitorCallback { boolean unlockingAllowed = mUpdateMonitor.isUnlockingWithBiometricAllowed(); boolean deviceDreaming = mUpdateMonitor.isDreaming(); boolean faceStayingOnKeyguard = biometricSourceType == BiometricSourceType.FACE - && !mFaceDismissesKeyguard; + && !mKeyguardBypassController.getBypassEnabled(); if (!mUpdateMonitor.isDeviceInteractive()) { if (!mStatusBarKeyguardViewManager.isShowing()) { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBypassController.kt b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBypassController.kt new file mode 100644 index 0000000000000000000000000000000000000000..5b5eb767e184e20c7f50275f01f8f64bf3b9dfd5 --- /dev/null +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBypassController.kt @@ -0,0 +1,59 @@ +/* + * Copyright (C) 2019 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License + */ + +package com.android.systemui.statusbar.phone + +import android.content.Context +import android.provider.Settings +import com.android.internal.annotations.VisibleForTesting +import com.android.keyguard.KeyguardUpdateMonitor +import com.android.systemui.R +import com.android.systemui.tuner.TunerService + +import javax.inject.Inject +import javax.inject.Singleton + +@Singleton +class KeyguardBypassController { + + @Inject + constructor(context: Context, + tunerService: TunerService) { + val dismissByDefault = if (context.getResources().getBoolean( + R.bool.config_faceAuthDismissesKeyguard)) 1 else 0 + tunerService.addTunable( + object : TunerService.Tunable { + override fun onTuningChanged(key: String?, newValue: String?) { + bypassEnabled = Settings.Secure.getIntForUser( + context.contentResolver, + Settings.Secure.FACE_UNLOCK_DISMISSES_KEYGUARD, + dismissByDefault, + KeyguardUpdateMonitor.getCurrentUser()) != 0 + } + }, Settings.Secure.FACE_UNLOCK_DISMISSES_KEYGUARD) + } + + @VisibleForTesting + constructor(bypassEnabled: Boolean) { + this.bypassEnabled = bypassEnabled; + } + + /** + * If face unlock dismisses the lock screen or keeps user on keyguard for the current user. + */ + var bypassEnabled: Boolean = false + private set +} diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java index 4e8f58413303093b22086ec81ae897d4cbdd9db9..75a820c8cc081cc0a25ab44e8c13e54e23498c9e 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java @@ -386,6 +386,8 @@ public class StatusBar extends SystemUI implements DemoMode, PulseExpansionHandler mPulseExpansionHandler; @Inject NotificationWakeUpCoordinator mWakeUpCoordinator; + @Inject + KeyguardBypassController mKeyguardBypassController; // expanded notifications protected NotificationPanelView mNotificationPanel; // the sliding/resizing panel within the notification window @@ -1229,7 +1231,7 @@ public class StatusBar extends SystemUI implements DemoMode, mBiometricUnlockController = new BiometricUnlockController(mContext, mDozeScrimController, keyguardViewMediator, mScrimController, this, UnlockMethodCache.getInstance(mContext), - new Handler(), mKeyguardUpdateMonitor, Dependency.get(TunerService.class)); + new Handler(), mKeyguardUpdateMonitor, mKeyguardBypassController); mStatusBarKeyguardViewManager = keyguardViewMediator.registerStatusBar(this, getBouncerContainer(), mNotificationPanel, mBiometricUnlockController, mStatusBarWindow.findViewById(R.id.lock_icon_container)); 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 d2d294bf8d373a5f86680dd8d1464413be375e44..fdc2cd3483cae025b9838665517f78282f17be8e 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 @@ -71,8 +71,6 @@ public class BiometricsUnlockControllerTest extends SysuiTestCase { @Mock private UnlockMethodCache mUnlockMethodCache; @Mock - private TunerService mTunerService; - @Mock private Handler mHandler; private BiometricUnlockController mBiometricUnlockController; @@ -192,9 +190,8 @@ public class BiometricsUnlockControllerTest extends SysuiTestCase { TestableBiometricUnlockController(boolean faceDismissesKeyguard) { super(mContext, mDozeScrimController, mKeyguardViewMediator, mScrimController, mStatusBar, mUnlockMethodCache, - mHandler, mUpdateMonitor, mTunerService, 0 /* wakeUpDelay */, - faceDismissesKeyguard); - mFaceDismissesKeyguard = faceDismissesKeyguard; + mHandler, mUpdateMonitor, 0 /* wakeUpDelay */, + new KeyguardBypassController(faceDismissesKeyguard)); } } }