Merge "Introduced KeyguardBypassController" into qt-r1-dev
This commit is contained in:
@@ -39,7 +39,6 @@ import com.android.systemui.keyguard.KeyguardViewMediator;
|
|||||||
import com.android.systemui.keyguard.ScreenLifecycle;
|
import com.android.systemui.keyguard.ScreenLifecycle;
|
||||||
import com.android.systemui.keyguard.WakefulnessLifecycle;
|
import com.android.systemui.keyguard.WakefulnessLifecycle;
|
||||||
import com.android.systemui.statusbar.NotificationMediaManager;
|
import com.android.systemui.statusbar.NotificationMediaManager;
|
||||||
import com.android.systemui.tuner.TunerService;
|
|
||||||
|
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
|
|
||||||
@@ -102,20 +101,10 @@ public class BiometricUnlockController extends KeyguardUpdateMonitorCallback {
|
|||||||
*/
|
*/
|
||||||
private static final float BIOMETRIC_COLLAPSE_SPEEDUP_FACTOR = 1.1f;
|
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 NotificationMediaManager mMediaManager;
|
||||||
private final PowerManager mPowerManager;
|
private final PowerManager mPowerManager;
|
||||||
private final Handler mHandler;
|
private final Handler mHandler;
|
||||||
|
private final KeyguardBypassController mKeyguardBypassController;
|
||||||
private PowerManager.WakeLock mWakeLock;
|
private PowerManager.WakeLock mWakeLock;
|
||||||
private final KeyguardUpdateMonitor mUpdateMonitor;
|
private final KeyguardUpdateMonitor mUpdateMonitor;
|
||||||
private final UnlockMethodCache mUnlockMethodCache;
|
private final UnlockMethodCache mUnlockMethodCache;
|
||||||
@@ -133,16 +122,6 @@ public class BiometricUnlockController extends KeyguardUpdateMonitorCallback {
|
|||||||
private boolean mPendingShowBouncer;
|
private boolean mPendingShowBouncer;
|
||||||
private boolean mHasScreenTurnedOnSinceAuthenticating;
|
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);
|
private final MetricsLogger mMetricsLogger = Dependency.get(MetricsLogger.class);
|
||||||
|
|
||||||
public BiometricUnlockController(Context context,
|
public BiometricUnlockController(Context context,
|
||||||
@@ -152,12 +131,12 @@ public class BiometricUnlockController extends KeyguardUpdateMonitorCallback {
|
|||||||
StatusBar statusBar,
|
StatusBar statusBar,
|
||||||
UnlockMethodCache unlockMethodCache, Handler handler,
|
UnlockMethodCache unlockMethodCache, Handler handler,
|
||||||
KeyguardUpdateMonitor keyguardUpdateMonitor,
|
KeyguardUpdateMonitor keyguardUpdateMonitor,
|
||||||
TunerService tunerService) {
|
KeyguardBypassController keyguardBypassController) {
|
||||||
this(context, dozeScrimController, keyguardViewMediator, scrimController, statusBar,
|
this(context, dozeScrimController, keyguardViewMediator, scrimController, statusBar,
|
||||||
unlockMethodCache, handler, keyguardUpdateMonitor, tunerService,
|
unlockMethodCache, handler, keyguardUpdateMonitor,
|
||||||
context.getResources()
|
context.getResources()
|
||||||
.getInteger(com.android.internal.R.integer.config_wakeUpDelayDoze),
|
.getInteger(com.android.internal.R.integer.config_wakeUpDelayDoze),
|
||||||
context.getResources().getBoolean(R.bool.config_faceAuthDismissesKeyguard));
|
keyguardBypassController);
|
||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
@@ -168,9 +147,8 @@ public class BiometricUnlockController extends KeyguardUpdateMonitorCallback {
|
|||||||
StatusBar statusBar,
|
StatusBar statusBar,
|
||||||
UnlockMethodCache unlockMethodCache, Handler handler,
|
UnlockMethodCache unlockMethodCache, Handler handler,
|
||||||
KeyguardUpdateMonitor keyguardUpdateMonitor,
|
KeyguardUpdateMonitor keyguardUpdateMonitor,
|
||||||
TunerService tunerService,
|
|
||||||
int wakeUpDelay,
|
int wakeUpDelay,
|
||||||
boolean faceDismissesKeyguard) {
|
KeyguardBypassController keyguardBypassController) {
|
||||||
mContext = context;
|
mContext = context;
|
||||||
mPowerManager = context.getSystemService(PowerManager.class);
|
mPowerManager = context.getSystemService(PowerManager.class);
|
||||||
mUpdateMonitor = keyguardUpdateMonitor;
|
mUpdateMonitor = keyguardUpdateMonitor;
|
||||||
@@ -186,9 +164,7 @@ public class BiometricUnlockController extends KeyguardUpdateMonitorCallback {
|
|||||||
mUnlockMethodCache = unlockMethodCache;
|
mUnlockMethodCache = unlockMethodCache;
|
||||||
mHandler = handler;
|
mHandler = handler;
|
||||||
mWakeUpDelay = wakeUpDelay;
|
mWakeUpDelay = wakeUpDelay;
|
||||||
mFaceDismissesKeyguardByDefault = faceDismissesKeyguard;
|
mKeyguardBypassController = keyguardBypassController;
|
||||||
tunerService.addTunable(mFaceDismissedKeyguardTunable,
|
|
||||||
Settings.Secure.FACE_UNLOCK_DISMISSES_KEYGUARD);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setStatusBarKeyguardViewManager(
|
public void setStatusBarKeyguardViewManager(
|
||||||
@@ -392,7 +368,7 @@ public class BiometricUnlockController extends KeyguardUpdateMonitorCallback {
|
|||||||
boolean unlockingAllowed = mUpdateMonitor.isUnlockingWithBiometricAllowed();
|
boolean unlockingAllowed = mUpdateMonitor.isUnlockingWithBiometricAllowed();
|
||||||
boolean deviceDreaming = mUpdateMonitor.isDreaming();
|
boolean deviceDreaming = mUpdateMonitor.isDreaming();
|
||||||
boolean faceStayingOnKeyguard = biometricSourceType == BiometricSourceType.FACE
|
boolean faceStayingOnKeyguard = biometricSourceType == BiometricSourceType.FACE
|
||||||
&& !mFaceDismissesKeyguard;
|
&& !mKeyguardBypassController.getBypassEnabled();
|
||||||
|
|
||||||
if (!mUpdateMonitor.isDeviceInteractive()) {
|
if (!mUpdateMonitor.isDeviceInteractive()) {
|
||||||
if (!mStatusBarKeyguardViewManager.isShowing()) {
|
if (!mStatusBarKeyguardViewManager.isShowing()) {
|
||||||
|
|||||||
@@ -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
|
||||||
|
}
|
||||||
@@ -386,6 +386,8 @@ public class StatusBar extends SystemUI implements DemoMode,
|
|||||||
PulseExpansionHandler mPulseExpansionHandler;
|
PulseExpansionHandler mPulseExpansionHandler;
|
||||||
@Inject
|
@Inject
|
||||||
NotificationWakeUpCoordinator mWakeUpCoordinator;
|
NotificationWakeUpCoordinator mWakeUpCoordinator;
|
||||||
|
@Inject
|
||||||
|
KeyguardBypassController mKeyguardBypassController;
|
||||||
|
|
||||||
// expanded notifications
|
// expanded notifications
|
||||||
protected NotificationPanelView mNotificationPanel; // the sliding/resizing panel within the notification window
|
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,
|
mBiometricUnlockController = new BiometricUnlockController(mContext,
|
||||||
mDozeScrimController, keyguardViewMediator,
|
mDozeScrimController, keyguardViewMediator,
|
||||||
mScrimController, this, UnlockMethodCache.getInstance(mContext),
|
mScrimController, this, UnlockMethodCache.getInstance(mContext),
|
||||||
new Handler(), mKeyguardUpdateMonitor, Dependency.get(TunerService.class));
|
new Handler(), mKeyguardUpdateMonitor, mKeyguardBypassController);
|
||||||
mStatusBarKeyguardViewManager = keyguardViewMediator.registerStatusBar(this,
|
mStatusBarKeyguardViewManager = keyguardViewMediator.registerStatusBar(this,
|
||||||
getBouncerContainer(), mNotificationPanel, mBiometricUnlockController,
|
getBouncerContainer(), mNotificationPanel, mBiometricUnlockController,
|
||||||
mStatusBarWindow.findViewById(R.id.lock_icon_container));
|
mStatusBarWindow.findViewById(R.id.lock_icon_container));
|
||||||
|
|||||||
@@ -71,8 +71,6 @@ public class BiometricsUnlockControllerTest extends SysuiTestCase {
|
|||||||
@Mock
|
@Mock
|
||||||
private UnlockMethodCache mUnlockMethodCache;
|
private UnlockMethodCache mUnlockMethodCache;
|
||||||
@Mock
|
@Mock
|
||||||
private TunerService mTunerService;
|
|
||||||
@Mock
|
|
||||||
private Handler mHandler;
|
private Handler mHandler;
|
||||||
private BiometricUnlockController mBiometricUnlockController;
|
private BiometricUnlockController mBiometricUnlockController;
|
||||||
|
|
||||||
@@ -192,9 +190,8 @@ public class BiometricsUnlockControllerTest extends SysuiTestCase {
|
|||||||
TestableBiometricUnlockController(boolean faceDismissesKeyguard) {
|
TestableBiometricUnlockController(boolean faceDismissesKeyguard) {
|
||||||
super(mContext, mDozeScrimController,
|
super(mContext, mDozeScrimController,
|
||||||
mKeyguardViewMediator, mScrimController, mStatusBar, mUnlockMethodCache,
|
mKeyguardViewMediator, mScrimController, mStatusBar, mUnlockMethodCache,
|
||||||
mHandler, mUpdateMonitor, mTunerService, 0 /* wakeUpDelay */,
|
mHandler, mUpdateMonitor, 0 /* wakeUpDelay */,
|
||||||
faceDismissesKeyguard);
|
new KeyguardBypassController(faceDismissesKeyguard));
|
||||||
mFaceDismissesKeyguard = faceDismissesKeyguard;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user