Push a potential fix for hotseat aggregation

This could be caused by landscape layout not receiving inset changes

Adding logs for hotseat layout info as well

Bug: 335141365
Flag: EXEMPT bugfix
Test: N/A
Change-Id: I987f8622907a10fac5375ddddac3db2c5eba41c1
diff --git a/src/com/android/launcher3/BaseDraggingActivity.java b/src/com/android/launcher3/BaseDraggingActivity.java
index cf93a79..8585b66 100644
--- a/src/com/android/launcher3/BaseDraggingActivity.java
+++ b/src/com/android/launcher3/BaseDraggingActivity.java
@@ -147,7 +147,8 @@
 
     @Override
     public void onDisplayInfoChanged(Context context, Info info, int flags) {
-        if ((flags & CHANGE_ROTATION) != 0 && mDeviceProfile.updateIsSeascape(this)) {
+        if ((flags & CHANGE_ROTATION) != 0 && mDeviceProfile.isVerticalBarLayout()) {
+            mDeviceProfile.updateIsSeascape(this);
             reapplyUi();
         }
     }
diff --git a/src/com/android/launcher3/Hotseat.java b/src/com/android/launcher3/Hotseat.java
index 37737d8..8546454 100644
--- a/src/com/android/launcher3/Hotseat.java
+++ b/src/com/android/launcher3/Hotseat.java
@@ -82,6 +82,10 @@
         return mHasVerticalHotseat ? (getCountY() - (rank + 1)) : 0;
     }
 
+    boolean isHasVerticalHotseat() {
+        return mHasVerticalHotseat;
+    }
+
     public void resetLayout(boolean hasVerticalHotseat) {
         ActivityContext activityContext = ActivityContext.lookupContext(getContext());
         boolean bubbleBarEnabled = activityContext.isBubbleBarEnabled();
diff --git a/src/com/android/launcher3/ModelCallbacks.kt b/src/com/android/launcher3/ModelCallbacks.kt
index 7d6d154..13062b6 100644
--- a/src/com/android/launcher3/ModelCallbacks.kt
+++ b/src/com/android/launcher3/ModelCallbacks.kt
@@ -3,6 +3,7 @@
 import android.annotation.TargetApi
 import android.os.Build
 import android.os.Trace
+import android.util.Log
 import androidx.annotation.UiThread
 import com.android.launcher3.Flags.enableSmartspaceRemovalToggle
 import com.android.launcher3.LauncherConstants.TraceEvents
@@ -29,6 +30,8 @@
 import com.android.launcher3.widget.model.WidgetsListBaseEntry
 import java.util.function.Predicate
 
+private const val TAG = "ModelCallbacks"
+
 class ModelCallbacks(private var launcher: Launcher) : BgDataModel.Callbacks {
 
     var synchronouslyBoundPages = LIntSet()
@@ -66,6 +69,13 @@
         launcher.workspace.removeAllWorkspaceScreens()
         // Avoid clearing the widget update listeners for staying up-to-date with widget info
         launcher.appWidgetHolder.clearWidgetViews()
+        // TODO(b/335141365): Remove this log after the bug is fixed.
+        Log.d(
+            TAG,
+            "startBinding: " +
+                "hotseat layout was vertical: ${launcher.hotseat?.isHasVerticalHotseat}" +
+                " and is setting to ${launcher.deviceProfile.isVerticalBarLayout}"
+        )
         launcher.hotseat?.resetLayout(launcher.deviceProfile.isVerticalBarLayout)
         TraceHelper.INSTANCE.endSection()
     }
@@ -142,7 +152,10 @@
         launcher.viewCache.setCacheSize(R.layout.folder_page, 2)
         TraceHelper.INSTANCE.endSection()
         launcher.workspace.removeExtraEmptyScreen(/* stripEmptyScreens= */ true)
-        launcher.workspace.pageIndicator.setPauseScroll(/*pause=*/ false, deviceProfile.isTwoPanels)
+        launcher.workspace.pageIndicator.setPauseScroll(
+            /*pause=*/ false,
+            deviceProfile.isTwoPanels
+        )
     }
 
     /**
@@ -290,8 +303,7 @@
         val widgetsListBaseEntry: WidgetsListBaseEntry =
             launcher.popupDataProvider.allWidgets.firstOrNull { item: WidgetsListBaseEntry ->
                 item.mPkgItem.packageName == BuildConfig.APPLICATION_ID
-            }
-                ?: return
+            } ?: return
 
         val info =
             PendingAddWidgetInfo(
@@ -315,16 +327,14 @@
         )
         val firstScreenPosition = 0
         if (
-            (isFirstPagePinnedItemEnabled &&
-                !SHOULD_SHOW_FIRST_PAGE_WIDGET) &&
+            (isFirstPagePinnedItemEnabled && !SHOULD_SHOW_FIRST_PAGE_WIDGET) &&
                 orderedScreenIds.indexOf(FIRST_SCREEN_ID) != firstScreenPosition
         ) {
             orderedScreenIds.removeValue(FIRST_SCREEN_ID)
             orderedScreenIds.add(firstScreenPosition, FIRST_SCREEN_ID)
         } else if (
-            (!isFirstPagePinnedItemEnabled ||
-                    SHOULD_SHOW_FIRST_PAGE_WIDGET)
-            && orderedScreenIds.isEmpty
+            (!isFirstPagePinnedItemEnabled || SHOULD_SHOW_FIRST_PAGE_WIDGET) &&
+                orderedScreenIds.isEmpty
         ) {
             // If there are no screens, we need to have an empty screen
             launcher.workspace.addExtraEmptyScreens()
@@ -380,7 +390,7 @@
         }
         orderedScreenIds
             .filterNot { screenId ->
-                    isFirstPagePinnedItemEnabled &&
+                isFirstPagePinnedItemEnabled &&
                     !SHOULD_SHOW_FIRST_PAGE_WIDGET &&
                     screenId == WorkspaceLayoutManager.FIRST_SCREEN_ID
             }
diff --git a/src/com/android/launcher3/WorkspaceLayoutManager.java b/src/com/android/launcher3/WorkspaceLayoutManager.java
index 4768773..f11a88f 100644
--- a/src/com/android/launcher3/WorkspaceLayoutManager.java
+++ b/src/com/android/launcher3/WorkspaceLayoutManager.java
@@ -58,6 +58,9 @@
             int screenId = presenterPos.screenId;
             x = getHotseat().getCellXFromOrder(screenId);
             y = getHotseat().getCellYFromOrder(screenId);
+            // TODO(b/335141365): Remove this log after the bug is fixed.
+            Log.d(TAG, "addInScreenFromBind: hotseat inflation with x = " + x
+                    + " and y = " + y);
         }
         addInScreen(child, info.container, presenterPos.screenId, x, y, info.spanX, info.spanY);
     }