summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Beverly Tai <beverlyt@google.com> 2024-04-12 18:57:16 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2024-04-12 18:57:16 +0000
commitebb7133fddc65f987159e7d0f35062796239476c (patch)
tree65ff4eca5c34209ec4c034513b2f67ee5a67f120
parent6a5dd3fb59bb279db1eb948e0c9fb73fea151066 (diff)
parentd29ccea8b04a686e8150cb65992f39f411247669 (diff)
Merge "Remove BypassController's reliance on StatusBarKeyguardViewManager for updates" into main
-rw-r--r--packages/SystemUI/src/com/android/keyguard/KeyguardViewController.java3
-rw-r--r--packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java5
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java3
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBypassController.kt121
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java6
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/keyguard/KeyguardViewMediatorTest.java2
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/CentralSurfacesImplTest.java3
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/KeyguardBypassControllerTest.kt31
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManagerTest.java3
9 files changed, 91 insertions, 86 deletions
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardViewController.java b/packages/SystemUI/src/com/android/keyguard/KeyguardViewController.java
index 9b09265763a2..afeb0f8cdb0d 100644
--- a/packages/SystemUI/src/com/android/keyguard/KeyguardViewController.java
+++ b/packages/SystemUI/src/com/android/keyguard/KeyguardViewController.java
@@ -189,6 +189,5 @@ public interface KeyguardViewController {
ShadeLockscreenInteractor shadeLockscreenInteractor,
@Nullable ShadeExpansionStateManager shadeExpansionStateManager,
BiometricUnlockController biometricUnlockController,
- View notificationContainer,
- KeyguardBypassController bypassController);
+ View notificationContainer);
}
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java
index 2a9dad0162c5..165de7cea9e6 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java
@@ -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();
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java
index 1d6b744a7bf0..08b65e3bb580 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java
@@ -1545,8 +1545,7 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces {
mShadeSurface,
mShadeExpansionStateManager,
mBiometricUnlockController,
- mStackScroller,
- mKeyguardBypassController);
+ mStackScroller);
mKeyguardStateController.addCallback(mKeyguardStateControllerCallback);
mKeyguardIndicationController
.setStatusBarKeyguardViewManager(mStatusBarKeyguardViewManager);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBypassController.kt b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBypassController.kt
index a3d316b611a7..a8941bb182ae 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBypassController.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBypassController.kt
@@ -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,70 +119,44 @@ 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
- }
-
-
- if (configFaceAuthSupportedPosture != DEVICE_POSTURE_UNKNOWN) {
- devicePostureController.addCallback { posture ->
- if (postureState != posture) {
- postureState = posture
- notifyListeners()
- }
- }
- }
-
- dumpManager.registerNormalDumpable("KeyguardBypassController", this)
- statusBarStateController.addCallback(object : StatusBarStateController.StateListener {
- override fun onStateChanged(newState: Int) {
- if (newState != StatusBarState.KEYGUARD) {
- pendingUnlock = null
+ 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) {
+ postureState = posture
+ notifyListeners()
+ }
}
}
- })
-
- listenForQsExpandedChange(applicationScope)
-
- val dismissByDefault = if (context.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) {
- pendingUnlock = null
+ dumpManager.registerNormalDumpable("KeyguardBypassController", this)
+ statusBarStateController.addCallback(object : StatusBarStateController.StateListener {
+ override fun onStateChanged(newState: Int) {
+ if (newState != StatusBarState.KEYGUARD) {
+ pendingUnlock = null
+ }
}
})
+ listenForQsExpandedChange(applicationScope)
+ 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) {
+ pendingUnlock = null
+ }
+ })
+ }
}
@VisibleForTesting
@@ -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)
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java
index dd7d282e67c5..a141b5348574 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java
@@ -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) {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/keyguard/KeyguardViewMediatorTest.java b/packages/SystemUI/tests/src/com/android/systemui/keyguard/KeyguardViewMediatorTest.java
index 318227f2d1a1..a46f7551fa0b 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/keyguard/KeyguardViewMediatorTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/keyguard/KeyguardViewMediatorTest.java
@@ -1243,7 +1243,7 @@ public class KeyguardViewMediatorTest extends SysuiTestCase {
mock(WindowManagerOcclusionManager.class));
mViewMediator.start();
- mViewMediator.registerCentralSurfaces(mCentralSurfaces, null, null, null, null, null);
+ mViewMediator.registerCentralSurfaces(mCentralSurfaces, null, null, null, null);
}
private void captureKeyguardStateControllerCallback() {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/CentralSurfacesImplTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/CentralSurfacesImplTest.java
index 25e4728725e9..783bf80000d6 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/CentralSurfacesImplTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/CentralSurfacesImplTest.java
@@ -572,8 +572,7 @@ public class CentralSurfacesImplTest extends SysuiTestCase {
any(NotificationPanelViewController.class),
any(ShadeExpansionStateManager.class),
any(BiometricUnlockController.class),
- any(ViewGroup.class),
- any(KeyguardBypassController.class)))
+ any(ViewGroup.class)))
.thenReturn(mStatusBarKeyguardViewManager);
when(mKeyguardViewMediator.getViewMediatorCallback()).thenReturn(
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/KeyguardBypassControllerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/KeyguardBypassControllerTest.kt
index 7362e342f321..6150253b917e 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/KeyguardBypassControllerTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/KeyguardBypassControllerTest.kt
@@ -24,6 +24,8 @@ import com.android.systemui.SysuiTestCase
import com.android.systemui.dump.DumpManager
import com.android.systemui.flags.FakeFeatureFlags
import com.android.systemui.flags.Flags
+import com.android.systemui.keyguard.domain.interactor.KeyguardTransitionInteractor
+import com.android.systemui.keyguard.shared.model.KeyguardState
import com.android.systemui.kosmos.testScope
import com.android.systemui.plugins.statusbar.StatusBarStateController
import com.android.systemui.res.R
@@ -72,6 +74,7 @@ class KeyguardBypassControllerTest : SysuiTestCase() {
@Mock private lateinit var statusBarStateController: StatusBarStateController
@Mock private lateinit var lockscreenUserManager: NotificationLockscreenUserManager
@Mock private lateinit var keyguardStateController: KeyguardStateController
+ @Mock private lateinit var keyguardTransitionInteractor: KeyguardTransitionInteractor
@Mock private lateinit var devicePostureController: DevicePostureController
@Mock private lateinit var dumpManager: DumpManager
@Mock private lateinit var packageManager: PackageManager
@@ -138,7 +141,8 @@ class KeyguardBypassControllerTest : SysuiTestCase() {
private fun initKeyguardBypassController() {
keyguardBypassController =
KeyguardBypassController(
- context,
+ context.resources,
+ context.packageManager,
testScope.backgroundScope,
tunerService,
statusBarStateController,
@@ -146,7 +150,8 @@ class KeyguardBypassControllerTest : SysuiTestCase() {
keyguardStateController,
shadeRepository,
devicePostureController,
- dumpManager
+ keyguardTransitionInteractor,
+ dumpManager,
)
}
@@ -302,4 +307,26 @@ class KeyguardBypassControllerTest : SysuiTestCase() {
job.cancel()
}
}
+
+ @Test
+ fun canBypass_bypassDisabled() {
+ context.orCreateTestableResources.addOverride(
+ R.integer.config_face_unlock_bypass_override,
+ 2 /* FACE_UNLOCK_BYPASS_NEVER */
+ )
+ initKeyguardBypassController()
+ assertThat(keyguardBypassController.canBypass()).isFalse()
+ }
+
+ @Test
+ fun canBypass_bypassEnabled_alternateBouncerShowing() {
+ context.orCreateTestableResources.addOverride(
+ R.integer.config_face_unlock_bypass_override,
+ 1 /* FACE_UNLOCK_BYPASS_ALWAYS */
+ )
+ initKeyguardBypassController()
+ whenever(keyguardTransitionInteractor.getCurrentState())
+ .thenReturn(KeyguardState.ALTERNATE_BOUNCER)
+ assertThat(keyguardBypassController.canBypass()).isTrue()
+ }
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManagerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManagerTest.java
index f8c01e7c5275..f04a5ab2d8f0 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManagerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManagerTest.java
@@ -241,8 +241,7 @@ public class StatusBarKeyguardViewManagerTest extends SysuiTestCase {
mShadeLockscreenInteractor,
new ShadeExpansionStateManager(),
mBiometricUnlockController,
- mNotificationContainer,
- mBypassController);
+ mNotificationContainer);
mStatusBarKeyguardViewManager.show(null);
ArgumentCaptor<PrimaryBouncerExpansionCallback> callbackArgumentCaptor =
ArgumentCaptor.forClass(PrimaryBouncerExpansionCallback.class);