summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Riddle Hsu <riddlehsu@google.com> 2020-05-27 23:15:39 +0800
committer Riddle Hsu <riddlehsu@google.com> 2020-05-28 21:41:32 +0800
commitf3ff9e7f61af16ca99c73c58b09bfdaebcc6bc99 (patch)
tree696ab633644baebf6e2790fb2004023535d50e12
parentedcb2c38f4a06fbc4fe786e3a5f441d0ef69b55c (diff)
Update top fixed rotation launching app when linking new top
Assume the foreground activity is fixed orientation landscape. Recents (home) is fixed orientation portrait. When swiping the navigation bar to switch to another fixed orientation portrait activity, before the recents animation is finished, the fixed rotation app is the recents activity. And after that, the top activity will be the portrait one. It will share the existing rotation transform of recents. If the top fixed rotation app is still the recents, its transform will be cleared too early (FixedRotationTransitionListener#onFinishRecentsAnimation) when finishing recents animation that causes flickering. Also change the usage of mAssociatedTokens to include the owner token, so that any linked token can clears all rotated state of associated token at the same time. Fixes: 157446289 Test: atest DisplayContentTests#testApplyTopFixedRotationTransform Change-Id: Ibc1c85cf9c9f61297cbcf13412f39b388b874557
-rw-r--r--services/core/java/com/android/server/wm/DisplayContent.java6
-rw-r--r--services/core/java/com/android/server/wm/WindowToken.java9
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java4
3 files changed, 13 insertions, 6 deletions
diff --git a/services/core/java/com/android/server/wm/DisplayContent.java b/services/core/java/com/android/server/wm/DisplayContent.java
index b6672d3c73c0..fcd642f9a9c9 100644
--- a/services/core/java/com/android/server/wm/DisplayContent.java
+++ b/services/core/java/com/android/server/wm/DisplayContent.java
@@ -1527,6 +1527,11 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
*/
void setFixedRotationLaunchingApp(@NonNull ActivityRecord r, @Surface.Rotation int rotation) {
final WindowToken prevRotatedLaunchingApp = mFixedRotationLaunchingApp;
+ if (prevRotatedLaunchingApp != null && prevRotatedLaunchingApp == r
+ && r.getWindowConfiguration().getRotation() == rotation) {
+ // The given launching app and target rotation are the same as the existing ones.
+ return;
+ }
if (prevRotatedLaunchingApp != null
&& prevRotatedLaunchingApp.getWindowConfiguration().getRotation() == rotation
// It is animating so we can expect there will have a transition callback.
@@ -1536,6 +1541,7 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
// the heavy operations. This also benefits that the states of multiple activities
// are handled together.
r.linkFixedRotationTransform(prevRotatedLaunchingApp);
+ setFixedRotationLaunchingAppUnchecked(r, rotation);
return;
}
diff --git a/services/core/java/com/android/server/wm/WindowToken.java b/services/core/java/com/android/server/wm/WindowToken.java
index 768f89eff774..d2570023f419 100644
--- a/services/core/java/com/android/server/wm/WindowToken.java
+++ b/services/core/java/com/android/server/wm/WindowToken.java
@@ -128,10 +128,10 @@ class WindowToken extends WindowContainer<WindowState> {
final Configuration mRotatedOverrideConfiguration;
final SeamlessRotator mRotator;
/**
- * The tokens that share the same transform. Their end time of transform are the same as
- * {@link #mOwner}.
+ * The tokens that share the same transform. Their end time of transform are the same. The
+ * list should at least contain the token who creates this state.
*/
- final ArrayList<WindowToken> mAssociatedTokens = new ArrayList<>(1);
+ final ArrayList<WindowToken> mAssociatedTokens = new ArrayList<>(3);
final ArrayList<WindowContainer<?>> mRotatedContainers = new ArrayList<>(3);
boolean mIsTransforming = true;
@@ -531,6 +531,7 @@ class WindowToken extends WindowContainer<WindowState> {
mDisplayContent.getConfiguration().uiMode);
mFixedRotationTransformState = new FixedRotationTransformState(info, displayFrames,
insetsState, new Configuration(config), mDisplayContent.getRotation());
+ mFixedRotationTransformState.mAssociatedTokens.add(this);
onConfigurationChanged(getParent().getConfiguration());
notifyFixedRotationTransform(true /* enabled */);
}
@@ -578,14 +579,12 @@ class WindowToken extends WindowContainer<WindowState> {
for (int i = state.mAssociatedTokens.size() - 1; i >= 0; i--) {
state.mAssociatedTokens.get(i).cancelFixedRotationTransform();
}
- cancelFixedRotationTransform();
}
// The state is cleared at the end, because it is used to indicate that other windows can
// use seamless rotation when applying rotation to display.
for (int i = state.mAssociatedTokens.size() - 1; i >= 0; i--) {
state.mAssociatedTokens.get(i).cleanUpFixedRotationTransformState();
}
- cleanUpFixedRotationTransformState();
}
private void cleanUpFixedRotationTransformState() {
diff --git a/services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java b/services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java
index 7be2b732ac62..7197ce9c22aa 100644
--- a/services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java
@@ -1134,8 +1134,10 @@ public class DisplayContentTests extends WindowTestsBase {
mDisplayContent.mOpeningApps.add(app2);
app2.setRequestedOrientation(newOrientation);
- // The activity should share the same transform state as the existing one.
+ // The activity should share the same transform state as the existing one. The activity
+ // should also be the fixed rotation launching app because it is the latest top.
assertTrue(app.hasFixedRotationTransform(app2));
+ assertTrue(mDisplayContent.isFixedRotationLaunchingApp(app2));
// The display should be rotated after the launch is finished.
mDisplayContent.mAppTransition.notifyAppTransitionFinishedLocked(app.token);