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

Commit 2ab01997 authored by Tom Natan's avatar Tom Natan Committed by Android (Google) Code Review
Browse files

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

parents 2a3027fd fdac4a25
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);