Loading core/java/android/window/TaskFragmentCreationParams.java +62 −3 Original line number Diff line number Diff line Loading @@ -52,10 +52,26 @@ public final class TaskFragmentCreationParams implements Parcelable { @NonNull private final IBinder mOwnerToken; /** The initial bounds of the TaskFragment. Fills parent if empty. */ /** * The initial bounds of the TaskFragment. Fills parent if empty. * TODO(b/232476698): cleanup with update CTS. */ @NonNull private final Rect mInitialBounds = new Rect(); /** * The initial relative bounds of the TaskFragment in parent coordinate. * Fills parent if empty. */ @NonNull private final Rect mInitialRelativeBounds = new Rect(); /** * Whether the params are using {@link Builder#setInitialRelativeBounds(Rect)}. * TODO(b/232476698): remove after remove mInitialBounds */ private final boolean mAreInitialRelativeBoundsSet; /** The initial windowing mode of the TaskFragment. Inherits from parent if not set. */ @WindowingMode private final int mWindowingMode; Loading Loading @@ -94,6 +110,7 @@ public final class TaskFragmentCreationParams implements Parcelable { private TaskFragmentCreationParams( @NonNull TaskFragmentOrganizerToken organizer, @NonNull IBinder fragmentToken, @NonNull IBinder ownerToken, @NonNull Rect initialBounds, @NonNull Rect initialRelativeBounds, boolean areInitialRelativeBoundsSet, @WindowingMode int windowingMode, @Nullable IBinder pairedPrimaryFragmentToken, @Nullable IBinder pairedActivityToken) { if (pairedPrimaryFragmentToken != null && pairedActivityToken != null) { Loading @@ -104,6 +121,8 @@ public final class TaskFragmentCreationParams implements Parcelable { mFragmentToken = fragmentToken; mOwnerToken = ownerToken; mInitialBounds.set(initialBounds); mInitialRelativeBounds.set(initialRelativeBounds); mAreInitialRelativeBoundsSet = areInitialRelativeBoundsSet; mWindowingMode = windowingMode; mPairedPrimaryFragmentToken = pairedPrimaryFragmentToken; mPairedActivityToken = pairedActivityToken; Loading @@ -129,6 +148,23 @@ public final class TaskFragmentCreationParams implements Parcelable { return mInitialBounds; } /** * TODO(b/232476698): remove the hide with adding CTS for this in next release. * @hide */ @NonNull public Rect getInitialRelativeBounds() { return mInitialRelativeBounds; } /** * TODO(b/232476698): remove after remove mInitialBounds. * @hide */ public boolean areInitialRelativeBoundsSet() { return mAreInitialRelativeBoundsSet; } @WindowingMode public int getWindowingMode() { return mWindowingMode; Loading Loading @@ -157,6 +193,8 @@ public final class TaskFragmentCreationParams implements Parcelable { mFragmentToken = in.readStrongBinder(); mOwnerToken = in.readStrongBinder(); mInitialBounds.readFromParcel(in); mInitialRelativeBounds.readFromParcel(in); mAreInitialRelativeBoundsSet = in.readBoolean(); mWindowingMode = in.readInt(); mPairedPrimaryFragmentToken = in.readStrongBinder(); mPairedActivityToken = in.readStrongBinder(); Loading @@ -169,6 +207,8 @@ public final class TaskFragmentCreationParams implements Parcelable { dest.writeStrongBinder(mFragmentToken); dest.writeStrongBinder(mOwnerToken); mInitialBounds.writeToParcel(dest, flags); mInitialRelativeBounds.writeToParcel(dest, flags); dest.writeBoolean(mAreInitialRelativeBoundsSet); dest.writeInt(mWindowingMode); dest.writeStrongBinder(mPairedPrimaryFragmentToken); dest.writeStrongBinder(mPairedActivityToken); Loading @@ -195,6 +235,7 @@ public final class TaskFragmentCreationParams implements Parcelable { + " fragmentToken=" + mFragmentToken + " ownerToken=" + mOwnerToken + " initialBounds=" + mInitialBounds + " initialRelativeBounds=" + mInitialRelativeBounds + " windowingMode=" + mWindowingMode + " pairedFragmentToken=" + mPairedPrimaryFragmentToken + " pairedActivityToken=" + mPairedActivityToken Loading Loading @@ -222,6 +263,11 @@ public final class TaskFragmentCreationParams implements Parcelable { @NonNull private final Rect mInitialBounds = new Rect(); @NonNull private final Rect mInitialRelativeBounds = new Rect(); private boolean mAreInitialRelativeBoundsSet; @WindowingMode private int mWindowingMode = WINDOWING_MODE_UNDEFINED; Loading @@ -245,6 +291,19 @@ public final class TaskFragmentCreationParams implements Parcelable { return this; } /** * Sets the initial relative bounds for the TaskFragment in parent coordinate. * Set to empty to fill parent. * TODO(b/232476698): remove the hide with adding CTS for this in next release. * @hide */ @NonNull public Builder setInitialRelativeBounds(@NonNull Rect bounds) { mInitialRelativeBounds.set(bounds); mAreInitialRelativeBoundsSet = true; return this; } /** Sets the initial windowing mode for the TaskFragment. */ @NonNull public Builder setWindowingMode(@WindowingMode int windowingMode) { Loading Loading @@ -296,8 +355,8 @@ public final class TaskFragmentCreationParams implements Parcelable { @NonNull public TaskFragmentCreationParams build() { return new TaskFragmentCreationParams(mOrganizer, mFragmentToken, mOwnerToken, mInitialBounds, mWindowingMode, mPairedPrimaryFragmentToken, mPairedActivityToken); mInitialBounds, mInitialRelativeBounds, mAreInitialRelativeBoundsSet, mWindowingMode, mPairedPrimaryFragmentToken, mPairedActivityToken); } } } core/java/android/window/WindowContainerTransaction.java +43 −0 Original line number Diff line number Diff line Loading @@ -305,6 +305,26 @@ public final class WindowContainerTransaction implements Parcelable { return this; } /** * Resizes a container by providing a bounds in its parent coordinate. * This is only used by {@link TaskFragmentOrganizer}. * @hide */ @NonNull public WindowContainerTransaction setRelativeBounds( @NonNull WindowContainerToken container, @NonNull Rect relBounds) { Change chg = getOrCreateChange(container.asBinder()); if (chg.mRelativeBounds == null) { chg.mRelativeBounds = new Rect(); } chg.mRelativeBounds.set(relBounds); chg.mChangeMask |= Change.CHANGE_RELATIVE_BOUNDS; // Bounds will be overridden. chg.mConfigSetMask |= ActivityInfo.CONFIG_WINDOW_CONFIGURATION; chg.mWindowSetMask |= WindowConfiguration.WINDOW_CONFIG_BOUNDS; return this; } /** * Reparents a container into another one. The effect of a {@code null} parent can vary. For * example, reparenting a stack to {@code null} will reparent it to its display. Loading Loading @@ -979,6 +999,7 @@ public final class WindowContainerTransaction implements Parcelable { public static final int CHANGE_FORCE_NO_PIP = 1 << 6; public static final int CHANGE_FORCE_TRANSLUCENT = 1 << 7; public static final int CHANGE_DRAG_RESIZING = 1 << 8; public static final int CHANGE_RELATIVE_BOUNDS = 1 << 9; private final Configuration mConfiguration = new Configuration(); private boolean mFocusable = true; Loading @@ -994,6 +1015,8 @@ public final class WindowContainerTransaction implements Parcelable { private Rect mPinnedBounds = null; private SurfaceControl.Transaction mBoundsChangeTransaction = null; private Rect mBoundsChangeSurfaceBounds = null; @Nullable private Rect mRelativeBounds = null; private int mActivityWindowingMode = -1; private int mWindowingMode = -1; Loading Loading @@ -1022,6 +1045,10 @@ public final class WindowContainerTransaction implements Parcelable { mBoundsChangeSurfaceBounds = new Rect(); mBoundsChangeSurfaceBounds.readFromParcel(in); } if ((mChangeMask & Change.CHANGE_RELATIVE_BOUNDS) != 0) { mRelativeBounds = new Rect(); mRelativeBounds.readFromParcel(in); } mWindowingMode = in.readInt(); mActivityWindowingMode = in.readInt(); Loading Loading @@ -1069,6 +1096,11 @@ public final class WindowContainerTransaction implements Parcelable { mBoundsChangeSurfaceBounds = transfer ? other.mBoundsChangeSurfaceBounds : new Rect(other.mBoundsChangeSurfaceBounds); } if (other.mRelativeBounds != null) { mRelativeBounds = transfer ? other.mRelativeBounds : new Rect(other.mRelativeBounds); } } public int getWindowingMode() { Loading Loading @@ -1156,6 +1188,11 @@ public final class WindowContainerTransaction implements Parcelable { return mBoundsChangeSurfaceBounds; } @Nullable public Rect getRelativeBounds() { return mRelativeBounds; } @Override public String toString() { final boolean changesBounds = Loading Loading @@ -1196,6 +1233,9 @@ public final class WindowContainerTransaction implements Parcelable { if ((mChangeMask & CHANGE_IGNORE_ORIENTATION_REQUEST) != 0) { sb.append("ignoreOrientationRequest:" + mIgnoreOrientationRequest + ","); } if ((mChangeMask & CHANGE_RELATIVE_BOUNDS) != 0) { sb.append("relativeBounds:").append(mRelativeBounds).append(","); } sb.append("}"); return sb.toString(); } Loading @@ -1221,6 +1261,9 @@ public final class WindowContainerTransaction implements Parcelable { if (mBoundsChangeSurfaceBounds != null) { mBoundsChangeSurfaceBounds.writeToParcel(dest, flags); } if (mRelativeBounds != null) { mRelativeBounds.writeToParcel(dest, flags); } dest.writeInt(mWindowingMode); dest.writeInt(mActivityWindowingMode); Loading libs/WindowManager/Jetpack/src/androidx/window/extensions/embedding/JetpackTaskFragmentOrganizer.java +18 −17 Original line number Diff line number Diff line Loading @@ -109,38 +109,38 @@ class JetpackTaskFragmentOrganizer extends TaskFragmentOrganizer { * be resized based on {@param launchingFragmentBounds}. * Otherwise, we will create a new TaskFragment with the given * token for the {@param launchingActivity}. * @param launchingFragmentBounds the initial bounds for the launching TaskFragment. * @param launchingRelBounds the initial relative bounds for the launching TaskFragment. * @param launchingActivity the Activity to put on the left hand side of the split as the * primary. * @param secondaryFragmentToken token to create the secondary TaskFragment with. * @param secondaryFragmentBounds the initial bounds for the secondary TaskFragment * @param secondaryRelBounds the initial relative bounds for the secondary TaskFragment * @param activityIntent Intent to start the secondary Activity with. * @param activityOptions ActivityOptions to start the secondary Activity with. * @param windowingMode the windowing mode to set for the TaskFragments. * @param splitAttributes the {@link SplitAttributes} to represent the split. */ void startActivityToSide(@NonNull WindowContainerTransaction wct, @NonNull IBinder launchingFragmentToken, @NonNull Rect launchingFragmentBounds, @NonNull IBinder launchingFragmentToken, @NonNull Rect launchingRelBounds, @NonNull Activity launchingActivity, @NonNull IBinder secondaryFragmentToken, @NonNull Rect secondaryFragmentBounds, @NonNull Intent activityIntent, @NonNull Rect secondaryRelBounds, @NonNull Intent activityIntent, @Nullable Bundle activityOptions, @NonNull SplitRule rule, @WindowingMode int windowingMode, @NonNull SplitAttributes splitAttributes) { final IBinder ownerToken = launchingActivity.getActivityToken(); // Create or resize the launching TaskFragment. if (mFragmentInfos.containsKey(launchingFragmentToken)) { resizeTaskFragment(wct, launchingFragmentToken, launchingFragmentBounds); resizeTaskFragment(wct, launchingFragmentToken, launchingRelBounds); updateWindowingMode(wct, launchingFragmentToken, windowingMode); } else { createTaskFragmentAndReparentActivity(wct, launchingFragmentToken, ownerToken, launchingFragmentBounds, windowingMode, launchingActivity); launchingRelBounds, windowingMode, launchingActivity); } updateAnimationParams(wct, launchingFragmentToken, splitAttributes); // Create a TaskFragment for the secondary activity. final TaskFragmentCreationParams fragmentOptions = new TaskFragmentCreationParams.Builder( getOrganizerToken(), secondaryFragmentToken, ownerToken) .setInitialBounds(secondaryFragmentBounds) .setInitialRelativeBounds(secondaryRelBounds) .setWindowingMode(windowingMode) // Make sure to set the paired fragment token so that the new TaskFragment will be // positioned right above the paired TaskFragment. Loading Loading @@ -190,8 +190,9 @@ class JetpackTaskFragmentOrganizer extends TaskFragmentOrganizer { * have to be a child of this task fragment, but must belong to the same task. */ void createTaskFragment(@NonNull WindowContainerTransaction wct, @NonNull IBinder fragmentToken, @NonNull IBinder ownerToken, @NonNull Rect bounds, @WindowingMode int windowingMode) { createTaskFragment(wct, fragmentToken, ownerToken, bounds, windowingMode, @NonNull IBinder ownerToken, @NonNull Rect relBounds, @WindowingMode int windowingMode) { createTaskFragment(wct, fragmentToken, ownerToken, relBounds, windowingMode, null /* pairedActivityToken */); } Loading @@ -203,11 +204,11 @@ class JetpackTaskFragmentOrganizer extends TaskFragmentOrganizer { * positioned right above it. */ void createTaskFragment(@NonNull WindowContainerTransaction wct, @NonNull IBinder fragmentToken, @NonNull IBinder ownerToken, @NonNull Rect bounds, @WindowingMode int windowingMode, @NonNull IBinder ownerToken, @NonNull Rect relBounds, @WindowingMode int windowingMode, @Nullable IBinder pairedActivityToken) { final TaskFragmentCreationParams fragmentOptions = new TaskFragmentCreationParams.Builder( getOrganizerToken(), fragmentToken, ownerToken) .setInitialBounds(bounds) .setInitialRelativeBounds(relBounds) .setWindowingMode(windowingMode) .setPairedActivityToken(pairedActivityToken) .build(); Loading @@ -229,10 +230,10 @@ class JetpackTaskFragmentOrganizer extends TaskFragmentOrganizer { * have to be a child of this task fragment, but must belong to the same task. */ private void createTaskFragmentAndReparentActivity(@NonNull WindowContainerTransaction wct, @NonNull IBinder fragmentToken, @NonNull IBinder ownerToken, @NonNull Rect bounds, @NonNull IBinder fragmentToken, @NonNull IBinder ownerToken, @NonNull Rect relBounds, @WindowingMode int windowingMode, @NonNull Activity activity) { final IBinder reparentActivityToken = activity.getActivityToken(); createTaskFragment(wct, fragmentToken, ownerToken, bounds, windowingMode, createTaskFragment(wct, fragmentToken, ownerToken, relBounds, windowingMode, reparentActivityToken); wct.reparentActivityToTaskFragment(fragmentToken, reparentActivityToken); } Loading Loading @@ -280,15 +281,15 @@ class JetpackTaskFragmentOrganizer extends TaskFragmentOrganizer { } void resizeTaskFragment(@NonNull WindowContainerTransaction wct, @NonNull IBinder fragmentToken, @Nullable Rect bounds) { @Nullable Rect relBounds) { if (!mFragmentInfos.containsKey(fragmentToken)) { throw new IllegalArgumentException( "Can't find an existing TaskFragment with fragmentToken=" + fragmentToken); } if (bounds == null) { bounds = new Rect(); if (relBounds == null) { relBounds = new Rect(); } wct.setBounds(mFragmentInfos.get(fragmentToken).getToken(), bounds); wct.setRelativeBounds(mFragmentInfos.get(fragmentToken).getToken(), relBounds); } void updateWindowingMode(@NonNull WindowContainerTransaction wct, Loading libs/WindowManager/Jetpack/src/androidx/window/extensions/embedding/SplitPresenter.java +44 −37 File changed.Preview size limit exceeded, changes collapsed. Show changes libs/WindowManager/Jetpack/src/androidx/window/extensions/embedding/TaskContainer.java +9 −0 Original line number Diff line number Diff line Loading @@ -243,6 +243,15 @@ class TaskContainer { return mConfiguration; } /** Translates the given absolute bounds to relative bounds in this Task coordinate. */ void translateAbsoluteBoundsToRelativeBounds(@NonNull Rect inOutBounds) { if (inOutBounds.isEmpty()) { return; } final Rect taskBounds = mConfiguration.windowConfiguration.getBounds(); inOutBounds.offset(-taskBounds.left, -taskBounds.top); } /** * Obtains the {@link TaskProperties} for the task that the provided {@link Activity} is * associated with. Loading Loading
core/java/android/window/TaskFragmentCreationParams.java +62 −3 Original line number Diff line number Diff line Loading @@ -52,10 +52,26 @@ public final class TaskFragmentCreationParams implements Parcelable { @NonNull private final IBinder mOwnerToken; /** The initial bounds of the TaskFragment. Fills parent if empty. */ /** * The initial bounds of the TaskFragment. Fills parent if empty. * TODO(b/232476698): cleanup with update CTS. */ @NonNull private final Rect mInitialBounds = new Rect(); /** * The initial relative bounds of the TaskFragment in parent coordinate. * Fills parent if empty. */ @NonNull private final Rect mInitialRelativeBounds = new Rect(); /** * Whether the params are using {@link Builder#setInitialRelativeBounds(Rect)}. * TODO(b/232476698): remove after remove mInitialBounds */ private final boolean mAreInitialRelativeBoundsSet; /** The initial windowing mode of the TaskFragment. Inherits from parent if not set. */ @WindowingMode private final int mWindowingMode; Loading Loading @@ -94,6 +110,7 @@ public final class TaskFragmentCreationParams implements Parcelable { private TaskFragmentCreationParams( @NonNull TaskFragmentOrganizerToken organizer, @NonNull IBinder fragmentToken, @NonNull IBinder ownerToken, @NonNull Rect initialBounds, @NonNull Rect initialRelativeBounds, boolean areInitialRelativeBoundsSet, @WindowingMode int windowingMode, @Nullable IBinder pairedPrimaryFragmentToken, @Nullable IBinder pairedActivityToken) { if (pairedPrimaryFragmentToken != null && pairedActivityToken != null) { Loading @@ -104,6 +121,8 @@ public final class TaskFragmentCreationParams implements Parcelable { mFragmentToken = fragmentToken; mOwnerToken = ownerToken; mInitialBounds.set(initialBounds); mInitialRelativeBounds.set(initialRelativeBounds); mAreInitialRelativeBoundsSet = areInitialRelativeBoundsSet; mWindowingMode = windowingMode; mPairedPrimaryFragmentToken = pairedPrimaryFragmentToken; mPairedActivityToken = pairedActivityToken; Loading @@ -129,6 +148,23 @@ public final class TaskFragmentCreationParams implements Parcelable { return mInitialBounds; } /** * TODO(b/232476698): remove the hide with adding CTS for this in next release. * @hide */ @NonNull public Rect getInitialRelativeBounds() { return mInitialRelativeBounds; } /** * TODO(b/232476698): remove after remove mInitialBounds. * @hide */ public boolean areInitialRelativeBoundsSet() { return mAreInitialRelativeBoundsSet; } @WindowingMode public int getWindowingMode() { return mWindowingMode; Loading Loading @@ -157,6 +193,8 @@ public final class TaskFragmentCreationParams implements Parcelable { mFragmentToken = in.readStrongBinder(); mOwnerToken = in.readStrongBinder(); mInitialBounds.readFromParcel(in); mInitialRelativeBounds.readFromParcel(in); mAreInitialRelativeBoundsSet = in.readBoolean(); mWindowingMode = in.readInt(); mPairedPrimaryFragmentToken = in.readStrongBinder(); mPairedActivityToken = in.readStrongBinder(); Loading @@ -169,6 +207,8 @@ public final class TaskFragmentCreationParams implements Parcelable { dest.writeStrongBinder(mFragmentToken); dest.writeStrongBinder(mOwnerToken); mInitialBounds.writeToParcel(dest, flags); mInitialRelativeBounds.writeToParcel(dest, flags); dest.writeBoolean(mAreInitialRelativeBoundsSet); dest.writeInt(mWindowingMode); dest.writeStrongBinder(mPairedPrimaryFragmentToken); dest.writeStrongBinder(mPairedActivityToken); Loading @@ -195,6 +235,7 @@ public final class TaskFragmentCreationParams implements Parcelable { + " fragmentToken=" + mFragmentToken + " ownerToken=" + mOwnerToken + " initialBounds=" + mInitialBounds + " initialRelativeBounds=" + mInitialRelativeBounds + " windowingMode=" + mWindowingMode + " pairedFragmentToken=" + mPairedPrimaryFragmentToken + " pairedActivityToken=" + mPairedActivityToken Loading Loading @@ -222,6 +263,11 @@ public final class TaskFragmentCreationParams implements Parcelable { @NonNull private final Rect mInitialBounds = new Rect(); @NonNull private final Rect mInitialRelativeBounds = new Rect(); private boolean mAreInitialRelativeBoundsSet; @WindowingMode private int mWindowingMode = WINDOWING_MODE_UNDEFINED; Loading @@ -245,6 +291,19 @@ public final class TaskFragmentCreationParams implements Parcelable { return this; } /** * Sets the initial relative bounds for the TaskFragment in parent coordinate. * Set to empty to fill parent. * TODO(b/232476698): remove the hide with adding CTS for this in next release. * @hide */ @NonNull public Builder setInitialRelativeBounds(@NonNull Rect bounds) { mInitialRelativeBounds.set(bounds); mAreInitialRelativeBoundsSet = true; return this; } /** Sets the initial windowing mode for the TaskFragment. */ @NonNull public Builder setWindowingMode(@WindowingMode int windowingMode) { Loading Loading @@ -296,8 +355,8 @@ public final class TaskFragmentCreationParams implements Parcelable { @NonNull public TaskFragmentCreationParams build() { return new TaskFragmentCreationParams(mOrganizer, mFragmentToken, mOwnerToken, mInitialBounds, mWindowingMode, mPairedPrimaryFragmentToken, mPairedActivityToken); mInitialBounds, mInitialRelativeBounds, mAreInitialRelativeBoundsSet, mWindowingMode, mPairedPrimaryFragmentToken, mPairedActivityToken); } } }
core/java/android/window/WindowContainerTransaction.java +43 −0 Original line number Diff line number Diff line Loading @@ -305,6 +305,26 @@ public final class WindowContainerTransaction implements Parcelable { return this; } /** * Resizes a container by providing a bounds in its parent coordinate. * This is only used by {@link TaskFragmentOrganizer}. * @hide */ @NonNull public WindowContainerTransaction setRelativeBounds( @NonNull WindowContainerToken container, @NonNull Rect relBounds) { Change chg = getOrCreateChange(container.asBinder()); if (chg.mRelativeBounds == null) { chg.mRelativeBounds = new Rect(); } chg.mRelativeBounds.set(relBounds); chg.mChangeMask |= Change.CHANGE_RELATIVE_BOUNDS; // Bounds will be overridden. chg.mConfigSetMask |= ActivityInfo.CONFIG_WINDOW_CONFIGURATION; chg.mWindowSetMask |= WindowConfiguration.WINDOW_CONFIG_BOUNDS; return this; } /** * Reparents a container into another one. The effect of a {@code null} parent can vary. For * example, reparenting a stack to {@code null} will reparent it to its display. Loading Loading @@ -979,6 +999,7 @@ public final class WindowContainerTransaction implements Parcelable { public static final int CHANGE_FORCE_NO_PIP = 1 << 6; public static final int CHANGE_FORCE_TRANSLUCENT = 1 << 7; public static final int CHANGE_DRAG_RESIZING = 1 << 8; public static final int CHANGE_RELATIVE_BOUNDS = 1 << 9; private final Configuration mConfiguration = new Configuration(); private boolean mFocusable = true; Loading @@ -994,6 +1015,8 @@ public final class WindowContainerTransaction implements Parcelable { private Rect mPinnedBounds = null; private SurfaceControl.Transaction mBoundsChangeTransaction = null; private Rect mBoundsChangeSurfaceBounds = null; @Nullable private Rect mRelativeBounds = null; private int mActivityWindowingMode = -1; private int mWindowingMode = -1; Loading Loading @@ -1022,6 +1045,10 @@ public final class WindowContainerTransaction implements Parcelable { mBoundsChangeSurfaceBounds = new Rect(); mBoundsChangeSurfaceBounds.readFromParcel(in); } if ((mChangeMask & Change.CHANGE_RELATIVE_BOUNDS) != 0) { mRelativeBounds = new Rect(); mRelativeBounds.readFromParcel(in); } mWindowingMode = in.readInt(); mActivityWindowingMode = in.readInt(); Loading Loading @@ -1069,6 +1096,11 @@ public final class WindowContainerTransaction implements Parcelable { mBoundsChangeSurfaceBounds = transfer ? other.mBoundsChangeSurfaceBounds : new Rect(other.mBoundsChangeSurfaceBounds); } if (other.mRelativeBounds != null) { mRelativeBounds = transfer ? other.mRelativeBounds : new Rect(other.mRelativeBounds); } } public int getWindowingMode() { Loading Loading @@ -1156,6 +1188,11 @@ public final class WindowContainerTransaction implements Parcelable { return mBoundsChangeSurfaceBounds; } @Nullable public Rect getRelativeBounds() { return mRelativeBounds; } @Override public String toString() { final boolean changesBounds = Loading Loading @@ -1196,6 +1233,9 @@ public final class WindowContainerTransaction implements Parcelable { if ((mChangeMask & CHANGE_IGNORE_ORIENTATION_REQUEST) != 0) { sb.append("ignoreOrientationRequest:" + mIgnoreOrientationRequest + ","); } if ((mChangeMask & CHANGE_RELATIVE_BOUNDS) != 0) { sb.append("relativeBounds:").append(mRelativeBounds).append(","); } sb.append("}"); return sb.toString(); } Loading @@ -1221,6 +1261,9 @@ public final class WindowContainerTransaction implements Parcelable { if (mBoundsChangeSurfaceBounds != null) { mBoundsChangeSurfaceBounds.writeToParcel(dest, flags); } if (mRelativeBounds != null) { mRelativeBounds.writeToParcel(dest, flags); } dest.writeInt(mWindowingMode); dest.writeInt(mActivityWindowingMode); Loading
libs/WindowManager/Jetpack/src/androidx/window/extensions/embedding/JetpackTaskFragmentOrganizer.java +18 −17 Original line number Diff line number Diff line Loading @@ -109,38 +109,38 @@ class JetpackTaskFragmentOrganizer extends TaskFragmentOrganizer { * be resized based on {@param launchingFragmentBounds}. * Otherwise, we will create a new TaskFragment with the given * token for the {@param launchingActivity}. * @param launchingFragmentBounds the initial bounds for the launching TaskFragment. * @param launchingRelBounds the initial relative bounds for the launching TaskFragment. * @param launchingActivity the Activity to put on the left hand side of the split as the * primary. * @param secondaryFragmentToken token to create the secondary TaskFragment with. * @param secondaryFragmentBounds the initial bounds for the secondary TaskFragment * @param secondaryRelBounds the initial relative bounds for the secondary TaskFragment * @param activityIntent Intent to start the secondary Activity with. * @param activityOptions ActivityOptions to start the secondary Activity with. * @param windowingMode the windowing mode to set for the TaskFragments. * @param splitAttributes the {@link SplitAttributes} to represent the split. */ void startActivityToSide(@NonNull WindowContainerTransaction wct, @NonNull IBinder launchingFragmentToken, @NonNull Rect launchingFragmentBounds, @NonNull IBinder launchingFragmentToken, @NonNull Rect launchingRelBounds, @NonNull Activity launchingActivity, @NonNull IBinder secondaryFragmentToken, @NonNull Rect secondaryFragmentBounds, @NonNull Intent activityIntent, @NonNull Rect secondaryRelBounds, @NonNull Intent activityIntent, @Nullable Bundle activityOptions, @NonNull SplitRule rule, @WindowingMode int windowingMode, @NonNull SplitAttributes splitAttributes) { final IBinder ownerToken = launchingActivity.getActivityToken(); // Create or resize the launching TaskFragment. if (mFragmentInfos.containsKey(launchingFragmentToken)) { resizeTaskFragment(wct, launchingFragmentToken, launchingFragmentBounds); resizeTaskFragment(wct, launchingFragmentToken, launchingRelBounds); updateWindowingMode(wct, launchingFragmentToken, windowingMode); } else { createTaskFragmentAndReparentActivity(wct, launchingFragmentToken, ownerToken, launchingFragmentBounds, windowingMode, launchingActivity); launchingRelBounds, windowingMode, launchingActivity); } updateAnimationParams(wct, launchingFragmentToken, splitAttributes); // Create a TaskFragment for the secondary activity. final TaskFragmentCreationParams fragmentOptions = new TaskFragmentCreationParams.Builder( getOrganizerToken(), secondaryFragmentToken, ownerToken) .setInitialBounds(secondaryFragmentBounds) .setInitialRelativeBounds(secondaryRelBounds) .setWindowingMode(windowingMode) // Make sure to set the paired fragment token so that the new TaskFragment will be // positioned right above the paired TaskFragment. Loading Loading @@ -190,8 +190,9 @@ class JetpackTaskFragmentOrganizer extends TaskFragmentOrganizer { * have to be a child of this task fragment, but must belong to the same task. */ void createTaskFragment(@NonNull WindowContainerTransaction wct, @NonNull IBinder fragmentToken, @NonNull IBinder ownerToken, @NonNull Rect bounds, @WindowingMode int windowingMode) { createTaskFragment(wct, fragmentToken, ownerToken, bounds, windowingMode, @NonNull IBinder ownerToken, @NonNull Rect relBounds, @WindowingMode int windowingMode) { createTaskFragment(wct, fragmentToken, ownerToken, relBounds, windowingMode, null /* pairedActivityToken */); } Loading @@ -203,11 +204,11 @@ class JetpackTaskFragmentOrganizer extends TaskFragmentOrganizer { * positioned right above it. */ void createTaskFragment(@NonNull WindowContainerTransaction wct, @NonNull IBinder fragmentToken, @NonNull IBinder ownerToken, @NonNull Rect bounds, @WindowingMode int windowingMode, @NonNull IBinder ownerToken, @NonNull Rect relBounds, @WindowingMode int windowingMode, @Nullable IBinder pairedActivityToken) { final TaskFragmentCreationParams fragmentOptions = new TaskFragmentCreationParams.Builder( getOrganizerToken(), fragmentToken, ownerToken) .setInitialBounds(bounds) .setInitialRelativeBounds(relBounds) .setWindowingMode(windowingMode) .setPairedActivityToken(pairedActivityToken) .build(); Loading @@ -229,10 +230,10 @@ class JetpackTaskFragmentOrganizer extends TaskFragmentOrganizer { * have to be a child of this task fragment, but must belong to the same task. */ private void createTaskFragmentAndReparentActivity(@NonNull WindowContainerTransaction wct, @NonNull IBinder fragmentToken, @NonNull IBinder ownerToken, @NonNull Rect bounds, @NonNull IBinder fragmentToken, @NonNull IBinder ownerToken, @NonNull Rect relBounds, @WindowingMode int windowingMode, @NonNull Activity activity) { final IBinder reparentActivityToken = activity.getActivityToken(); createTaskFragment(wct, fragmentToken, ownerToken, bounds, windowingMode, createTaskFragment(wct, fragmentToken, ownerToken, relBounds, windowingMode, reparentActivityToken); wct.reparentActivityToTaskFragment(fragmentToken, reparentActivityToken); } Loading Loading @@ -280,15 +281,15 @@ class JetpackTaskFragmentOrganizer extends TaskFragmentOrganizer { } void resizeTaskFragment(@NonNull WindowContainerTransaction wct, @NonNull IBinder fragmentToken, @Nullable Rect bounds) { @Nullable Rect relBounds) { if (!mFragmentInfos.containsKey(fragmentToken)) { throw new IllegalArgumentException( "Can't find an existing TaskFragment with fragmentToken=" + fragmentToken); } if (bounds == null) { bounds = new Rect(); if (relBounds == null) { relBounds = new Rect(); } wct.setBounds(mFragmentInfos.get(fragmentToken).getToken(), bounds); wct.setRelativeBounds(mFragmentInfos.get(fragmentToken).getToken(), relBounds); } void updateWindowingMode(@NonNull WindowContainerTransaction wct, Loading
libs/WindowManager/Jetpack/src/androidx/window/extensions/embedding/SplitPresenter.java +44 −37 File changed.Preview size limit exceeded, changes collapsed. Show changes
libs/WindowManager/Jetpack/src/androidx/window/extensions/embedding/TaskContainer.java +9 −0 Original line number Diff line number Diff line Loading @@ -243,6 +243,15 @@ class TaskContainer { return mConfiguration; } /** Translates the given absolute bounds to relative bounds in this Task coordinate. */ void translateAbsoluteBoundsToRelativeBounds(@NonNull Rect inOutBounds) { if (inOutBounds.isEmpty()) { return; } final Rect taskBounds = mConfiguration.windowConfiguration.getBounds(); inOutBounds.offset(-taskBounds.left, -taskBounds.top); } /** * Obtains the {@link TaskProperties} for the task that the provided {@link Activity} is * associated with. Loading