Merge "Propagate status bar state to NSSL on reattach" into tm-qpr-dev am: 1d810ad9b8 am: 8c61fcacd3 am: 95358927c4

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

Change-Id: I7edaa68a8b06e57ea529b36c1fc5abde8dcf4318
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Steve Elliott
2023-03-01 13:18:59 +00:00
committed by Automerger Merge Worker
2 changed files with 36 additions and 1 deletions

View File

@@ -211,7 +211,11 @@ public class NotificationStackScrollLayoutController {
public void onViewAttachedToWindow(View v) {
mConfigurationController.addCallback(mConfigurationListener);
mZenModeController.addCallback(mZenModeControllerCallback);
mBarState = mStatusBarStateController.getState();
final int newBarState = mStatusBarStateController.getState();
if (newBarState != mBarState) {
mStateListener.onStateChanged(newBarState);
mStateListener.onStatePostChange();
}
mStatusBarStateController.addCallback(
mStateListener, SysuiStatusBarStateController.RANK_STACK_SCROLLER);
}

View File

@@ -415,6 +415,37 @@ public class NotificationStackScrollLayoutControllerTest extends SysuiTestCase {
verify(mNotificationStackScrollLayout).updateEmptyShadeView(anyBoolean(), anyBoolean());
}
@Test
public void testAttach_updatesViewStatusBarState() {
// GIVEN: Controller is attached
mController.attach(mNotificationStackScrollLayout);
ArgumentCaptor<StatusBarStateController.StateListener> captor =
ArgumentCaptor.forClass(StatusBarStateController.StateListener.class);
verify(mSysuiStatusBarStateController).addCallback(captor.capture(), anyInt());
StatusBarStateController.StateListener stateListener = captor.getValue();
// WHEN: StatusBarState changes to SHADE
when(mSysuiStatusBarStateController.getState()).thenReturn(SHADE);
stateListener.onStateChanged(SHADE);
// THEN: NSSL is updated with the current state
verify(mNotificationStackScrollLayout).setStatusBarState(SHADE);
// WHEN: Controller is detached
mController.mOnAttachStateChangeListener
.onViewDetachedFromWindow(mNotificationStackScrollLayout);
// WHEN: StatusBarState changes to KEYGUARD
when(mSysuiStatusBarStateController.getState()).thenReturn(KEYGUARD);
// WHEN: Controller is re-attached
mController.mOnAttachStateChangeListener
.onViewAttachedToWindow(mNotificationStackScrollLayout);
// THEN: NSSL is updated with the current state
verify(mNotificationStackScrollLayout).setStatusBarState(KEYGUARD);
}
private LogMaker logMatcher(int category, int type) {
return argThat(new LogMatcher(category, type));
}