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

Commit d29ccea8 authored by Beverly's avatar Beverly
Browse files

Remove BypassController's reliance on StatusBarKeyguardViewManager for updates

Instead, directly inject KeyguardTransitionInteractor into the
BypassController to determine whether the current keyguard state
is the alternateBouncer.

Fixes: 333883098
Bug: 308819693
Flag: None
Test: atest KeyguardBypassControllerTest
Change-Id: I1e229aa9c5cde338ee683ba593aac7a215f7ecb0
parent 3f4b04b8
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -189,6 +189,5 @@ public interface KeyguardViewController {
            ShadeLockscreenInteractor shadeLockscreenInteractor,
            @Nullable ShadeExpansionStateManager shadeExpansionStateManager,
            BiometricUnlockController biometricUnlockController,
            View notificationContainer,
            KeyguardBypassController bypassController);
            View notificationContainer);
}
+2 −3
Original line number Diff line number Diff line
@@ -3559,15 +3559,14 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable,
            ShadeLockscreenInteractor shadeLockscreenInteractor,
            @Nullable ShadeExpansionStateManager shadeExpansionStateManager,
            BiometricUnlockController biometricUnlockController,
            View notificationContainer, KeyguardBypassController bypassController) {
            View notificationContainer) {
        mCentralSurfaces = centralSurfaces;
        mKeyguardViewControllerLazy.get().registerCentralSurfaces(
                centralSurfaces,
                shadeLockscreenInteractor,
                shadeExpansionStateManager,
                biometricUnlockController,
                notificationContainer,
                bypassController);
                notificationContainer);
        return mKeyguardViewControllerLazy.get();
    }

+1 −2
Original line number Diff line number Diff line
@@ -1545,8 +1545,7 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces {
                mShadeSurface,
                mShadeExpansionStateManager,
                mBiometricUnlockController,
                mStackScroller,
                mKeyguardBypassController);
                mStackScroller);
        mKeyguardStateController.addCallback(mKeyguardStateControllerCallback);
        mKeyguardIndicationController
                .setStatusBarKeyguardViewManager(mStatusBarKeyguardViewManager);
+54 −67
Original line number Diff line number Diff line
@@ -17,8 +17,8 @@
package com.android.systemui.statusbar.phone

import android.annotation.IntDef
import android.content.Context
import android.content.pm.PackageManager
import android.content.res.Resources
import android.hardware.biometrics.BiometricSourceType
import android.provider.Settings
import androidx.annotation.VisibleForTesting
@@ -26,7 +26,10 @@ import com.android.app.tracing.ListenersTracing.forEachTraced
import com.android.systemui.Dumpable
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.qualifiers.Application
import com.android.systemui.dagger.qualifiers.Main
import com.android.systemui.dump.DumpManager
import com.android.systemui.keyguard.domain.interactor.KeyguardTransitionInteractor
import com.android.systemui.keyguard.shared.model.KeyguardState
import com.android.systemui.plugins.statusbar.StatusBarStateController
import com.android.systemui.res.R
import com.android.systemui.shade.data.repository.ShadeRepository
@@ -46,12 +49,20 @@ import java.io.PrintWriter
import javax.inject.Inject

