Fixing insets mapping in 3-button and 2-button mode

Bug: 131360075
Change-Id: If6e3a4fbb011fc313efeb91686a9d787761862c5
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 417c5a2..823fb6b 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -431,8 +431,8 @@
     @Override
     protected void reapplyUi() {
         if (FeatureFlags.FAKE_LANDSCAPE_UI.get()) {
-            mRotationMode = mStableDeviceProfile == null ? RotationMode.NORMAL :
-                    (mDeviceProfile.isSeascape() ? RotationMode.SEASCAPE : RotationMode.LANDSCAPE);
+            mRotationMode = mStableDeviceProfile == null
+                    ? RotationMode.NORMAL : UiFactory.getRotationMode(mDeviceProfile);
         }
         getRootView().dispatchInsets();
         getStateManager().reapplyState(true /* cancelCurrentAnimation */);
@@ -489,8 +489,7 @@
         if (FeatureFlags.FAKE_LANDSCAPE_UI.get() && mDeviceProfile.isVerticalBarLayout()
                 && !mDeviceProfile.isMultiWindowMode) {
             mStableDeviceProfile = mDeviceProfile.inv.portraitProfile;
-            mRotationMode = mDeviceProfile.isSeascape()
-                    ? RotationMode.SEASCAPE : RotationMode.LANDSCAPE;
+            mRotationMode = UiFactory.getRotationMode(mDeviceProfile);
         } else {
             mStableDeviceProfile = null;
             mRotationMode = RotationMode.NORMAL;
@@ -503,7 +502,9 @@
     public void updateInsets(Rect insets) {
         mDeviceProfile.updateInsets(insets);
         if (mStableDeviceProfile != null) {
-            mStableDeviceProfile.updateInsets(insets);
+            Rect r = mStableDeviceProfile.getInsets();
+            mRotationMode.mapInsets(this, insets, r);
+            mStableDeviceProfile.updateInsets(r);
         }
     }