Merge "Moving away from obsolete Display#getRealSize()." into tm-dev
diff --git a/quickstep/res/layout/activity_allset.xml b/quickstep/res/layout/activity_allset.xml
index 06dfa37..0cae733 100644
--- a/quickstep/res/layout/activity_allset.xml
+++ b/quickstep/res/layout/activity_allset.xml
@@ -72,12 +72,11 @@
             <TextView
                 android:id="@+id/subtitle"
                 style="@style/TextAppearance.GestureTutorial.Feedback.Subtitle.AllSet"
-                android:layout_width="0dp"
+                android:layout_width="match_parent"
                 android:layout_height="wrap_content"
                 android:layout_marginTop="@dimen/allset_subtitle_margin_top"
                 app:layout_constraintTop_toBottomOf="@id/title"
                 app:layout_constraintStart_toStartOf="parent"
-                app:layout_constraintWidth_max="@dimen/allset_subtitle_width_max"
                 android:gravity="start"/>
 
             <androidx.constraintlayout.widget.Guideline
diff --git a/quickstep/res/values/colors.xml b/quickstep/res/values/colors.xml
index 8f439a2..185c815 100644
--- a/quickstep/res/values/colors.xml
+++ b/quickstep/res/values/colors.xml
@@ -24,7 +24,6 @@
     <color name="all_apps_prediction_row_separator_dark">#3cffffff</color>
 
     <!-- Taskbar -->
-    <color name="taskbar_background">@color/overview_scrim_dark</color>
     <color name="taskbar_nav_icon_selection_ripple">#E0E0E0</color>
     <color name="taskbar_nav_icon_light_color">#ffffff</color>
     <!-- The dark navigation button color is only used in the rare cases that taskbar isn't drawing
diff --git a/quickstep/src/com/android/quickstep/interaction/AssistantGestureTutorialFragment.java b/quickstep/src/com/android/quickstep/interaction/AssistantGestureTutorialFragment.java
index b3f2354..f440638 100644
--- a/quickstep/src/com/android/quickstep/interaction/AssistantGestureTutorialFragment.java
+++ b/quickstep/src/com/android/quickstep/interaction/AssistantGestureTutorialFragment.java
@@ -15,20 +15,18 @@
  */
 package com.android.quickstep.interaction;
 
-import android.content.SharedPreferences;
 import android.view.MotionEvent;
 import android.view.View;
 
