DO NOT MERGE - Merge TP1A.220624.021.A1
Merged-In: Ice6de1149b05564294e5c51308e962112cf4eda7 Change-Id: Ibe4efa97b786828db4ddce40f0cfcd45c6188682
This commit is contained in:
@@ -1323,10 +1323,24 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
|
|||||||
if (mOnStackYChanged != null) {
|
if (mOnStackYChanged != null) {
|
||||||
mOnStackYChanged.accept(listenerNeedsAnimation);
|
mOnStackYChanged.accept(listenerNeedsAnimation);
|
||||||
}
|
}
|
||||||
|
updateStackEndHeightAndStackHeight(fraction);
|
||||||
|
}
|
||||||
|
|
||||||
|
@VisibleForTesting
|
||||||
|
public void updateStackEndHeightAndStackHeight(float fraction) {
|
||||||
|
final float oldStackHeight = mAmbientState.getStackHeight();
|
||||||
if (mQsExpansionFraction <= 0 && !shouldSkipHeightUpdate()) {
|
if (mQsExpansionFraction <= 0 && !shouldSkipHeightUpdate()) {
|
||||||
final float endHeight = updateStackEndHeight(
|
final float endHeight = updateStackEndHeight(
|
||||||
getHeight(), getEmptyBottomMargin(), mTopPadding);
|
getHeight(), getEmptyBottomMargin(), mTopPadding);
|
||||||
updateStackHeight(endHeight, fraction);
|
updateStackHeight(endHeight, fraction);
|
||||||
|
} else {
|
||||||
|
// Always updateStackHeight to prevent jumps in the stack height when this fraction
|
||||||
|
// suddenly reapplies after a freeze.
|
||||||
|
final float endHeight = mAmbientState.getStackEndHeight();
|
||||||
|
updateStackHeight(endHeight, fraction);
|
||||||
|
}
|
||||||
|
if (oldStackHeight != mAmbientState.getStackHeight()) {
|
||||||
|
requestChildrenUpdate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1343,6 +1357,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
|
|||||||
return stackEndHeight;
|
return stackEndHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@VisibleForTesting
|
||||||
public void updateStackHeight(float endHeight, float fraction) {
|
public void updateStackHeight(float endHeight, float fraction) {
|
||||||
// During the (AOD<=>LS) transition where dozeAmount is changing,
|
// During the (AOD<=>LS) transition where dozeAmount is changing,
|
||||||
// apply dozeAmount to stack height instead of expansionFraction
|
// apply dozeAmount to stack height instead of expansionFraction
|
||||||
@@ -5041,6 +5056,19 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
|
|||||||
@ShadeViewRefactor(RefactorComponent.SHADE_VIEW)
|
@ShadeViewRefactor(RefactorComponent.SHADE_VIEW)
|
||||||
public void setUnlockHintRunning(boolean running) {
|
public void setUnlockHintRunning(boolean running) {
|
||||||
mAmbientState.setUnlockHintRunning(running);
|
mAmbientState.setUnlockHintRunning(running);
|
||||||
|
if (!running) {
|
||||||
|
// re-calculate the stack height which was frozen while running this animation
|
||||||
|
updateStackPosition();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@ShadeViewRefactor(RefactorComponent.SHADE_VIEW)
|
||||||
|
public void setPanelFlinging(boolean flinging) {
|
||||||
|
mAmbientState.setIsFlinging(flinging);
|
||||||
|
if (!flinging) {
|
||||||
|
// re-calculate the stack height which was frozen while flinging
|
||||||
|
updateStackPosition();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ShadeViewRefactor(RefactorComponent.SHADE_VIEW)
|
@ShadeViewRefactor(RefactorComponent.SHADE_VIEW)
|
||||||
|
|||||||
@@ -1190,6 +1190,10 @@ public class NotificationStackScrollLayoutController {
|
|||||||
mView.setUnlockHintRunning(running);
|
mView.setUnlockHintRunning(running);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setPanelFlinging(boolean flinging) {
|
||||||
|
mView.setPanelFlinging(flinging);
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isFooterViewNotGone() {
|
public boolean isFooterViewNotGone() {
|
||||||
return mView.isFooterViewNotGone();
|
return mView.isFooterViewNotGone();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1782,14 +1782,14 @@ public class NotificationPanelViewController extends PanelViewController {
|
|||||||
mHeadsUpTouchHelper.notifyFling(!expand);
|
mHeadsUpTouchHelper.notifyFling(!expand);
|
||||||
mKeyguardStateController.notifyPanelFlingStart(!expand /* flingingToDismiss */);
|
mKeyguardStateController.notifyPanelFlingStart(!expand /* flingingToDismiss */);
|
||||||
setClosingWithAlphaFadeout(!expand && !isOnKeyguard() && getFadeoutAlpha() == 1.0f);
|
setClosingWithAlphaFadeout(!expand && !isOnKeyguard() && getFadeoutAlpha() == 1.0f);
|
||||||
mAmbientState.setIsFlinging(true);
|
mNotificationStackScrollLayoutController.setPanelFlinging(true);
|
||||||
super.flingToHeight(vel, expand, target, collapseSpeedUpFactor, expandBecauseOfFalsing);
|
super.flingToHeight(vel, expand, target, collapseSpeedUpFactor, expandBecauseOfFalsing);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onFlingEnd(boolean cancelled) {
|
protected void onFlingEnd(boolean cancelled) {
|
||||||
super.onFlingEnd(cancelled);
|
super.onFlingEnd(cancelled);
|
||||||
mAmbientState.setIsFlinging(false);
|
mNotificationStackScrollLayoutController.setPanelFlinging(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean onQsIntercept(MotionEvent event) {
|
private boolean onQsIntercept(MotionEvent event) {
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ import static org.mockito.Mockito.clearInvocations;
|
|||||||
import static org.mockito.Mockito.doAnswer;
|
import static org.mockito.Mockito.doAnswer;
|
||||||
import static org.mockito.Mockito.doNothing;
|
import static org.mockito.Mockito.doNothing;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
|
import static org.mockito.Mockito.never;
|
||||||
import static org.mockito.Mockito.spy;
|
import static org.mockito.Mockito.spy;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
@@ -122,12 +123,12 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase {
|
|||||||
allowTestableLooperAsMainThread();
|
allowTestableLooperAsMainThread();
|
||||||
|
|
||||||
// Interact with real instance of AmbientState.
|
// Interact with real instance of AmbientState.
|
||||||
mAmbientState = new AmbientState(
|
mAmbientState = spy(new AmbientState(
|
||||||
mContext,
|
mContext,
|
||||||
mDumpManager,
|
mDumpManager,
|
||||||
mNotificationSectionsManager,
|
mNotificationSectionsManager,
|
||||||
mBypassController,
|
mBypassController,
|
||||||
mStatusBarKeyguardViewManager);
|
mStatusBarKeyguardViewManager));
|
||||||
|
|
||||||
// Inject dependencies before initializing the layout
|
// Inject dependencies before initializing the layout
|
||||||
mDependency.injectTestDependency(SysuiStatusBarStateController.class, mBarState);
|
mDependency.injectTestDependency(SysuiStatusBarStateController.class, mBarState);
|
||||||
@@ -190,7 +191,7 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase {
|
|||||||
endHeight, dozeAmount);
|
endHeight, dozeAmount);
|
||||||
|
|
||||||
mStackScroller.updateStackHeight(endHeight, expansionFraction);
|
mStackScroller.updateStackHeight(endHeight, expansionFraction);
|
||||||
assertTrue(mAmbientState.getStackHeight() == expected);
|
assertThat(mAmbientState.getStackHeight()).isEqualTo(expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -205,7 +206,74 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase {
|
|||||||
endHeight, expansionFraction);
|
endHeight, expansionFraction);
|
||||||
|
|
||||||
mStackScroller.updateStackHeight(endHeight, expansionFraction);
|
mStackScroller.updateStackHeight(endHeight, expansionFraction);
|
||||||
assertTrue(mAmbientState.getStackHeight() == expected);
|
assertThat(mAmbientState.getStackHeight()).isEqualTo(expected);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void updateStackEndHeightAndStackHeight_normallyUpdatesBoth() {
|
||||||
|
final float expansionFraction = 0.5f;
|
||||||
|
mAmbientState.setStatusBarState(StatusBarState.KEYGUARD);
|
||||||
|
|
||||||
|
// Validate that by default we update everything
|
||||||
|
clearInvocations(mAmbientState);
|
||||||
|
mStackScroller.updateStackEndHeightAndStackHeight(expansionFraction);
|
||||||
|
verify(mAmbientState).setStackEndHeight(anyFloat());
|
||||||
|
verify(mAmbientState).setStackHeight(anyFloat());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void updateStackEndHeightAndStackHeight_onlyUpdatesStackHeightDuringSwipeUp() {
|
||||||
|
final float expansionFraction = 0.5f;
|
||||||
|
mAmbientState.setStatusBarState(StatusBarState.KEYGUARD);
|
||||||
|
mAmbientState.setSwipingUp(true);
|
||||||
|
|
||||||
|
// Validate that when the gesture is in progress, we update only the stackHeight
|
||||||
|
clearInvocations(mAmbientState);
|
||||||
|
mStackScroller.updateStackEndHeightAndStackHeight(expansionFraction);
|
||||||
|
verify(mAmbientState, never()).setStackEndHeight(anyFloat());
|
||||||
|
verify(mAmbientState).setStackHeight(anyFloat());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void setPanelFlinging_updatesStackEndHeightOnlyOnFinish() {
|
||||||
|
final float expansionFraction = 0.5f;
|
||||||
|
mAmbientState.setStatusBarState(StatusBarState.KEYGUARD);
|
||||||
|
mAmbientState.setSwipingUp(true);
|
||||||
|
mStackScroller.setPanelFlinging(true);
|
||||||
|
mAmbientState.setSwipingUp(false);
|
||||||
|
|
||||||
|
// Validate that when the animation is running, we update only the stackHeight
|
||||||
|
clearInvocations(mAmbientState);
|
||||||
|
mStackScroller.updateStackEndHeightAndStackHeight(expansionFraction);
|
||||||
|
verify(mAmbientState, never()).setStackEndHeight(anyFloat());
|
||||||
|
verify(mAmbientState).setStackHeight(anyFloat());
|
||||||
|
|
||||||
|
// Validate that when the animation ends the stackEndHeight is recalculated immediately
|
||||||
|
clearInvocations(mAmbientState);
|
||||||
|
mStackScroller.setPanelFlinging(false);
|
||||||
|
verify(mAmbientState).setIsFlinging(eq(false));
|
||||||
|
verify(mAmbientState).setStackEndHeight(anyFloat());
|
||||||
|
verify(mAmbientState).setStackHeight(anyFloat());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void setUnlockHintRunning_updatesStackEndHeightOnlyOnFinish() {
|
||||||
|
final float expansionFraction = 0.5f;
|
||||||
|
mAmbientState.setStatusBarState(StatusBarState.KEYGUARD);
|
||||||
|
mStackScroller.setUnlockHintRunning(true);
|
||||||
|
|
||||||
|
// Validate that when the animation is running, we update only the stackHeight
|
||||||
|
clearInvocations(mAmbientState);
|
||||||
|
mStackScroller.updateStackEndHeightAndStackHeight(expansionFraction);
|
||||||
|
verify(mAmbientState, never()).setStackEndHeight(anyFloat());
|
||||||
|
verify(mAmbientState).setStackHeight(anyFloat());
|
||||||
|
|
||||||
|
// Validate that when the animation ends the stackEndHeight is recalculated immediately
|
||||||
|
clearInvocations(mAmbientState);
|
||||||
|
mStackScroller.setUnlockHintRunning(false);
|
||||||
|
verify(mAmbientState).setUnlockHintRunning(eq(false));
|
||||||
|
verify(mAmbientState).setStackEndHeight(anyFloat());
|
||||||
|
verify(mAmbientState).setStackHeight(anyFloat());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
@@ -759,7 +759,7 @@ class WindowOrganizerController extends IWindowOrganizerController.Stub
|
|||||||
}
|
}
|
||||||
if (parent.isAllowedToEmbedActivity(activity) != EMBEDDING_ALLOWED) {
|
if (parent.isAllowedToEmbedActivity(activity) != EMBEDDING_ALLOWED) {
|
||||||
final Throwable exception = new SecurityException(
|
final Throwable exception = new SecurityException(
|
||||||
"The task fragment is not trusted to embed the given activity.");
|
"The task fragment is not allowed to embed the given activity.");
|
||||||
sendTaskFragmentOperationFailure(organizer, errorCallbackToken, exception);
|
sendTaskFragmentOperationFailure(organizer, errorCallbackToken, exception);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -769,11 +769,6 @@ class WindowOrganizerController extends IWindowOrganizerController.Stub
|
|||||||
sendTaskFragmentOperationFailure(organizer, errorCallbackToken, exception);
|
sendTaskFragmentOperationFailure(organizer, errorCallbackToken, exception);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (parent.smallerThanMinDimension(activity)) {
|
|
||||||
sendMinimumDimensionViolation(parent, activity.getMinDimensions(),
|
|
||||||
errorCallbackToken, "reparentActivityToTask");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
activity.reparent(parent, POSITION_TOP);
|
activity.reparent(parent, POSITION_TOP);
|
||||||
effects |= TRANSACT_EFFECTS_LIFECYCLE;
|
effects |= TRANSACT_EFFECTS_LIFECYCLE;
|
||||||
@@ -1583,10 +1578,10 @@ class WindowOrganizerController extends IWindowOrganizerController.Stub
|
|||||||
// We are reparenting activities to a new embedded TaskFragment, this operation is only
|
// We are reparenting activities to a new embedded TaskFragment, this operation is only
|
||||||
// allowed if the new parent is trusted by all reparent activities.
|
// allowed if the new parent is trusted by all reparent activities.
|
||||||
final boolean isEmbeddingDisallowed = oldParent.forAllActivities(activity ->
|
final boolean isEmbeddingDisallowed = oldParent.forAllActivities(activity ->
|
||||||
newParentTF.isAllowedToEmbedActivity(activity) == EMBEDDING_ALLOWED);
|
newParentTF.isAllowedToEmbedActivity(activity) != EMBEDDING_ALLOWED);
|
||||||
if (isEmbeddingDisallowed) {
|
if (isEmbeddingDisallowed) {
|
||||||
final Throwable exception = new SecurityException(
|
final Throwable exception = new SecurityException(
|
||||||
"The new parent is not trusted to embed the activities.");
|
"The new parent is not allowed to embed the activities.");
|
||||||
sendTaskFragmentOperationFailure(organizer, errorCallbackToken, exception);
|
sendTaskFragmentOperationFailure(organizer, errorCallbackToken, exception);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -1603,14 +1598,6 @@ class WindowOrganizerController extends IWindowOrganizerController.Stub
|
|||||||
sendTaskFragmentOperationFailure(organizer, errorCallbackToken, exception);
|
sendTaskFragmentOperationFailure(organizer, errorCallbackToken, exception);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final Point minDimensions = oldParent.calculateMinDimension();
|
|
||||||
final Rect newParentBounds = newParentTF.getBounds();
|
|
||||||
if (newParentBounds.width() < minDimensions.x
|
|
||||||
|| newParentBounds.height() < minDimensions.y) {
|
|
||||||
sendMinimumDimensionViolation(newParentTF, minDimensions, errorCallbackToken,
|
|
||||||
"reparentTaskFragment");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
while (oldParent.hasChild()) {
|
while (oldParent.hasChild()) {
|
||||||
oldParent.getChildAt(0).reparent(newParentTF, POSITION_TOP);
|
oldParent.getChildAt(0).reparent(newParentTF, POSITION_TOP);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user