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

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

Change-Id: I64f0df954ae8cc53ea4058dfbf748f1e2b0ab028
This commit is contained in:
Tom Natan
2021-11-15 16:22:44 +00:00
committed by Automerger Merge Worker
2 changed files with 52 additions and 8 deletions

View File

@@ -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;
}

View File

@@ -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);