Merge "Remove CentralSurfaces.collapseShade" into udc-qpr-dev

This commit is contained in:
Treehugger Robot
2023-06-05 18:26:14 +00:00
committed by Android (Google) Code Review
8 changed files with 42 additions and 43 deletions

View File

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

View File

@@ -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.
*

View File

@@ -269,6 +269,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()) {

View File

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

View File

@@ -318,8 +318,6 @@ public interface CentralSurfaces extends Dumpable, LifecycleOwner {
void setBouncerShowingOverDream(boolean bouncerShowingOverDream);
void collapseShade();
int getWakefulnessState();
boolean isScreenFullyOff();

View File

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

View File

@@ -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()
}
}

View File

@@ -1141,32 +1141,6 @@ public class CentralSurfacesImplTest extends SysuiTestCase {
verify(mStatusBarKeyguardViewManager).updateResources();
}
@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);