[Divider] Draw the divider on the decor surface

This CL draws the divider based on DividerAttributes. Handling drag
events will be in a separate CL.

Bug: 293654166
Test: atest DividerContainerTest
Change-Id: I02eec0b42035058d38db49d52f19b8fd127c1193
diff --git a/core/java/android/window/TaskFragmentOperation.java b/core/java/android/window/TaskFragmentOperation.java
index 7e77f15..43df4f9 100644
--- a/core/java/android/window/TaskFragmentOperation.java
+++ b/core/java/android/window/TaskFragmentOperation.java
@@ -112,10 +112,13 @@
     /**
      * Creates a decor surface in the parent Task of the TaskFragment. The created decor surface
      * will be provided in {@link TaskFragmentTransaction#TYPE_TASK_FRAGMENT_PARENT_INFO_CHANGED}
-     * event callback. The decor surface can be used to draw the divider between TaskFragments or
-     * other decorations.
+     * event callback. If a decor surface already exists in the parent Task, the current
+     * TaskFragment will become the new owner of the decor surface and the decor surface will be
+     * moved above the TaskFragment.
+     *
+     * The decor surface can be used to draw the divider between TaskFragments or other decorations.
      */
-    public static final int OP_TYPE_CREATE_TASK_FRAGMENT_DECOR_SURFACE = 14;
+    public static final int OP_TYPE_CREATE_OR_MOVE_TASK_FRAGMENT_DECOR_SURFACE = 14;
 
     /**
      * Removes the decor surface in the parent Task of the TaskFragment.
@@ -162,7 +165,7 @@
             OP_TYPE_SET_ISOLATED_NAVIGATION,
             OP_TYPE_REORDER_TO_BOTTOM_OF_TASK,
             OP_TYPE_REORDER_TO_TOP_OF_TASK,
-            OP_TYPE_CREATE_TASK_FRAGMENT_DECOR_SURFACE,
+            OP_TYPE_CREATE_OR_MOVE_TASK_FRAGMENT_DECOR_SURFACE,
             OP_TYPE_REMOVE_TASK_FRAGMENT_DECOR_SURFACE,
             OP_TYPE_SET_DIM_ON_TASK,
             OP_TYPE_SET_MOVE_TO_BOTTOM_IF_CLEAR_WHEN_LAUNCH,
diff --git a/core/res/res/drawable/activity_embedding_divider_handle.xml b/core/res/res/drawable/activity_embedding_divider_handle.xml
new file mode 100644
index 0000000..d9f363c
--- /dev/null
+++ b/core/res/res/drawable/activity_embedding_divider_handle.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+  Copyright 2024 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:state_pressed="true"
+        android:drawable="@drawable/activity_embedding_divider_handle_pressed" />
+    <item android:drawable="@drawable/activity_embedding_divider_handle_default" />
+</selector>
\ No newline at end of file
diff --git a/core/res/res/drawable/activity_embedding_divider_handle_default.xml b/core/res/res/drawable/activity_embedding_divider_handle_default.xml
new file mode 100644
index 0000000..565f671
--- /dev/null
+++ b/core/res/res/drawable/activity_embedding_divider_handle_default.xml
@@ -0,0 +1,23 @@
+<!--
+  Copyright 2024 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.
+  -->
+
+<shape xmlns:android="http://schemas.android.com/apk/res/android">
+    <corners android:radius="@dimen/activity_embedding_divider_handle_radius" />
+    <size
+        android:width="@dimen/activity_embedding_divider_handle_width"
+        android:height="@dimen/activity_embedding_divider_handle_height" />
+    <solid android:color="@color/activity_embedding_divider_color" />
+</shape>
\ No newline at end of file
diff --git a/core/res/res/drawable/activity_embedding_divider_handle_pressed.xml b/core/res/res/drawable/activity_embedding_divider_handle_pressed.xml
new file mode 100644
index 0000000..e5cca239
--- /dev/null
+++ b/core/res/res/drawable/activity_embedding_divider_handle_pressed.xml
@@ -0,0 +1,23 @@
+<!--
+  Copyright 2024 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.
+  -->
+
+<shape xmlns:android="http://schemas.android.com/apk/res/android">
+    <corners android:radius="@dimen/activity_embedding_divider_handle_radius_pressed" />
+    <size
+        android:width="@dimen/activity_embedding_divider_handle_width_pressed"
+        android:height="@dimen/activity_embedding_divider_handle_height_pressed" />
+    <solid android:color="@color/activity_embedding_divider_color_pressed" />
+</shape>
\ No newline at end of file
diff --git a/core/res/res/values/colors.xml b/core/res/res/values/colors.xml
index 417c6df..e671919 100644
--- a/core/res/res/values/colors.xml
+++ b/core/res/res/values/colors.xml
@@ -593,6 +593,10 @@
     <color name="accessibility_magnification_thumbnail_container_background_color">#99000000</color>
     <color name="accessibility_magnification_thumbnail_container_stroke_color">#FFFFFF</color>
 
+    <!-- Activity Embedding divider -->
+    <color name="activity_embedding_divider_color">#8e918f</color>
+    <color name="activity_embedding_divider_color_pressed">#e3e3e3</color>
+
     <!-- Lily Language Picker language item view colors -->
     <color name="language_picker_item_text_color">#202124</color>
     <color name="language_picker_item_text_color_secondary">#5F6368</color>
diff --git a/core/res/res/values/dimens.xml b/core/res/res/values/dimens.xml
index 291a593..4aa741d 100644
--- a/core/res/res/values/dimens.xml
+++ b/core/res/res/values/dimens.xml
@@ -1028,6 +1028,16 @@
     <dimen name="popup_enter_animation_from_y_delta">20dp</dimen>
     <dimen name="popup_exit_animation_to_y_delta">-10dp</dimen>
 
+    <!-- Dimensions for the activity embedding divider. -->
+    <dimen name="activity_embedding_divider_handle_width">4dp</dimen>
+    <dimen name="activity_embedding_divider_handle_height">48dp</dimen>
+    <dimen name="activity_embedding_divider_handle_radius">2dp</dimen>
+    <dimen name="activity_embedding_divider_handle_width_pressed">12dp</dimen>
+    <dimen name="activity_embedding_divider_handle_height_pressed">53dp</dimen>
+    <dimen name="activity_embedding_divider_handle_radius_pressed">6dp</dimen>
+    <dimen name="activity_embedding_divider_touch_target_width">24dp</dimen>
+    <dimen name="activity_embedding_divider_touch_target_height">64dp</dimen>
+
     <!-- Default handwriting bounds offsets for editors. -->
     <dimen name="handwriting_bounds_offset_left">10dp</dimen>
     <dimen name="handwriting_bounds_offset_top">40dp</dimen>
diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml
index 9628d30..9a8b7f6 100644
--- a/core/res/res/values/symbols.xml
+++ b/core/res/res/values/symbols.xml
@@ -5334,6 +5334,11 @@
 
   <java-symbol type="raw" name="default_ringtone_vibration_effect" />
 
+  <!-- For activity embedding divider -->
+  <java-symbol type="drawable" name="activity_embedding_divider_handle" />
+  <java-symbol type="dimen" name="activity_embedding_divider_touch_target_width" />
+  <java-symbol type="dimen" name="activity_embedding_divider_touch_target_height" />
+
   <!-- Whether we order unlocking and waking -->
   <java-symbol type="bool" name="config_orderUnlockAndWake" />
 
diff --git a/libs/WindowManager/Jetpack/src/androidx/window/extensions/embedding/DividerPresenter.java b/libs/WindowManager/Jetpack/src/androidx/window/extensions/embedding/DividerPresenter.java
index 100185b..cae232e 100644
--- a/libs/WindowManager/Jetpack/src/androidx/window/extensions/embedding/DividerPresenter.java
+++ b/libs/WindowManager/Jetpack/src/androidx/window/extensions/embedding/DividerPresenter.java
@@ -17,6 +17,12 @@
 package androidx.window.extensions.embedding;
 
 import static android.util.TypedValue.COMPLEX_UNIT_DIP;
+import static android.view.WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;
+import static android.view.WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL;
+import static android.view.WindowManager.LayoutParams.FLAG_SLIPPERY;
+import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_PANEL;
+import static android.window.TaskFragmentOperation.OP_TYPE_CREATE_OR_MOVE_TASK_FRAGMENT_DECOR_SURFACE;
+import static android.window.TaskFragmentOperation.OP_TYPE_REMOVE_TASK_FRAGMENT_DECOR_SURFACE;
 
 import static androidx.window.extensions.embedding.DividerAttributes.RATIO_UNSET;
 import static androidx.window.extensions.embedding.DividerAttributes.WIDTH_UNSET;
@@ -28,34 +34,253 @@
 import android.annotation.Nullable;
 import android.app.ActivityThread;
 import android.content.Context;
+import android.content.pm.ActivityInfo;
+import android.content.res.Configuration;
+import android.graphics.Color;
+import android.graphics.PixelFormat;
+import android.graphics.Rect;
+import android.graphics.drawable.Drawable;
+import android.graphics.drawable.RotateDrawable;
+import android.hardware.display.DisplayManager;
+import android.os.IBinder;
 import android.util.TypedValue;
+import android.view.Gravity;
+import android.view.SurfaceControl;
+import android.view.SurfaceControlViewHost;
+import android.view.WindowManager;
+import android.view.WindowlessWindowManager;
+import android.widget.FrameLayout;
+import android.widget.ImageButton;
+import android.window.InputTransferToken;
+import android.window.TaskFragmentOperation;
+import android.window.TaskFragmentParentInfo;
+import android.window.WindowContainerTransaction;
 
+import androidx.annotation.IdRes;
 import androidx.annotation.NonNull;
 
+import com.android.internal.R;
 import com.android.internal.annotations.VisibleForTesting;
 import com.android.window.flags.Flags;
 
+import java.util.Objects;
+
 /**
  * Manages the rendering and interaction of the divider.
  */
 class DividerPresenter {
+    private static final String WINDOW_NAME = "AE Divider";
+
     // TODO(b/327067596) Update based on UX guidance.
-    @VisibleForTesting static final float DEFAULT_MIN_RATIO = 0.35f;
-    @VisibleForTesting static final float DEFAULT_MAX_RATIO = 0.65f;
-    @VisibleForTesting static final int DEFAULT_DIVIDER_WIDTH_DP = 24;
+    private static final Color DEFAULT_DIVIDER_COLOR = Color.valueOf(Color.BLACK);
+    @VisibleForTesting
+    static final float DEFAULT_MIN_RATIO = 0.35f;
+    @VisibleForTesting
+    static final float DEFAULT_MAX_RATIO = 0.65f;
+    @VisibleForTesting
+    static final int DEFAULT_DIVIDER_WIDTH_DP = 24;
 
-    static int getDividerWidthPx(@NonNull DividerAttributes dividerAttributes) {
+    /**
+     * The {@link Properties} of the divider. This field is {@code null} when no divider should be
+     * drawn, e.g. when the split doesn't have {@link DividerAttributes} or when the decor surface
+     * is not available.
+     */
+    @Nullable
+    @VisibleForTesting
+    Properties mProperties;
+
+    /**
+     * The {@link Renderer} of the divider. This field is {@code null} when no divider should be
+     * drawn, i.e. when {@link #mProperties} is {@code null}. The {@link Renderer} is recreated or
+     * updated when {@link #mProperties} is changed.
+     */
+    @Nullable
+    @VisibleForTesting
+    Renderer mRenderer;
+
+    /**
+     * The owner TaskFragment token of the decor surface. The decor surface is placed right above
+     * the owner TaskFragment surface and is removed if the owner TaskFragment is destroyed.
+     */
+    @Nullable
+    @VisibleForTesting
+    IBinder mDecorSurfaceOwner;
+
+    /** Updates the divider when external conditions are changed. */
+    void updateDivider(
+            @NonNull WindowContainerTransaction wct,
+            @NonNull TaskFragmentParentInfo parentInfo,
+            @Nullable SplitContainer topSplitContainer) {
+        if (!Flags.activityEmbeddingInteractiveDividerFlag()) {
+            return;
+        }
+
+        // Clean up the decor surface if top SplitContainer is null.
+        if (topSplitContainer == null) {
+            removeDecorSurfaceAndDivider(wct);
+            return;
+        }
+
+        // Clean up the decor surface if DividerAttributes is null.
+        final DividerAttributes dividerAttributes =
+                topSplitContainer.getCurrentSplitAttributes().getDividerAttributes();
+        if (dividerAttributes == null) {
+            removeDecorSurfaceAndDivider(wct);
+            return;
+        }
+
+        if (topSplitContainer.getCurrentSplitAttributes().getSplitType()
+                instanceof SplitAttributes.SplitType.ExpandContainersSplitType) {
+            // No divider is needed for ExpandContainersSplitType.
+            removeDivider();
+            return;
+        }
+
+        // Skip updating when the TFs have not been updated to match the SplitAttributes.
+        if (topSplitContainer.getPrimaryContainer().getLastRequestedBounds().isEmpty()
+                || topSplitContainer.getSecondaryContainer().getLastRequestedBounds().isEmpty()) {
+            return;
+        }
+
+        final SurfaceControl decorSurface = parentInfo.getDecorSurface();
+        if (decorSurface == null) {
+            // Clean up when the decor surface is currently unavailable.
+            removeDivider();
+            // Request to create the decor surface
+            createOrMoveDecorSurface(wct, topSplitContainer.getPrimaryContainer());
+            return;
+        }
+
+        // make the top primary container the owner of the decor surface.
+        if (!Objects.equals(mDecorSurfaceOwner,
+                topSplitContainer.getPrimaryContainer().getTaskFragmentToken())) {
+            createOrMoveDecorSurface(wct, topSplitContainer.getPrimaryContainer());
+        }
+
+        updateProperties(
+                new Properties(
+                        parentInfo.getConfiguration(),
+                        dividerAttributes,
+                        decorSurface,
+                        getInitialDividerPosition(topSplitContainer),
+                        isVerticalSplit(topSplitContainer),
+                        parentInfo.getDisplayId()));
+    }
+
+    private void updateProperties(@NonNull Properties properties) {
+        if (Properties.equalsForDivider(mProperties, properties)) {
+            return;
+        }
+        final Properties previousProperties = mProperties;
+        mProperties = properties;
+
+        if (mRenderer == null) {
+            // Create a new renderer when a renderer doesn't exist yet.
+            mRenderer = new Renderer();
+        } else if (!Properties.areSameSurfaces(
+                previousProperties.mDecorSurface, mProperties.mDecorSurface)
+                || previousProperties.mDisplayId != mProperties.mDisplayId) {
+            // Release and recreate the renderer if the decor surface or the display has changed.
+            mRenderer.release();
+            mRenderer = new Renderer();
+        } else {
+            // Otherwise, update the renderer for the new properties.
+            mRenderer.update();
+        }
+    }
+
+    /**
+     * Creates a decor surface for the TaskFragment if no decor surface exists, or changes the owner
+     * of the existing decor surface to be the specified TaskFragment.
+     *
+     * See {@link TaskFragmentOperation#OP_TYPE_CREATE_OR_MOVE_TASK_FRAGMENT_DECOR_SURFACE}.
+     */
+    private void createOrMoveDecorSurface(
+            @NonNull WindowContainerTransaction wct, @NonNull TaskFragmentContainer container) {
+        final TaskFragmentOperation operation = new TaskFragmentOperation.Builder(
+                OP_TYPE_CREATE_OR_MOVE_TASK_FRAGMENT_DECOR_SURFACE)
+                .build();
+        wct.addTaskFragmentOperation(container.getTaskFragmentToken(), operation);
+        mDecorSurfaceOwner = container.getTaskFragmentToken();
+    }
+
+    private void removeDecorSurfaceAndDivider(@NonNull WindowContainerTransaction wct) {
+        if (mDecorSurfaceOwner != null) {
+            final TaskFragmentOperation operation = new TaskFragmentOperation.Builder(
+                    OP_TYPE_REMOVE_TASK_FRAGMENT_DECOR_SURFACE)
+                    .build();
+            wct.addTaskFragmentOperation(mDecorSurfaceOwner, operation);
+            mDecorSurfaceOwner = null;
+        }
+        removeDivider();
+    }
+
+    private void removeDivider() {
+        if (mRenderer != null) {
+            mRenderer.release();
+        }
+        mProperties = null;
+        mRenderer = null;
+    }
+
+    @VisibleForTesting
+    static int getInitialDividerPosition(@NonNull SplitContainer splitContainer) {
+        final Rect primaryBounds =
+                splitContainer.getPrimaryContainer().getLastRequestedBounds();
+        final Rect secondaryBounds =
+                splitContainer.getSecondaryContainer().getLastRequestedBounds();
+        if (isVerticalSplit(splitContainer)) {
+            return Math.min(primaryBounds.right, secondaryBounds.right);
+        } else {
+            return Math.min(primaryBounds.bottom, secondaryBounds.bottom);
+        }
+    }
+
+    private static boolean isVerticalSplit(@NonNull SplitContainer splitContainer) {
+        final int layoutDirection = splitContainer.getCurrentSplitAttributes().getLayoutDirection();
+        switch(layoutDirection) {
+            case SplitAttributes.LayoutDirection.LEFT_TO_RIGHT:
+            case SplitAttributes.LayoutDirection.RIGHT_TO_LEFT:
+            case SplitAttributes.LayoutDirection.LOCALE:
+                return true;
+            case SplitAttributes.LayoutDirection.TOP_TO_BOTTOM:
+            case SplitAttributes.LayoutDirection.BOTTOM_TO_TOP:
+                return false;
+            default:
+                throw new IllegalArgumentException("Invalid layout direction:" + layoutDirection);
+        }
+    }
+
+    private static void safeReleaseSurfaceControl(@Nullable SurfaceControl sc) {
+        if (sc != null) {
+            sc.release();
+        }
+    }
+
+    private static int getDividerWidthPx(@NonNull DividerAttributes dividerAttributes) {
         int dividerWidthDp = dividerAttributes.getWidthDp();
+        return convertDpToPixel(dividerWidthDp);
+    }
 
+    private static int convertDpToPixel(int dp) {
         // TODO(b/329193115) support divider on secondary display
         final Context applicationContext = ActivityThread.currentActivityThread().getApplication();
 
         return (int) TypedValue.applyDimension(
                 COMPLEX_UNIT_DIP,
-                dividerWidthDp,
+                dp,
                 applicationContext.getResources().getDisplayMetrics());
     }
 
+    private static int getDimensionDp(@IdRes int resId) {
+        final Context context = ActivityThread.currentActivityThread().getApplication();
+        final int px = context.getResources().getDimensionPixelSize(resId);
+        return (int) TypedValue.convertPixelsToDimension(
+                COMPLEX_UNIT_DIP,
+                px,
+                context.getResources().getDisplayMetrics());
+    }
+
     /**
      * Returns the container bound offset that is a result of the presence of a divider.
      *
@@ -140,6 +365,12 @@
             widthDp = DEFAULT_DIVIDER_WIDTH_DP;
         }
 
+        if (dividerAttributes.getDividerType() == DividerAttributes.DIVIDER_TYPE_DRAGGABLE) {
+            // Draggable divider width must be larger than the drag handle size.
+            widthDp = Math.max(widthDp,
+                    getDimensionDp(R.dimen.activity_embedding_divider_touch_target_width));
+        }
+
         float minRatio = dividerAttributes.getPrimaryMinRatio();
         if (minRatio == RATIO_UNSET) {
             minRatio = DEFAULT_MIN_RATIO;
@@ -156,4 +387,231 @@
                 .setPrimaryMaxRatio(maxRatio)
                 .build();
     }
+
+    /**
+     * Properties for the {@link DividerPresenter}. The rendering of the divider solely depends on
+     * these properties. When any value is updated, the divider is re-rendered. The Properties
+     * instance is created only when all the pre-conditions of drawing a divider are met.
+     */
+    @VisibleForTesting
+    static class Properties {
+        private static final int CONFIGURATION_MASK_FOR_DIVIDER =
+                ActivityInfo.CONFIG_DENSITY | ActivityInfo.CONFIG_WINDOW_CONFIGURATION;
+        @NonNull
+        private final Configuration mConfiguration;
+        @NonNull
+        private final DividerAttributes mDividerAttributes;
+        @NonNull
+        private final SurfaceControl mDecorSurface;
+
+        /** The initial position of the divider calculated based on container bounds. */
+        private final int mInitialDividerPosition;
+
+        /** Whether the split is vertical, such as left-to-right or right-to-left split. */
+        private final boolean mIsVerticalSplit;
+
+        private final int mDisplayId;
+
+        @VisibleForTesting
+        Properties(
+                @NonNull Configuration configuration,
+                @NonNull DividerAttributes dividerAttributes,
+                @NonNull SurfaceControl decorSurface,
+                int initialDividerPosition,
+                boolean isVerticalSplit,
+                int displayId) {
+            mConfiguration = configuration;
+            mDividerAttributes = dividerAttributes;
+            mDecorSurface = decorSurface;
+            mInitialDividerPosition = initialDividerPosition;
+            mIsVerticalSplit = isVerticalSplit;
+            mDisplayId = displayId;
+        }
+
+        /**
+         * Compares whether two Properties objects are equal for rendering the divider. The
+         * Configuration is checked for rendering related fields, and other fields are checked for
+         * regular equality.
+         */
+        private static boolean equalsForDivider(@Nullable Properties a, @Nullable Properties b) {
+            if (a == b) {
+                return true;
+            }
+            if (a == null || b == null) {
+                return false;
+            }
+            return areSameSurfaces(a.mDecorSurface, b.mDecorSurface)
+                    && Objects.equals(a.mDividerAttributes, b.mDividerAttributes)
+                    && areConfigurationsEqualForDivider(a.mConfiguration, b.mConfiguration)
+                    && a.mInitialDividerPosition == b.mInitialDividerPosition
+                    && a.mIsVerticalSplit == b.mIsVerticalSplit
+                    && a.mDisplayId == b.mDisplayId;
+        }
+
+        private static boolean areSameSurfaces(
+                @Nullable SurfaceControl sc1, @Nullable SurfaceControl sc2) {
+            if (sc1 == sc2) {
+                // If both are null or both refer to the same object.
+                return true;
+            }
+            if (sc1 == null || sc2 == null) {
+                return false;
+            }
+            return sc1.isSameSurface(sc2);
+        }
+
+        private static boolean areConfigurationsEqualForDivider(
+                @NonNull Configuration a, @NonNull Configuration b) {
+            final int diff = a.diff(b);
+            return (diff & CONFIGURATION_MASK_FOR_DIVIDER) == 0;
+        }
+    }
+
+    /**
+     * Handles the rendering of the divider. When the decor surface is updated, the renderer is
+     * recreated. When other fields in the Properties are changed, the renderer is updated.
+     */
+    @VisibleForTesting
+    class Renderer {
+        @NonNull
+        private final SurfaceControl mDividerSurface;
+        @NonNull
+        private final WindowlessWindowManager mWindowlessWindowManager;
+        @NonNull
+        private final SurfaceControlViewHost mViewHost;
+        @NonNull
+        private final FrameLayout mDividerLayout;
+        private final int mDividerWidthPx;
+
+        private Renderer() {
+            mDividerWidthPx = getDividerWidthPx(mProperties.mDividerAttributes);
+
+            mDividerSurface = createChildSurface("DividerSurface", true /* visible */);
+            mWindowlessWindowManager = new WindowlessWindowManager(
+                    mProperties.mConfiguration,
+                    mDividerSurface,
+                    new InputTransferToken());
+
+            final Context context = ActivityThread.currentActivityThread().getApplication();
+            final DisplayManager displayManager = context.getSystemService(DisplayManager.class);
+            mViewHost = new SurfaceControlViewHost(
+                    context, displayManager.getDisplay(mProperties.mDisplayId),
+                    mWindowlessWindowManager, "DividerContainer");
+            mDividerLayout = new FrameLayout(context);
+
+            update();
+        }
+
+        /** Updates the divider when properties are changed */
+        @VisibleForTesting
+        void update() {
+            mWindowlessWindowManager.setConfiguration(mProperties.mConfiguration);
+            updateSurface();
+            updateLayout();
+            updateDivider();
+        }
+
+        @VisibleForTesting
+        void release() {
+            mViewHost.release();
+            // TODO handle synchronization between surface transactions and WCT.
+            new SurfaceControl.Transaction().remove(mDividerSurface).apply();
+            safeReleaseSurfaceControl(mDividerSurface);
+        }
+
+        private void updateSurface() {
+            final Rect taskBounds = mProperties.mConfiguration.windowConfiguration.getBounds();
+            // TODO handle synchronization between surface transactions and WCT.
+            final SurfaceControl.Transaction t = new SurfaceControl.Transaction();
+            if (mProperties.mIsVerticalSplit) {
+                t.setPosition(mDividerSurface, mProperties.mInitialDividerPosition, 0.0f);
+                t.setWindowCrop(mDividerSurface, mDividerWidthPx, taskBounds.height());
+            } else {
+                t.setPosition(mDividerSurface, 0.0f, mProperties.mInitialDividerPosition);
+                t.setWindowCrop(mDividerSurface, taskBounds.width(), mDividerWidthPx);
+            }
+            t.apply();
+        }
+
+        private void updateLayout() {
+            final Rect taskBounds = mProperties.mConfiguration.windowConfiguration.getBounds();
+            final WindowManager.LayoutParams lp = mProperties.mIsVerticalSplit
+                    ? new WindowManager.LayoutParams(
+                            mDividerWidthPx,
+                            taskBounds.height(),
+                            TYPE_APPLICATION_PANEL,
+                            FLAG_NOT_FOCUSABLE | FLAG_NOT_TOUCH_MODAL | FLAG_SLIPPERY,
+                            PixelFormat.TRANSLUCENT)
+                    : new WindowManager.LayoutParams(
+                            taskBounds.width(),
+                            mDividerWidthPx,
+                            TYPE_APPLICATION_PANEL,
+                            FLAG_NOT_FOCUSABLE | FLAG_NOT_TOUCH_MODAL | FLAG_SLIPPERY,
+                            PixelFormat.TRANSLUCENT);
+            lp.setTitle(WINDOW_NAME);
+            mViewHost.setView(mDividerLayout, lp);
+        }
+
+        private void updateDivider() {
+            mDividerLayout.removeAllViews();
+            mDividerLayout.setBackgroundColor(DEFAULT_DIVIDER_COLOR.toArgb());
+            if (mProperties.mDividerAttributes.getDividerType()
+                    == DividerAttributes.DIVIDER_TYPE_DRAGGABLE) {
+                drawDragHandle();
+            }
+            mViewHost.getView().invalidate();
+        }
+
+        private void drawDragHandle() {
+            final Context context = mDividerLayout.getContext();
+            final ImageButton button = new ImageButton(context);
+            final FrameLayout.LayoutParams params = mProperties.mIsVerticalSplit
+                    ? new FrameLayout.LayoutParams(
+                            context.getResources().getDimensionPixelSize(
+                                    R.dimen.activity_embedding_divider_touch_target_width),
+                            context.getResources().getDimensionPixelSize(
+                                    R.dimen.activity_embedding_divider_touch_target_height))
+                    : new FrameLayout.LayoutParams(
+                            context.getResources().getDimensionPixelSize(
+                                    R.dimen.activity_embedding_divider_touch_target_height),
+                            context.getResources().getDimensionPixelSize(
+                                    R.dimen.activity_embedding_divider_touch_target_width));
+            params.gravity = Gravity.CENTER;
+            button.setLayoutParams(params);
+            button.setBackgroundColor(R.color.transparent);
+
+            final Drawable handle =  context.getResources().getDrawable(
+                    R.drawable.activity_embedding_divider_handle, context.getTheme());
+            if (mProperties.mIsVerticalSplit) {
+                button.setImageDrawable(handle);
+            } else {
+                // Rotate the handle drawable
+                RotateDrawable rotatedHandle = new RotateDrawable();
+                rotatedHandle.setFromDegrees(90f);
+                rotatedHandle.setToDegrees(90f);
+                rotatedHandle.setPivotXRelative(true);
+                rotatedHandle.setPivotYRelative(true);
+                rotatedHandle.setPivotX(0.5f);
+                rotatedHandle.setPivotY(0.5f);
+                rotatedHandle.setLevel(1);
+                rotatedHandle.setDrawable(handle);
+
+                button.setImageDrawable(rotatedHandle);
+            }
+            mDividerLayout.addView(button);
+        }
+
+        @NonNull
+        private SurfaceControl createChildSurface(@NonNull String name, boolean visible) {
+            final Rect bounds = mProperties.mConfiguration.windowConfiguration.getBounds();
+            return new SurfaceControl.Builder()
+                    .setParent(mProperties.mDecorSurface)
+                    .setName(name)
+                    .setHidden(!visible)
+                    .setCallsite("DividerManager.createChildSurface")
+                    .setBufferSize(bounds.width(), bounds.height())
+                    .setColorLayer()
+                    .build();
+        }
+    }
 }
diff --git a/libs/WindowManager/Jetpack/src/androidx/window/extensions/embedding/JetpackTaskFragmentOrganizer.java b/libs/WindowManager/Jetpack/src/androidx/window/extensions/embedding/JetpackTaskFragmentOrganizer.java
index 80afb16d..3f4dddf 100644
--- a/libs/WindowManager/Jetpack/src/androidx/window/extensions/embedding/JetpackTaskFragmentOrganizer.java
+++ b/libs/WindowManager/Jetpack/src/androidx/window/extensions/embedding/JetpackTaskFragmentOrganizer.java
@@ -168,11 +168,14 @@
      * @param fragmentToken token of an existing TaskFragment.
      */
     void expandTaskFragment(@NonNull WindowContainerTransaction wct,
-            @NonNull IBinder fragmentToken) {
+            @NonNull TaskFragmentContainer container) {
+        final IBinder fragmentToken = container.getTaskFragmentToken();
         resizeTaskFragment(wct, fragmentToken, new Rect());
         clearAdjacentTaskFragments(wct, fragmentToken);
         updateWindowingMode(wct, fragmentToken, WINDOWING_MODE_UNDEFINED);
         updateAnimationParams(wct, fragmentToken, TaskFragmentAnimationParams.DEFAULT);
+
+        container.getTaskContainer().updateDivider(wct);
     }
 
     /**
diff --git a/libs/WindowManager/Jetpack/src/androidx/window/extensions/embedding/SplitController.java b/libs/WindowManager/Jetpack/src/androidx/window/extensions/embedding/SplitController.java
index 1abda42..cf29877 100644
--- a/libs/WindowManager/Jetpack/src/androidx/window/extensions/embedding/SplitController.java
+++ b/libs/WindowManager/Jetpack/src/androidx/window/extensions/embedding/SplitController.java
@@ -844,6 +844,7 @@
         // Checks if container should be updated before apply new parentInfo.
         final boolean shouldUpdateContainer = taskContainer.shouldUpdateContainer(parentInfo);
         taskContainer.updateTaskFragmentParentInfo(parentInfo);
+        taskContainer.updateDivider(wct);
 
         // If the last direct activity of the host task is dismissed and the overlay container is
         // the only taskFragment, the overlay container should also be dismissed.
@@ -1224,7 +1225,7 @@
         final TaskFragmentContainer container = getContainerWithActivity(activity);
         if (shouldContainerBeExpanded(container)) {
             // Make sure that the existing container is expanded.
-            mPresenter.expandTaskFragment(wct, container.getTaskFragmentToken());
+            mPresenter.expandTaskFragment(wct, container);
         } else {
             // Put activity into a new expanded container.
             final TaskFragmentContainer newContainer = newContainer(activity, getTaskId(activity));
@@ -1928,7 +1929,7 @@
         }
         if (shouldContainerBeExpanded(container)) {
             if (container.getInfo() != null) {
-                mPresenter.expandTaskFragment(wct, container.getTaskFragmentToken());
+                mPresenter.expandTaskFragment(wct, container);
             }
             // If the info is not available yet the task fragment will be expanded when it's ready
             return;
diff --git a/libs/WindowManager/Jetpack/src/androidx/window/extensions/embedding/SplitPresenter.java b/libs/WindowManager/Jetpack/src/androidx/window/extensions/embedding/SplitPresenter.java
index f680694..20bc820 100644
--- a/libs/WindowManager/Jetpack/src/androidx/window/extensions/embedding/SplitPresenter.java
+++ b/libs/WindowManager/Jetpack/src/androidx/window/extensions/embedding/SplitPresenter.java
@@ -368,6 +368,7 @@
         updateTaskFragmentWindowingModeIfRegistered(wct, secondaryContainer, windowingMode);
         updateAnimationParams(wct, primaryContainer.getTaskFragmentToken(), splitAttributes);
         updateAnimationParams(wct, secondaryContainer.getTaskFragmentToken(), splitAttributes);
+        taskContainer.updateDivider(wct);
     }
 
     private void setAdjacentTaskFragments(@NonNull WindowContainerTransaction wct,
@@ -686,8 +687,8 @@
                     splitContainer.getPrimaryContainer().getTaskFragmentToken();
             final IBinder secondaryToken =
                     splitContainer.getSecondaryContainer().getTaskFragmentToken();
-            expandTaskFragment(wct, primaryToken);
-            expandTaskFragment(wct, secondaryToken);
+            expandTaskFragment(wct, splitContainer.getPrimaryContainer());
+            expandTaskFragment(wct, splitContainer.getSecondaryContainer());
             // Set the companion TaskFragment when the two containers stacked.
             setCompanionTaskFragment(wct, primaryToken, secondaryToken,
                     splitContainer.getSplitRule(), true /* isStacked */);
