Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 97442f5c authored by Selim Cinek's avatar Selim Cinek Committed by Android (Google) Code Review
Browse files

Merge "Introduced KeyguardBypassController" into qt-r1-dev

parents 9adfabc7 2c890ee6
Loading
Loading
Loading
Loading
+7 −31
Original line number Diff line number Diff line
@@ -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()) {
+59 −0
Original line number Diff line number Diff line
/*
 * 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
}
+3 −1
Original line number Diff line number Diff line
@@ -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));
+2 −5
Original line number Diff line number Diff line
@@ -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));
        }
    }
}