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

Commit 694e8a7f authored by Tom Natan's avatar Tom Natan Committed by Automerger Merge Worker
Browse files

Merge "Fix issue where onKeyguardOccludedChanged isn't called when occluded...

Merge "Fix issue where onKeyguardOccludedChanged isn't called when occluded changes" into sc-v2-dev am: 2ab01997

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/16241358

Change-Id: Ie80f921df078a45a210ce9500273ac30fe680318
parents dacab64e 2ab01997
Loading
Loading
Loading
Loading
+8 −3
Original line number Diff line number Diff line
@@ -627,7 +627,7 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
            SysUiStatsLog.write(SysUiStatsLog.KEYGUARD_STATE_CHANGED,
                    SysUiStatsLog.KEYGUARD_STATE_CHANGED__STATE__OCCLUDED);
            if (mStatusBar.isInLaunchTransition()) {
                mOccluded = true;
                setOccludedAndUpdateStates(true);
                mStatusBar.fadeKeyguardAfterLaunchTransition(null /* beforeFading */,
                        new Runnable() {
                            @Override
@@ -640,7 +640,7 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
            }

            if (mStatusBar.isLaunchingActivityOverLockscreen()) {
                mOccluded = true;
                setOccludedAndUpdateStates(true);

                // When isLaunchingActivityOverLockscreen() is true, we know for sure that the post
                // collapse runnables will be run.
@@ -655,7 +655,7 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
                    SysUiStatsLog.KEYGUARD_STATE_CHANGED__STATE__SHOWN);
        }
        boolean isOccluding = !mOccluded && occluded;
        mOccluded = occluded;
        setOccludedAndUpdateStates(occluded);
        if (mShowing) {
            mMediaManager.updateMediaMetaData(false, animate && !occluded);
        }
@@ -672,6 +672,11 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
        }
    }

    private void setOccludedAndUpdateStates(boolean occluded) {
        mOccluded = occluded;
        updateStates();
    }

    public boolean isOccluded() {
        return mOccluded;
    }
+44 −5
Original line number Diff line number Diff line
@@ -61,8 +61,6 @@ import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;

import dagger.Lazy;

@SmallTest
@RunWith(AndroidTestingRunner.class)
@TestableLooper.RunWithLooper
@@ -87,6 +85,8 @@ public class StatusBarKeyguardViewManagerTest extends SysuiTestCase {
    @Mock
    private SysuiStatusBarStateController mStatusBarStateController;
    @Mock
    private KeyguardUpdateMonitor mKeyguardUpdateMonitor;
    @Mock
    private View mNotificationContainer;
    @Mock
    private KeyguardBypassController mBypassController;
@@ -103,7 +103,7 @@ public class StatusBarKeyguardViewManagerTest extends SysuiTestCase {
    @Mock
    private KeyguardMessageArea mKeyguardMessageArea;
    @Mock
    private Lazy<ShadeController> mShadeController;
    private ShadeController mShadeController;

    private WakefulnessLifecycle mWakefulnessLifecycle;
    private StatusBarKeyguardViewManager mStatusBarKeyguardViewManager;
@@ -127,7 +127,7 @@ public class StatusBarKeyguardViewManagerTest extends SysuiTestCase {
                mLockPatternUtils,
                mStatusBarStateController,
                mock(ConfigurationController.class),
                mock(KeyguardUpdateMonitor.class),
                mKeyguardUpdateMonitor,
                mock(NavigationModeController.class),
                mock(DockManager.class),
                mock(NotificationShadeWindowController.class),
@@ -137,7 +137,7 @@ public class StatusBarKeyguardViewManagerTest extends SysuiTestCase {
                mWakefulnessLifecycle,
                mUnlockedScreenOffAnimationController,
                mKeyguardMessageAreaFactory,
                mShadeController);
                () -> mShadeController);
        mStatusBarKeyguardViewManager.registerStatusBar(
                mStatusBar,
                mNotificationPanelView,
@@ -291,6 +291,45 @@ public class StatusBarKeyguardViewManagerTest extends SysuiTestCase {
        verify(mStatusBar, never()).animateKeyguardUnoccluding();
    }

    @Test
    public void setOccluded_onKeyguardOccludedChangedCalledCorrectly() {
        mStatusBarKeyguardViewManager.setOccluded(false /* occluded */, false /* animated */);
        verify(mKeyguardUpdateMonitor).onKeyguardOccludedChanged(false);

        clearInvocations(mKeyguardUpdateMonitor);

        mStatusBarKeyguardViewManager.setOccluded(false /* occluded */, false /* animated */);
        verify(mKeyguardUpdateMonitor, never()).onKeyguardOccludedChanged(anyBoolean());

        clearInvocations(mKeyguardUpdateMonitor);

        mStatusBarKeyguardViewManager.setOccluded(true /* occluded */, false /* animated */);
        verify(mKeyguardUpdateMonitor).onKeyguardOccludedChanged(true);

        clearInvocations(mKeyguardUpdateMonitor);

        mStatusBarKeyguardViewManager.setOccluded(true /* occluded */, false /* animated */);
        verify(mKeyguardUpdateMonitor, never()).onKeyguardOccludedChanged(anyBoolean());
    }

    @Test
    public void setOccluded_isInLaunchTransition_onKeyguardOccludedChangedCalled() {
        when(mStatusBar.isInLaunchTransition()).thenReturn(true);
        mStatusBarKeyguardViewManager.show(null);

        mStatusBarKeyguardViewManager.setOccluded(true /* occluded */, false /* animated */);
        verify(mKeyguardUpdateMonitor).onKeyguardOccludedChanged(true);
    }

    @Test
    public void setOccluded_isLaunchingActivityOverLockscreen_onKeyguardOccludedChangedCalled() {
        when(mStatusBar.isLaunchingActivityOverLockscreen()).thenReturn(true);
        mStatusBarKeyguardViewManager.show(null);

        mStatusBarKeyguardViewManager.setOccluded(true /* occluded */, false /* animated */);
        verify(mKeyguardUpdateMonitor).onKeyguardOccludedChanged(true);
    }

    @Test
    public void testHiding_cancelsGoneRunnable() {
        OnDismissAction action = mock(OnDismissAction.class);