diff --git a/libs/WindowManager/Jetpack/src/androidx/window/extensions/embedding/TaskContainer.java b/libs/WindowManager/Jetpack/src/androidx/window/extensions/embedding/TaskContainer.java
index 73109e2..e75a317 100644
--- a/libs/WindowManager/Jetpack/src/androidx/window/extensions/embedding/TaskContainer.java
+++ b/libs/WindowManager/Jetpack/src/androidx/window/extensions/embedding/TaskContainer.java
@@ -77,6 +77,9 @@
 
     private boolean mHasDirectActivity;
 
+    @Nullable
+    private TaskFragmentParentInfo mTaskFragmentParentInfo;
+
     /**
      * TaskFragments that the organizer has requested to be closed. They should be removed when
      * the organizer receives
@@ -85,14 +88,17 @@
      */
     final Set<IBinder> mFinishedContainer = new ArraySet<>();
 
+    // TODO(b/293654166): move DividerPresenter to SplitController.
+    @NonNull
+    final DividerPresenter mDividerPresenter;
+
     /**
      * The {@link TaskContainer} constructor
      *
-     * @param taskId The ID of the Task, which must match {@link Activity#getTaskId()} with
-     *               {@code activityInTask}.
+     * @param taskId         The ID of the Task, which must match {@link Activity#getTaskId()} with
+     *                       {@code activityInTask}.
      * @param activityInTask The {@link Activity} in the Task with {@code taskId}. It is used to
      *                       initialize the {@link TaskContainer} properties.
-     *
      */
     TaskContainer(int taskId, @NonNull Activity activityInTask) {
         if (taskId == INVALID_TASK_ID) {
@@ -107,6 +113,7 @@
         // the host task is visible and has an activity in the task.
         mIsVisible = true;
         mHasDirectActivity = true;
+        mDividerPresenter = new DividerPresenter();
     }
 
     int getTaskId() {
@@ -136,10 +143,12 @@
     }
 
     void updateTaskFragmentParentInfo(@NonNull TaskFragmentParentInfo info) {
+        // TODO(b/293654166): cache the TaskFragmentParentInfo and remove these fields.
         mConfiguration.setTo(info.getConfiguration());
         mDisplayId = info.getDisplayId();
         mIsVisible = info.isVisible();
         mHasDirectActivity = info.hasDirectActivity();
+        mTaskFragmentParentInfo = info;
     }
 
     /**
@@ -161,8 +170,8 @@
      * Returns the windowing mode for the TaskFragments below this Task, which should be split with
      * other TaskFragments.
      *
-     * @param taskFragmentBounds    Requested bounds for the TaskFragment. It will be empty when
-     *                              the pair of TaskFragments are stacked due to the limited space.
+     * @param taskFragmentBounds Requested bounds for the TaskFragment. It will be empty when
+     *                           the pair of TaskFragments are stacked due to the limited space.
      */
     @WindowingMode
     int getWindowingModeForTaskFragment(@Nullable Rect taskFragmentBounds) {
@@ -228,7 +237,7 @@
 
     @Nullable
     TaskFragmentContainer getTopNonFinishingTaskFragmentContainer(boolean includePin,
-                                                                  boolean includeOverlay) {
+            boolean includeOverlay) {
         for (int i = mContainers.size() - 1; i >= 0; i--) {
             final TaskFragmentContainer container = mContainers.get(i);
             if (!includePin && isTaskFragmentContainerPinned(container)) {
@@ -283,7 +292,7 @@
         return mContainers.indexOf(child);
     }
 
-    /** Whether the Task is in an intermediate state waiting for the server update.*/
+    /** Whether the Task is in an intermediate state waiting for the server update. */
     boolean isInIntermediateState() {
         for (TaskFragmentContainer container : mContainers) {
             if (container.isInIntermediateState()) {
@@ -389,6 +398,26 @@
         return mContainers;
     }
 
+    void updateDivider(@NonNull WindowContainerTransaction wct) {
+        if (mTaskFragmentParentInfo != null) {
+            // Update divider only if TaskFragmentParentInfo is available.
+            mDividerPresenter.updateDivider(
+                    wct, mTaskFragmentParentInfo, getTopNonFinishingSplitContainer());
+        }
+    }
+
+    @Nullable
+    private SplitContainer getTopNonFinishingSplitContainer() {
+        for (int i = mSplitContainers.size() - 1; i >= 0; i--) {
+            final SplitContainer splitContainer = mSplitContainers.get(i);
+            if (!splitContainer.getPrimaryContainer().isFinished()
+                    && !splitContainer.getSecondaryContainer().isFinished()) {
+                return splitContainer;
+            }
+        }
+        return null;
+    }
+
     private void onTaskFragmentContainerUpdated() {
         // TODO(b/300211704): Find a better mechanism to handle the z-order in case we introduce
         //  another special container that should also be on top in the future.
diff --git a/libs/WindowManager/Jetpack/src/androidx/window/extensions/embedding/TaskFragmentContainer.java b/libs/WindowManager/Jetpack/src/androidx/window/extensions/embedding/TaskFragmentContainer.java
index a6bf99d..e20a3e0 100644
--- a/libs/WindowManager/Jetpack/src/androidx/window/extensions/embedding/TaskFragmentContainer.java
+++ b/libs/WindowManager/Jetpack/src/androidx/window/extensions/embedding/TaskFragmentContainer.java
@@ -748,6 +748,10 @@
         }
     }
 
+    @NonNull Rect getLastRequestedBounds() {
+        return mLastRequestedBounds;
+    }
+
     /**
      * Checks if last requested windowing mode is equal to the provided value.
      * @see WindowContainerTransaction#setWindowingMode
diff --git a/libs/WindowManager/Jetpack/tests/unittest/src/androidx/window/extensions/embedding/DividerPresenterTest.java b/libs/WindowManager/Jetpack/tests/unittest/src/androidx/window/extensions/embedding/DividerPresenterTest.java
index 2a277f4..4d1d807 100644
--- a/libs/WindowManager/Jetpack/tests/unittest/src/androidx/window/extensions/embedding/DividerPresenterTest.java
+++ b/libs/WindowManager/Jetpack/tests/unittest/src/androidx/window/extensions/embedding/DividerPresenterTest.java
@@ -16,22 +16,49 @@
 
 package androidx.window.extensions.embedding;
 
+import static android.window.TaskFragmentOperation.OP_TYPE_CREATE_OR_MOVE_TASK_FRAGMENT_DECOR_SURFACE;
+import static android.window.TaskFragmentOperation.OP_TYPE_REMOVE_TASK_FRAGMENT_DECOR_SURFACE;
+
 import static androidx.window.extensions.embedding.DividerPresenter.getBoundsOffsetForDivider;
+import static androidx.window.extensions.embedding.DividerPresenter.getInitialDividerPosition;
 import static androidx.window.extensions.embedding.SplitPresenter.CONTAINER_POSITION_BOTTOM;
 import static androidx.window.extensions.embedding.SplitPresenter.CONTAINER_POSITION_LEFT;
 import static androidx.window.extensions.embedding.SplitPresenter.CONTAINER_POSITION_RIGHT;
 import static androidx.window.extensions.embedding.SplitPresenter.CONTAINER_POSITION_TOP;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertNull;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
 
+import android.content.res.Configuration;
+import android.graphics.Rect;
+import android.os.Binder;
+import android.os.IBinder;
 import android.platform.test.annotations.Presubmit;
+import android.platform.test.flag.junit.SetFlagsRule;
+import android.view.Display;
+import android.view.SurfaceControl;
+import android.window.TaskFragmentOperation;
+import android.window.TaskFragmentParentInfo;
+import android.window.WindowContainerTransaction;
 
 import androidx.annotation.NonNull;
 import androidx.test.ext.junit.runners.AndroidJUnit4;
 import androidx.test.filters.SmallTest;
 
+import com.android.window.flags.Flags;
+
+import org.junit.Before;
+import org.junit.Rule;
 import org.junit.Test;
 import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
 
 /**
  * Test class for {@link DividerPresenter}.
@@ -43,6 +70,167 @@
 @SmallTest
 @RunWith(AndroidJUnit4.class)
 public class DividerPresenterTest {
+    @Rule
+    public final SetFlagsRule mSetFlagRule = new SetFlagsRule();
+
+    @Mock
+    private DividerPresenter.Renderer mRenderer;
+
+    @Mock
+    private WindowContainerTransaction mTransaction;
+
+    @Mock
+    private TaskFragmentParentInfo mParentInfo;
+
+    @Mock
+    private SplitContainer mSplitContainer;
+
+    @Mock
+    private SurfaceControl mSurfaceControl;
+
+    private DividerPresenter mDividerPresenter;
+
+    private final IBinder mPrimaryContainerToken = new Binder();
+
+    private final IBinder mSecondaryContainerToken = new Binder();
+
+    private final IBinder mAnotherContainerToken = new Binder();
+
+    private DividerPresenter.Properties mProperties;
+
+    private static final DividerAttributes DEFAULT_DIVIDER_ATTRIBUTES =
+            new DividerAttributes.Builder(DividerAttributes.DIVIDER_TYPE_DRAGGABLE).build();
+
+    private static final DividerAttributes ANOTHER_DIVIDER_ATTRIBUTES =
+            new DividerAttributes.Builder(DividerAttributes.DIVIDER_TYPE_DRAGGABLE)
+                    .setWidthDp(10).build();
+
+    @Before
+    public void setUp() {
+        MockitoAnnotations.initMocks(this);
+        mSetFlagRule.enableFlags(Flags.FLAG_ACTIVITY_EMBEDDING_INTERACTIVE_DIVIDER_FLAG);
+
+        when(mParentInfo.getDisplayId()).thenReturn(Display.DEFAULT_DISPLAY);
+        when(mParentInfo.getConfiguration()).thenReturn(new Configuration());
+        when(mParentInfo.getDecorSurface()).thenReturn(mSurfaceControl);
+
+        when(mSplitContainer.getCurrentSplitAttributes()).thenReturn(
+                new SplitAttributes.Builder()
+                        .setDividerAttributes(DEFAULT_DIVIDER_ATTRIBUTES)
+                        .build());
+        final TaskFragmentContainer mockPrimaryContainer =
+                createMockTaskFragmentContainer(
+                        mPrimaryContainerToken, new Rect(0, 0, 950, 1000));
+        final TaskFragmentContainer mockSecondaryContainer =
+                createMockTaskFragmentContainer(
+                        mSecondaryContainerToken, new Rect(1000, 0, 2000, 1000));
+        when(mSplitContainer.getPrimaryContainer()).thenReturn(mockPrimaryContainer);
+        when(mSplitContainer.getSecondaryContainer()).thenReturn(mockSecondaryContainer);
+
+        mProperties = new DividerPresenter.Properties(
+                new Configuration(),
+                DEFAULT_DIVIDER_ATTRIBUTES,
+                mSurfaceControl,
+                getInitialDividerPosition(mSplitContainer),
+                true /* isVerticalSplit */,
+                Display.DEFAULT_DISPLAY);
+
+        mDividerPresenter = new DividerPresenter();
+        mDividerPresenter.mProperties = mProperties;
+        mDividerPresenter.mRenderer = mRenderer;
+        mDividerPresenter.mDecorSurfaceOwner = mPrimaryContainerToken;
+    }
+
+    @Test
+    public void testUpdateDivider() {
+        when(mSplitContainer.getCurrentSplitAttributes()).thenReturn(
+                new SplitAttributes.Builder()
+                        .setDividerAttributes(ANOTHER_DIVIDER_ATTRIBUTES)
+                        .build());
+        mDividerPresenter.updateDivider(
+                mTransaction,
+                mParentInfo,
+                mSplitContainer);
+
+        assertNotEquals(mProperties, mDividerPresenter.mProperties);
+        verify(mRenderer).update();
+        verify(mTransaction, never()).addTaskFragmentOperation(any(), any());
+    }
+
+    @Test
+    public void testUpdateDivider_updateDecorSurfaceOwnerIfPrimaryContainerChanged() {
+        final TaskFragmentContainer mockPrimaryContainer =
+                createMockTaskFragmentContainer(
+                        mAnotherContainerToken, new Rect(0, 0, 750, 1000));
+        final TaskFragmentContainer mockSecondaryContainer =
+                createMockTaskFragmentContainer(
+                        mSecondaryContainerToken, new Rect(800, 0, 2000, 1000));
+        when(mSplitContainer.getPrimaryContainer()).thenReturn(mockPrimaryContainer);
+        when(mSplitContainer.getSecondaryContainer()).thenReturn(mockSecondaryContainer);
+        mDividerPresenter.updateDivider(
+                mTransaction,
+                mParentInfo,
+                mSplitContainer);
+
+        assertNotEquals(mProperties, mDividerPresenter.mProperties);
+        verify(mRenderer).update();
+        final TaskFragmentOperation operation = new TaskFragmentOperation.Builder(
+                OP_TYPE_CREATE_OR_MOVE_TASK_FRAGMENT_DECOR_SURFACE)
+                .build();
+        assertEquals(mAnotherContainerToken, mDividerPresenter.mDecorSurfaceOwner);
+        verify(mTransaction).addTaskFragmentOperation(mAnotherContainerToken, operation);
+    }
+
+    @Test
+    public void testUpdateDivider_noChangeIfPropertiesIdentical() {
+        mDividerPresenter.updateDivider(
+                mTransaction,
+                mParentInfo,
+                mSplitContainer);
+
+        assertEquals(mProperties, mDividerPresenter.mProperties);
+        verify(mRenderer, never()).update();
+        verify(mTransaction, never()).addTaskFragmentOperation(any(), any());
+    }
+
+    @Test
+    public void testUpdateDivider_dividerRemovedWhenSplitContainerIsNull() {
+        mDividerPresenter.updateDivider(
+                mTransaction,
+                mParentInfo,
+                null /* splitContainer */);
+        final TaskFragmentOperation taskFragmentOperation = new TaskFragmentOperation.Builder(
+                OP_TYPE_REMOVE_TASK_FRAGMENT_DECOR_SURFACE)
+                .build();
+
+        verify(mTransaction).addTaskFragmentOperation(
+                mPrimaryContainerToken, taskFragmentOperation);
+        verify(mRenderer).release();
+        assertNull(mDividerPresenter.mRenderer);
+        assertNull(mDividerPresenter.mProperties);
+        assertNull(mDividerPresenter.mDecorSurfaceOwner);
+    }
+
+    @Test
+    public void testUpdateDivider_dividerRemovedWhenDividerAttributesIsNull() {
+        when(mSplitContainer.getCurrentSplitAttributes()).thenReturn(
+                new SplitAttributes.Builder().setDividerAttributes(null).build());
+        mDividerPresenter.updateDivider(
+                mTransaction,
+                mParentInfo,
+                mSplitContainer);
+        final TaskFragmentOperation taskFragmentOperation = new TaskFragmentOperation.Builder(
+                OP_TYPE_REMOVE_TASK_FRAGMENT_DECOR_SURFACE)
+                .build();
+
+        verify(mTransaction).addTaskFragmentOperation(
+                mPrimaryContainerToken, taskFragmentOperation);
+        verify(mRenderer).release();
+        assertNull(mDividerPresenter.mRenderer);
+        assertNull(mDividerPresenter.mProperties);
+        assertNull(mDividerPresenter.mDecorSurfaceOwner);
+    }
+
     @Test
     public void testSanitizeDividerAttributes_setDefaultValues() {
         DividerAttributes attributes =
@@ -61,7 +249,7 @@
     public void testSanitizeDividerAttributes_notChangingValidValues() {
         DividerAttributes attributes =
                 new DividerAttributes.Builder(DividerAttributes.DIVIDER_TYPE_DRAGGABLE)
-                        .setWidthDp(10)
+                        .setWidthDp(24)
                         .setPrimaryMinRatio(0.3f)
                         .setPrimaryMaxRatio(0.7f)
                         .build();
@@ -123,6 +311,14 @@
                 dividerWidthPx, splitType, expectedTopLeftOffset, expectedBottomRightOffset);
     }
 
+    private TaskFragmentContainer createMockTaskFragmentContainer(
+            @NonNull IBinder token, @NonNull Rect bounds) {
+        final TaskFragmentContainer container = mock(TaskFragmentContainer.class);
+        when(container.getTaskFragmentToken()).thenReturn(token);
+        when(container.getLastRequestedBounds()).thenReturn(bounds);
+        return container;
+    }
+
     private void assertDividerOffsetEquals(
             int dividerWidthPx,
             @NonNull SplitAttributes.SplitType splitType,
diff --git a/libs/WindowManager/Jetpack/tests/unittest/src/androidx/window/extensions/embedding/JetpackTaskFragmentOrganizerTest.java b/libs/WindowManager/Jetpack/tests/unittest/src/androidx/window/extensions/embedding/JetpackTaskFragmentOrganizerTest.java
index dd087e8..6f37e9c 100644
--- a/libs/WindowManager/Jetpack/tests/unittest/src/androidx/window/extensions/embedding/JetpackTaskFragmentOrganizerTest.java
+++ b/libs/WindowManager/Jetpack/tests/unittest/src/androidx/window/extensions/embedding/JetpackTaskFragmentOrganizerTest.java
@@ -107,7 +107,7 @@
         mOrganizer.mFragmentInfos.put(container.getTaskFragmentToken(), info);
         container.setInfo(mTransaction, info);
 
-        mOrganizer.expandTaskFragment(mTransaction, container.getTaskFragmentToken());
+        mOrganizer.expandTaskFragment(mTransaction, container);
 
         verify(mTransaction).setWindowingMode(container.getInfo().getToken(),
                 WINDOWING_MODE_UNDEFINED);
diff --git a/libs/WindowManager/Jetpack/tests/unittest/src/androidx/window/extensions/embedding/SplitControllerTest.java b/libs/WindowManager/Jetpack/tests/unittest/src/androidx/window/extensions/embedding/SplitControllerTest.java
index cdb37ac..c246a19 100644
--- a/libs/WindowManager/Jetpack/tests/unittest/src/androidx/window/extensions/embedding/SplitControllerTest.java
+++ b/libs/WindowManager/Jetpack/tests/unittest/src/androidx/window/extensions/embedding/SplitControllerTest.java
@@ -642,7 +642,7 @@
                 false /* isOnReparent */);
 
         assertTrue(result);
-        verify(mSplitPresenter).expandTaskFragment(mTransaction, container.getTaskFragmentToken());
+        verify(mSplitPresenter).expandTaskFragment(mTransaction, container);
     }
 
     @Test
diff --git a/libs/WindowManager/Jetpack/tests/unittest/src/androidx/window/extensions/embedding/SplitPresenterTest.java b/libs/WindowManager/Jetpack/tests/unittest/src/androidx/window/extensions/embedding/SplitPresenterTest.java
index 941b4e1..62d8aa3 100644
--- a/libs/WindowManager/Jetpack/tests/unittest/src/androidx/window/extensions/embedding/SplitPresenterTest.java
+++ b/libs/WindowManager/Jetpack/tests/unittest/src/androidx/window/extensions/embedding/SplitPresenterTest.java
@@ -665,8 +665,8 @@
 
         assertEquals(RESULT_EXPANDED, mPresenter.expandSplitContainerIfNeeded(mTransaction,
                 splitContainer, mActivity, secondaryActivity, null /* secondaryIntent */));
-        verify(mPresenter).expandTaskFragment(mTransaction, primaryTf.getTaskFragmentToken());
-        verify(mPresenter).expandTaskFragment(mTransaction, secondaryTf.getTaskFragmentToken());
+        verify(mPresenter).expandTaskFragment(mTransaction, primaryTf);
+        verify(mPresenter).expandTaskFragment(mTransaction, secondaryTf);
 
         splitContainer.updateCurrentSplitAttributes(SPLIT_ATTRIBUTES);
         clearInvocations(mPresenter);
@@ -675,8 +675,8 @@
                 splitContainer, mActivity, null /* secondaryActivity */,
                 new Intent(ApplicationProvider.getApplicationContext(),
                         MinimumDimensionActivity.class)));
