Merge "Introduced KeyguardBypassController" into qt-r1-dev

am: 97442f5cd7

Change-Id: I3b53a9a11bdf03a7d06036974505816a5f4efbce
This commit is contained in:
Selim Cinek
2019-05-28 09:08:07 -07:00
committed by android-build-merger
4 changed files with 71 additions and 37 deletions

View File

@@ -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()) {

View File

@@ -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
}

View File

@@ -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));

View File

@@ -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));
}
}
}