Fixing broken shade after unfolding during expanding QS
The goal of this change is to transmit `QuickSettingsController#computeExpansionFraction() > 0` to CentralSurfacesImpl so in this case we can also close QS before turning screen off. Now CentralSurfacesImpl checks for shade being fully open or shade being in process of opening/collapsing In the meantime I noticed mIsExpanding really means mIsExpandingOrCollapsing and renamed it like so - that's why so many files are modified. Also changed isExpanding() function to be more comprehensive and properly handle shade opening on lockscreen. Fixes: 277909752 Test: NotificationPanelViewControllerTest#isExpandingOrCollapsing_returnsTrue_whenQsLockscreenDragInProgress Test: CentralSurfacesImplTest#deviceStateChange_unfolded_shadeExpanding_onKeyguard_closesQS Test: CentralSurfacesImplTest#deviceStateChange_unfolded_shadeExpanded_onKeyguard_closesQS Change-Id: I22373e6aaf472a9df50c31fb38db26147b4d3d31
This commit is contained in:
@@ -84,7 +84,7 @@ public class DebugDrawable extends Drawable {
|
||||
Color.YELLOW, "calculatePanelHeightShade()");
|
||||
drawDebugInfo(canvas,
|
||||
(int) mQsController.calculateNotificationsTopPadding(
|
||||
mNotificationPanelViewController.isExpanding(),
|
||||
mNotificationPanelViewController.isExpandingOrCollapsing(),
|
||||
mNotificationPanelViewController.getKeyguardNotificationStaticPadding(),
|
||||
mNotificationPanelViewController.getExpandedFraction()),
|
||||
Color.MAGENTA, "calculateNotificationsTopPadding()");
|
||||
|
||||
@@ -233,7 +233,6 @@ import javax.inject.Inject;
|
||||
import javax.inject.Provider;
|
||||
|
||||
import kotlin.Unit;
|
||||
|
||||
import kotlinx.coroutines.CoroutineDispatcher;
|
||||
|
||||
@CentralSurfacesComponent.CentralSurfacesScope
|
||||
@@ -415,7 +414,11 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump
|
||||
private final KeyguardClockPositionAlgorithm.Result
|
||||
mClockPositionResult =
|
||||
new KeyguardClockPositionAlgorithm.Result();
|
||||
private boolean mIsExpanding;
|
||||
/**
|
||||
* Indicates shade (or just QS) is expanding or collapsing but doesn't fully cover KEYGUARD
|
||||
* state when shade can be expanded with swipe down or swipe down from the top to full QS.
|
||||
*/
|
||||
private boolean mIsExpandingOrCollapsing;
|
||||
|
||||
/**
|
||||
* Indicates drag starting height when swiping down or up on heads-up notifications.
|
||||
@@ -1860,7 +1863,7 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump
|
||||
|
||||
@Override
|
||||
public void expandToNotifications() {
|
||||
if (mSplitShadeEnabled && (isShadeFullyExpanded() || isExpanding())) {
|
||||
if (mSplitShadeEnabled && (isShadeFullyExpanded() || isExpandingOrCollapsing())) {
|
||||
return;
|
||||
}
|
||||
if (mQsController.getExpanded()) {
|
||||
@@ -2267,7 +2270,7 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump
|
||||
|
||||
void requestScrollerTopPaddingUpdate(boolean animate) {
|
||||
mNotificationStackScrollLayoutController.updateTopPadding(
|
||||
mQsController.calculateNotificationsTopPadding(mIsExpanding,
|
||||
mQsController.calculateNotificationsTopPadding(mIsExpandingOrCollapsing,
|
||||
getKeyguardNotificationStaticPadding(), mExpandedFraction), animate);
|
||||
if (isKeyguardShowing()
|
||||
&& mKeyguardBypassController.getBypassEnabled()) {
|
||||
@@ -2320,7 +2323,7 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump
|
||||
}
|
||||
int maxHeight;
|
||||
if (mQsController.isExpandImmediate() || mQsController.getExpanded()
|
||||
|| mIsExpanding && mQsController.getExpandedWhenExpandingStarted()
|
||||
|| mIsExpandingOrCollapsing && mQsController.getExpandedWhenExpandingStarted()
|
||||
|| mPulsing || mSplitShadeEnabled) {
|
||||
maxHeight = mQsController.calculatePanelHeightExpanded(
|
||||
mClockPositionResult.stackScrollerPadding);
|
||||
@@ -2340,8 +2343,11 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump
|
||||
return maxHeight;
|
||||
}
|
||||
|
||||
public boolean isExpanding() {
|
||||
return mIsExpanding;
|
||||
@Override
|
||||
public boolean isExpandingOrCollapsing() {
|
||||
float lockscreenExpansionProgress = mQsController.getLockscreenShadeDragProgress();
|
||||
return mIsExpandingOrCollapsing
|
||||
|| (0 < lockscreenExpansionProgress && lockscreenExpansionProgress < 1);
|
||||
}
|
||||
|
||||
private void onHeightUpdated(float expandedHeight) {
|
||||
@@ -2353,7 +2359,7 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump
|
||||
mExpandedFraction, isExpanded(), mTracking, mExpansionDragDownAmountPx);
|
||||
}
|
||||
if (!mQsController.getExpanded() || mQsController.isExpandImmediate()
|
||||
|| mIsExpanding && mQsController.getExpandedWhenExpandingStarted()) {
|
||||
|| mIsExpandingOrCollapsing && mQsController.getExpandedWhenExpandingStarted()) {
|
||||
// Updating the clock position will set the top padding which might
|
||||
// trigger a new panel height and re-position the clock.
|
||||
// This is a circular dependency and should be avoided, otherwise we'll have
|
||||
@@ -2491,7 +2497,7 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump
|
||||
mNotificationStackScrollLayoutController.onExpansionStopped();
|
||||
mHeadsUpManager.onExpandingFinished();
|
||||
mConversationNotificationManager.onNotificationPanelExpandStateChanged(isFullyCollapsed());
|
||||
mIsExpanding = false;
|
||||
mIsExpandingOrCollapsing = false;
|
||||
mMediaHierarchyManager.setCollapsingShadeFromQS(false);
|
||||
mMediaHierarchyManager.setQsExpanded(mQsController.getExpanded());
|
||||
if (isFullyCollapsed()) {
|
||||
@@ -3197,7 +3203,7 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump
|
||||
ipw.print("mDisplayTopInset="); ipw.println(mDisplayTopInset);
|
||||
ipw.print("mDisplayRightInset="); ipw.println(mDisplayRightInset);
|
||||
ipw.print("mDisplayLeftInset="); ipw.println(mDisplayLeftInset);
|
||||
ipw.print("mIsExpanding="); ipw.println(mIsExpanding);
|
||||
ipw.print("mIsExpandingOrCollapsing="); ipw.println(mIsExpandingOrCollapsing);
|
||||
ipw.print("mHeadsUpStartHeight="); ipw.println(mHeadsUpStartHeight);
|
||||
ipw.print("mListenForHeadsUp="); ipw.println(mListenForHeadsUp);
|
||||
ipw.print("mNavigationBarBottomHeight="); ipw.println(mNavigationBarBottomHeight);
|
||||
@@ -3429,7 +3435,7 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump
|
||||
void notifyExpandingStarted() {
|
||||
if (!mExpanding) {
|
||||
mExpanding = true;
|
||||
mIsExpanding = true;
|
||||
mIsExpandingOrCollapsing = true;
|
||||
mQsController.onExpandingStarted(mQsController.getFullyExpanded());
|
||||
}
|
||||
}
|
||||
@@ -3790,7 +3796,7 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump
|
||||
} else if (mBarState == SHADE_LOCKED) {
|
||||
return true;
|
||||
} else {
|
||||
// case of two finger swipe from the top of keyguard
|
||||
// case of swipe from the top of keyguard to expanded QS
|
||||
return mQsController.computeExpansionFraction() == 1;
|
||||
}
|
||||
}
|
||||
@@ -4042,7 +4048,7 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump
|
||||
* shade QS are always expanded
|
||||
*/
|
||||
private void closeQsIfPossible() {
|
||||
boolean openOrOpening = isShadeFullyExpanded() || isExpanding();
|
||||
boolean openOrOpening = isShadeFullyExpanded() || isExpandingOrCollapsing();
|
||||
if (!(mSplitShadeEnabled && openOrOpening)) {
|
||||
mQsController.closeQs();
|
||||
}
|
||||
@@ -4764,7 +4770,7 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump
|
||||
|
||||
// If pulse is expanding already, let's give it the touch. There are situations
|
||||
// where the panel starts expanding even though we're also pulsing
|
||||
boolean pulseShouldGetTouch = (!mIsExpanding
|
||||
boolean pulseShouldGetTouch = (!mIsExpandingOrCollapsing
|
||||
&& !mQsController.shouldQuickSettingsIntercept(mDownX, mDownY, 0))
|
||||
|| mPulseExpansionHandler.isExpanding();
|
||||
if (pulseShouldGetTouch && mPulseExpansionHandler.onTouchEvent(event)) {
|
||||
|
||||
@@ -77,6 +77,11 @@ public interface ShadeController {
|
||||
*/
|
||||
boolean isShadeFullyOpen();
|
||||
|
||||
/**
|
||||
* Returns whether shade or QS are currently opening or collapsing.
|
||||
*/
|
||||
boolean isExpandingOrCollapsing();
|
||||
|
||||
/**
|
||||
* Add a runnable for NotificationPanelView to post when the panel is expanded.
|
||||
*
|
||||
|
||||
@@ -163,6 +163,11 @@ public final class ShadeControllerImpl implements ShadeController {
|
||||
return mNotificationPanelViewController.isShadeFullyExpanded();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isExpandingOrCollapsing() {
|
||||
return mNotificationPanelViewController.isExpandingOrCollapsing();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postOnShadeExpanded(Runnable executable) {
|
||||
mNotificationPanelViewController.addOnGlobalLayoutListener(
|
||||
|
||||
@@ -48,7 +48,7 @@ interface ShadeViewController {
|
||||
fun expandToNotifications()
|
||||
|
||||
/** Returns whether the shade is expanding or collapsing itself or quick settings. */
|
||||
val isExpanding: Boolean
|
||||
val isExpandingOrCollapsing: Boolean
|
||||
|
||||
/**
|
||||
* Returns whether the shade height is greater than zero (i.e. partially or fully expanded),
|
||||
|
||||
@@ -339,7 +339,7 @@ public class CentralSurfacesCommandQueueCallbacks implements CommandQueue.Callba
|
||||
mHeadsUpManager.unpinAll(true /* userUnpinned */);
|
||||
mMetricsLogger.count("panel_open", 1);
|
||||
} else if (!mQsController.getExpanded()
|
||||
&& !mShadeViewController.isExpanding()) {
|
||||
&& !mShadeViewController.isExpandingOrCollapsing()) {
|
||||
mQsController.flingQs(0 /* velocity */,
|
||||
ShadeViewController.FLING_EXPAND);
|
||||
mMetricsLogger.count("panel_open_qs", 1);
|
||||
|
||||
@@ -1224,6 +1224,7 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces {
|
||||
// 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.isShadeFullyOpen();
|
||||
boolean isShadeExpandingOrCollapsing = mShadeController.isExpandingOrCollapsing();
|
||||
boolean leaveOpen = isShadeOpen && !willGoToSleep && mState == SHADE;
|
||||
if (DEBUG) {
|
||||
Log.d(TAG, String.format(
|
||||
@@ -1231,14 +1232,15 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces {
|
||||
+ "isFolded=%s, "
|
||||
+ "willGoToSleep=%s, "
|
||||
+ "isShadeOpen=%s, "
|
||||
+ "isShadeExpandingOrCollapsing=%s, "
|
||||
+ "leaveOpen=%s",
|
||||
isFolded, willGoToSleep, isShadeOpen, leaveOpen));
|
||||
isFolded, willGoToSleep, isShadeOpen, isShadeExpandingOrCollapsing, leaveOpen));
|
||||
}
|
||||
if (leaveOpen) {
|
||||
// below makes shade stay open when going from folded to unfolded
|
||||
mStatusBarStateController.setLeaveOpenOnKeyguardHide(true);
|
||||
}
|
||||
if (mState != SHADE && isShadeOpen) {
|
||||
if (mState != SHADE && (isShadeOpen || isShadeExpandingOrCollapsing)) {
|
||||
// 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
|
||||
|
||||
@@ -487,7 +487,7 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
|
||||
final boolean hideBouncerOverDream =
|
||||
mDreamOverlayStateController.isOverlayActive()
|
||||
&& (mShadeViewController.isExpanded()
|
||||
|| mShadeViewController.isExpanding());
|
||||
|| mShadeViewController.isExpandingOrCollapsing());
|
||||
|
||||
final boolean isUserTrackingStarted =
|
||||
event.getFraction() != EXPANSION_HIDDEN && event.getTracking();
|
||||
|
||||
@@ -901,6 +901,13 @@ public class NotificationPanelViewControllerTest extends NotificationPanelViewCo
|
||||
assertThat(maxDistance).isEqualTo(SPLIT_SHADE_FULL_TRANSITION_DISTANCE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isExpandingOrCollapsing_returnsTrue_whenQsLockscreenDragInProgress() {
|
||||
when(mQsController.getLockscreenShadeDragProgress()).thenReturn(0.5f);
|
||||
assertThat(mNotificationPanelViewController.isExpandingOrCollapsing()).isTrue();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void getMaxPanelTransitionDistance_inSplitShade_withHeadsUp_returnsBiggerValue() {
|
||||
enableSplitShade(true);
|
||||
|
||||
@@ -335,6 +335,7 @@ public class CentralSurfacesImplTest extends SysuiTestCase {
|
||||
private final FakeFeatureFlags mFeatureFlags = new FakeFeatureFlags();
|
||||
private final InitController mInitController = new InitController();
|
||||
private final DumpManager mDumpManager = new DumpManager();
|
||||
private final ScreenLifecycle mScreenLifecycle = new ScreenLifecycle(mDumpManager);
|
||||
|
||||
@Before
|
||||
public void setup() throws Exception {
|
||||
@@ -487,7 +488,7 @@ public class CentralSurfacesImplTest extends SysuiTestCase {
|
||||
mUserSwitcherController,
|
||||
mBatteryController,
|
||||
mColorExtractor,
|
||||
new ScreenLifecycle(mDumpManager),
|
||||
mScreenLifecycle,
|
||||
mWakefulnessLifecycle,
|
||||
mStatusBarStateController,
|
||||
Optional.of(mBubbles),
|
||||
@@ -554,6 +555,7 @@ public class CentralSurfacesImplTest extends SysuiTestCase {
|
||||
return mViewRootImpl;
|
||||
}
|
||||
};
|
||||
mScreenLifecycle.addObserver(mCentralSurfaces.mScreenObserver);
|
||||
mCentralSurfaces.initShadeVisibilityListener();
|
||||
when(mViewRootImpl.getOnBackInvokedDispatcher())
|
||||
.thenReturn(mOnBackInvokedDispatcher);
|
||||
@@ -1252,6 +1254,32 @@ public class CentralSurfacesImplTest extends SysuiTestCase {
|
||||
verify(mStatusBarStateController, never()).setLeaveOpenOnKeyguardHide(true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void deviceStateChange_unfolded_shadeExpanding_onKeyguard_closesQS() {
|
||||
setFoldedStates(FOLD_STATE_FOLDED);
|
||||
setGoToSleepStates(FOLD_STATE_FOLDED);
|
||||
mCentralSurfaces.setBarStateForTest(KEYGUARD);
|
||||
when(mNotificationPanelViewController.isExpandingOrCollapsing()).thenReturn(true);
|
||||
|
||||
setDeviceState(FOLD_STATE_UNFOLDED);
|
||||
mScreenLifecycle.dispatchScreenTurnedOff();
|
||||
|
||||
verify(mQuickSettingsController).closeQs();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void deviceStateChange_unfolded_shadeExpanded_onKeyguard_closesQS() {
|
||||
setFoldedStates(FOLD_STATE_FOLDED);
|
||||
setGoToSleepStates(FOLD_STATE_FOLDED);
|
||||
mCentralSurfaces.setBarStateForTest(KEYGUARD);
|
||||
when(mNotificationPanelViewController.isShadeFullyExpanded()).thenReturn(true);
|
||||
|
||||
setDeviceState(FOLD_STATE_UNFOLDED);
|
||||
mScreenLifecycle.dispatchScreenTurnedOff();
|
||||
|
||||
verify(mQuickSettingsController).closeQs();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void startActivityDismissingKeyguard_isShowingAndIsOccluded() {
|
||||
when(mKeyguardStateController.isShowing()).thenReturn(true);
|
||||
|
||||
Reference in New Issue
Block a user