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

Commit ad9db9cf authored by axfordjc's avatar axfordjc
Browse files

Only reinflate bouncer after rotation if flag enabled

Re-inflating on orientation change is now guarded by the unreleased flag "lockscreen.enable_landscape", b/293252410, so the behaviour is back to the usual when this flag is off.

New tests to cover this case.

Bug: 295603468
Test: PinBouncerLandscapeLayout, PinBouncerPortraitLayout, PinBouncerLargeLayout
Change-Id: Ida08cc6e5c022a457e0d603ab75424d563dc0538
parent 8c45339d
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ import static com.android.keyguard.KeyguardSecurityContainer.USER_TYPE_PRIMARY;
import static com.android.keyguard.KeyguardSecurityContainer.USER_TYPE_SECONDARY_USER;
import static com.android.keyguard.KeyguardSecurityContainer.USER_TYPE_WORK_PROFILE;
import static com.android.systemui.DejankUtils.whitelistIpcs;
import static com.android.systemui.flags.Flags.LOCKSCREEN_ENABLE_LANDSCAPE;
import static com.android.systemui.flags.Flags.REVAMPED_BOUNCER_MESSAGES;

import android.app.ActivityManager;
@@ -370,9 +371,13 @@ public class KeyguardSecurityContainerController extends ViewController<Keyguard

                @Override
                public void onOrientationChanged(int orientation) {
                    if (mFeatureFlags.isEnabled(LOCKSCREEN_ENABLE_LANDSCAPE)) {
                        // TODO(b/295603468)
                        // Fix reinflation of views when flag is enabled.
                        KeyguardSecurityContainerController.this
                            .onDensityOrFontScaleOrOrientationChanged();
                    }
                }
            };
    private final KeyguardUpdateMonitorCallback mKeyguardUpdateMonitorCallback =
            new KeyguardUpdateMonitorCallback() {
+45 −0
Original line number Diff line number Diff line
@@ -620,6 +620,51 @@ class KeyguardSecurityContainerControllerTest : SysuiTestCase() {
        configurationListenerArgumentCaptor.value.onUiModeChanged()
        verify(view).reloadColors()
    }
    @Test
    fun onOrientationChanged_landscapeKeyguardFlagDisabled_blockReinflate() {
        featureFlags.set(Flags.LOCKSCREEN_ENABLE_LANDSCAPE, false)

        // Run onOrientationChanged
        val configurationListenerArgumentCaptor =
            ArgumentCaptor.forClass(ConfigurationController.ConfigurationListener::class.java)
        underTest.onViewAttached()
        verify(configurationController).addCallback(configurationListenerArgumentCaptor.capture())
        clearInvocations(viewFlipperController)
        configurationListenerArgumentCaptor.value.onOrientationChanged(
            Configuration.ORIENTATION_LANDSCAPE
        )
        // Verify view is reinflated when flag is on
        verify(viewFlipperController, never()).clearViews()
        verify(viewFlipperController, never())
            .asynchronouslyInflateView(
                eq(SecurityMode.PIN),
                any(),
                onViewInflatedCallbackArgumentCaptor.capture()
            )
    }

    @Test
    fun onOrientationChanged_landscapeKeyguardFlagEnabled_doesReinflate() {
        featureFlags.set(Flags.LOCKSCREEN_ENABLE_LANDSCAPE, true)

        // Run onOrientationChanged
        val configurationListenerArgumentCaptor =
            ArgumentCaptor.forClass(ConfigurationController.ConfigurationListener::class.java)
        underTest.onViewAttached()
        verify(configurationController).addCallback(configurationListenerArgumentCaptor.capture())
        clearInvocations(viewFlipperController)
        configurationListenerArgumentCaptor.value.onOrientationChanged(
            Configuration.ORIENTATION_LANDSCAPE
        )
        // Verify view is reinflated when flag is on
        verify(viewFlipperController).clearViews()
        verify(viewFlipperController)
            .asynchronouslyInflateView(
                eq(SecurityMode.PIN),
                any(),
                onViewInflatedCallbackArgumentCaptor.capture()
            )
    }

    @Test
    fun hasDismissActions() {