Merge "Fix split task position behavior when landscape" into rvc-dev
diff --git a/packages/SystemUI/src/com/android/systemui/stackdivider/DividerView.java b/packages/SystemUI/src/com/android/systemui/stackdivider/DividerView.java
index 366ef93..2df4506 100644
--- a/packages/SystemUI/src/com/android/systemui/stackdivider/DividerView.java
+++ b/packages/SystemUI/src/com/android/systemui/stackdivider/DividerView.java
@@ -1042,7 +1042,8 @@
         dockedTaskRect = dockedTaskRect == null ? dockedRect : dockedTaskRect;
         otherTaskRect = otherTaskRect == null ? otherRect : otherTaskRect;
 
-        mDividerPositionX = dockedRect.right;
+        mDividerPositionX = mSplitLayout.getPrimarySplitSide() == DOCKED_RIGHT
+                ? otherRect.right : dockedRect.right;
         mDividerPositionY = dockedRect.bottom;
 
         if (DEBUG) {
diff --git a/packages/SystemUI/src/com/android/systemui/stackdivider/SplitDisplayLayout.java b/packages/SystemUI/src/com/android/systemui/stackdivider/SplitDisplayLayout.java
index 3b8addb..92f6b4a 100644
--- a/packages/SystemUI/src/com/android/systemui/stackdivider/SplitDisplayLayout.java
+++ b/packages/SystemUI/src/com/android/systemui/stackdivider/SplitDisplayLayout.java
@@ -101,7 +101,16 @@
     }
 
     int getPrimarySplitSide() {
-        return mDisplayLayout.isLandscape() ? DOCKED_LEFT : DOCKED_TOP;
+        switch (mDisplayLayout.getNavigationBarPosition(mContext.getResources())) {
+            case DisplayLayout.NAV_BAR_BOTTOM:
+                return mDisplayLayout.isLandscape() ? DOCKED_LEFT : DOCKED_TOP;
+            case DisplayLayout.NAV_BAR_LEFT:
+                return DOCKED_RIGHT;
+            case DisplayLayout.NAV_BAR_RIGHT:
+                return DOCKED_LEFT;
+            default:
+                return DOCKED_INVALID;
+        }
     }
 
     boolean isMinimized() {
diff --git a/packages/SystemUI/src/com/android/systemui/wm/DisplayLayout.java b/packages/SystemUI/src/com/android/systemui/wm/DisplayLayout.java
index 4652abf..cfec1c0 100644
--- a/packages/SystemUI/src/com/android/systemui/wm/DisplayLayout.java
+++ b/packages/SystemUI/src/com/android/systemui/wm/DisplayLayout.java
@@ -27,6 +27,7 @@
 import static android.view.Surface.ROTATION_270;
 import static android.view.Surface.ROTATION_90;
 
+import android.annotation.IntDef;
 import android.annotation.NonNull;
 import android.content.ContentResolver;
 import android.content.Context;
@@ -46,16 +47,27 @@
 
 import com.android.internal.R;
 
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
 /**
  * Contains information about the layout-properties of a display. This refers to internal layout
  * like insets/cutout/rotation. In general, this can be thought of as the System-UI analog to
  * DisplayPolicy.
  */
 public class DisplayLayout {
+    @IntDef(prefix = { "NAV_BAR_" }, value = {
+            NAV_BAR_LEFT,
+            NAV_BAR_RIGHT,
+            NAV_BAR_BOTTOM,
+    })
+    @Retention(RetentionPolicy.SOURCE)
+    public @interface NavBarPosition {}
+
     // Navigation bar position values
-    private static final int NAV_BAR_LEFT = 1 << 0;
-    private static final int NAV_BAR_RIGHT = 1 << 1;
-    private static final int NAV_BAR_BOTTOM = 1 << 2;
+    public static final int NAV_BAR_LEFT = 1 << 0;
+    public static final int NAV_BAR_RIGHT = 1 << 1;
+    public static final int NAV_BAR_BOTTOM = 1 << 2;
 
     private int mUiMode;
     private int mWidth;
@@ -214,6 +226,14 @@
     }
 
     /**
+     * Gets navigation bar position for this layout
+     * @return Navigation bar position for this layout.
+     */
+    public @NavBarPosition int getNavigationBarPosition(Resources res) {
+        return navigationBarPosition(res, mWidth, mHeight, mRotation);
+    }
+
+    /**
      * Rotates bounds as if parentBounds and bounds are a group. The group is rotated by `delta`
      * 90-degree counter-clockwise increments. This assumes that parentBounds is at 0,0 and
      * remains at 0,0 after rotation.
@@ -437,8 +457,8 @@
     }
 
     /** Retrieve navigation bar position from resources based on rotation and size. */
-    public static int navigationBarPosition(Resources res, int displayWidth, int displayHeight,
-            int rotation) {
+    public static @NavBarPosition int navigationBarPosition(Resources res, int displayWidth,
+            int displayHeight, int rotation) {
         boolean navBarCanMove = displayWidth != displayHeight && res.getBoolean(
                 com.android.internal.R.bool.config_navBarCanMove);
         if (navBarCanMove && displayWidth > displayHeight) {