Loading packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java +27 −0 Original line number Diff line number Diff line Loading @@ -4994,10 +4994,37 @@ public final class NotificationPanelViewController implements Dumpable { return mExpandedFraction; } /** * This method should not be used anymore, you should probably use {@link #isShadeFullyOpen()} * instead. It was overused as indicating if shade is open or we're on keyguard/AOD. * Moving forward we should be explicit about the what state we're checking. * @return if panel is covering the screen, which means we're in expanded shade or keyguard/AOD * * @deprecated depends on the state you check, use {@link #isShadeFullyOpen()}, * {@link #isOnAod()}, {@link #isOnKeyguard()} instead. */ @Deprecated public boolean isFullyExpanded() { return mExpandedHeight >= getMaxPanelTransitionDistance(); } /** * Returns true if shade is fully opened, that is we're actually in the notification shade * with QQS or QS. It's different from {@link #isFullyExpanded()} that it will not report * shade as always expanded if we're on keyguard/AOD. It will return true only when user goes * from keyguard to shade. */ public boolean isShadeFullyOpen() { if (mBarState == SHADE) { return isFullyExpanded(); } else if (mBarState == SHADE_LOCKED) { return true; } else { // case of two finger swipe from the top of keyguard return computeQsExpansionFraction() == 1; } } public boolean isFullyCollapsed() { return mExpandedFraction <= 0.0f; } Loading packages/SystemUI/src/com/android/systemui/shade/ShadeController.java +8 −2 Original line number Diff line number Diff line Loading @@ -63,8 +63,14 @@ public interface ShadeController { */ boolean closeShadeIfOpen(); /** Returns whether the shade is currently open or opening. */ boolean isShadeOpen(); /** * Returns whether the shade is currently open. * Even though in the current implementation shade is in expanded state on keyguard, this * method makes distinction between shade being truly open and plain keyguard state: * - if QS and notifications are visible on the screen, return true * - for any other state, including keyguard, return false */ boolean isShadeFullyOpen(); /** * Add a runnable for NotificationPanelView to post when the panel is expanded. Loading packages/SystemUI/src/com/android/systemui/shade/ShadeControllerImpl.java +2 −3 Original line number Diff line number Diff line Loading @@ -154,9 +154,8 @@ public final class ShadeControllerImpl implements ShadeController { } @Override public boolean isShadeOpen() { return mNotificationPanelViewController.isExpanding() || mNotificationPanelViewController.isFullyExpanded(); public boolean isShadeFullyOpen() { return mNotificationPanelViewController.isShadeFullyOpen(); } @Override Loading packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java +15 −16 Original line number Diff line number Diff line Loading @@ -35,6 +35,7 @@ import static com.android.systemui.Dependency.TIME_TICK_HANDLER_NAME; import static com.android.systemui.charging.WirelessChargingAnimation.UNKNOWN_BATTERY_LEVEL; import static com.android.systemui.keyguard.WakefulnessLifecycle.WAKEFULNESS_ASLEEP; import static com.android.systemui.statusbar.NotificationLockscreenUserManager.PERMISSION_SELF; import static com.android.systemui.statusbar.StatusBarState.SHADE; import static com.android.systemui.statusbar.phone.BarTransitions.MODE_LIGHTS_OUT; import static com.android.systemui.statusbar.phone.BarTransitions.MODE_LIGHTS_OUT_TRANSPARENT; import static com.android.systemui.statusbar.phone.BarTransitions.MODE_OPAQUE; Loading Loading @@ -1147,10 +1148,9 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces { private void onFoldedStateChangedInternal(boolean isFolded, boolean willGoToSleep) { // Folded state changes are followed by a screen off event. // By default turning off the screen also closes the shade. // We want to make sure that the shade status is kept after // folding/unfolding. boolean isShadeOpen = mShadeController.isShadeOpen(); boolean leaveOpen = isShadeOpen && !willGoToSleep; // We want to make sure that the shade status is kept after folding/unfolding. boolean isShadeOpen = mShadeController.isShadeFullyOpen(); boolean leaveOpen = isShadeOpen && !willGoToSleep && mState == SHADE; if (DEBUG) { Log.d(TAG, String.format( "#onFoldedStateChanged(): " Loading @@ -1161,18 +1161,17 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces { isFolded, willGoToSleep, isShadeOpen, leaveOpen)); } if (leaveOpen) { if (mKeyguardStateController.isShowing()) { // When device state changes on keyguard we don't want to keep the state of // below makes shade stay open when going from folded to unfolded mStatusBarStateController.setLeaveOpenOnKeyguardHide(true); } if (mState != SHADE && isShadeOpen) { // When device state changes on KEYGUARD/SHADE_LOCKED we don't want to keep the state of // the shade and instead we open clean state of keyguard with shade closed. // Normally some parts of QS state (like expanded/collapsed) are persisted and // that causes incorrect UI rendering, especially when changing state with QS // expanded. To prevent that we can close QS which resets QS and some parts of // the shade to its default state. Read more in b/201537421 mCloseQsBeforeScreenOff = true; } else { // below makes shade stay open when going from folded to unfolded mStatusBarStateController.setLeaveOpenOnKeyguardHide(true); } } } Loading packages/SystemUI/tests/src/com/android/systemui/shade/NotificationPanelViewControllerTest.java +36 −0 Original line number Diff line number Diff line Loading @@ -1681,6 +1681,42 @@ public class NotificationPanelViewControllerTest extends SysuiTestCase { assertThat(mNotificationPanelViewController.isFullyExpanded()).isTrue(); } @Test public void shadeExpanded_inShadeState() { mStatusBarStateController.setState(SHADE); mNotificationPanelViewController.setExpandedHeight(0); assertThat(mNotificationPanelViewController.isShadeFullyOpen()).isFalse(); int transitionDistance = mNotificationPanelViewController.getMaxPanelTransitionDistance(); mNotificationPanelViewController.setExpandedHeight(transitionDistance); assertThat(mNotificationPanelViewController.isShadeFullyOpen()).isTrue(); } @Test public void shadeExpanded_onKeyguard() { mStatusBarStateController.setState(KEYGUARD); int transitionDistance = mNotificationPanelViewController.getMaxPanelTransitionDistance(); mNotificationPanelViewController.setExpandedHeight(transitionDistance); assertThat(mNotificationPanelViewController.isShadeFullyOpen()).isFalse(); // set maxQsExpansion in NPVC int maxQsExpansion = 123; mNotificationPanelViewController.setQs(mQs); when(mQs.getDesiredHeight()).thenReturn(maxQsExpansion); triggerLayoutChange(); mNotificationPanelViewController.setQsExpansionHeight(maxQsExpansion); assertThat(mNotificationPanelViewController.isShadeFullyOpen()).isTrue(); } @Test public void shadeExpanded_onShadeLocked() { mStatusBarStateController.setState(SHADE_LOCKED); assertThat(mNotificationPanelViewController.isShadeFullyOpen()).isTrue(); } private static MotionEvent createMotionEvent(int x, int y, int action) { return MotionEvent.obtain( /* downTime= */ 0, /* eventTime= */ 0, action, x, y, /* metaState= */ 0); Loading Loading
packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java +27 −0 Original line number Diff line number Diff line Loading @@ -4994,10 +4994,37 @@ public final class NotificationPanelViewController implements Dumpable { return mExpandedFraction; } /** * This method should not be used anymore, you should probably use {@link #isShadeFullyOpen()} * instead. It was overused as indicating if shade is open or we're on keyguard/AOD. * Moving forward we should be explicit about the what state we're checking. * @return if panel is covering the screen, which means we're in expanded shade or keyguard/AOD * * @deprecated depends on the state you check, use {@link #isShadeFullyOpen()}, * {@link #isOnAod()}, {@link #isOnKeyguard()} instead. */ @Deprecated public boolean isFullyExpanded() { return mExpandedHeight >= getMaxPanelTransitionDistance(); } /** * Returns true if shade is fully opened, that is we're actually in the notification shade * with QQS or QS. It's different from {@link #isFullyExpanded()} that it will not report * shade as always expanded if we're on keyguard/AOD. It will return true only when user goes * from keyguard to shade. */ public boolean isShadeFullyOpen() { if (mBarState == SHADE) { return isFullyExpanded(); } else if (mBarState == SHADE_LOCKED) { return true; } else { // case of two finger swipe from the top of keyguard return computeQsExpansionFraction() == 1; } } public boolean isFullyCollapsed() { return mExpandedFraction <= 0.0f; } Loading
packages/SystemUI/src/com/android/systemui/shade/ShadeController.java +8 −2 Original line number Diff line number Diff line Loading @@ -63,8 +63,14 @@ public interface ShadeController { */ boolean closeShadeIfOpen(); /** Returns whether the shade is currently open or opening. */ boolean isShadeOpen(); /** * Returns whether the shade is currently open. * Even though in the current implementation shade is in expanded state on keyguard, this * method makes distinction between shade being truly open and plain keyguard state: * - if QS and notifications are visible on the screen, return true * - for any other state, including keyguard, return false */ boolean isShadeFullyOpen(); /** * Add a runnable for NotificationPanelView to post when the panel is expanded. Loading
packages/SystemUI/src/com/android/systemui/shade/ShadeControllerImpl.java +2 −3 Original line number Diff line number Diff line Loading @@ -154,9 +154,8 @@ public final class ShadeControllerImpl implements ShadeController { } @Override public boolean isShadeOpen() { return mNotificationPanelViewController.isExpanding() || mNotificationPanelViewController.isFullyExpanded(); public boolean isShadeFullyOpen() { return mNotificationPanelViewController.isShadeFullyOpen(); } @Override Loading
packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java +15 −16 Original line number Diff line number Diff line Loading @@ -35,6 +35,7 @@ import static com.android.systemui.Dependency.TIME_TICK_HANDLER_NAME; import static com.android.systemui.charging.WirelessChargingAnimation.UNKNOWN_BATTERY_LEVEL; import static com.android.systemui.keyguard.WakefulnessLifecycle.WAKEFULNESS_ASLEEP; import static com.android.systemui.statusbar.NotificationLockscreenUserManager.PERMISSION_SELF; import static com.android.systemui.statusbar.StatusBarState.SHADE; import static com.android.systemui.statusbar.phone.BarTransitions.MODE_LIGHTS_OUT; import static com.android.systemui.statusbar.phone.BarTransitions.MODE_LIGHTS_OUT_TRANSPARENT; import static com.android.systemui.statusbar.phone.BarTransitions.MODE_OPAQUE; Loading Loading @@ -1147,10 +1148,9 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces { private void onFoldedStateChangedInternal(boolean isFolded, boolean willGoToSleep) { // Folded state changes are followed by a screen off event. // By default turning off the screen also closes the shade. // We want to make sure that the shade status is kept after // folding/unfolding. boolean isShadeOpen = mShadeController.isShadeOpen(); boolean leaveOpen = isShadeOpen && !willGoToSleep; // We want to make sure that the shade status is kept after folding/unfolding. boolean isShadeOpen = mShadeController.isShadeFullyOpen(); boolean leaveOpen = isShadeOpen && !willGoToSleep && mState == SHADE; if (DEBUG) { Log.d(TAG, String.format( "#onFoldedStateChanged(): " Loading @@ -1161,18 +1161,17 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces { isFolded, willGoToSleep, isShadeOpen, leaveOpen)); } if (leaveOpen) { if (mKeyguardStateController.isShowing()) { // When device state changes on keyguard we don't want to keep the state of // below makes shade stay open when going from folded to unfolded mStatusBarStateController.setLeaveOpenOnKeyguardHide(true); } if (mState != SHADE && isShadeOpen) { // When device state changes on KEYGUARD/SHADE_LOCKED we don't want to keep the state of // the shade and instead we open clean state of keyguard with shade closed. // Normally some parts of QS state (like expanded/collapsed) are persisted and // that causes incorrect UI rendering, especially when changing state with QS // expanded. To prevent that we can close QS which resets QS and some parts of // the shade to its default state. Read more in b/201537421 mCloseQsBeforeScreenOff = true; } else { // below makes shade stay open when going from folded to unfolded mStatusBarStateController.setLeaveOpenOnKeyguardHide(true); } } } Loading
packages/SystemUI/tests/src/com/android/systemui/shade/NotificationPanelViewControllerTest.java +36 −0 Original line number Diff line number Diff line Loading @@ -1681,6 +1681,42 @@ public class NotificationPanelViewControllerTest extends SysuiTestCase { assertThat(mNotificationPanelViewController.isFullyExpanded()).isTrue(); } @Test public void shadeExpanded_inShadeState() { mStatusBarStateController.setState(SHADE); mNotificationPanelViewController.setExpandedHeight(0); assertThat(mNotificationPanelViewController.isShadeFullyOpen()).isFalse(); int transitionDistance = mNotificationPanelViewController.getMaxPanelTransitionDistance(); mNotificationPanelViewController.setExpandedHeight(transitionDistance); assertThat(mNotificationPanelViewController.isShadeFullyOpen()).isTrue(); } @Test public void shadeExpanded_onKeyguard() { mStatusBarStateController.setState(KEYGUARD); int transitionDistance = mNotificationPanelViewController.getMaxPanelTransitionDistance(); mNotificationPanelViewController.setExpandedHeight(transitionDistance); assertThat(mNotificationPanelViewController.isShadeFullyOpen()).isFalse(); // set maxQsExpansion in NPVC int maxQsExpansion = 123; mNotificationPanelViewController.setQs(mQs); when(mQs.getDesiredHeight()).thenReturn(maxQsExpansion); triggerLayoutChange(); mNotificationPanelViewController.setQsExpansionHeight(maxQsExpansion); assertThat(mNotificationPanelViewController.isShadeFullyOpen()).isTrue(); } @Test public void shadeExpanded_onShadeLocked() { mStatusBarStateController.setState(SHADE_LOCKED); assertThat(mNotificationPanelViewController.isShadeFullyOpen()).isTrue(); } private static MotionEvent createMotionEvent(int x, int y, int action) { return MotionEvent.obtain( /* downTime= */ 0, /* eventTime= */ 0, action, x, y, /* metaState= */ 0); Loading