Fix NPE of BaseContainerInterface#calculateTaskSizeInternal

Fix: 351861547
Flag: NONE - Bug fix
Test: Presubmit
Change-Id: I984748a6c5487a946a96aa3e2183b5d13a370b6d
diff --git a/quickstep/src/com/android/quickstep/BaseContainerInterface.java b/quickstep/src/com/android/quickstep/BaseContainerInterface.java
index b1d511c..3a8c141 100644
--- a/quickstep/src/com/android/quickstep/BaseContainerInterface.java
+++ b/quickstep/src/com/android/quickstep/BaseContainerInterface.java
@@ -42,6 +42,7 @@
 import com.android.launcher3.statemanager.BaseState;
 import com.android.launcher3.taskbar.TaskbarUIController;
 import com.android.launcher3.util.DisplayController;
+import com.android.launcher3.util.WindowBounds;
 import com.android.launcher3.views.ScrimView;
 import com.android.quickstep.orientation.RecentsPagedOrientationHandler;
 import com.android.quickstep.util.ActivityInitListener;
@@ -51,6 +52,7 @@
 import com.android.systemui.shared.recents.model.ThumbnailData;
 
 import java.util.HashMap;
+import java.util.List;
 import java.util.function.Consumer;
 import java.util.function.Predicate;
 
@@ -269,8 +271,11 @@
         } else {
             Rect portraitInsets = dp.getInsets();
             DisplayController displayController = DisplayController.INSTANCE.get(context);
-            Rect deviceRotationInsets = displayController.getInfo().getCurrentBounds().get(
-                    orientationHandler.getRotation()).insets;
+            @Nullable List<WindowBounds> windowBounds =
+                    displayController.getInfo().getCurrentBounds();
+            Rect deviceRotationInsets = windowBounds != null
+                    ? windowBounds.get(orientationHandler.getRotation()).insets
+                    : new Rect();
             // Obtain the landscape/seascape insets, and rotate it to portrait perspective.
             orientationHandler.rotateInsets(deviceRotationInsets, outRect);
             // Then combine with portrait's insets to leave space for status bar/nav bar in
diff --git a/src/com/android/launcher3/util/DisplayController.java b/src/com/android/launcher3/util/DisplayController.java
index 3dcc663..f65f46a 100644
--- a/src/com/android/launcher3/util/DisplayController.java
+++ b/src/com/android/launcher3/util/DisplayController.java
@@ -49,6 +49,7 @@
 import android.view.Display;
 
 import androidx.annotation.AnyThread;
+import androidx.annotation.Nullable;
 import androidx.annotation.UiThread;
 import androidx.annotation.VisibleForTesting;
 
@@ -513,9 +514,8 @@
             return Collections.unmodifiableSet(mPerDisplayBounds.keySet());
         }
 
-        /**
-         * Returns all {@link WindowBounds}s for the current display.
-         */
+        /** Returns all {@link WindowBounds}s for the current display. */
+        @Nullable
         public List<WindowBounds> getCurrentBounds() {
             return mPerDisplayBounds.get(normalizedDisplayInfo);
         }