Avoid DisplayController.currentSize from being stuck at wrong value

- Update Info when perDisplayBounds has changed
- Add more detailed logging to displayInfo, realBounds and perDisplayBounds
- Add perDisplayBounds to dumpsys and replace supportedBounds

Bug: 233562339
Test: manual
Change-Id: I9a040e8465a8b0a2dcde61bab06c6ca1df3006da
diff --git a/src/com/android/launcher3/util/DisplayController.java b/src/com/android/launcher3/util/DisplayController.java
index 7c73be5..9ed6bee 100644
--- a/src/com/android/launcher3/util/DisplayController.java
+++ b/src/com/android/launcher3/util/DisplayController.java
@@ -55,6 +55,7 @@
 
 import java.io.PrintWriter;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Collections;
 import java.util.Objects;
 import java.util.Set;
@@ -238,7 +239,8 @@
         if (newInfo.navigationMode != oldInfo.navigationMode) {
             change |= CHANGE_NAVIGATION_MODE;
         }
-        if (!newInfo.supportedBounds.equals(oldInfo.supportedBounds)) {
+        if (!newInfo.supportedBounds.equals(oldInfo.supportedBounds)
+                || !newInfo.mPerDisplayBounds.equals(oldInfo.mPerDisplayBounds)) {
             change |= CHANGE_SUPPORTED_BOUNDS;
 
             Point currentS = newInfo.currentSize;
@@ -261,6 +263,9 @@
                 return;
             }
         }
+        Log.d("b/198965093", "handleInfoChange"
+                + "\n\tchange: " + change
+                + "\n\tConfiguration diff: " + newInfo.mConfiguration.diff(oldInfo.mConfiguration));
 
         if (change != 0) {
             mInfo = newInfo;
@@ -300,6 +305,9 @@
         private final ArrayMap<String, Pair<CachedDisplayInfo, WindowBounds[]>> mPerDisplayBounds =
                 new ArrayMap<>();
 
+        // TODO(b/198965093): Remove after investigation
+        private Configuration mConfiguration;
+
         public Info(Context context, Display display) {
             /* don't need system overrides for external displays */
             this(context, display, new WindowManagerProxy(), new ArrayMap<>());
@@ -321,6 +329,9 @@
             mScreenSizeDp = new PortraitSize(config.screenHeightDp, config.screenWidthDp);
             navigationMode = parseNavigationMode(context);
 
+            // TODO(b/198965093): Remove after investigation
+            mConfiguration = config;
+
             mPerDisplayBounds.putAll(perDisplayBoundsCache);
             Pair<CachedDisplayInfo, WindowBounds[]> cachedValue = mPerDisplayBounds.get(displayId);
 
@@ -340,8 +351,11 @@
             }
             mPerDisplayBounds.values().forEach(
                     pair -> Collections.addAll(supportedBounds, pair.second));
-            Log.d("b/211775278", "displayId: " + displayId + ", currentSize: " + currentSize);
-            Log.d("b/211775278", "perDisplayBounds: " + mPerDisplayBounds);
+            Log.e("b/198965093", "mConfiguration: " + mConfiguration);
+            Log.d("b/198965093", "displayInfo: " + displayInfo);
+            Log.d("b/198965093", "realBounds: " + realBounds);
+            mPerDisplayBounds.values().forEach(pair -> Log.d("b/198965093",
+                    "perDisplayBounds - " + pair.first + ": " + Arrays.deepToString(pair.second)));
         }
 
         /**
@@ -375,7 +389,8 @@
         pw.println("  densityDpi=" + info.densityDpi);
         pw.println("  navigationMode=" + info.navigationMode.name());
         pw.println("  currentSize=" + info.currentSize);
-        pw.println("  supportedBounds=" + info.supportedBounds);
+        info.mPerDisplayBounds.values().forEach(pair -> pw.println(
+                "  perDisplayBounds - " + pair.first + ": " + Arrays.deepToString(pair.second)));
     }
 
     /**
diff --git a/src/com/android/launcher3/util/WindowBounds.java b/src/com/android/launcher3/util/WindowBounds.java
index a15679a..91480e1 100644
--- a/src/com/android/launcher3/util/WindowBounds.java
+++ b/src/com/android/launcher3/util/WindowBounds.java
@@ -76,6 +76,7 @@
                 + "bounds=" + bounds
                 + ", insets=" + insets
                 + ", availableSize=" + availableSize
+                + ", rotationHint=" + rotationHint
                 + '}';
     }