Merge "Finish fixed rotation while the task has done transition" into rvc-dev am: 1a3468740a
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/11894999 Change-Id: I52e62f2f07a12982016db3ae2b62eb19172b293f
This commit is contained in:
@@ -1464,9 +1464,10 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (checkOpening) {
|
if (checkOpening) {
|
||||||
if (!mAppTransition.isTransitionSet() && !mOpeningApps.contains(r)) {
|
if (!mAppTransition.isTransitionSet() || !mOpeningApps.contains(r)) {
|
||||||
// Apply normal rotation animation in case of the activity set different requested
|
// Apply normal rotation animation in case of the activity set different requested
|
||||||
// orientation without activity switch.
|
// orientation without activity switch, or the transition is unset due to starting
|
||||||
|
// window was transferred ({@link #mSkipAppTransitionAnimation}).
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else if (r != topRunningActivity()) {
|
} else if (r != topRunningActivity()) {
|
||||||
@@ -5680,16 +5681,36 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
|
|||||||
if (r == null || r == mAnimatingRecents) {
|
if (r == null || r == mAnimatingRecents) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (mFixedRotationLaunchingApp != null
|
if (mFixedRotationLaunchingApp == null) {
|
||||||
&& mFixedRotationLaunchingApp.hasFixedRotationTransform(r)) {
|
// In most cases this is a no-op if the activity doesn't have fixed rotation.
|
||||||
// Waiting until all of the associated activities have done animation, or the
|
// Otherwise it could be from finishing recents animation while the display has
|
||||||
// orientation would be updated too early and cause flickers.
|
// different orientation.
|
||||||
if (!mFixedRotationLaunchingApp.hasAnimatingFixedRotationTransition()) {
|
r.finishFixedRotationTransform();
|
||||||
continueUpdateOrientationForDiffOrienLaunchingApp();
|
return;
|
||||||
|
}
|
||||||
|
if (mFixedRotationLaunchingApp.hasFixedRotationTransform(r)) {
|
||||||
|
if (mFixedRotationLaunchingApp.hasAnimatingFixedRotationTransition()) {
|
||||||
|
// Waiting until all of the associated activities have done animation, or the
|
||||||
|
// orientation would be updated too early and cause flickering.
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
r.finishFixedRotationTransform();
|
// Handle a corner case that the task of {@link #mFixedRotationLaunchingApp} is no
|
||||||
|
// longer animating but the corresponding transition finished event won't notify.
|
||||||
|
// E.g. activity A transferred starting window to B, only A will receive transition
|
||||||
|
// finished event. A doesn't have fixed rotation but B is the rotated launching app.
|
||||||
|
final Task task = r.getTask();
|
||||||
|
if (task == null || task != mFixedRotationLaunchingApp.getTask()) {
|
||||||
|
// Different tasks won't be in one activity transition animation.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (task.isAppTransitioning()) {
|
||||||
|
return;
|
||||||
|
// Continue to update orientation because the transition of the top rotated
|
||||||
|
// launching activity is done.
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
continueUpdateOrientationForDiffOrienLaunchingApp();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -1135,8 +1135,6 @@ public class DisplayContentTests extends WindowTestsBase {
|
|||||||
// Launch another activity before the transition is finished.
|
// Launch another activity before the transition is finished.
|
||||||
final ActivityRecord app2 = new ActivityTestsBase.StackBuilder(mWm.mRoot)
|
final ActivityRecord app2 = new ActivityTestsBase.StackBuilder(mWm.mRoot)
|
||||||
.setDisplay(mDisplayContent).build().getTopMostActivity();
|
.setDisplay(mDisplayContent).build().getTopMostActivity();
|
||||||
mDisplayContent.prepareAppTransition(WindowManager.TRANSIT_ACTIVITY_OPEN,
|
|
||||||
false /* alwaysKeepCurrent */);
|
|
||||||
mDisplayContent.mOpeningApps.add(app2);
|
mDisplayContent.mOpeningApps.add(app2);
|
||||||
app2.setRequestedOrientation(newOrientation);
|
app2.setRequestedOrientation(newOrientation);
|
||||||
|
|
||||||
@@ -1162,6 +1160,29 @@ public class DisplayContentTests extends WindowTestsBase {
|
|||||||
assertNull(mDisplayContent.getFixedRotationAnimationController());
|
assertNull(mDisplayContent.getFixedRotationAnimationController());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testFinishFixedRotationNoAppTransitioningTask() {
|
||||||
|
final ActivityRecord app = mAppWindow.mActivityRecord;
|
||||||
|
final Task task = app.getTask();
|
||||||
|
final ActivityRecord app2 = new ActivityTestsBase.ActivityBuilder(mWm.mAtmService)
|
||||||
|
.setTask(task).build();
|
||||||
|
mDisplayContent.setFixedRotationLaunchingApp(app2, (mDisplayContent.getRotation() + 1) % 4);
|
||||||
|
doReturn(true).when(task).isAppTransitioning();
|
||||||
|
// If the task is animating transition, this should be no-op.
|
||||||
|
mDisplayContent.mFixedRotationTransitionListener.onAppTransitionFinishedLocked(app.token);
|
||||||
|
|
||||||
|
assertTrue(app2.hasFixedRotationTransform());
|
||||||
|
assertTrue(mDisplayContent.hasTopFixedRotationLaunchingApp());
|
||||||
|
|
||||||
|
doReturn(false).when(task).isAppTransitioning();
|
||||||
|
// Although this notifies app instead of app2 that uses the fixed rotation, app2 should
|
||||||
|
// still finish the transform because there is no more transition event.
|
||||||
|
mDisplayContent.mFixedRotationTransitionListener.onAppTransitionFinishedLocked(app.token);
|
||||||
|
|
||||||
|
assertFalse(app2.hasFixedRotationTransform());
|
||||||
|
assertFalse(mDisplayContent.hasTopFixedRotationLaunchingApp());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRotateSeamlesslyWithFixedRotation() {
|
public void testRotateSeamlesslyWithFixedRotation() {
|
||||||
final DisplayRotation displayRotation = mDisplayContent.getDisplayRotation();
|
final DisplayRotation displayRotation = mDisplayContent.getDisplayRotation();
|
||||||
|
|||||||
Reference in New Issue
Block a user