Merge "Finish the recents animation upon home rotation" into sc-dev am: dc2be3d8a2

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Launcher3/+/14613421

Change-Id: I75d9bc3759ed5b1aca66dab92d6fae38288317fe
diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java
index 96f8df0..25e850c 100644
--- a/quickstep/src/com/android/quickstep/views/RecentsView.java
+++ b/quickstep/src/com/android/quickstep/views/RecentsView.java
@@ -388,6 +388,8 @@
 
     private final TaskOverlayFactory mTaskOverlayFactory;
 
+    private int mOrientation;
+
     protected boolean mDisallowScrollToClearAll;
     private boolean mOverlayEnabled;
     protected boolean mFreezeViewVisibility;
@@ -580,6 +582,7 @@
                 .getDimensionPixelSize(R.dimen.recents_fast_fling_velocity);
         mModel = RecentsModel.INSTANCE.get(context);
         mIdp = InvariantDeviceProfile.INSTANCE.get(context);
+        mOrientation = getResources().getConfiguration().orientation;
 
         mClearAllButton = (ClearAllButton) LayoutInflater.from(context)
                 .inflate(R.layout.overview_clear_all_button, this, false);
@@ -2574,6 +2577,18 @@
     @Override
     protected void onConfigurationChanged(Configuration newConfig) {
         super.onConfigurationChanged(newConfig);
+        if (LIVE_TILE.get() && mEnableDrawingLiveTile && newConfig.orientation != mOrientation) {
+            switchToScreenshot(
+                    () -> finishRecentsAnimation(true /* toRecents */,
+                            this::onConfigurationChangedInternal));
+            mEnableDrawingLiveTile = false;
+        } else {
+            onConfigurationChangedInternal();
+        }
+        mOrientation = newConfig.orientation;
+    }
+
+    private void onConfigurationChangedInternal() {
         final int rotation = mActivity.getDisplay().getRotation();
         if (mOrientationState.setRecentsRotation(rotation)) {
             updateOrientationHandler();