Merge changes Ie1523446,I0263f704 into main

* changes:
  Do not pre-add All Apps icon in phone mode.
  Fix LayoutTransition All Apps divider logic for RTL.
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarView.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarView.java
index b609511..f2355b8 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarView.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarView.java
@@ -199,7 +199,8 @@
         // TODO: Disable touch events on QSB otherwise it can crash.
         mQsb = LayoutInflater.from(context).inflate(R.layout.search_container_hotseat, this, false);
 
-        mNumStaticViews = taskbarRecentsLayoutTransition() ? addStaticViews() : 0;
+        mNumStaticViews = taskbarRecentsLayoutTransition() && !mActivityContext.isPhoneMode()
+                ? addStaticViews() : 0;
     }
 
     /**
@@ -501,16 +502,20 @@
     }
 
     private void updateAllAppsDivider() {
-        final int allAppsDividerIndex =
-                mIsRtl ? getChildCount() - mNumStaticViews : mNumStaticViews;
-        if (getChildAt(allAppsDividerIndex) == mTaskbarDividerContainer
+        // Index where All Apps divider would be if it is already in Taskbar.
+        final int expectedAllAppsDividerIndex =
+                mIsRtl ? getChildCount() - mNumStaticViews - 1 : mNumStaticViews;
+        if (getChildAt(expectedAllAppsDividerIndex) == mTaskbarDividerContainer
                 && getChildCount() == mNumStaticViews + 1) {
             // Only static views with divider so remove divider.
             removeView(mTaskbarDividerContainer);
-        } else if (getChildAt(allAppsDividerIndex) != mTaskbarDividerContainer
+        } else if (getChildAt(expectedAllAppsDividerIndex) != mTaskbarDividerContainer
                 && getChildCount() >= mNumStaticViews + 1) {
-            // Static views with at least one app icon so add divider.
-            addView(mTaskbarDividerContainer, allAppsDividerIndex);
+            // Static views with at least one app icon so add divider. For RTL, add it after the
+            // icon that is at the expected index.
+            addView(
+                    mTaskbarDividerContainer,
+                    mIsRtl ? expectedAllAppsDividerIndex + 1 : expectedAllAppsDividerIndex);
         }
     }
 
diff --git a/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/TaskbarViewWithLayoutTransitionTest.kt b/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/TaskbarViewWithLayoutTransitionTest.kt
index 15ded8d..78d8e5d 100644
--- a/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/TaskbarViewWithLayoutTransitionTest.kt
+++ b/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/TaskbarViewWithLayoutTransitionTest.kt
@@ -84,7 +84,17 @@
 
     @Test
     @ForceRtl
-    fun testUpdateItems_rtl_addHotseatItem_updatesHotseat() {
+    fun testUpdateItems_rtl_addHotseatItemWithoutRecents_updatesHotseat() {
+        runOnMainSync {
+            taskbarView.updateItems(createHotseatItems(1), emptyList())
+            taskbarView.updateItems(createHotseatItems(2), emptyList())
+        }
+        assertThat(taskbarView).hasIconTypes(*HOTSEAT * 2, DIVIDER, ALL_APPS)
+    }
+
+    @Test
+    @ForceRtl
+    fun testUpdateItems_rtl_addHotseatItemWithRecents_updatesHotseat() {
         runOnMainSync {
             taskbarView.updateItems(createHotseatItems(1), createRecents(1))
             taskbarView.updateItems(createHotseatItems(2), createRecents(1))