+import androidx.annotation.NonNull;
+
 import com.android.launcher3.logging.StatsLogManager;
 import com.android.quickstep.interaction.TutorialController.TutorialType;
 
 /** Shows the Home gesture interactive tutorial. */
 public class AssistantGestureTutorialFragment extends TutorialFragment {
 
-    protected AssistantGestureTutorialFragment(
-            SharedPreferences sharedPrefs, StatsLogManager statsLogManager) {
-        super(sharedPrefs, statsLogManager);
-    }
+    public AssistantGestureTutorialFragment() {}
 
     @Override
     TutorialController createController(TutorialType type) {
@@ -49,12 +47,12 @@
     }
 
     @Override
-    void logTutorialStepShown() {
+    void logTutorialStepShown(@NonNull StatsLogManager statsLogManager) {
         // No-Op: tutorial step not currently shown to users
     }
 
     @Override
-    void logTutorialStepCompleted() {
+    void logTutorialStepCompleted(@NonNull StatsLogManager statsLogManager) {
         // No-Op: tutorial step not currently shown to users
     }
 }
diff --git a/quickstep/src/com/android/quickstep/interaction/BackGestureTutorialFragment.java b/quickstep/src/com/android/quickstep/interaction/BackGestureTutorialFragment.java
index e7ed0b4..37253e2 100644
--- a/quickstep/src/com/android/quickstep/interaction/BackGestureTutorialFragment.java
+++ b/quickstep/src/com/android/quickstep/interaction/BackGestureTutorialFragment.java
@@ -19,10 +19,10 @@
 import android.animation.AnimatorListenerAdapter;
 import android.animation.AnimatorSet;
 import android.animation.ObjectAnimator;
-import android.content.SharedPreferences;
 import android.view.MotionEvent;
 import android.view.View;
 
+import androidx.annotation.NonNull;
 import androidx.annotation.Nullable;
 
 import com.android.launcher3.R;
@@ -34,10 +34,7 @@
 /** Shows the Back gesture interactive tutorial. */
 public class BackGestureTutorialFragment extends TutorialFragment {
 
-    protected BackGestureTutorialFragment(
-            SharedPreferences sharedPrefs, StatsLogManager statsLogManager) {
-        super(sharedPrefs, statsLogManager);
-    }
+    public BackGestureTutorialFragment() {}
 
     @Nullable
     @Override
@@ -126,14 +123,14 @@
     }
 
     @Override
-    void logTutorialStepShown() {
-        mStatsLogManager.logger().log(
+    void logTutorialStepShown(@NonNull StatsLogManager statsLogManager) {
+        statsLogManager.logger().log(
                 StatsLogManager.LauncherEvent.LAUNCHER_GESTURE_TUTORIAL_BACK_STEP_SHOWN);
     }
 
     @Override
-    void logTutorialStepCompleted() {
-        mStatsLogManager.logger().log(
+    void logTutorialStepCompleted(@NonNull StatsLogManager statsLogManager) {
+        statsLogManager.logger().log(
                 StatsLogManager.LauncherEvent.LAUNCHER_GESTURE_TUTORIAL_BACK_STEP_COMPLETED);
     }
 }
diff --git a/quickstep/src/com/android/quickstep/interaction/GestureSandboxActivity.java b/quickstep/src/com/android/quickstep/interaction/GestureSandboxActivity.java
index 002e8b7..7daac81 100644
--- a/quickstep/src/com/android/quickstep/interaction/GestureSandboxActivity.java
+++ b/quickstep/src/com/android/quickstep/interaction/GestureSandboxActivity.java
@@ -65,10 +65,7 @@
         mTutorialSteps = getTutorialSteps(args);
         mCurrentTutorialStep = mTutorialSteps[mCurrentStep - 1];
         mFragment = TutorialFragment.newInstance(
-                mCurrentTutorialStep,
-                args.getBoolean(KEY_GESTURE_COMPLETE, false),
-                mSharedPrefs,
-                mStatsLogManager);
+                mCurrentTutorialStep, args.getBoolean(KEY_GESTURE_COMPLETE, false));
         getSupportFragmentManager().beginTransaction()
                 .add(R.id.gesture_tutorial_fragment_container, mFragment)
                 .commit();
@@ -103,6 +100,14 @@
         super.onSaveInstanceState(savedInstanceState);
     }
 
+    protected SharedPreferences getSharedPrefs() {
+        return mSharedPrefs;
+    }
+
+    protected StatsLogManager getStatsLogManager() {
+        return mStatsLogManager;
+    }
+
     /** Returns true iff there aren't anymore tutorial types to display to the user. */
     public boolean isTutorialComplete() {
         return mCurrentStep >= mNumSteps;
@@ -128,7 +133,7 @@
         }
         mCurrentTutorialStep = mTutorialSteps[mCurrentStep];
         mFragment = TutorialFragment.newInstance(
-                mCurrentTutorialStep, /* gestureComplete= */ false, mSharedPrefs, mStatsLogManager);
+                mCurrentTutorialStep, /* gestureComplete= */ false);
         getSupportFragmentManager().beginTransaction()
                 .replace(R.id.gesture_tutorial_fragment_container, mFragment)
                 .runOnCommit(() -> mFragment.onAttachedToWindow())
diff --git a/quickstep/src/com/android/quickstep/interaction/HomeGestureTutorialFragment.java b/quickstep/src/com/android/quickstep/interaction/HomeGestureTutorialFragment.java
index e987d5a..95eafda 100644
--- a/quickstep/src/com/android/quickstep/interaction/HomeGestureTutorialFragment.java
+++ b/quickstep/src/com/android/quickstep/interaction/HomeGestureTutorialFragment.java
@@ -18,10 +18,10 @@
 import android.animation.Animator;
 import android.animation.AnimatorListenerAdapter;
 import android.animation.AnimatorSet;
-import android.content.SharedPreferences;
 import android.view.MotionEvent;
 import android.view.View;
 
+import androidx.annotation.NonNull;
 import androidx.annotation.Nullable;
 
 import com.android.launcher3.R;
@@ -33,10 +33,7 @@
 /** Shows the Home gesture interactive tutorial. */
 public class HomeGestureTutorialFragment extends TutorialFragment {
 
-    protected HomeGestureTutorialFragment(
-            SharedPreferences sharedPrefs, StatsLogManager statsLogManager) {
-        super(sharedPrefs, statsLogManager);
-    }
+    public HomeGestureTutorialFragment() {}
 
     @Nullable
     @Override
@@ -108,14 +105,14 @@
     }
 
     @Override
-    void logTutorialStepShown() {
-        mStatsLogManager.logger().log(
+    void logTutorialStepShown(@NonNull StatsLogManager statsLogManager) {
+        statsLogManager.logger().log(
                 StatsLogManager.LauncherEvent.LAUNCHER_GESTURE_TUTORIAL_HOME_STEP_SHOWN);
     }
 
     @Override
-    void logTutorialStepCompleted() {
-        mStatsLogManager.logger().log(
+    void logTutorialStepCompleted(@NonNull StatsLogManager statsLogManager) {
+        statsLogManager.logger().log(
                 StatsLogManager.LauncherEvent.LAUNCHER_GESTURE_TUTORIAL_HOME_STEP_COMPLETED);
     }
 }
diff --git a/quickstep/src/com/android/quickstep/interaction/OverviewGestureTutorialFragment.java b/quickstep/src/com/android/quickstep/interaction/OverviewGestureTutorialFragment.java
index c7e24db..4e1521f 100644
--- a/quickstep/src/com/android/quickstep/interaction/OverviewGestureTutorialFragment.java
+++ b/quickstep/src/com/android/quickstep/interaction/OverviewGestureTutorialFragment.java
@@ -18,10 +18,10 @@
 import android.animation.Animator;
 import android.animation.AnimatorListenerAdapter;
 import android.animation.AnimatorSet;
-import android.content.SharedPreferences;
 import android.view.MotionEvent;
 import android.view.View;
 
+import androidx.annotation.NonNull;
 import androidx.annotation.Nullable;
 
 import com.android.launcher3.R;
@@ -33,10 +33,7 @@
 /** Shows the Overview gesture interactive tutorial. */
 public class OverviewGestureTutorialFragment extends TutorialFragment {
 
-    protected OverviewGestureTutorialFragment(
-            SharedPreferences sharedPrefs, StatsLogManager statsLogManager) {
-        super(sharedPrefs, statsLogManager);
-    }
+    public OverviewGestureTutorialFragment() {}
 
     @Nullable
     @Override
@@ -120,14 +117,14 @@
     }
 
     @Override
-    void logTutorialStepShown() {
-        mStatsLogManager.logger().log(
+    void logTutorialStepShown(@NonNull StatsLogManager statsLogManager) {
+        statsLogManager.logger().log(
                 StatsLogManager.LauncherEvent.LAUNCHER_GESTURE_TUTORIAL_OVERVIEW_STEP_SHOWN);
     }
 
     @Override
-    void logTutorialStepCompleted() {
-        mStatsLogManager.logger().log(
+    void logTutorialStepCompleted(@NonNull StatsLogManager statsLogManager) {
+        statsLogManager.logger().log(
                 StatsLogManager.LauncherEvent.LAUNCHER_GESTURE_TUTORIAL_OVERVIEW_STEP_COMPLETED);
     }
 }
diff --git a/quickstep/src/com/android/quickstep/interaction/SandboxModeTutorialFragment.java b/quickstep/src/com/android/quickstep/interaction/SandboxModeTutorialFragment.java
index 92a2731..5183e2c 100644
--- a/quickstep/src/com/android/quickstep/interaction/SandboxModeTutorialFragment.java
+++ b/quickstep/src/com/android/quickstep/interaction/SandboxModeTutorialFragment.java
@@ -15,20 +15,18 @@
  */
 package com.android.quickstep.interaction;
 
-import android.content.SharedPreferences;
 import android.view.MotionEvent;
 import android.view.View;
 
+import androidx.annotation.NonNull;
+
 import com.android.launcher3.logging.StatsLogManager;
 import com.android.quickstep.interaction.TutorialController.TutorialType;
 
 /** Shows the general navigation gesture sandbox environment. */
 public class SandboxModeTutorialFragment extends TutorialFragment {
 
-    protected SandboxModeTutorialFragment(
-            SharedPreferences sharedPrefs, StatsLogManager statsLogManager) {
-        super(sharedPrefs, statsLogManager);
-    }
+    public SandboxModeTutorialFragment() {}
 
     @Override
     TutorialController createController(TutorialType type) {
@@ -49,12 +47,12 @@
     }
 
     @Override
-    void logTutorialStepShown() {
+    void logTutorialStepShown(@NonNull StatsLogManager statsLogManager) {
         // No-Op: tutorial step not currently shown to users
     }
 
     @Override
-    void logTutorialStepCompleted() {
+    void logTutorialStepCompleted(@NonNull StatsLogManager statsLogManager) {
         // No-Op: tutorial step not currently shown to users
     }
 }
diff --git a/quickstep/src/com/android/quickstep/interaction/TutorialFragment.java b/quickstep/src/com/android/quickstep/interaction/TutorialFragment.java
index 7556bf4..33e800d 100644
--- a/quickstep/src/com/android/quickstep/interaction/TutorialFragment.java
+++ b/quickstep/src/com/android/quickstep/interaction/TutorialFragment.java
@@ -60,9 +60,6 @@
     private static final String COMPLETED_TUTORIAL_STEPS_PREFERENCE_KEY =
             "pref_completedTutorialSteps";
 
-    private final SharedPreferences mSharedPrefs;
-    protected final StatsLogManager mStatsLogManager;
-
     TutorialType mTutorialType;
     boolean mGestureComplete = false;
     @Nullable TutorialController mTutorialController = null;
@@ -84,14 +81,10 @@
     private boolean mIsFoldable;
 
     public static TutorialFragment newInstance(
-            TutorialType tutorialType,
-            boolean gestureComplete,
-            SharedPreferences sharedPrefs,
-            StatsLogManager statsLogManager) {
-        TutorialFragment fragment =
-                getFragmentForTutorialType(tutorialType, sharedPrefs, statsLogManager);
+            TutorialType tutorialType, boolean gestureComplete) {
+        TutorialFragment fragment = getFragmentForTutorialType(tutorialType);
         if (fragment == null) {
-            fragment = new BackGestureTutorialFragment(sharedPrefs, statsLogManager);
+            fragment = new BackGestureTutorialFragment();
             tutorialType = TutorialType.BACK_NAVIGATION;
         }
 
@@ -103,36 +96,28 @@
     }
 
     @Nullable
-    private static TutorialFragment getFragmentForTutorialType(
-            TutorialType tutorialType,
-            SharedPreferences sharedPrefs,
-            StatsLogManager statsLogManager) {
+    private static TutorialFragment getFragmentForTutorialType(TutorialType tutorialType) {
         switch (tutorialType) {
             case BACK_NAVIGATION:
             case BACK_NAVIGATION_COMPLETE:
-                return new BackGestureTutorialFragment(sharedPrefs, statsLogManager);
+                return new BackGestureTutorialFragment();
             case HOME_NAVIGATION:
             case HOME_NAVIGATION_COMPLETE:
-                return new HomeGestureTutorialFragment(sharedPrefs, statsLogManager);
+                return new HomeGestureTutorialFragment();
             case OVERVIEW_NAVIGATION:
             case OVERVIEW_NAVIGATION_COMPLETE:
-                return new OverviewGestureTutorialFragment(sharedPrefs, statsLogManager);
+                return new OverviewGestureTutorialFragment();
             case ASSISTANT:
             case ASSISTANT_COMPLETE:
-                return new AssistantGestureTutorialFragment(sharedPrefs, statsLogManager);
+                return new AssistantGestureTutorialFragment();
             case SANDBOX_MODE:
-                return new SandboxModeTutorialFragment(sharedPrefs, statsLogManager);
+                return new SandboxModeTutorialFragment();
             default:
                 Log.e(LOG_TAG, "Failed to find an appropriate fragment for " + tutorialType.name());
         }
         return null;
     }
 
-    protected TutorialFragment(SharedPreferences sharedPrefs, StatsLogManager statsLogManager) {
-        mSharedPrefs = sharedPrefs;
-        mStatsLogManager = statsLogManager;
-    }
-
     @Nullable Integer getEdgeAnimationResId() {
         return null;
     }
@@ -340,7 +325,10 @@
     }
 
     void onAttachedToWindow() {
-        logTutorialStepShown();
+        StatsLogManager statsLogManager = getStatsLogManager();
+        if (statsLogManager != null) {
+            logTutorialStepShown(statsLogManager);
+        }
         mEdgeBackGestureHandler.setViewGroupParent(getRootView());
     }
 
@@ -374,14 +362,20 @@
     }
 
     void continueTutorial() {
-        Set<String> updatedCompletedSteps = new ArraySet<>(mSharedPrefs.getStringSet(
-                COMPLETED_TUTORIAL_STEPS_PREFERENCE_KEY, new ArraySet<>()));
+        SharedPreferences sharedPrefs = getSharedPreferences();
+        if (sharedPrefs != null) {
+            Set<String> updatedCompletedSteps = new ArraySet<>(sharedPrefs.getStringSet(
+                    COMPLETED_TUTORIAL_STEPS_PREFERENCE_KEY, new ArraySet<>()));
 
-        updatedCompletedSteps.add(mTutorialType.toString());
+            updatedCompletedSteps.add(mTutorialType.toString());
 
-        mSharedPrefs.edit().putStringSet(
-                COMPLETED_TUTORIAL_STEPS_PREFERENCE_KEY, updatedCompletedSteps).apply();
-        logTutorialStepCompleted();
+            sharedPrefs.edit().putStringSet(
+                    COMPLETED_TUTORIAL_STEPS_PREFERENCE_KEY, updatedCompletedSteps).apply();
+        }
+        StatsLogManager statsLogManager = getStatsLogManager();
+        if (statsLogManager != null) {
+            logTutorialStepCompleted(statsLogManager);
+        }
 
         GestureSandboxActivity gestureSandboxActivity = getGestureSandboxActivity();
         if (gestureSandboxActivity == null) {
@@ -397,9 +391,15 @@
 
     void closeTutorial(boolean tutorialSkipped) {
         if (tutorialSkipped) {
-            mSharedPrefs.edit().putBoolean(TUTORIAL_SKIPPED_PREFERENCE_KEY, true).apply();
-            mStatsLogManager.logger().log(
-                    StatsLogManager.LauncherEvent.LAUNCHER_GESTURE_TUTORIAL_SKIPPED);
+            SharedPreferences sharedPrefs = getSharedPreferences();
+            if (sharedPrefs != null) {
+                sharedPrefs.edit().putBoolean(TUTORIAL_SKIPPED_PREFERENCE_KEY, true).apply();
+            }
+            StatsLogManager statsLogManager = getStatsLogManager();
+            if (statsLogManager != null) {
+                statsLogManager.logger().log(
+                        StatsLogManager.LauncherEvent.LAUNCHER_GESTURE_TUTORIAL_SKIPPED);
+            }
         }
         FragmentActivity activity = getActivity();
         if (activity != null) {
@@ -433,9 +433,9 @@
                 || (mTutorialController != null && mTutorialController.isGestureCompleted());
     }
 
-    abstract void logTutorialStepShown();
+    abstract void logTutorialStepShown(@NonNull StatsLogManager statsLogManager);
 
-    abstract void logTutorialStepCompleted();
+    abstract void logTutorialStepCompleted(@NonNull StatsLogManager statsLogManager);
 
     @Nullable
     private GestureSandboxActivity getGestureSandboxActivity() {
@@ -443,4 +443,18 @@
 
         return context instanceof GestureSandboxActivity ? (GestureSandboxActivity) context : null;
     }
+
+    @Nullable
+    private StatsLogManager getStatsLogManager() {
+        GestureSandboxActivity activity = getGestureSandboxActivity();
+
+        return activity != null ? activity.getStatsLogManager() : null;
+    }
+
+    @Nullable
+    private SharedPreferences getSharedPreferences() {
+        GestureSandboxActivity activity = getGestureSandboxActivity();
+
+        return activity != null ? activity.getSharedPrefs() : null;
+    }
 }
diff --git a/quickstep/src/com/android/quickstep/views/GroupedTaskView.java b/quickstep/src/com/android/quickstep/views/GroupedTaskView.java
index b9615ab..955fffc 100644
--- a/quickstep/src/com/android/quickstep/views/GroupedTaskView.java
+++ b/quickstep/src/com/android/quickstep/views/GroupedTaskView.java
@@ -237,7 +237,7 @@
         }
         getPagedOrientationHandler().measureGroupedTaskViewThumbnailBounds(mSnapshotView,
                 mSnapshotView2, widthSize, heightSize, mSplitBoundsConfig,
-                mActivity.getDeviceProfile());
+                mActivity.getDeviceProfile(), getLayoutDirection() == LAYOUT_DIRECTION_RTL);
         updateIconPlacement();
     }
 
diff --git a/quickstep/tests/src/com/android/quickstep/OrientationTouchTransformerTest.java b/quickstep/tests/src/com/android/quickstep/OrientationTouchTransformerTest.java
index 6b3f699..9e5d958 100644
--- a/quickstep/tests/src/com/android/quickstep/OrientationTouchTransformerTest.java
+++ b/quickstep/tests/src/com/android/quickstep/OrientationTouchTransformerTest.java
@@ -17,8 +17,6 @@
 
 package com.android.quickstep;
 
-import static android.view.Display.DEFAULT_DISPLAY;
-
 import static androidx.test.core.app.ApplicationProvider.getApplicationContext;
 
 import static com.android.launcher3.util.DisplayController.NavigationMode.NO_BUTTON;
@@ -27,17 +25,16 @@
 import static org.junit.Assert.assertTrue;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.ArgumentMatchers.anyInt;
-import static org.mockito.Mockito.doAnswer;
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.spy;
 import static org.mockito.Mockito.when;
 
-import android.content.Context;
 import android.content.res.Resources;
 import android.graphics.Point;
-import android.hardware.display.DisplayManager;
+import android.graphics.Rect;
+import android.util.ArrayMap;
 import android.util.DisplayMetrics;
+import android.util.Size;
 import android.view.Display;
 import android.view.MotionEvent;
 import android.view.Surface;
@@ -47,6 +44,10 @@
 
 import com.android.launcher3.ResourceUtils;
 import com.android.launcher3.util.DisplayController;
+import com.android.launcher3.util.RotationUtils;
+import com.android.launcher3.util.WindowBounds;
+import com.android.launcher3.util.window.CachedDisplayInfo;
+import com.android.launcher3.util.window.WindowManagerProxy;
 
 import org.junit.Before;
 import org.junit.Test;
@@ -56,18 +57,9 @@
 @SmallTest
 @RunWith(AndroidJUnit4.class)
 public class OrientationTouchTransformerTest {
-    static class ScreenSize {
-        int mHeight;
-        int mWidth;
 
-        ScreenSize(int height, int width) {
-            mHeight = height;
-            mWidth = width;
-        }
-    }
-
-    private static final ScreenSize NORMAL_SCREEN_SIZE = new ScreenSize(2280, 1080);
-    private static final ScreenSize LARGE_SCREEN_SIZE = new ScreenSize(3280, 1080);
+    private static final Size NORMAL_SCREEN_SIZE = new Size(1080, 2280);
+    private static final Size LARGE_SCREEN_SIZE = new Size(1080, 3280);
     private static final float DENSITY_DISPLAY_METRICS = 3.0f;
 
     private OrientationTouchTransformer mTouchTransformer;
@@ -75,7 +67,6 @@
     Resources mResources;
     private DisplayController.Info mInfo;
 
-
     @Before
     public void setup() {
         MockitoAnnotations.initMocks(this);
@@ -296,33 +287,24 @@
         assertTrue(mTouchTransformer.touchInValidSwipeRegions(inRegion2.getX(), inRegion2.getY()));
     }
 
-    private DisplayController.Info createDisplayInfo(ScreenSize screenSize, int rotation) {
-        Context context = getApplicationContext();
-        Display display = spy(context.getSystemService(DisplayManager.class)
-                .getDisplay(DEFAULT_DISPLAY));
-
-        Point p = new Point(screenSize.mWidth, screenSize.mHeight);
-        if (rotation == Surface.ROTATION_90 || rotation == Surface.ROTATION_270) {
-            p.set(screenSize.mHeight, screenSize.mWidth);
-        }
-
-        doReturn(rotation).when(display).getRotation();
-        doAnswer(i -> {
-            ((Point) i.getArgument(0)).set(p.x, p.y);
-            return null;
-        }).when(display).getRealSize(any(Point.class));
-        doAnswer(i -> {
-            ((Point) i.getArgument(0)).set(p.x, p.y);
-            ((Point) i.getArgument(1)).set(p.x, p.y);
-            return null;
-        }).when(display).getCurrentSizeRange(any(Point.class), any(Point.class));
-        return new DisplayController.Info(context, display);
+    private DisplayController.Info createDisplayInfo(Size screenSize, int rotation) {
+        Point displaySize = new Point(screenSize.getWidth(), screenSize.getHeight());
+        RotationUtils.rotateSize(displaySize, rotation);
+        CachedDisplayInfo cdi = new CachedDisplayInfo(displaySize, rotation);
+        WindowBounds wm = new WindowBounds(
+                new Rect(0, 0, displaySize.x, displaySize.y),
+                new Rect());
+        WindowManagerProxy wmProxy = mock(WindowManagerProxy.class);
+        doReturn(cdi).when(wmProxy).getDisplayInfo(any(), any());
+        doReturn(wm).when(wmProxy).getRealBounds(any(), any(), any());
+        return new DisplayController.Info(
+                getApplicationContext(), mock(Display.class), wmProxy, new ArrayMap<>());
     }
 
-    private float generateTouchRegionHeight(ScreenSize screenSize, int rotation) {
-        float height = screenSize.mHeight;
+    private float generateTouchRegionHeight(Size screenSize, int rotation) {
+        float height = screenSize.getHeight();
         if (rotation == Surface.ROTATION_90 || rotation == Surface.ROTATION_270) {
-            height = screenSize.mWidth;
+            height = screenSize.getWidth();
         }
         return height - ResourceUtils.DEFAULT_NAVBAR_VALUE * DENSITY_DISPLAY_METRICS;
     }
diff --git a/quickstep/tests/src/com/android/quickstep/util/TaskViewSimulatorTest.java b/quickstep/tests/src/com/android/quickstep/util/TaskViewSimulatorTest.java
index c6cdafc..7d414f4 100644
--- a/quickstep/tests/src/com/android/quickstep/util/TaskViewSimulatorTest.java
+++ b/quickstep/tests/src/com/android/quickstep/util/TaskViewSimulatorTest.java
@@ -164,7 +164,7 @@
                 }
 
                 WindowManagerProxy wmProxy = mock(WindowManagerProxy.class);
-                doReturn(cdi).when(wmProxy).getDisplayInfo(any());
+                doReturn(cdi).when(wmProxy).getDisplayInfo(any(), any());
                 doReturn(wm).when(wmProxy).getRealBounds(any(), any(), any());
 
                 ArrayMap<String, Pair<CachedDisplayInfo, WindowBounds[]>> perDisplayBoundsCache =
diff --git a/res/color-v31/overview_scrim.xml b/res/color-v31/overview_scrim.xml
index 8079995..212518f 100644
--- a/res/color-v31/overview_scrim.xml
+++ b/res/color-v31/overview_scrim.xml
@@ -14,5 +14,5 @@
      limitations under the License.
 -->
 <selector xmlns:android="http://schemas.android.com/apk/res/android">
-  <item android:color="@android:color/system_neutral2_500" android:lStar="87" />
+  <item android:color="@android:color/system_neutral2_200" />
 </selector>
diff --git a/res/color-v31/overview_scrim_dark.xml b/res/color-v31/overview_scrim_dark.xml
index 487b9f8..2ab8ecd 100644
--- a/res/color-v31/overview_scrim_dark.xml
+++ b/res/color-v31/overview_scrim_dark.xml
@@ -14,5 +14,5 @@
      limitations under the License.
 -->
 <selector xmlns:android="http://schemas.android.com/apk/res/android">
-  <item android:color="@android:color/system_neutral1_500" android:lStar="15" />
+  <item android:color="@android:color/system_neutral1_500" android:lStar="35" />
 </selector>
diff --git a/res/color-v31/taskbar_background.xml b/res/color-v31/taskbar_background.xml
new file mode 100644
index 0000000..eaf676f
--- /dev/null
+++ b/res/color-v31/taskbar_background.xml
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2022 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+  <item android:color="@android:color/system_neutral1_500" android:lStar="15" />
+</selector>
diff --git a/res/values/attrs.xml b/res/values/attrs.xml
index 187689f..dd3e08b 100644
--- a/res/values/attrs.xml
+++ b/res/values/attrs.xml
@@ -342,6 +342,18 @@
         <attr name="horizontalMarginTwoPanelLandscape" format="float"/>
         <!-- defaults to horizontalMargin if not specified -->
         <attr name="horizontalMarginTwoPanelPortrait" format="float"/>
+
+        <!-- By default all are false -->
+        <attr name="inlineQsb" format="integer" >
+            <!-- Enable on landscape only -->
+            <flag name="portrait" value="1" />
+            <!-- Enable on portrait only -->
+            <flag name="landscape" value="2" />
+            <!-- Enable on two panel portrait only -->
+            <flag name="twoPanelPortrait" value="4" />
+            <!-- Enable on two panel landscape only -->
+            <flag name="twoPanelLandscape" value="8" />
+        </attr>
     </declare-styleable>
 
     <declare-styleable name="CellLayout">
diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java
index 7e7e078..500244c 100644
--- a/src/com/android/launcher3/DeviceProfile.java
+++ b/src/com/android/launcher3/DeviceProfile.java
@@ -16,6 +16,10 @@
 
 package com.android.launcher3;
 
+import static com.android.launcher3.InvariantDeviceProfile.INDEX_DEFAULT;
+import static com.android.launcher3.InvariantDeviceProfile.INDEX_LANDSCAPE;
+import static com.android.launcher3.InvariantDeviceProfile.INDEX_TWO_PANEL_LANDSCAPE;
+import static com.android.launcher3.InvariantDeviceProfile.INDEX_TWO_PANEL_PORTRAIT;
 import static com.android.launcher3.ResourceUtils.pxFromDp;
 import static com.android.launcher3.Utilities.dpiFromPx;
 import static com.android.launcher3.Utilities.pxFromSp;
@@ -58,7 +62,6 @@
 
     // Device properties
     public final boolean isTablet;
-    public final boolean isLargeTablet;
     public final boolean isPhone;
     public final boolean transposeLayoutWithOrientation;
     public final boolean isTwoPanels;
@@ -253,7 +256,6 @@
         // Determine device posture.
         mInfo = info;
         isTablet = info.isTablet(windowBounds);
-        isLargeTablet = info.isLargeTablet(windowBounds);
         isPhone = !isTablet;
         isTwoPanels = isTablet && useTwoPanels;
         isTaskbarPresent = isTablet && ApiWrapper.TASKBAR_DRAWN_IN_PROCESS;
@@ -278,15 +280,15 @@
 
         if (isTwoPanels) {
             if (isLandscape) {
-                mTypeIndex = InvariantDeviceProfile.INDEX_TWO_PANEL_LANDSCAPE;
+                mTypeIndex = INDEX_TWO_PANEL_LANDSCAPE;
             } else {
-                mTypeIndex = InvariantDeviceProfile.INDEX_TWO_PANEL_PORTRAIT;
+                mTypeIndex = INDEX_TWO_PANEL_PORTRAIT;
             }
         } else {
             if (isLandscape) {
-                mTypeIndex = InvariantDeviceProfile.INDEX_LANDSCAPE;
+                mTypeIndex = INDEX_LANDSCAPE;
             } else {
-                mTypeIndex = InvariantDeviceProfile.INDEX_DEFAULT;
+                mTypeIndex = INDEX_DEFAULT;
             }
         }
 
@@ -348,9 +350,12 @@
         workspaceCellPaddingXPx = res.getDimensionPixelSize(R.dimen.dynamic_grid_cell_padding_x);
 
         hotseatQsbHeight = res.getDimensionPixelSize(R.dimen.qsb_widget_height);
-        // Whether QSB might be inline in appropriate orientation (landscape).
-        boolean canQsbInline = isLargeTablet && hotseatQsbHeight > 0;
-        isQsbInline = canQsbInline && isLandscape;
+        // Whether QSB might be inline in appropriate orientation (e.g. landscape).
+        boolean canQsbInline = (isTwoPanels ? inv.inlineQsb[INDEX_TWO_PANEL_PORTRAIT]
+                || inv.inlineQsb[INDEX_TWO_PANEL_LANDSCAPE]
+                : inv.inlineQsb[INDEX_DEFAULT] || inv.inlineQsb[INDEX_LANDSCAPE])
+                && hotseatQsbHeight > 0;
+        isQsbInline = inv.inlineQsb[mTypeIndex] && canQsbInline;
 
         // We shrink hotseat sizes regardless of orientation, if nav buttons are inline and QSB
         // might be inline in either orientations, to keep hotseat size consistent across rotation.
@@ -388,7 +393,7 @@
                 res.getDimensionPixelSize(R.dimen.dynamic_grid_hotseat_extra_vertical_size);
         hotseatBorderSpace = pxFromDp(inv.hotseatBorderSpaces[mTypeIndex], mMetrics);
         updateHotseatIconSize(
-                pxFromDp(inv.iconSize[InvariantDeviceProfile.INDEX_DEFAULT], mMetrics));
+                pxFromDp(inv.iconSize[INDEX_DEFAULT], mMetrics));
 
         qsbBottomMarginOriginalPx = isScalableGrid
                 ? res.getDimensionPixelSize(R.dimen.scalable_grid_qsb_bottom_margin)
@@ -819,11 +824,11 @@
 
     private void updateFolderCellSize(float scale, Resources res) {
         float invIconSizeDp = isVerticalBarLayout()
-                ? inv.iconSize[InvariantDeviceProfile.INDEX_LANDSCAPE]
-                : inv.iconSize[InvariantDeviceProfile.INDEX_DEFAULT];
+                ? inv.iconSize[INDEX_LANDSCAPE]
+                : inv.iconSize[INDEX_DEFAULT];
         folderChildIconSizePx = Math.max(1, pxFromDp(invIconSizeDp, mMetrics, scale));
         folderChildTextSizePx =
-                pxFromSp(inv.iconTextSize[InvariantDeviceProfile.INDEX_DEFAULT], mMetrics, scale);
+                pxFromSp(inv.iconTextSize[INDEX_DEFAULT], mMetrics, scale);
         folderLabelTextSizePx = (int) (folderChildTextSizePx * folderLabelTextScale);
 
         int textHeight = Utilities.calculateTextHeight(folderChildTextSizePx);
@@ -1174,7 +1179,6 @@
         writer.println(prefix + "\t1 dp = " + mMetrics.density + " px");
 
         writer.println(prefix + "\tisTablet:" + isTablet);
-        writer.println(prefix + "\tisLargeTablet:" + isLargeTablet);
         writer.println(prefix + "\tisPhone:" + isPhone);
         writer.println(prefix + "\ttransposeLayoutWithOrientation:"
                 + transposeLayoutWithOrientation);
diff --git a/src/com/android/launcher3/InvariantDeviceProfile.java b/src/com/android/launcher3/InvariantDeviceProfile.java
index 59ef283..36c1797 100644
--- a/src/com/android/launcher3/InvariantDeviceProfile.java
+++ b/src/com/android/launcher3/InvariantDeviceProfile.java
@@ -167,6 +167,7 @@
     public String dbFile;
     public int defaultLayoutId;
     int demoModeLayoutId;
+    boolean[] inlineQsb = new boolean[COUNT_SIZES];
 
     /**
      * An immutable list of supported profiles.
@@ -250,6 +251,8 @@
                 COUNT_SIZES);
         System.arraycopy(defaultDisplayOption.borderSpaces, 0, result.borderSpaces, 0,
                 COUNT_SIZES);
+        System.arraycopy(defaultDisplayOption.inlineQsb, 0, result.inlineQsb, 0,
+                COUNT_SIZES);
 
         initGrid(context, myInfo, result, deviceType);
     }
@@ -371,6 +374,8 @@
             devicePaddings = new DevicePaddings(context, devicePaddingId);
         }
 
+        inlineQsb = displayOption.inlineQsb;
+
         // If the partner customization apk contains any grid overrides, apply them
         // Supported overrides: numRows, numColumns, iconSize
         applyPartnerDeviceProfileOverrides(context, metrics);
@@ -783,12 +788,18 @@
 
     @VisibleForTesting
     static final class DisplayOption {
+        private static final int INLINE_QSB_FOR_PORTRAIT = 1 << 0;
+        private static final int INLINE_QSB_FOR_LANDSCAPE = 1 << 1;
+        private static final int INLINE_QSB_FOR_TWO_PANEL_PORTRAIT = 1 << 2;
+        private static final int INLINE_QSB_FOR_TWO_PANEL_LANDSCAPE = 1 << 3;
+        private static final int DONT_INLINE_QSB = 0;
 
         public final GridOption grid;
 
         private final float minWidthDps;
         private final float minHeightDps;
         private final boolean canBeDefault;
+        private final boolean[] inlineQsb = new boolean[COUNT_SIZES];
 
         private final PointF[] minCellSize = new PointF[COUNT_SIZES];
 
@@ -815,6 +826,19 @@
 
             canBeDefault = a.getBoolean(R.styleable.ProfileDisplayOption_canBeDefault, false);
 
+            int inlineForRotation = a.getInt(R.styleable.ProfileDisplayOption_inlineQsb,
+                    DONT_INLINE_QSB);
+            inlineQsb[INDEX_DEFAULT] =
+                    (inlineForRotation & INLINE_QSB_FOR_PORTRAIT) == INLINE_QSB_FOR_PORTRAIT;
+            inlineQsb[INDEX_LANDSCAPE] =
+                    (inlineForRotation & INLINE_QSB_FOR_LANDSCAPE) == INLINE_QSB_FOR_LANDSCAPE;
+            inlineQsb[INDEX_TWO_PANEL_PORTRAIT] =
+                    (inlineForRotation & INLINE_QSB_FOR_TWO_PANEL_PORTRAIT)
+                            == INLINE_QSB_FOR_TWO_PANEL_PORTRAIT;
+            inlineQsb[INDEX_TWO_PANEL_LANDSCAPE] =
+                    (inlineForRotation & INLINE_QSB_FOR_TWO_PANEL_LANDSCAPE)
+                            == INLINE_QSB_FOR_TWO_PANEL_LANDSCAPE;
+
             float x;
             float y;
 
@@ -1029,6 +1053,7 @@
                 allAppsIconSizes[i] = 0;
                 allAppsIconTextSizes[i] = 0;
                 allAppsBorderSpaces[i] = new PointF();
+                inlineQsb[i] = false;
             }
         }
 
@@ -1071,6 +1096,7 @@
                 allAppsIconTextSizes[i] += p.allAppsIconTextSizes[i];
                 allAppsBorderSpaces[i].x += p.allAppsBorderSpaces[i].x;
                 allAppsBorderSpaces[i].y += p.allAppsBorderSpaces[i].y;
+                inlineQsb[i] |= p.inlineQsb[i];
             }
 
             folderBorderSpace += p.folderBorderSpace;
diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java
index a7fc2f5..6ec789a 100644
--- a/src/com/android/launcher3/Workspace.java
+++ b/src/com/android/launcher3/Workspace.java
@@ -113,6 +113,7 @@
 import com.android.launcher3.widget.LauncherAppWidgetHost;
 import com.android.launcher3.widget.LauncherAppWidgetHost.ProviderChangedListener;
 import com.android.launcher3.widget.LauncherAppWidgetHostView;
+import com.android.launcher3.widget.NavigableAppWidgetHostView;
 import com.android.launcher3.widget.PendingAddShortcutInfo;
 import com.android.launcher3.widget.PendingAddWidgetInfo;
 import com.android.launcher3.widget.PendingAppWidgetHostView;
@@ -2831,7 +2832,8 @@
     }
 
     private void getFinalPositionForDropAnimation(int[] loc, float[] scaleXY,
-            DragView dragView, CellLayout layout, ItemInfo info, int[] targetCell, boolean scale) {
+            DragView dragView, CellLayout layout, ItemInfo info, int[] targetCell, boolean scale,
+            final View finalView) {
         // Now we animate the dragView, (ie. the widget or shortcut preview) into its final
         // location and size on the home screen.
         int spanX = info.spanX;
@@ -2840,6 +2842,14 @@
         Rect r = estimateItemPosition(layout, targetCell[0], targetCell[1], spanX, spanY);
         if (info.itemType == LauncherSettings.Favorites.ITEM_TYPE_APPWIDGET) {
             DeviceProfile profile = mLauncher.getDeviceProfile();
+            if (profile.shouldInsetWidgets() && finalView instanceof NavigableAppWidgetHostView) {
+                Rect widgetPadding = new Rect();
+                ((NavigableAppWidgetHostView) finalView).getWidgetInset(profile, widgetPadding);
+                r.left -= widgetPadding.left;
+                r.right += widgetPadding.right;
+                r.top -= widgetPadding.top;
+                r.bottom += widgetPadding.bottom;
+            }
             Utilities.shrinkRect(r, profile.appWidgetScale.x, profile.appWidgetScale.y);
         }
 
@@ -2886,7 +2896,7 @@
         float scaleXY[] = new float[2];
         boolean scalePreview = !(info instanceof PendingAddShortcutInfo);
         getFinalPositionForDropAnimation(finalPos, scaleXY, dragView, cellLayout, info, mTargetCell,
-                scalePreview);
+                scalePreview, finalView);
 
         Resources res = mLauncher.getResources();
         final int duration = res.getInteger(R.integer.config_dropAnimMaxDuration) - 200;
diff --git a/src/com/android/launcher3/popup/PopupContainerWithArrow.java b/src/com/android/launcher3/popup/PopupContainerWithArrow.java
index 2fa7945..7692bbf 100644
--- a/src/com/android/launcher3/popup/PopupContainerWithArrow.java
+++ b/src/com/android/launcher3/popup/PopupContainerWithArrow.java
@@ -148,7 +148,6 @@
     public OnClickListener getItemClickListener() {
         return (view) -> {
             mActivityContext.getItemOnClickListener().onClick(view);
-            close(true);
         };
     }
 
diff --git a/src/com/android/launcher3/touch/LandscapePagedViewHandler.java b/src/com/android/launcher3/touch/LandscapePagedViewHandler.java
index 88a4d66..cba5be5 100644
--- a/src/com/android/launcher3/touch/LandscapePagedViewHandler.java
+++ b/src/com/android/launcher3/touch/LandscapePagedViewHandler.java
@@ -454,8 +454,8 @@
 
     @Override
     public void measureGroupedTaskViewThumbnailBounds(View primarySnapshot, View secondarySnapshot,
-            int parentWidth, int parentHeight,
-            StagedSplitBounds splitBoundsConfig, DeviceProfile dp) {
+            int parentWidth, int parentHeight, StagedSplitBounds splitBoundsConfig,
+            DeviceProfile dp, boolean isRtl) {
         int spaceAboveSnapshot = dp.overviewTaskThumbnailTopMarginPx;
         int totalThumbnailHeight = parentHeight - spaceAboveSnapshot;
         int dividerBar = splitBoundsConfig.appsStackedVertically
diff --git a/src/com/android/launcher3/touch/PagedOrientationHandler.java b/src/com/android/launcher3/touch/PagedOrientationHandler.java
index 510a728..911f2b0 100644
--- a/src/com/android/launcher3/touch/PagedOrientationHandler.java
+++ b/src/com/android/launcher3/touch/PagedOrientationHandler.java
@@ -158,7 +158,7 @@
 
     void measureGroupedTaskViewThumbnailBounds(View primarySnapshot, View secondarySnapshot,
             int parentWidth, int parentHeight,
-            StagedSplitBounds splitBoundsConfig, DeviceProfile dp);
+            StagedSplitBounds splitBoundsConfig, DeviceProfile dp, boolean isRtl);
 
     // Overview TaskMenuView methods
     void setTaskIconParams(FrameLayout.LayoutParams iconParams,
diff --git a/src/com/android/launcher3/touch/PortraitPagedViewHandler.java b/src/com/android/launcher3/touch/PortraitPagedViewHandler.java
index d88656c..2ca236e 100644
--- a/src/com/android/launcher3/touch/PortraitPagedViewHandler.java
+++ b/src/com/android/launcher3/touch/PortraitPagedViewHandler.java
@@ -571,8 +571,8 @@
 
     @Override
     public void measureGroupedTaskViewThumbnailBounds(View primarySnapshot, View secondarySnapshot,
-            int parentWidth, int parentHeight,
-            StagedSplitBounds splitBoundsConfig, DeviceProfile dp) {
+            int parentWidth, int parentHeight, StagedSplitBounds splitBoundsConfig,
+            DeviceProfile dp, boolean isRtl) {
         int spaceAboveSnapshot = dp.overviewTaskThumbnailTopMarginPx;
         int totalThumbnailHeight = parentHeight - spaceAboveSnapshot;
         int dividerBar = splitBoundsConfig.appsStackedVertically
@@ -591,7 +591,13 @@
             secondarySnapshotHeight = totalThumbnailHeight;
             secondarySnapshotWidth = parentWidth - primarySnapshotWidth - dividerBar;
             int translationX = primarySnapshotWidth + dividerBar;
-            secondarySnapshot.setTranslationX(translationX);
+            if (isRtl) {
+                primarySnapshot.setTranslationX(-translationX);
+                secondarySnapshot.setTranslationX(0);
+            } else {
+                secondarySnapshot.setTranslationX(translationX);
+                primarySnapshot.setTranslationX(0);
+            }
             secondarySnapshot.setTranslationY(spaceAboveSnapshot);
         } else {
             primarySnapshotWidth = parentWidth;
@@ -602,6 +608,7 @@
             int translationY = primarySnapshotHeight + spaceAboveSnapshot + dividerBar;
             secondarySnapshot.setTranslationY(translationY);
             secondarySnapshot.setTranslationX(0);
+            primarySnapshot.setTranslationX(0);
         }
         primarySnapshot.measure(
                 View.MeasureSpec.makeMeasureSpec(primarySnapshotWidth, View.MeasureSpec.EXACTLY),
diff --git a/src/com/android/launcher3/util/DisplayController.java b/src/com/android/launcher3/util/DisplayController.java
index 8b4ff85..8005181 100644
--- a/src/com/android/launcher3/util/DisplayController.java
+++ b/src/com/android/launcher3/util/DisplayController.java
@@ -26,7 +26,6 @@
 import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_NAVIGATION_MODE_GESTURE_BUTTON;
 import static com.android.launcher3.util.Executors.MAIN_EXECUTOR;
 import static com.android.launcher3.util.PackageManagerHelper.getPackageFilter;
-import static com.android.launcher3.util.window.WindowManagerProxy.MIN_LARGE_TABLET_WIDTH;
 import static com.android.launcher3.util.window.WindowManagerProxy.MIN_TABLET_WIDTH;
 
 import android.annotation.SuppressLint;
@@ -306,7 +305,7 @@
         public Info(Context context, Display display,
                 WindowManagerProxy wmProxy,
                 ArrayMap<String, Pair<CachedDisplayInfo, WindowBounds[]>> perDisplayBoundsCache) {
-            CachedDisplayInfo displayInfo = wmProxy.getDisplayInfo(display);
+            CachedDisplayInfo displayInfo = wmProxy.getDisplayInfo(context, display);
             rotation = displayInfo.rotation;
             currentSize = displayInfo.size;
             displayId = displayInfo.id;
@@ -349,13 +348,6 @@
         }
 
         /**
-         * Returns {@code true} if the bounds represent a large tablet.
-         */
-        public boolean isLargeTablet(WindowBounds bounds) {
-            return smallestSizeDp(bounds) >= MIN_LARGE_TABLET_WIDTH;
-        }
-
-        /**
          * Returns smallest size in dp for given bounds.
          */
         public float smallestSizeDp(WindowBounds bounds) {
@@ -372,7 +364,7 @@
         pw.println("  id=" + info.displayId);
         pw.println("  rotation=" + info.rotation);
         pw.println("  fontScale=" + info.fontScale);
-        pw.println("  densityDpi=" + info.displayId);
+        pw.println("  densityDpi=" + info.densityDpi);
         pw.println("  navigationMode=" + info.navigationMode.name());
         pw.println("  currentSize=" + info.currentSize);
         pw.println("  supportedBounds=" + info.supportedBounds);
diff --git a/src/com/android/launcher3/util/SplitConfigurationOptions.java b/src/com/android/launcher3/util/SplitConfigurationOptions.java
index b40493a..6a336cc 100644
--- a/src/com/android/launcher3/util/SplitConfigurationOptions.java
+++ b/src/com/android/launcher3/util/SplitConfigurationOptions.java
@@ -154,10 +154,12 @@
                 }
             }
 
-            leftTaskPercent = this.leftTopBounds.width() / (float) rightBottomBounds.right;
-            topTaskPercent = this.leftTopBounds.height() / (float) rightBottomBounds.bottom;
-            dividerWidthPercent = visualDividerBounds.width() / (float) rightBottomBounds.right;
-            dividerHeightPercent = visualDividerBounds.height() / (float) rightBottomBounds.bottom;
+            float totalWidth = rightBottomBounds.right - leftTopBounds.left;
+            float totalHeight = rightBottomBounds.bottom - leftTopBounds.top;
+            leftTaskPercent = leftTopBounds.width() / totalWidth;
+            topTaskPercent = leftTopBounds.height() / totalHeight;
+            dividerWidthPercent = visualDividerBounds.width() / totalWidth;
+            dividerHeightPercent = visualDividerBounds.height() / totalHeight;
         }
     }
 
diff --git a/src/com/android/launcher3/util/window/WindowManagerProxy.java b/src/com/android/launcher3/util/window/WindowManagerProxy.java
index ba3d981..2fd0a7e 100644
--- a/src/com/android/launcher3/util/window/WindowManagerProxy.java
+++ b/src/com/android/launcher3/util/window/WindowManagerProxy.java
@@ -15,6 +15,9 @@
  */
 package com.android.launcher3.util.window;
 
+import static android.view.Display.DEFAULT_DISPLAY;
+import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION;
+
 import static com.android.launcher3.ResourceUtils.INVALID_RESOURCE_HANDLE;
 import static com.android.launcher3.ResourceUtils.NAVBAR_HEIGHT;
 import static com.android.launcher3.ResourceUtils.NAVBAR_HEIGHT_LANDSCAPE;
@@ -47,7 +50,6 @@
 import com.android.launcher3.R;
 import com.android.launcher3.ResourceUtils;
 import com.android.launcher3.Utilities;
-import com.android.launcher3.util.DisplayController;
 import com.android.launcher3.util.MainThreadInitializedObject;
 import com.android.launcher3.util.ResourceBasedOverride;
 import com.android.launcher3.util.WindowBounds;
@@ -58,7 +60,6 @@
 public class WindowManagerProxy implements ResourceBasedOverride {
 
     public static final int MIN_TABLET_WIDTH = 600;
-    public static final int MIN_LARGE_TABLET_WIDTH = 720;
 
     public static final MainThreadInitializedObject<WindowManagerProxy> INSTANCE =
             forOverride(WindowManagerProxy.class, R.string.window_manager_proxy_class);
@@ -91,7 +92,10 @@
         ArrayMap<String, Pair<CachedDisplayInfo, WindowBounds[]>> result = new ArrayMap<>();
         for (Display display : displays) {
             if (isInternalDisplay(display)) {
-                CachedDisplayInfo info = getDisplayInfo(display).normalize();
+                Context displayContext = Utilities.ATLEAST_S
+                        ? context.createWindowContext(display, TYPE_APPLICATION, null)
+                        : context.createDisplayContext(display);
+                CachedDisplayInfo info = getDisplayInfo(displayContext, display).normalize();
                 WindowBounds[] bounds = estimateWindowBounds(context, info);
                 result.put(info.id, Pair.create(info, bounds));
             }
@@ -122,7 +126,7 @@
         }
 
         WindowMetrics wm = windowContext.getSystemService(WindowManager.class)
-                .getCurrentWindowMetrics();
+                .getMaximumWindowMetrics();
 
         Rect insets = new Rect();
         normalizeWindowInsets(windowContext, wm.getWindowInsets(), insets);
@@ -268,21 +272,23 @@
      * Returns a CachedDisplayInfo initialized for the current display
      */
     @TargetApi(Build.VERSION_CODES.S)
-    public CachedDisplayInfo getDisplayInfo(Display display) {
-        int rotation = display.getRotation();
-
-        Point size = new Point();
-        display.getRealSize(size);
-
+    public CachedDisplayInfo getDisplayInfo(Context displayContext, Display display) {
+        int rotation = getRotation(displayContext);
         Rect cutoutRect = new Rect();
+        Point size = new Point();
         if (Utilities.ATLEAST_S) {
-            DisplayCutout cutout = display.getCutout();
+            WindowMetrics wm = displayContext.getSystemService(WindowManager.class)
+                    .getMaximumWindowMetrics();
+            DisplayCutout cutout = wm.getWindowInsets().getDisplayCutout();
             if (cutout != null) {
                 cutoutRect.set(cutout.getSafeInsetLeft(), cutout.getSafeInsetTop(),
                         cutout.getSafeInsetRight(), cutout.getSafeInsetBottom());
             }
-        }
 
+            size.set(wm.getBounds().right, wm.getBounds().bottom);
+        } else {
+            display.getRealSize(size);
+        }
         return new CachedDisplayInfo(getDisplayId(display), size, rotation, cutoutRect);
     }
 
@@ -305,7 +311,9 @@
                 // Ignore
             }
         }
-        return d == null ? DisplayController.INSTANCE.get(context).getInfo().rotation
-                : d.getRotation();
+        if (d == null) {
+            d = context.getSystemService(DisplayManager.class).getDisplay(DEFAULT_DISPLAY);
+        }
+        return d.getRotation();
     }
 }
diff --git a/tests/src/com/android/launcher3/DeviceProfileBaseTest.kt b/tests/src/com/android/launcher3/DeviceProfileBaseTest.kt
new file mode 100644
index 0000000..e598df9
--- /dev/null
+++ b/tests/src/com/android/launcher3/DeviceProfileBaseTest.kt
@@ -0,0 +1,133 @@
+/*
+ * Copyright (C) 2022 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.launcher3
+
+import android.content.Context
+import android.graphics.PointF
+import androidx.test.core.app.ApplicationProvider
+import com.android.launcher3.util.DisplayController.Info
+import com.android.launcher3.util.WindowBounds
+import org.junit.Before
+import org.mockito.ArgumentMatchers.any
+import org.mockito.Mockito.mock
+import org.mockito.Mockito.`when` as whenever
+
+abstract class DeviceProfileBaseTest {
+
+    protected var context: Context? = null
+    protected var inv: InvariantDeviceProfile? = null
+    protected var info: Info = mock(Info::class.java)
+    protected var windowBounds: WindowBounds? = null
+    protected var isMultiWindowMode: Boolean = false
+    protected var transposeLayoutWithOrientation: Boolean = false
+    protected var useTwoPanels: Boolean = false
+    protected var isGestureMode: Boolean = true
+
+    @Before
+    fun setUp() {
+        context = ApplicationProvider.getApplicationContext()
+        // make sure to reset values
+        useTwoPanels = false
+        isGestureMode = true
+    }
+
+    protected fun newDP(): DeviceProfile = DeviceProfile(
+        context,
+        inv,
+        info,
+        windowBounds,
+        isMultiWindowMode,
+        transposeLayoutWithOrientation,
+        useTwoPanels,
+        isGestureMode
+    )
+
+    protected fun initializeVarsForPhone(isLandscape: Boolean = false) {
+        val (x, y) = if (isLandscape)
+            Pair(3120, 1440)
+        else
+            Pair(1440, 3120)
+
+        windowBounds = WindowBounds(x, y, x, y - 100, 0)
+
+        whenever(info.isTablet(any())).thenReturn(false)
+
+        inv = newScalableInvariantDeviceProfile()
+    }
+
+    protected fun initializeVarsForTablet(isLandscape: Boolean = false) {
+        val (x, y) = if (isLandscape)
+            Pair(2560, 1600)
+        else
+            Pair(1600, 2560)
+
+        windowBounds = WindowBounds(x, y, x, y - 100, 0)
+
+        whenever(info.isTablet(any())).thenReturn(true)
+
+        inv = newScalableInvariantDeviceProfile()
+    }
+
+    /**
+     * A very generic grid, just to make qsb tests work. For real calculations, make sure to use
+     * values that better represent a real grid.
+     */
+    protected fun newScalableInvariantDeviceProfile(): InvariantDeviceProfile =
+        InvariantDeviceProfile().apply {
+            isScalable = true
+            numColumns = 5
+            numRows = 5
+            numShownHotseatIcons = 5
+            numDatabaseHotseatIcons = 6
+            numShrunkenHotseatIcons = 4
+            horizontalMargin = FloatArray(4) { 22f }
+            borderSpaces = listOf(
+                PointF(16f, 16f),
+                PointF(16f, 16f),
+                PointF(16f, 16f),
+                PointF(16f, 16f)
+            ).toTypedArray()
+            allAppsBorderSpaces = listOf(
+                PointF(16f, 16f),
+                PointF(16f, 16f),
+                PointF(16f, 16f),
+                PointF(16f, 16f)
+            ).toTypedArray()
+            hotseatBorderSpaces = FloatArray(4) { 16f }
+            iconSize = FloatArray(4) { 56f }
+            allAppsIconSize = FloatArray(4) { 56f }
+            iconTextSize = FloatArray(4) { 14f }
+            allAppsIconTextSize = FloatArray(4) { 14f }
+            minCellSize = listOf(
+                PointF(64f, 83f),
+                PointF(64f, 83f),
+                PointF(64f, 83f),
+                PointF(64f, 83f)
+            ).toTypedArray()
+            allAppsCellSize = listOf(
+                PointF(64f, 83f),
+                PointF(64f, 83f),
+                PointF(64f, 83f),
+                PointF(64f, 83f)
+            ).toTypedArray()
+            inlineQsb = booleanArrayOf(
+                false,
+                false,
+                false,
+                false
+            )
+        }
+}
\ No newline at end of file
diff --git a/tests/src/com/android/launcher3/DeviceProfileTest.kt b/tests/src/com/android/launcher3/DeviceProfileTest.kt
deleted file mode 100644
index d1e91ed..0000000
--- a/tests/src/com/android/launcher3/DeviceProfileTest.kt
+++ /dev/null
@@ -1,219 +0,0 @@
-/*
- * Copyright (C) 2022 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.launcher3
-
-import android.content.Context
-import android.graphics.PointF
-import androidx.test.core.app.ApplicationProvider
-import androidx.test.ext.junit.runners.AndroidJUnit4
-import androidx.test.filters.SmallTest
-import com.android.launcher3.util.DisplayController.Info
-import com.android.launcher3.util.WindowBounds
-import com.google.common.truth.Truth.assertThat
-import org.junit.Before
-import org.junit.Test
-import org.junit.runner.RunWith
-import org.mockito.Mockito.*
-
-@SmallTest
-@RunWith(AndroidJUnit4::class)
-class DeviceProfileTest {
-
-    private var context: Context? = null
-    private var inv: InvariantDeviceProfile? = null
-    private var info: Info = mock(Info::class.java)
-    private var windowBounds: WindowBounds? = null
-    private var isMultiWindowMode: Boolean = false
-    private var transposeLayoutWithOrientation: Boolean = false
-    private var useTwoPanels: Boolean = false
-    private var isGestureMode: Boolean = true
-
-    @Before
-    fun setUp() {
-        context = ApplicationProvider.getApplicationContext()
-        // make sure to reset values
-        useTwoPanels = false
-    }
-
-    @Test
-    fun qsbWidth_is_match_parent_for_phones() {
-        initializeVarsForPhone()
-
-        val dp = DeviceProfile(
-            context,
-            inv,
-            info,
-            windowBounds,
-            isMultiWindowMode,
-            transposeLayoutWithOrientation,
-            useTwoPanels,
-            isGestureMode
-        )
-
-        assertThat(dp.isQsbInline).isFalse()
-        assertThat(dp.qsbWidth).isEqualTo(0)
-    }
-
-    @Test
-    fun qsbWidth_is_match_parent_for_tablet_portrait() {
-        initializeVarsForLargeTablet()
-
-        val dp = DeviceProfile(
-            context,
-            inv,
-            info,
-            windowBounds,
-            isMultiWindowMode,
-            transposeLayoutWithOrientation,
-            useTwoPanels,
-            isGestureMode
-        )
-
-        assertThat(dp.isQsbInline).isFalse()
-        assertThat(dp.qsbWidth).isEqualTo(0)
-    }
-
-    @Test
-    fun qsbWidth_has_size_for_large_tablet_landscape() {
-        initializeVarsForLargeTablet(true)
-
-        val dp = DeviceProfile(
-            context,
-            inv,
-            info,
-            windowBounds,
-            isMultiWindowMode,
-            transposeLayoutWithOrientation,
-            useTwoPanels,
-            isGestureMode
-        )
-
-        if (dp.hotseatQsbHeight > 0) {
-            assertThat(dp.isQsbInline).isTrue()
-            assertThat(dp.qsbWidth).isGreaterThan(0)
-        } else {
-            assertThat(dp.isQsbInline).isFalse()
-            assertThat(dp.qsbWidth).isEqualTo(0)
-        }
-    }
-
-    /**
-     * This test is to make sure that two panels don't inline the QSB as tablets do
-     */
-    @Test
-    fun qsbWidth_is_match_parent_for_small_two_panel_landscape() {
-        initializeVarsForSmallTablet(true)
-        useTwoPanels = true
-
-        val dp = DeviceProfile(
-            context,
-            inv,
-            info,
-            windowBounds,
-            isMultiWindowMode,
-            transposeLayoutWithOrientation,
-            useTwoPanels,
-            isGestureMode
-        )
-
-        assertThat(dp.isQsbInline).isFalse()
-        assertThat(dp.qsbWidth).isEqualTo(0)
-    }
-
-    private fun initializeVarsForPhone(isLandscape: Boolean = false) {
-        val (x, y) = if (isLandscape)
-            Pair(3120, 1440)
-        else
-            Pair(1440, 3120)
-
-        windowBounds = WindowBounds(x, y, x, y - 100, 0)
-
-        `when`(info.isTablet(any())).thenReturn(false)
-        `when`(info.isLargeTablet(any())).thenReturn(false)
-
-        scalableInvariantDeviceProfile()
-    }
-
-    private fun initializeVarsForSmallTablet(isLandscape: Boolean = false) {
-        val (x, y) = if (isLandscape)
-            Pair(2560, 1600)
-        else
-            Pair(1600, 2560)
-
-        windowBounds = WindowBounds(x, y, x, y - 100, 0)
-
-        `when`(info.isTablet(any())).thenReturn(true)
-        `when`(info.isLargeTablet(any())).thenReturn(false)
-
-        scalableInvariantDeviceProfile()
-    }
-
-    private fun initializeVarsForLargeTablet(isLandscape: Boolean = false) {
-        val (x, y) = if (isLandscape)
-            Pair(2560, 1600)
-        else
-            Pair(1600, 2560)
-
-        windowBounds = WindowBounds(x, y, x, y - 100, 0)
-
-        `when`(info.isTablet(any())).thenReturn(true)
-        `when`(info.isLargeTablet(any())).thenReturn(true)
-
-        scalableInvariantDeviceProfile()
-    }
-
-    /**
-     * A very generic grid, just to make qsb tests work. For real calculations, make sure to use
-     * values that better represent a real grid.
-     */
-    private fun scalableInvariantDeviceProfile() {
-        inv = InvariantDeviceProfile().apply {
-            isScalable = true
-            numColumns = 5
-            numRows = 5
-            horizontalMargin = FloatArray(4) { 22f }
-            borderSpaces = listOf(
-                PointF(16f, 16f),
-                PointF(16f, 16f),
-                PointF(16f, 16f),
-                PointF(16f, 16f)
-            ).toTypedArray()
-            allAppsBorderSpaces = listOf(
-                PointF(16f, 16f),
-                PointF(16f, 16f),
-                PointF(16f, 16f),
-                PointF(16f, 16f)
-            ).toTypedArray()
-            hotseatBorderSpaces = FloatArray(4) { 16f }
-            iconSize = FloatArray(4) { 56f }
-            allAppsIconSize = FloatArray(4) { 56f }
-            iconTextSize = FloatArray(4) { 14f }
-            allAppsIconTextSize = FloatArray(4) { 14f }
-            minCellSize = listOf(
-                PointF(64f, 83f),
-                PointF(64f, 83f),
-                PointF(64f, 83f),
-                PointF(64f, 83f)
-            ).toTypedArray()
-            allAppsCellSize = listOf(
-                PointF(64f, 83f),
-                PointF(64f, 83f),
-                PointF(64f, 83f),
-                PointF(64f, 83f)
-            ).toTypedArray()
-        }
-    }
-}
\ No newline at end of file
diff --git a/tests/src/com/android/launcher3/HotseatSizeTest.kt b/tests/src/com/android/launcher3/HotseatSizeTest.kt
new file mode 100644
index 0000000..ca697d7
--- /dev/null
+++ b/tests/src/com/android/launcher3/HotseatSizeTest.kt
@@ -0,0 +1,186 @@
+/*
+ * Copyright (C) 2022 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.launcher3
+
+import androidx.test.ext.junit.runners.AndroidJUnit4
+import androidx.test.filters.SmallTest
+import com.android.launcher3.InvariantDeviceProfile.TYPE_MULTI_DISPLAY
+import com.android.launcher3.InvariantDeviceProfile.TYPE_PHONE
+import com.android.launcher3.InvariantDeviceProfile.TYPE_TABLET
+import com.google.common.truth.Truth.assertThat
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.mockito.ArgumentMatchers
+import org.mockito.Mockito.`when` as whenever
+
+/**
+ * Test for [DeviceProfile]
+ */
+@SmallTest
+@RunWith(AndroidJUnit4::class)
+class HotseatSizeTest : DeviceProfileBaseTest() {
+
+    @Test
+    fun hotseat_size_is_normal_for_handhelds() {
+        initializeVarsForPhone()
+        inv = newScalableInvariantDeviceProfile().apply {
+            deviceType = TYPE_PHONE
+        }
+
+        val dp = newDP()
+
+        assertThat(dp.isQsbInline).isFalse()
+        assertThat(dp.numShownHotseatIcons).isEqualTo(5)
+    }
+
+    @Test
+    fun hotseat_size_is_max_for_foldables() {
+        initializeVarsForTablet(isLandscape = true)
+        inv = newScalableInvariantDeviceProfile().apply {
+            deviceType = TYPE_MULTI_DISPLAY
+        }
+        useTwoPanels = true
+
+        val dp = newDP()
+
+        assertThat(dp.isQsbInline).isFalse()
+        assertThat(dp.numShownHotseatIcons).isEqualTo(6)
+    }
+
+    @Test
+    fun hotseat_size_is_shrunk_if_needed() {
+        initializeVarsForTablet(isLandscape = true)
+        inv = newScalableInvariantDeviceProfile().apply {
+            deviceType = TYPE_MULTI_DISPLAY
+            inlineQsb = booleanArrayOf(
+                false,
+                false,
+                false,
+                true // two panels landscape
+            )
+        }
+        useTwoPanels = true
+
+        isGestureMode = false
+        val dp = newDP()
+
+        if (dp.hotseatQsbHeight > 0) {
+            assertThat(dp.isQsbInline).isTrue()
+            assertThat(dp.numShownHotseatIcons).isEqualTo(4)
+        } else { // Launcher3 doesn't have QSB height
+            assertThat(dp.isQsbInline).isFalse()
+            assertThat(dp.numShownHotseatIcons).isEqualTo(6)
+        }
+    }
+
+    /**
+     * For consistency, the hotseat should shrink if any orientation on the device type has an
+     * inline qsb
+     */
+    @Test
+    fun hotseat_size_is_shrunk_even_in_portrait() {
+        initializeVarsForTablet()
+        inv = newScalableInvariantDeviceProfile().apply {
+            deviceType = TYPE_MULTI_DISPLAY
+            inlineQsb = booleanArrayOf(
+                false,
+                false,
+                false,
+                true // two panels landscape
+            )
+        }
+        useTwoPanels = true
+
+        isGestureMode = false
+        val dp = newDP()
+
+        if (dp.hotseatQsbHeight > 0) {
+            assertThat(dp.isQsbInline).isFalse()
+            assertThat(dp.numShownHotseatIcons).isEqualTo(4)
+        } else { // Launcher3 doesn't have QSB height
+            assertThat(dp.isQsbInline).isFalse()
+            assertThat(dp.numShownHotseatIcons).isEqualTo(6)
+        }
+    }
+
+    @Test
+    fun hotseat_size_is_default_when_folded() {
+        initializeVarsForPhone()
+        inv = newScalableInvariantDeviceProfile().apply {
+            deviceType = TYPE_MULTI_DISPLAY
+        }
+        useTwoPanels = true
+
+        val dp = newDP()
+
+        assertThat(dp.numShownHotseatIcons).isEqualTo(5)
+    }
+
+    @Test
+    fun hotseat_size_is_shrunk_if_needed_on_tablet() {
+        initializeVarsForTablet(isLandscape = true)
+        inv = newScalableInvariantDeviceProfile().apply {
+            deviceType = TYPE_TABLET
+            inlineQsb = booleanArrayOf(
+                false,
+                true, // landscape
+                false,
+                false
+            )
+        }
+
+        isGestureMode = false
+        val dp = newDP()
+
+        if (dp.hotseatQsbHeight > 0) {
+            assertThat(dp.isQsbInline).isTrue()
+            assertThat(dp.numShownHotseatIcons).isEqualTo(4)
+        } else { // Launcher3 doesn't have QSB height
+            assertThat(dp.isQsbInline).isFalse()
+            assertThat(dp.numShownHotseatIcons).isEqualTo(5)
+        }
+    }
+
+    /**
+     * For consistency, the hotseat should shrink if any orientation on the device type has an
+     * inline qsb
+     */
+    @Test
+    fun hotseat_size_is_shrunk_even_in_portrait_on_tablet() {
+        initializeVarsForTablet()
+        inv = newScalableInvariantDeviceProfile().apply {
+            deviceType = TYPE_TABLET
+            inlineQsb = booleanArrayOf(
+                false,
+                true, // landscape
+                false,
+                false
+            )
+        }
+
+        isGestureMode = false
+        val dp = newDP()
+
+        if (dp.hotseatQsbHeight > 0) {
+            assertThat(dp.isQsbInline).isFalse()
+            assertThat(dp.numShownHotseatIcons).isEqualTo(4)
+        } else { // Launcher3 doesn't have QSB height
+            assertThat(dp.isQsbInline).isFalse()
+            assertThat(dp.numShownHotseatIcons).isEqualTo(5)
+        }
+    }
+
+}
\ No newline at end of file
diff --git a/tests/src/com/android/launcher3/InlineQsbTest.kt b/tests/src/com/android/launcher3/InlineQsbTest.kt
new file mode 100644
index 0000000..e00dca8
--- /dev/null
+++ b/tests/src/com/android/launcher3/InlineQsbTest.kt
@@ -0,0 +1,105 @@
+/*
+ * Copyright (C) 2022 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.launcher3
+
+import androidx.test.ext.junit.runners.AndroidJUnit4
+import androidx.test.filters.SmallTest
+import com.google.common.truth.Truth.assertThat
+import org.junit.Test
+import org.junit.runner.RunWith
+
+/**
+ * Test for [DeviceProfile]
+ */
+@SmallTest
+@RunWith(AndroidJUnit4::class)
+class InlineQsbTest : DeviceProfileBaseTest() {
+
+    @Test
+    fun qsbWidth_is_match_parent_for_phones() {
+        initializeVarsForPhone()
+
+        val dp = newDP()
+
+        assertThat(dp.isQsbInline).isFalse()
+        assertThat(dp.qsbWidth).isEqualTo(0)
+    }
+
+    @Test
+    fun qsbWidth_is_match_parent_for_tablet_portrait() {
+        initializeVarsForTablet()
+        inv = newScalableInvariantDeviceProfile().apply {
+            inlineQsb = booleanArrayOf(
+                false,
+                true, // landscape
+                false,
+                false
+            )
+        }
+
+        val dp = DeviceProfile(
+            context,
+            inv,
+            info,
+            windowBounds,
+            isMultiWindowMode,
+            transposeLayoutWithOrientation,
+            useTwoPanels,
+            isGestureMode
+        )
+
+        assertThat(dp.isQsbInline).isFalse()
+        assertThat(dp.qsbWidth).isEqualTo(0)
+    }
+
+    @Test
+    fun qsbWidth_has_size_for_tablet_landscape() {
+        initializeVarsForTablet(isLandscape = true)
+        inv = newScalableInvariantDeviceProfile().apply {
+            inlineQsb = booleanArrayOf(
+                false,
+                true, // landscape
+                false,
+                false
+            )
+        }
+
+        val dp = newDP()
+
+        if (dp.hotseatQsbHeight > 0) {
+            assertThat(dp.isQsbInline).isTrue()
+            assertThat(dp.qsbWidth).isGreaterThan(0)
+        } else { // Launcher3 doesn't have QSB height
+            assertThat(dp.isQsbInline).isFalse()
+            assertThat(dp.qsbWidth).isEqualTo(0)
+        }
+    }
+
+    /**
+     * This test is to make sure that a tablet doesn't inline the QSB if the layout doesn't support
+     */
+    @Test
+    fun qsbWidth_is_match_parent_for_tablet_landscape_without_inline() {
+        initializeVarsForTablet(isLandscape = true)
+        useTwoPanels = true
+
+        val dp = newDP()
+
+        assertThat(dp.isQsbInline).isFalse()
+        assertThat(dp.qsbWidth).isEqualTo(0)
+    }
+
+}
\ No newline at end of file
diff --git a/tests/src/com/android/launcher3/ui/workspace/TwoPanelWorkspaceTest.java b/tests/src/com/android/launcher3/ui/workspace/TwoPanelWorkspaceTest.java
index d0daefc..f646b50 100644
--- a/tests/src/com/android/launcher3/ui/workspace/TwoPanelWorkspaceTest.java
+++ b/tests/src/com/android/launcher3/ui/workspace/TwoPanelWorkspaceTest.java
@@ -255,24 +255,24 @@
         Workspace workspace = mLauncher.getWorkspace();
 
         workspace.dragIcon(workspace.getWorkspaceAppIcon("Play Store"), 2);
-        workspace.dragIcon(workspace.getHotseatAppIcon("Camera"), 1);
+        workspace.dragIcon(workspace.getHotseatAppIcon("Chrome"), 1);
 
         executeOnLauncher(launcher -> {
             assertPagesExist(launcher, 0, 1, 2, 3);
             assertItemsOnPage(launcher, 0, "Maps");
             assertPageEmpty(launcher, 1);
             assertItemsOnPage(launcher, 2, "Play Store");
-            assertItemsOnPage(launcher, 3, "Camera");
+            assertItemsOnPage(launcher, 3, "Chrome");
         });
 
-        workspace.dragIcon(workspace.getWorkspaceAppIcon("Camera"), -1);
+        workspace.dragIcon(workspace.getWorkspaceAppIcon("Chrome"), -1);
         workspace.flingForward();
         workspace.dragIcon(workspace.getWorkspaceAppIcon("Play Store"), -2);
 
         executeOnLauncher(launcher -> {
             assertPagesExist(launcher, 0, 1);
             assertItemsOnPage(launcher, 0, "Play Store", "Maps");
-            assertItemsOnPage(launcher, 1, "Camera");
+            assertItemsOnPage(launcher, 1, "Chrome");
         });
     }