From 354b8fc0810ae7c965183d3fc31cdc3965da1ac9 Mon Sep 17 00:00:00 2001 From: Riddle Hsu Date: Fri, 10 Jul 2020 21:07:55 +0800 Subject: [PATCH] Use display of activity to get rotation for recents The rotation of WindowConfiguration in Configuration is non-public field. There is no guarantee that the information will be updated. E.g. a 180 degree rotation change won't make difference to the public configurations, so the Resources will keep the old one. The display rotation of activity is accurate to use for its content because even the activity is transformed to different rotation than the physical display, there is FixedRotationAdjustments to adjust the information which will be consistent as how the activity is laid out. Bug: 159877752 Test: 1. Enable auto rotation. 2. Launch some portrait activities. 3. Put device in reverse portrait (upside down). 4. Launch a landscape activity. 5. Swipe to another activity with full-sensor orientation. 6. Return to home and enter recents to check the task views of step 2 don't show upside down. Change-Id: I5e16e71d43b8892a394c06de9e76fb3d4ad55919 --- .../android/quickstep/BaseSwipeUpHandlerV2.java | 2 +- .../quickstep/util/TaskViewSimulator.java | 4 ++-- .../com/android/quickstep/views/RecentsView.java | 4 ++-- .../quickstep/views/TaskThumbnailView.java | 5 ++--- .../quickstep/util/RecentsOrientedState.java | 16 +++++----------- 5 files changed, 12 insertions(+), 19 deletions(-) diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/BaseSwipeUpHandlerV2.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/BaseSwipeUpHandlerV2.java index e084de1acb..80c145a959 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/BaseSwipeUpHandlerV2.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/BaseSwipeUpHandlerV2.java @@ -333,7 +333,7 @@ public abstract class BaseSwipeUpHandlerV2, Q exte if (mStateCallback.hasStates(STATE_HANDLER_INVALIDATED)) { return; } - mTaskViewSimulator.setRecentsConfiguration(mActivity.getResources().getConfiguration()); + mTaskViewSimulator.setRecentsRotation(mActivity.getDisplay().getRotation()); // If we've already ended the gesture and are going home, don't prepare recents UI, // as that will set the state as BACKGROUND_APP, overriding the animation to NORMAL. diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/util/TaskViewSimulator.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/util/TaskViewSimulator.java index c9ed498af1..8a6efe4715 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/util/TaskViewSimulator.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/util/TaskViewSimulator.java @@ -129,8 +129,8 @@ public class TaskViewSimulator implements TransformParams.BuilderProxy { /** * @see com.android.quickstep.views.RecentsView#onConfigurationChanged(Configuration) */ - public void setRecentsConfiguration(Configuration configuration) { - mOrientationState.setActivityConfiguration(configuration); + public void setRecentsRotation(int recentsRotation) { + mOrientationState.setRecentsRotation(recentsRotation); mLayoutValid = false; } diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/views/RecentsView.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/views/RecentsView.java index 027a737cef..49c83e45fc 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/views/RecentsView.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/views/RecentsView.java @@ -393,7 +393,7 @@ public abstract class RecentsView extends PagedView mActivity = BaseActivity.fromContext(context); mOrientationState = new RecentsOrientedState( context, mSizeStrategy, this::animateRecentsRotationInPlace); - mOrientationState.setActivityConfiguration(context.getResources().getConfiguration()); + mOrientationState.setRecentsRotation(mActivity.getDisplay().getRotation()); mFastFlingVelocity = getResources() .getDimensionPixelSize(R.dimen.recents_fast_fling_velocity); @@ -1657,7 +1657,7 @@ public abstract class RecentsView extends PagedView @Override protected void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); - if (mOrientationState.setActivityConfiguration(newConfig)) { + if (mOrientationState.setRecentsRotation(mActivity.getDisplay().getRotation())) { updateOrientationHandler(); } } diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/views/TaskThumbnailView.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/views/TaskThumbnailView.java index 37f6faf523..a8d6442135 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/views/TaskThumbnailView.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/views/TaskThumbnailView.java @@ -59,7 +59,6 @@ import com.android.systemui.plugins.OverviewScreenshotActions; import com.android.systemui.plugins.PluginListener; import com.android.systemui.shared.recents.model.Task; import com.android.systemui.shared.recents.model.ThumbnailData; -import com.android.systemui.shared.system.ConfigurationCompat; /** * A task in the Recents view. @@ -385,8 +384,8 @@ public class TaskThumbnailView extends View implements PluginListener