Fix broken Splitscreen in Overview on orientation change in foldables

We should make sure that only either `topMargin` or a Y translation is
used at a time on an Overview snapshot view to avoid seeing the snapshot
shifted down by an unexpected amount.

Detailed explanation can be found here: https://b.corp.google.com/issues/347143158#comment16

Fixes: 347143158
Test: Manually by following the steps described in the above comment and
      verifying the bug no longer repros.
Flag: EXEMPT bugfix
Change-Id: I699b0ccd9630c10d973fc28abb1228359184929b
diff --git a/quickstep/src/com/android/quickstep/orientation/PortraitPagedViewHandler.java b/quickstep/src/com/android/quickstep/orientation/PortraitPagedViewHandler.java
index eeacee1..96b686c 100644
--- a/quickstep/src/com/android/quickstep/orientation/PortraitPagedViewHandler.java
+++ b/quickstep/src/com/android/quickstep/orientation/PortraitPagedViewHandler.java
@@ -535,6 +535,18 @@
             int parentWidth, int parentHeight, SplitBounds splitBoundsConfig,
             DeviceProfile dp, boolean isRtl) {
         int spaceAboveSnapshot = dp.overviewTaskThumbnailTopMarginPx;
+
+        FrameLayout.LayoutParams primaryParams =
+                (FrameLayout.LayoutParams) primarySnapshot.getLayoutParams();
+        FrameLayout.LayoutParams secondaryParams =
+                (FrameLayout.LayoutParams) secondarySnapshot.getLayoutParams();
+
+        // Reset margin and translations that aren't used in this method, but are used in other
+        // `RecentsPagedOrientationHandler` variants.
+        secondaryParams.topMargin = 0;
+        primaryParams.topMargin = spaceAboveSnapshot;
+        primarySnapshot.setTranslationY(0);
+
         int totalThumbnailHeight = parentHeight - spaceAboveSnapshot;
         float dividerScale = splitBoundsConfig.appsStackedVertically
                 ? splitBoundsConfig.dividerHeightPercent
@@ -552,24 +564,14 @@
                 secondarySnapshot.setTranslationX(translationX);
                 primarySnapshot.setTranslationX(0);
             }
-            secondarySnapshot.setTranslationY(spaceAboveSnapshot);
 
-            // Reset unused translations
-            primarySnapshot.setTranslationY(0);
+            secondarySnapshot.setTranslationY(spaceAboveSnapshot);
         } else {
             float finalDividerHeight = Math.round(totalThumbnailHeight * dividerScale);
             float translationY = taskViewSizes.first.y + spaceAboveSnapshot + finalDividerHeight;
             secondarySnapshot.setTranslationY(translationY);
 
-            FrameLayout.LayoutParams primaryParams =
-                    (FrameLayout.LayoutParams) primarySnapshot.getLayoutParams();
-            FrameLayout.LayoutParams secondaryParams =
-                    (FrameLayout.LayoutParams) secondarySnapshot.getLayoutParams();
-            secondaryParams.topMargin = 0;
-            primaryParams.topMargin = spaceAboveSnapshot;
-
-            // Reset unused translations
-            primarySnapshot.setTranslationY(0);
+            // Reset unused translations.
             secondarySnapshot.setTranslationX(0);
             primarySnapshot.setTranslationX(0);
         }