Fix issue where onKeyguardOccludedChanged isn't called when occluded changes
This occurs when the keyguard becomes not occluded while the lockscreen is already dismissed. Fix: 205976368 Test: atest SystemUITests:StatusBarKeyguardViewManagerTest Change-Id: Ie9a7b8916b1edeaf574677d8ffd1d3cf5eb4f8d9
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user