-        verify(mPresenter).expandTaskFragment(mTransaction, primaryTf.getTaskFragmentToken());
-        verify(mPresenter).expandTaskFragment(mTransaction, secondaryTf.getTaskFragmentToken());
+        verify(mPresenter).expandTaskFragment(mTransaction, primaryTf);
+        verify(mPresenter).expandTaskFragment(mTransaction, secondaryTf);
     }
 
     @Test
diff --git a/services/core/java/com/android/server/wm/Task.java b/services/core/java/com/android/server/wm/Task.java
index 55dc30c..5019c8b 100644
--- a/services/core/java/com/android/server/wm/Task.java
+++ b/services/core/java/com/android/server/wm/Task.java
@@ -6823,8 +6823,8 @@
      * A decor surface is requested by a {@link TaskFragmentOrganizer} and is placed below children
      * windows in the Task except for own Activities and TaskFragments in fully trusted mode. The
      * decor surface is created and shared with the client app with
-     * {@link android.window.TaskFragmentOperation#OP_TYPE_CREATE_TASK_FRAGMENT_DECOR_SURFACE} and
-     * be removed with
+     * {@link android.window.TaskFragmentOperation#OP_TYPE_CREATE_OR_MOVE_TASK_FRAGMENT_DECOR_SURFACE}
+     * and be removed with
      * {@link android.window.TaskFragmentOperation#OP_TYPE_REMOVE_TASK_FRAGMENT_DECOR_SURFACE}.
      *
      * When boosted with
diff --git a/services/core/java/com/android/server/wm/WindowOrganizerController.java b/services/core/java/com/android/server/wm/WindowOrganizerController.java
index d967cde..14ec41f 100644
--- a/services/core/java/com/android/server/wm/WindowOrganizerController.java
+++ b/services/core/java/com/android/server/wm/WindowOrganizerController.java
@@ -23,7 +23,7 @@
 import static android.view.Display.DEFAULT_DISPLAY;
 import static android.window.TaskFragmentOperation.OP_TYPE_CLEAR_ADJACENT_TASK_FRAGMENTS;
 import static android.window.TaskFragmentOperation.OP_TYPE_CREATE_TASK_FRAGMENT;
-import static android.window.TaskFragmentOperation.OP_TYPE_CREATE_TASK_FRAGMENT_DECOR_SURFACE;
+import static android.window.TaskFragmentOperation.OP_TYPE_CREATE_OR_MOVE_TASK_FRAGMENT_DECOR_SURFACE;
 import static android.window.TaskFragmentOperation.OP_TYPE_DELETE_TASK_FRAGMENT;
 import static android.window.TaskFragmentOperation.OP_TYPE_REMOVE_TASK_FRAGMENT_DECOR_SURFACE;
 import static android.window.TaskFragmentOperation.OP_TYPE_REORDER_TO_BOTTOM_OF_TASK;
@@ -1558,7 +1558,7 @@
                 }
                 break;
             }
-            case OP_TYPE_CREATE_TASK_FRAGMENT_DECOR_SURFACE: {
+            case OP_TYPE_CREATE_OR_MOVE_TASK_FRAGMENT_DECOR_SURFACE: {
                 taskFragment.getTask().moveOrCreateDecorSurfaceFor(taskFragment);
                 break;
             }
diff --git a/services/tests/wmtests/src/com/android/server/wm/TaskFragmentOrganizerControllerTest.java b/services/tests/wmtests/src/com/android/server/wm/TaskFragmentOrganizerControllerTest.java
index 897a3da..52485ee 100644
--- a/services/tests/wmtests/src/com/android/server/wm/TaskFragmentOrganizerControllerTest.java
+++ b/services/tests/wmtests/src/com/android/server/wm/TaskFragmentOrganizerControllerTest.java
@@ -25,7 +25,7 @@
 import static android.view.WindowManager.TRANSIT_NONE;
 import static android.view.WindowManager.TRANSIT_OPEN;
 import static android.window.TaskFragmentOperation.OP_TYPE_CREATE_TASK_FRAGMENT;
-import static android.window.TaskFragmentOperation.OP_TYPE_CREATE_TASK_FRAGMENT_DECOR_SURFACE;
+import static android.window.TaskFragmentOperation.OP_TYPE_CREATE_OR_MOVE_TASK_FRAGMENT_DECOR_SURFACE;
 import static android.window.TaskFragmentOperation.OP_TYPE_DELETE_TASK_FRAGMENT;
 import static android.window.TaskFragmentOperation.OP_TYPE_REMOVE_TASK_FRAGMENT_DECOR_SURFACE;
 import static android.window.TaskFragmentOperation.OP_TYPE_REORDER_TO_BOTTOM_OF_TASK;
@@ -1835,7 +1835,7 @@
 
         final TaskFragment tf = createTaskFragment(task);
         final TaskFragmentOperation operation = new TaskFragmentOperation.Builder(
-                OP_TYPE_CREATE_TASK_FRAGMENT_DECOR_SURFACE).build();
+                OP_TYPE_CREATE_OR_MOVE_TASK_FRAGMENT_DECOR_SURFACE).build();
         mTransaction.addTaskFragmentOperation(tf.getFragmentToken(), operation);
 
         assertApplyTransactionAllowed(mTransaction);