@SysUISingleton
open class KeyguardBypassController : Dumpable, StackScrollAlgorithm.BypassController {
class KeyguardBypassController @Inject constructor(
        @Main resources: Resources,
        packageManager: PackageManager,
        @Application applicationScope: CoroutineScope,
        tunerService: TunerService,
        private val statusBarStateController: StatusBarStateController,
        lockscreenUserManager: NotificationLockscreenUserManager,
        private val keyguardStateController: KeyguardStateController,
        private val shadeRepository: ShadeRepository,
        devicePostureController: DevicePostureController,
        private val keyguardTransitionInteractor: KeyguardTransitionInteractor,
        dumpManager: DumpManager
) : Dumpable, StackScrollAlgorithm.BypassController {

    private val mKeyguardStateController: KeyguardStateController
    private val statusBarStateController: StatusBarStateController
    private val shadeRepository: ShadeRepository
    private val devicePostureController: DevicePostureController
    @BypassOverride private val bypassOverride: Int
    private var hasFaceFeature: Boolean
    @DevicePostureInt private val configFaceAuthSupportedPosture: Int
@@ -99,7 +110,7 @@ open class KeyguardBypassController : Dumpable, StackScrollAlgorithm.BypassContr
                FACE_UNLOCK_BYPASS_NEVER -> false
                else -> field
            }
            return enabled && mKeyguardStateController.isFaceEnrolledAndEnabled &&
            return enabled && keyguardStateController.isFaceEnrolledAndEnabled &&
                    isPostureAllowedForFaceAuth()
        }
        private set(value) {
@@ -108,37 +119,15 @@ open class KeyguardBypassController : Dumpable, StackScrollAlgorithm.BypassContr
        }

    var bouncerShowing: Boolean = false
    var altBouncerShowing: Boolean = false
    var launchingAffordance: Boolean = false
    var qsExpanded = false

    @Inject
    constructor(
        context: Context,
        @Application applicationScope: CoroutineScope,
        tunerService: TunerService,
        statusBarStateController: StatusBarStateController,
        lockscreenUserManager: NotificationLockscreenUserManager,
        keyguardStateController: KeyguardStateController,
        shadeRepository: ShadeRepository,
        devicePostureController: DevicePostureController,
        dumpManager: DumpManager
    ) {
        this.mKeyguardStateController = keyguardStateController
        this.statusBarStateController = statusBarStateController
        this.shadeRepository = shadeRepository
        this.devicePostureController = devicePostureController

        bypassOverride = context.resources.getInteger(R.integer.config_face_unlock_bypass_override)
    init {
        bypassOverride = resources.getInteger(R.integer.config_face_unlock_bypass_override)
        configFaceAuthSupportedPosture =
            context.resources.getInteger(R.integer.config_face_auth_supported_posture)

        hasFaceFeature = context.packageManager.hasSystemFeature(PackageManager.FEATURE_FACE)
        if (!hasFaceFeature) {
            return
        }


            resources.getInteger(R.integer.config_face_auth_supported_posture)
        hasFaceFeature = packageManager.hasSystemFeature(PackageManager.FEATURE_FACE)
        if (hasFaceFeature) {
            if (configFaceAuthSupportedPosture != DEVICE_POSTURE_UNKNOWN) {
                devicePostureController.addCallback { posture ->
                    if (postureState != posture) {
@@ -147,7 +136,6 @@ open class KeyguardBypassController : Dumpable, StackScrollAlgorithm.BypassContr
                    }
                }
            }

            dumpManager.registerNormalDumpable("KeyguardBypassController", this)
            statusBarStateController.addCallback(object : StatusBarStateController.StateListener {
                override fun onStateChanged(newState: Int) {
@@ -156,16 +144,12 @@ open class KeyguardBypassController : Dumpable, StackScrollAlgorithm.BypassContr
                    }
                }
            })

            listenForQsExpandedChange(applicationScope)

        val dismissByDefault = if (context.resources.getBoolean(
            val dismissByDefault = if (resources.getBoolean(
                            com.android.internal.R.bool.config_faceAuthDismissesKeyguard)) 1 else 0

            tunerService.addTunable({ key, _ ->
                bypassEnabled = tunerService.getValue(key, dismissByDefault) != 0
            }, Settings.Secure.FACE_UNLOCK_DISMISSES_KEYGUARD)

            lockscreenUserManager.addUserChangedListener(
                    object : NotificationLockscreenUserManager.UserChangedListener {
                        override fun onUserChanged(userId: Int) {
@@ -173,6 +157,7 @@ open class KeyguardBypassController : Dumpable, StackScrollAlgorithm.BypassContr
                        }
                    })
        }
    }

    @VisibleForTesting
    fun listenForQsExpandedChange(scope: CoroutineScope) =
@@ -228,7 +213,8 @@ open class KeyguardBypassController : Dumpable, StackScrollAlgorithm.BypassContr
        if (bypassEnabled) {
            return when {
                bouncerShowing -> true
                altBouncerShowing -> true
                keyguardTransitionInteractor.getCurrentState() == KeyguardState.ALTERNATE_BOUNCER ->
                    true
                statusBarStateController.state != StatusBarState.KEYGUARD -> false
                launchingAffordance -> false
                isPulseExpanding || qsExpanded -> false
@@ -260,7 +246,8 @@ open class KeyguardBypassController : Dumpable, StackScrollAlgorithm.BypassContr
        pw.println("  bypassEnabled: $bypassEnabled")
        pw.println("  canBypass: ${canBypass()}")
        pw.println("  bouncerShowing: $bouncerShowing")
        pw.println("  altBouncerShowing: $altBouncerShowing")
        pw.println("  altBouncerShowing:" +
            " ${keyguardTransitionInteractor.getCurrentState() == KeyguardState.ALTERNATE_BOUNCER}")
        pw.println("  isPulseExpanding: $isPulseExpanding")
        pw.println("  launchingAffordance: $launchingAffordance")
        pw.println("  qSExpanded: $qsExpanded")
@@ -273,7 +260,7 @@ open class KeyguardBypassController : Dumpable, StackScrollAlgorithm.BypassContr
        val start = listeners.isEmpty()
        listeners.add(listener)
        if (start) {
            mKeyguardStateController.addCallback(faceAuthEnabledChangedCallback)
            keyguardStateController.addCallback(faceAuthEnabledChangedCallback)
        }
    }

@@ -284,7 +271,7 @@ open class KeyguardBypassController : Dumpable, StackScrollAlgorithm.BypassContr
    fun unregisterOnBypassStateChangedListener(listener: OnBypassStateChangedListener) {
        listeners.remove(listener)
        if (listeners.isEmpty()) {
            mKeyguardStateController.removeCallback(faceAuthEnabledChangedCallback)
            keyguardStateController.removeCallback(faceAuthEnabledChangedCallback)
        }
    }

+1 −5
Original line number Diff line number Diff line
@@ -332,7 +332,6 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
    private final LatencyTracker mLatencyTracker;
    private final KeyguardSecurityModel mKeyguardSecurityModel;
    private final SelectedUserInteractor mSelectedUserInteractor;
    @Nullable private KeyguardBypassController mBypassController;
    @Nullable private OccludingAppBiometricUI mOccludingAppBiometricUI;

    @Nullable private TaskbarDelegate mTaskbarDelegate;
@@ -440,8 +439,7 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
            ShadeLockscreenInteractor shadeLockscreenInteractor,
            ShadeExpansionStateManager shadeExpansionStateManager,
            BiometricUnlockController biometricUnlockController,
            View notificationContainer,
            KeyguardBypassController bypassController) {
            View notificationContainer) {
        mCentralSurfaces = centralSurfaces;
        mBiometricUnlockController = biometricUnlockController;

@@ -452,7 +450,6 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
                    shadeExpansionStateManager.addExpansionListener(this);
            onPanelExpansionChanged(currentState);
        }
        mBypassController = bypassController;
        mNotificationContainer = notificationContainer;
        if (!DeviceEntryUdfpsRefactor.isEnabled()) {
            mKeyguardMessageAreaController = mKeyguardMessageAreaFactory.create(
@@ -973,7 +970,6 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
            mKeyguardMessageAreaController.setIsVisible(isShowingAlternateBouncer);
            mKeyguardMessageAreaController.setMessage("");
        }
        mBypassController.setAltBouncerShowing(isShowingAlternateBouncer);
        mKeyguardUpdateManager.setAlternateBouncerShowing(isShowingAlternateBouncer);

        if (updateScrim) {
Loading