Skip to content

Commit 5958828

Browse files
TreeHugger RobotAndroid (Google) Code Review
authored andcommitted
Merge "Update top fixed rotation launching app when linking new top" into rvc-dev
2 parents 9aa8852 + f3ff9e7 commit 5958828

3 files changed

Lines changed: 13 additions & 6 deletions

File tree

services/core/java/com/android/server/wm/DisplayContent.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1527,6 +1527,11 @@ void setFixedRotationLaunchingAppUnchecked(@Nullable ActivityRecord r, int rotat
15271527
*/
15281528
void setFixedRotationLaunchingApp(@NonNull ActivityRecord r, @Surface.Rotation int rotation) {
15291529
final WindowToken prevRotatedLaunchingApp = mFixedRotationLaunchingApp;
1530+
if (prevRotatedLaunchingApp != null && prevRotatedLaunchingApp == r
1531+
&& r.getWindowConfiguration().getRotation() == rotation) {
1532+
// The given launching app and target rotation are the same as the existing ones.
1533+
return;
1534+
}
15301535
if (prevRotatedLaunchingApp != null
15311536
&& prevRotatedLaunchingApp.getWindowConfiguration().getRotation() == rotation
15321537
// It is animating so we can expect there will have a transition callback.
@@ -1536,6 +1541,7 @@ void setFixedRotationLaunchingApp(@NonNull ActivityRecord r, @Surface.Rotation i
15361541
// the heavy operations. This also benefits that the states of multiple activities
15371542
// are handled together.
15381543
r.linkFixedRotationTransform(prevRotatedLaunchingApp);
1544+
setFixedRotationLaunchingAppUnchecked(r, rotation);
15391545
return;
15401546
}
15411547

services/core/java/com/android/server/wm/WindowToken.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,10 @@ private static class FixedRotationTransformState {
128128
final Configuration mRotatedOverrideConfiguration;
129129
final SeamlessRotator mRotator;
130130
/**
131-
* The tokens that share the same transform. Their end time of transform are the same as
132-
* {@link #mOwner}.
131+
* The tokens that share the same transform. Their end time of transform are the same. The
132+
* list should at least contain the token who creates this state.
133133
*/
134-
final ArrayList<WindowToken> mAssociatedTokens = new ArrayList<>(1);
134+
final ArrayList<WindowToken> mAssociatedTokens = new ArrayList<>(3);
135135
final ArrayList<WindowContainer<?>> mRotatedContainers = new ArrayList<>(3);
136136
boolean mIsTransforming = true;
137137

@@ -531,6 +531,7 @@ void applyFixedRotationTransform(DisplayInfo info, DisplayFrames displayFrames,
531531
mDisplayContent.getConfiguration().uiMode);
532532
mFixedRotationTransformState = new FixedRotationTransformState(info, displayFrames,
533533
insetsState, new Configuration(config), mDisplayContent.getRotation());
534+
mFixedRotationTransformState.mAssociatedTokens.add(this);
534535
onConfigurationChanged(getParent().getConfiguration());
535536
notifyFixedRotationTransform(true /* enabled */);
536537
}
@@ -578,14 +579,12 @@ void finishFixedRotationTransform(Runnable applyDisplayRotation) {
578579
for (int i = state.mAssociatedTokens.size() - 1; i >= 0; i--) {
579580
state.mAssociatedTokens.get(i).cancelFixedRotationTransform();
580581
}
581-
cancelFixedRotationTransform();
582582
}
583583
// The state is cleared at the end, because it is used to indicate that other windows can
584584
// use seamless rotation when applying rotation to display.
585585
for (int i = state.mAssociatedTokens.size() - 1; i >= 0; i--) {
586586
state.mAssociatedTokens.get(i).cleanUpFixedRotationTransformState();
587587
}
588-
cleanUpFixedRotationTransformState();
589588
}
590589

591590
private void cleanUpFixedRotationTransformState() {

services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1134,8 +1134,10 @@ public void testApplyTopFixedRotationTransform() {
11341134
mDisplayContent.mOpeningApps.add(app2);
11351135
app2.setRequestedOrientation(newOrientation);
11361136

1137-
// The activity should share the same transform state as the existing one.
1137+
// The activity should share the same transform state as the existing one. The activity
1138+
// should also be the fixed rotation launching app because it is the latest top.
11381139
assertTrue(app.hasFixedRotationTransform(app2));
1140+
assertTrue(mDisplayContent.isFixedRotationLaunchingApp(app2));
11391141

11401142
// The display should be rotated after the launch is finished.
11411143
mDisplayContent.mAppTransition.notifyAppTransitionFinishedLocked(app.token);

0 commit comments

Comments
 (0)