Loading packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java +10 −4 Original line number Diff line number Diff line Loading @@ -1499,10 +1499,7 @@ public final class NotificationPanelViewController extends PanelViewController { } private void updateKeyguardStatusViewAlignment(boolean animate) { boolean hasVisibleNotifications = mNotificationStackScrollLayoutController .getVisibleNotificationCount() != 0 || mMediaDataManager.hasActiveMediaOrRecommendation(); boolean shouldBeCentered = !mSplitShadeEnabled || !hasVisibleNotifications || mDozing; boolean shouldBeCentered = shouldKeyguardStatusViewBeCentered(); if (mStatusViewCentered != shouldBeCentered) { mStatusViewCentered = shouldBeCentered; ConstraintSet constraintSet = new ConstraintSet(); Loading @@ -1526,6 +1523,15 @@ public final class NotificationPanelViewController extends PanelViewController { mKeyguardUnfoldTransition.ifPresent(t -> t.setStatusViewCentered(mStatusViewCentered)); } private boolean shouldKeyguardStatusViewBeCentered() { boolean hasVisibleNotifications = mNotificationStackScrollLayoutController .getVisibleNotificationCount() != 0 || mMediaDataManager.hasActiveMediaOrRecommendation(); boolean isOnAod = mDozing && mDozeParameters.getAlwaysOn(); return !mSplitShadeEnabled || !hasVisibleNotifications || isOnAod || hasPulsingNotifications(); } /** * @return the padding of the stackscroller when unlocked */ Loading packages/SystemUI/tests/src/com/android/systemui/shade/NotificationPanelViewControllerTest.java +86 −0 Original line number Diff line number Diff line Loading @@ -47,6 +47,7 @@ import android.content.ContentResolver; import android.content.res.Configuration; import android.content.res.Resources; import android.database.ContentObserver; import android.graphics.PointF; import android.os.Handler; import android.os.Looper; import android.os.PowerManager; Loading Loading @@ -901,6 +902,76 @@ public class NotificationPanelViewControllerTest extends SysuiTestCase { .isEqualTo(ConstraintSet.PARENT_ID); } @Test public void keyguardStatusView_splitShade_dozing_alwaysDozingOn_isCentered() { when(mNotificationStackScrollLayoutController.getVisibleNotificationCount()).thenReturn(2); mStatusBarStateController.setState(KEYGUARD); enableSplitShade(/* enabled= */ true); setDozing(/* dozing= */ true, /* dozingAlwaysOn= */ true); assertThat(isKeyguardStatusViewCentered()).isTrue(); } @Test public void keyguardStatusView_splitShade_dozing_alwaysDozingOff_isNotCentered() { when(mNotificationStackScrollLayoutController.getVisibleNotificationCount()).thenReturn(2); mStatusBarStateController.setState(KEYGUARD); enableSplitShade(/* enabled= */ true); setDozing(/* dozing= */ true, /* dozingAlwaysOn= */ false); assertThat(isKeyguardStatusViewCentered()).isFalse(); } @Test public void keyguardStatusView_splitShade_notDozing_alwaysDozingOn_isNotCentered() { when(mNotificationStackScrollLayoutController.getVisibleNotificationCount()).thenReturn(2); mStatusBarStateController.setState(KEYGUARD); enableSplitShade(/* enabled= */ true); setDozing(/* dozing= */ false, /* dozingAlwaysOn= */ true); assertThat(isKeyguardStatusViewCentered()).isFalse(); } @Test public void keyguardStatusView_splitShade_pulsing_isCentered() { when(mNotificationStackScrollLayoutController.getVisibleNotificationCount()).thenReturn(2); when(mNotificationListContainer.hasPulsingNotifications()).thenReturn(true); mStatusBarStateController.setState(KEYGUARD); enableSplitShade(/* enabled= */ true); setDozing(/* dozing= */ false, /* dozingAlwaysOn= */ true); assertThat(isKeyguardStatusViewCentered()).isFalse(); } @Test public void keyguardStatusView_splitShade_notPulsing_isNotCentered() { when(mNotificationStackScrollLayoutController.getVisibleNotificationCount()).thenReturn(2); when(mNotificationListContainer.hasPulsingNotifications()).thenReturn(false); mStatusBarStateController.setState(KEYGUARD); enableSplitShade(/* enabled= */ true); setDozing(/* dozing= */ false, /* dozingAlwaysOn= */ true); assertThat(isKeyguardStatusViewCentered()).isFalse(); } @Test public void keyguardStatusView_singleShade_isCentered() { enableSplitShade(/* enabled= */ false); // The conditions below would make the clock NOT be centered on split shade. // On single shade it should always be centered though. when(mNotificationStackScrollLayoutController.getVisibleNotificationCount()).thenReturn(2); when(mNotificationListContainer.hasPulsingNotifications()).thenReturn(false); mStatusBarStateController.setState(KEYGUARD); setDozing(/* dozing= */ false, /* dozingAlwaysOn= */ false); assertThat(isKeyguardStatusViewCentered()).isFalse(); } @Test public void testDisableUserSwitcherAfterEnabling_returnsViewStubToTheViewHierarchy() { givenViewAttached(); Loading Loading @@ -1473,4 +1544,19 @@ public class NotificationPanelViewControllerTest extends SysuiTestCase { .thenReturn(splitShadeFullTransitionDistance); mNotificationPanelViewController.updateResources(); } private void setDozing(boolean dozing, boolean dozingAlwaysOn) { when(mDozeParameters.getAlwaysOn()).thenReturn(dozingAlwaysOn); mNotificationPanelViewController.setDozing( /* dozing= */ dozing, /* animate= */ false, /* wakeUpTouchLocation= */ new PointF() ); } private boolean isKeyguardStatusViewCentered() { mNotificationPanelViewController.updateResources(); return getConstraintSetLayout(R.id.keyguard_status_view).endToEnd == ConstraintSet.PARENT_ID; } } Loading
packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java +10 −4 Original line number Diff line number Diff line Loading @@ -1499,10 +1499,7 @@ public final class NotificationPanelViewController extends PanelViewController { } private void updateKeyguardStatusViewAlignment(boolean animate) { boolean hasVisibleNotifications = mNotificationStackScrollLayoutController .getVisibleNotificationCount() != 0 || mMediaDataManager.hasActiveMediaOrRecommendation(); boolean shouldBeCentered = !mSplitShadeEnabled || !hasVisibleNotifications || mDozing; boolean shouldBeCentered = shouldKeyguardStatusViewBeCentered(); if (mStatusViewCentered != shouldBeCentered) { mStatusViewCentered = shouldBeCentered; ConstraintSet constraintSet = new ConstraintSet(); Loading @@ -1526,6 +1523,15 @@ public final class NotificationPanelViewController extends PanelViewController { mKeyguardUnfoldTransition.ifPresent(t -> t.setStatusViewCentered(mStatusViewCentered)); } private boolean shouldKeyguardStatusViewBeCentered() { boolean hasVisibleNotifications = mNotificationStackScrollLayoutController .getVisibleNotificationCount() != 0 || mMediaDataManager.hasActiveMediaOrRecommendation(); boolean isOnAod = mDozing && mDozeParameters.getAlwaysOn(); return !mSplitShadeEnabled || !hasVisibleNotifications || isOnAod || hasPulsingNotifications(); } /** * @return the padding of the stackscroller when unlocked */ Loading
packages/SystemUI/tests/src/com/android/systemui/shade/NotificationPanelViewControllerTest.java +86 −0 Original line number Diff line number Diff line Loading @@ -47,6 +47,7 @@ import android.content.ContentResolver; import android.content.res.Configuration; import android.content.res.Resources; import android.database.ContentObserver; import android.graphics.PointF; import android.os.Handler; import android.os.Looper; import android.os.PowerManager; Loading Loading @@ -901,6 +902,76 @@ public class NotificationPanelViewControllerTest extends SysuiTestCase { .isEqualTo(ConstraintSet.PARENT_ID); } @Test public void keyguardStatusView_splitShade_dozing_alwaysDozingOn_isCentered() { when(mNotificationStackScrollLayoutController.getVisibleNotificationCount()).thenReturn(2); mStatusBarStateController.setState(KEYGUARD); enableSplitShade(/* enabled= */ true); setDozing(/* dozing= */ true, /* dozingAlwaysOn= */ true); assertThat(isKeyguardStatusViewCentered()).isTrue(); } @Test public void keyguardStatusView_splitShade_dozing_alwaysDozingOff_isNotCentered() { when(mNotificationStackScrollLayoutController.getVisibleNotificationCount()).thenReturn(2); mStatusBarStateController.setState(KEYGUARD); enableSplitShade(/* enabled= */ true); setDozing(/* dozing= */ true, /* dozingAlwaysOn= */ false); assertThat(isKeyguardStatusViewCentered()).isFalse(); } @Test public void keyguardStatusView_splitShade_notDozing_alwaysDozingOn_isNotCentered() { when(mNotificationStackScrollLayoutController.getVisibleNotificationCount()).thenReturn(2); mStatusBarStateController.setState(KEYGUARD); enableSplitShade(/* enabled= */ true); setDozing(/* dozing= */ false, /* dozingAlwaysOn= */ true); assertThat(isKeyguardStatusViewCentered()).isFalse(); } @Test public void keyguardStatusView_splitShade_pulsing_isCentered() { when(mNotificationStackScrollLayoutController.getVisibleNotificationCount()).thenReturn(2); when(mNotificationListContainer.hasPulsingNotifications()).thenReturn(true); mStatusBarStateController.setState(KEYGUARD); enableSplitShade(/* enabled= */ true); setDozing(/* dozing= */ false, /* dozingAlwaysOn= */ true); assertThat(isKeyguardStatusViewCentered()).isFalse(); } @Test public void keyguardStatusView_splitShade_notPulsing_isNotCentered() { when(mNotificationStackScrollLayoutController.getVisibleNotificationCount()).thenReturn(2); when(mNotificationListContainer.hasPulsingNotifications()).thenReturn(false); mStatusBarStateController.setState(KEYGUARD); enableSplitShade(/* enabled= */ true); setDozing(/* dozing= */ false, /* dozingAlwaysOn= */ true); assertThat(isKeyguardStatusViewCentered()).isFalse(); } @Test public void keyguardStatusView_singleShade_isCentered() { enableSplitShade(/* enabled= */ false); // The conditions below would make the clock NOT be centered on split shade. // On single shade it should always be centered though. when(mNotificationStackScrollLayoutController.getVisibleNotificationCount()).thenReturn(2); when(mNotificationListContainer.hasPulsingNotifications()).thenReturn(false); mStatusBarStateController.setState(KEYGUARD); setDozing(/* dozing= */ false, /* dozingAlwaysOn= */ false); assertThat(isKeyguardStatusViewCentered()).isFalse(); } @Test public void testDisableUserSwitcherAfterEnabling_returnsViewStubToTheViewHierarchy() { givenViewAttached(); Loading Loading @@ -1473,4 +1544,19 @@ public class NotificationPanelViewControllerTest extends SysuiTestCase { .thenReturn(splitShadeFullTransitionDistance); mNotificationPanelViewController.updateResources(); } private void setDozing(boolean dozing, boolean dozingAlwaysOn) { when(mDozeParameters.getAlwaysOn()).thenReturn(dozingAlwaysOn); mNotificationPanelViewController.setDozing( /* dozing= */ dozing, /* animate= */ false, /* wakeUpTouchLocation= */ new PointF() ); } private boolean isKeyguardStatusViewCentered() { mNotificationPanelViewController.updateResources(); return getConstraintSetLayout(R.id.keyguard_status_view).endToEnd == ConstraintSet.PARENT_ID; } }