summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Matt Pietal <mpietal@google.com> 2024-07-30 16:05:18 +0000
committer Matt Pietal <mpietal@google.com> 2024-07-31 11:38:38 +0000
commitef503de1ad478abee9ababd65be13fa40a297410 (patch)
tree421d916a105516b0ae22db20c077f80f3be40228
parent3adb62b1bf6b6dbb32ec3d118b63c0d8cebcfc47 (diff)
Fix bouncer inflation race condition
For the multi-user bouncer only, the user switcher and the security screen are inflated separately but need to reference each other. After the security screen is reinflated, such as after a display settings change, pass the new reference back to the user switcher. Fixes: 335347904 Test: atest KeyguardSecurityContainerControllerTest Test: manual continuously switch users Test: manual update display settings and go back to bouncer Flag: EXEMPT bugfix Change-Id: Ibb1d61305513b88aa3b9f7c0dd3755b7013b917c
-rw-r--r--packages/SystemUI/multivalentTests/src/com/android/keyguard/KeyguardSecurityContainerControllerTest.kt20
-rw-r--r--packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainer.java9
-rw-r--r--packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainerController.java18
3 files changed, 21 insertions, 26 deletions
diff --git a/packages/SystemUI/multivalentTests/src/com/android/keyguard/KeyguardSecurityContainerControllerTest.kt b/packages/SystemUI/multivalentTests/src/com/android/keyguard/KeyguardSecurityContainerControllerTest.kt
index 6c3f3c181d45..f7f69d373959 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/keyguard/KeyguardSecurityContainerControllerTest.kt
+++ b/packages/SystemUI/multivalentTests/src/com/android/keyguard/KeyguardSecurityContainerControllerTest.kt
@@ -105,6 +105,7 @@ import org.mockito.Mockito.atLeastOnce
import org.mockito.Mockito.clearInvocations
import org.mockito.Mockito.mock
import org.mockito.Mockito.never
+import org.mockito.Mockito.reset
import org.mockito.Mockito.spy
import org.mockito.Mockito.verify
import org.mockito.MockitoAnnotations
@@ -183,7 +184,7 @@ class KeyguardSecurityContainerControllerTest : SysuiTestCase() {
whenever(view.context).thenReturn(mContext)
whenever(view.resources).thenReturn(testableResources.resources)
- val lp = FrameLayout.LayoutParams(/* width= */ 0, /* height= */ 0)
+ val lp = FrameLayout.LayoutParams(/* width= */ 0, /* height= */ 0)
lp.gravity = 0
whenever(view.layoutParams).thenReturn(lp)
@@ -542,6 +543,7 @@ class KeyguardSecurityContainerControllerTest : SysuiTestCase() {
// THEN the next security method of None will dismiss keyguard.
verify(viewMediatorCallback, never()).keyguardDone(anyInt())
}
+
@Test
fun showNextSecurityScreenOrFinish_SimPin_Swipe_userNotSetup() {
// GIVEN the current security method is SimPin
@@ -635,14 +637,6 @@ class KeyguardSecurityContainerControllerTest : SysuiTestCase() {
verify(configurationController).addCallback(configurationListenerArgumentCaptor.capture())
clearInvocations(viewFlipperController)
configurationListenerArgumentCaptor.value.onDensityOrFontScaleChanged()
- verify(viewFlipperController).clearViews()
- verify(viewFlipperController)
- .asynchronouslyInflateView(
- eq(SecurityMode.PIN),
- any(),
- onViewInflatedCallbackArgumentCaptor.capture()
- )
- onViewInflatedCallbackArgumentCaptor.value.onViewInflated(inputViewController)
verify(view).onDensityOrFontScaleChanged()
}
@@ -771,7 +765,9 @@ class KeyguardSecurityContainerControllerTest : SysuiTestCase() {
underTest.reinflateViewFlipper(onViewInflatedCallback)
verify(viewFlipperController).clearViews()
verify(viewFlipperController)
- .asynchronouslyInflateView(any(), any(), eq(onViewInflatedCallback))
+ .asynchronouslyInflateView(any(), any(), onViewInflatedCallbackArgumentCaptor.capture())
+ onViewInflatedCallbackArgumentCaptor.value.onViewInflated(inputViewController)
+ verify(view).updateSecurityViewFlipper()
}
@Test
@@ -935,8 +931,10 @@ class KeyguardSecurityContainerControllerTest : SysuiTestCase() {
underTest.onViewAttached()
verify(userSwitcherController)
.addUserSwitchCallback(capture(userSwitchCallbackArgumentCaptor))
+ reset(primaryBouncerInteractor)
userSwitchCallbackArgumentCaptor.value.onUserSwitched()
- verify(viewFlipperController).asynchronouslyInflateView(any(), any(), any())
+
+ verify(primaryBouncerInteractor).setLastShownPrimarySecurityScreen(any())
}
@Test
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainer.java b/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainer.java
index 421782039043..bf905dbe5543 100644
--- a/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainer.java
+++ b/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainer.java
@@ -647,7 +647,12 @@ public class KeyguardSecurityContainer extends ConstraintLayout {
@Override
public void onFinishInflate() {
super.onFinishInflate();
+ updateSecurityViewFlipper();
+ }
+
+ protected void updateSecurityViewFlipper() {
mSecurityViewFlipper = findViewById(R.id.view_flipper);
+ setupViewMode();
}
@Override
@@ -1004,10 +1009,10 @@ public class KeyguardSecurityContainer extends ConstraintLayout {
if (mUserSwitcherViewGroup == null) {
inflateUserSwitcher();
+ setupUserSwitcher();
+ mUserSwitcherController.addUserSwitchCallback(mUserSwitchCallback);
}
updateSecurityViewLocation();
- setupUserSwitcher();
- mUserSwitcherController.addUserSwitchCallback(mUserSwitchCallback);
}
@Override
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainerController.java b/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainerController.java
index 93ee179c5b63..afd42cbfdb25 100644
--- a/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainerController.java
+++ b/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainerController.java
@@ -164,11 +164,6 @@ public class KeyguardSecurityContainerController extends ViewController<Keyguard
}
mCurrentUser = mSelectedUserInteractor.getSelectedUserId();
showPrimarySecurityScreen(false);
- if (mCurrentSecurityMode != SimPin
- && mCurrentSecurityMode != SimPuk) {
- reinflateViewFlipper((l) -> {
- });
- }
}
};
@@ -375,8 +370,7 @@ public class KeyguardSecurityContainerController extends ViewController<Keyguard
@Override
public void onDensityOrFontScaleChanged() {
- KeyguardSecurityContainerController.this
- .onDensityOrFontScaleOrOrientationChanged();
+ mView.onDensityOrFontScaleChanged();
}
@Override
@@ -1227,11 +1221,6 @@ public class KeyguardSecurityContainerController extends ViewController<Keyguard
mView.reloadColors();
}
- /** Handles density or font scale changes. */
- private void onDensityOrFontScaleOrOrientationChanged() {
- reinflateViewFlipper(controller -> mView.onDensityOrFontScaleChanged());
- }
-
/**
* Reinflate the view flipper child view.
*/
@@ -1239,7 +1228,10 @@ public class KeyguardSecurityContainerController extends ViewController<Keyguard
KeyguardSecurityViewFlipperController.OnViewInflatedCallback onViewInflatedListener) {
mSecurityViewFlipperController.clearViews();
mSecurityViewFlipperController.asynchronouslyInflateView(mCurrentSecurityMode,
- mKeyguardSecurityCallback, onViewInflatedListener);
+ mKeyguardSecurityCallback, (controller) -> {
+ mView.updateSecurityViewFlipper();
+ onViewInflatedListener.onViewInflated(controller);
+ });
}
/**