Reapply insets normalization on configuration changes

- When going from an app to Overview after deivce is rotated, sometimes the Configuration associated with Launcher activity have old information (dimension from preious rotation), causing LauncherRootView.onApplyWindowInsets to store wrong insets from WindowManagerProxy.normalizeWindowInsets
- The fix is when LaucnehrRootView.dispatchInsets is called, reapply insets by calling onApplyWindowInsets again to get updated normalized insets.

Fix: 323105140
Test: Launch an app, rotate to landscape, tap Recents button to go to Overview
Flag: EXEMPT BUG_FIX
Change-Id: I8e641a2702670d1364ee5a0f10a1b3c8d1a2b324
diff --git a/src/com/android/launcher3/LauncherRootView.java b/src/com/android/launcher3/LauncherRootView.java
index d645734..a5b95c7 100644
--- a/src/com/android/launcher3/LauncherRootView.java
+++ b/src/com/android/launcher3/LauncherRootView.java
@@ -10,7 +10,6 @@
 import android.view.WindowInsets;
 
 import com.android.launcher3.graphics.SysUiScrim;
-import com.android.launcher3.statemanager.StatefulActivity;
 import com.android.launcher3.statemanager.StatefulContainer;
 import com.android.launcher3.util.window.WindowManagerProxy;
 
@@ -56,7 +55,10 @@
     public WindowInsets onApplyWindowInsets(WindowInsets insets) {
         mStatefulContainer.handleConfigurationChanged(
                 mStatefulContainer.getContext().getResources().getConfiguration());
+        return updateInsets(insets);
+    }
 
+    private WindowInsets updateInsets(WindowInsets insets) {
         insets = WindowManagerProxy.INSTANCE.get(getContext())
                 .normalizeWindowInsets(getContext(), insets, mTempRect);
         handleSystemWindowInsets(mTempRect);
@@ -74,7 +76,11 @@
     }
 
     public void dispatchInsets() {
-        mStatefulContainer.getDeviceProfile().updateInsets(mInsets);
+        if (isAttachedToWindow()) {
+            updateInsets(getRootWindowInsets());
+        } else {
+            mStatefulContainer.getDeviceProfile().updateInsets(mInsets);
+        }
         super.setInsets(mInsets);
     }