summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Justin Weir <justinweir@google.com> 2023-06-01 16:13:25 -0400
committer Justin Weir <justinweir@google.com> 2023-06-03 15:34:03 +0000
commit8ad463c6b90c09b4cf2f7078f62f733a7ec7550c (patch)
tree9b5ecabca144ea09bfc228335376bf9a085c8679
parent35fd336aa4c1a8fb751967a764b973676cff4bc2 (diff)
Remove CentralSurfaces.collapseShade
Adds ShadeController.cancelExpansionAndCollapseShade to replace it Bug: 249277686 Test: Manual Test: replaced dead CS tests with new SC tests Change-Id: I7e65f8b95bebf6f10e7af6f240bf6d548e17f41c
-rw-r--r--packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialogLite.java2
-rw-r--r--packages/SystemUI/src/com/android/systemui/shade/ShadeController.java3
-rw-r--r--packages/SystemUI/src/com/android/systemui/shade/ShadeControllerImpl.java11
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/ActivityStarterImpl.kt2
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfaces.java2
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java13
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/shade/ShadeControllerImplTest.kt26
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/CentralSurfacesImplTest.java26
8 files changed, 42 insertions, 43 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialogLite.java b/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialogLite.java
index c71775b19e90..52483646f01e 100644
--- a/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialogLite.java
+++ b/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialogLite.java
@@ -914,7 +914,7 @@ public class GlobalActionsDialogLite implements DialogInterface.OnDismissListene
mUiEventLogger.log(GlobalActionsEvent.GA_EMERGENCY_DIALER_PRESS);
if (mTelecomManager != null) {
// Close shade so user sees the activity
- mCentralSurfacesOptional.ifPresent(CentralSurfaces::collapseShade);
+ mShadeController.cancelExpansionAndCollapseShade();
Intent intent = mTelecomManager.createLaunchEmergencyDialerIntent(
null /* number */);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK
diff --git a/packages/SystemUI/src/com/android/systemui/shade/ShadeController.java b/packages/SystemUI/src/com/android/systemui/shade/ShadeController.java
index 29c4acc792ca..9ed0e9a8b359 100644
--- a/packages/SystemUI/src/com/android/systemui/shade/ShadeController.java
+++ b/packages/SystemUI/src/com/android/systemui/shade/ShadeController.java
@@ -71,6 +71,9 @@ public interface ShadeController {
/** Posts a request to expand the shade to quick settings. */
void postAnimateExpandQs();
+ /** Cancels any ongoing expansion touch handling and collapses the shade. */
+ void cancelExpansionAndCollapseShade();
+
/**
* If the shade is not fully expanded, collapse it animated.
*
diff --git a/packages/SystemUI/src/com/android/systemui/shade/ShadeControllerImpl.java b/packages/SystemUI/src/com/android/systemui/shade/ShadeControllerImpl.java
index 7942b588866a..c9338b3614ea 100644
--- a/packages/SystemUI/src/com/android/systemui/shade/ShadeControllerImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/shade/ShadeControllerImpl.java
@@ -270,6 +270,17 @@ public final class ShadeControllerImpl implements ShadeController {
}
@Override
+ public void cancelExpansionAndCollapseShade() {
+ if (mNotificationPanelViewController.isTracking()) {
+ mNotificationShadeWindowViewController.cancelCurrentTouch();
+ }
+ if (mNotificationPanelViewController.isPanelExpanded()
+ && mStatusBarStateController.getState() == StatusBarState.SHADE) {
+ animateCollapseShade();
+ }
+ }
+
+ @Override
public void collapseOnMainThread() {
if (Looper.getMainLooper().isCurrentThread()) {
collapseShade();
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ActivityStarterImpl.kt b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ActivityStarterImpl.kt
index 217d32c93c6d..730ef57f1972 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ActivityStarterImpl.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ActivityStarterImpl.kt
@@ -744,7 +744,7 @@ constructor(
} else if (dismissShade) {
// The animation will take care of dismissing the shade at the end of the animation.
// If we don't animate, collapse it directly.
- centralSurfaces?.collapseShade()
+ shadeControllerLazy.get().cancelExpansionAndCollapseShade()
}
// We should exit the dream to prevent the activity from starting below the
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfaces.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfaces.java
index f0b82f477c4a..796ffd375f7c 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfaces.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfaces.java
@@ -318,8 +318,6 @@ public interface CentralSurfaces extends Dumpable, LifecycleOwner {
void setBouncerShowingOverDream(boolean bouncerShowingOverDream);
- void collapseShade();
-
int getWakefulnessState();
boolean isScreenFullyOff();
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java
index cb9a88b24749..7b3453056934 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java
@@ -2960,19 +2960,6 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces {
mShadeSurface.setBouncerShowing(bouncerShowing);
}
- /**
- * Collapses the notification shade if it is tracking or expanded.
- */
- @Override
- public void collapseShade() {
- if (mShadeSurface.isTracking()) {
- mNotificationShadeWindowViewController.cancelCurrentTouch();
- }
- if (mShadeSurface.isPanelExpanded() && mState == StatusBarState.SHADE) {
- mShadeController.animateCollapseShade();
- }
- }
-
@VisibleForTesting
final WakefulnessLifecycle.Observer mWakefulnessObserver = new WakefulnessLifecycle.Observer() {
@Override
diff --git a/packages/SystemUI/tests/src/com/android/systemui/shade/ShadeControllerImplTest.kt b/packages/SystemUI/tests/src/com/android/systemui/shade/ShadeControllerImplTest.kt
index ef66756790d8..00a056708f07 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/shade/ShadeControllerImplTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/shade/ShadeControllerImplTest.kt
@@ -57,6 +57,7 @@ class ShadeControllerImplTest : SysuiTestCase() {
@Mock private lateinit var assistManager: AssistManager
@Mock private lateinit var gutsManager: NotificationGutsManager
@Mock private lateinit var notificationPanelViewController: NotificationPanelViewController
+ @Mock private lateinit var nswvc: NotificationShadeWindowViewController
@Mock private lateinit var display: Display
private lateinit var shadeController: ShadeControllerImpl
@@ -80,6 +81,7 @@ class ShadeControllerImplTest : SysuiTestCase() {
Lazy { assistManager },
Lazy { gutsManager },
)
+ shadeController.setNotificationShadeWindowViewController(nswvc)
shadeController.setNotificationPanelViewController(notificationPanelViewController)
}
@@ -104,4 +106,28 @@ class ShadeControllerImplTest : SysuiTestCase() {
shadeController.animateExpandQs()
verify(notificationPanelViewController).expandToQs()
}
+
+ @Test
+ fun cancelExpansionAndCollapseShade_callsCancelCurrentTouch() {
+ // GIVEN the shade is tracking a touch
+ whenever(notificationPanelViewController.isTracking).thenReturn(true)
+
+ // WHEN cancelExpansionAndCollapseShade is called
+ shadeController.cancelExpansionAndCollapseShade()
+
+ // VERIFY that cancelCurrentTouch is called
+ verify(nswvc).cancelCurrentTouch()
+ }
+
+ @Test
+ fun cancelExpansionAndCollapseShade_doesNotCallAnimateCollapseShade_whenCollapsed() {
+ // GIVEN the shade is tracking a touch
+ whenever(notificationPanelViewController.isTracking).thenReturn(false)
+
+ // WHEN cancelExpansionAndCollapseShade is called
+ shadeController.cancelExpansionAndCollapseShade()
+
+ // VERIFY that cancelCurrentTouch is NOT called
+ verify(nswvc, never()).cancelCurrentTouch()
+ }
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/CentralSurfacesImplTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/CentralSurfacesImplTest.java
index c254783ed81b..024947754dad 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/CentralSurfacesImplTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/CentralSurfacesImplTest.java
@@ -1142,32 +1142,6 @@ public class CentralSurfacesImplTest extends SysuiTestCase {
}
@Test
- public void collapseShade_callsanimateCollapseShade_whenExpanded() {
- // GIVEN the shade is expanded
- when(mNotificationPanelViewController.isPanelExpanded()).thenReturn(true);
- mCentralSurfaces.setBarStateForTest(SHADE);
-
- // WHEN collapseShade is called
- mCentralSurfaces.collapseShade();
-
- // VERIFY that animateCollapseShade is called
- verify(mShadeController).animateCollapseShade();
- }
-
- @Test
- public void collapseShade_doesNotCallAnimateCollapseShade_whenCollapsed() {
- // GIVEN the shade is collapsed
- when(mNotificationPanelViewController.isPanelExpanded()).thenReturn(false);
- mCentralSurfaces.setBarStateForTest(SHADE);
-
- // WHEN collapseShade is called
- mCentralSurfaces.collapseShade();
-
- // VERIFY that animateCollapseShade is NOT called
- verify(mShadeController, never()).animateCollapseShade();
- }
-
- @Test
public void deviceStateChange_unfolded_shadeOpen_setsLeaveOpenOnKeyguardHide() {
setFoldedStates(FOLD_STATE_FOLDED);
setGoToSleepStates(FOLD_STATE_FOLDED);