Merge "Fixing broken shade after unfolding during expanding QS" into udc-dev

This commit is contained in:
Michał Brzeziński
2023-05-15 11:13:57 +00:00
committed by Android (Google) Code Review
10 changed files with 74 additions and 21 deletions

View File

@@ -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()");

View File

@@ -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.
@@ -1862,7 +1865,7 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump
@Override
public void expandToNotifications() {
if (mSplitShadeEnabled && (isShadeFullyExpanded() || isExpanding())) {
if (mSplitShadeEnabled && (isShadeFullyExpanded() || isExpandingOrCollapsing())) {
return;
}
if (mQsController.getExpanded()) {
@@ -2269,7 +2272,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()) {
@@ -2322,7 +2325,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);
@@ -2342,8 +2345,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) {
@@ -2355,7 +2361,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
@@ -2493,7 +2499,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()) {
@@ -3199,7 +3205,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);
@@ -3431,7 +3437,7 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump
void notifyExpandingStarted() {
if (!mExpanding) {
mExpanding = true;
mIsExpanding = true;
mIsExpandingOrCollapsing = true;
mQsController.onExpandingStarted(mQsController.getFullyExpanded());
}
}
@@ -3792,7 +3798,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;
}
}
@@ -4044,7 +4050,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();
}
@@ -4767,7 +4773,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)) {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -488,7 +488,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();

View File

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

View File

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