Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 51d602dc authored by Chris Li's avatar Chris Li Committed by Android (Google) Code Review
Browse files

Merge "Separate WCT#setAdjacentTaskFragments into set/clear"

parents 4c340346 9248b4f4
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -3670,6 +3670,7 @@ package android.window {

  public final class WindowContainerTransaction implements android.os.Parcelable {
    ctor public WindowContainerTransaction();
    method @NonNull public android.window.WindowContainerTransaction clearAdjacentTaskFragments(@NonNull android.os.IBinder);
    method @NonNull public android.window.WindowContainerTransaction clearLaunchAdjacentFlagRoot(@NonNull android.window.WindowContainerToken);
    method @NonNull public android.window.WindowContainerTransaction createTaskFragment(@NonNull android.window.TaskFragmentCreationParams);
    method @NonNull public android.window.WindowContainerTransaction deleteTaskFragment(@NonNull android.os.IBinder);
@@ -3684,7 +3685,7 @@ package android.window {
    method @NonNull public android.window.WindowContainerTransaction scheduleFinishEnterPip(@NonNull android.window.WindowContainerToken, @NonNull android.graphics.Rect);
    method @NonNull public android.window.WindowContainerTransaction setActivityWindowingMode(@NonNull android.window.WindowContainerToken, int);
    method @NonNull public android.window.WindowContainerTransaction setAdjacentRoots(@NonNull android.window.WindowContainerToken, @NonNull android.window.WindowContainerToken);
    method @NonNull public android.window.WindowContainerTransaction setAdjacentTaskFragments(@NonNull android.os.IBinder, @Nullable android.os.IBinder, @Nullable android.window.WindowContainerTransaction.TaskFragmentAdjacentParams);
    method @NonNull public android.window.WindowContainerTransaction setAdjacentTaskFragments(@NonNull android.os.IBinder, @NonNull android.os.IBinder, @Nullable android.window.WindowContainerTransaction.TaskFragmentAdjacentParams);
    method @NonNull public android.window.WindowContainerTransaction setAppBounds(@NonNull android.window.WindowContainerToken, @NonNull android.graphics.Rect);
    method @NonNull public android.window.WindowContainerTransaction setBounds(@NonNull android.window.WindowContainerToken, @NonNull android.graphics.Rect);
    method @NonNull public android.window.WindowContainerTransaction setBoundsChangeTransaction(@NonNull android.window.WindowContainerToken, @NonNull android.view.SurfaceControl.Transaction);
+7 −3
Original line number Diff line number Diff line
@@ -58,14 +58,17 @@ public final class TaskFragmentOperation implements Parcelable {
    /** Sets two TaskFragments adjacent to each other. */
    public static final int OP_TYPE_SET_ADJACENT_TASK_FRAGMENTS = 4;

    /** Clears the adjacent TaskFragments relationship. */
    public static final int OP_TYPE_CLEAR_ADJACENT_TASK_FRAGMENTS = 5;

    /** Requests focus on the top running Activity in the given TaskFragment. */
    public static final int OP_TYPE_REQUEST_FOCUS_ON_TASK_FRAGMENT = 5;
    public static final int OP_TYPE_REQUEST_FOCUS_ON_TASK_FRAGMENT = 6;

    /** Sets a given TaskFragment to have a companion TaskFragment. */
    public static final int OP_TYPE_SET_COMPANION_TASK_FRAGMENT = 6;
    public static final int OP_TYPE_SET_COMPANION_TASK_FRAGMENT = 7;

    /** Sets the {@link TaskFragmentAnimationParams} for the given TaskFragment. */
    public static final int OP_TYPE_SET_ANIMATION_PARAMS = 7;
    public static final int OP_TYPE_SET_ANIMATION_PARAMS = 8;

    @IntDef(prefix = { "OP_TYPE_" }, value = {
            OP_TYPE_UNKNOWN,
@@ -74,6 +77,7 @@ public final class TaskFragmentOperation implements Parcelable {
            OP_TYPE_START_ACTIVITY_IN_TASK_FRAGMENT,
            OP_TYPE_REPARENT_ACTIVITY_TO_TASK_FRAGMENT,
            OP_TYPE_SET_ADJACENT_TASK_FRAGMENTS,
            OP_TYPE_CLEAR_ADJACENT_TASK_FRAGMENTS,
            OP_TYPE_REQUEST_FOCUS_ON_TASK_FRAGMENT,
            OP_TYPE_SET_COMPANION_TASK_FRAGMENT,
            OP_TYPE_SET_ANIMATION_PARAMS
+18 −4
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package android.window;

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_DELETE_TASK_FRAGMENT;
import static android.window.TaskFragmentOperation.OP_TYPE_REPARENT_ACTIVITY_TO_TASK_FRAGMENT;
@@ -582,16 +583,14 @@ public final class WindowContainerTransaction implements Parcelable {
     * {@link #setAdjacentRoots(WindowContainerToken, WindowContainerToken)}, but can be used with
     * fragmentTokens when that TaskFragments haven't been created (but will be created in the same
     * {@link WindowContainerTransaction}).
     * To reset it, pass {@code null} for {@code fragmentToken2}.
     * @param fragmentToken1    client assigned unique token to create TaskFragment with specified
     *                          in {@link TaskFragmentCreationParams#getFragmentToken()}.
     * @param fragmentToken2    client assigned unique token to create TaskFragment with specified
     *                          in {@link TaskFragmentCreationParams#getFragmentToken()}. If it is
     *                          {@code null}, the transaction will reset the adjacent TaskFragment.
     *                          in {@link TaskFragmentCreationParams#getFragmentToken()}.
     */
    @NonNull
    public WindowContainerTransaction setAdjacentTaskFragments(
            @NonNull IBinder fragmentToken1, @Nullable IBinder fragmentToken2,
            @NonNull IBinder fragmentToken1, @NonNull IBinder fragmentToken2,
            @Nullable TaskFragmentAdjacentParams params) {
        final TaskFragmentOperation operation = new TaskFragmentOperation.Builder(
                OP_TYPE_SET_ADJACENT_TASK_FRAGMENTS)
@@ -601,6 +600,21 @@ public final class WindowContainerTransaction implements Parcelable {
        return addTaskFragmentOperation(fragmentToken1, operation);
    }

    /**
     * Clears the adjacent TaskFragments relationship that is previously set through
     * {@link #setAdjacentTaskFragments}. Clear operation on one TaskFragment will also clear its
     * current adjacent TaskFragment's.
     * @param fragmentToken     client assigned unique token to create TaskFragment with specified
     *                          in {@link TaskFragmentCreationParams#getFragmentToken()}.
     */
    @NonNull
    public WindowContainerTransaction clearAdjacentTaskFragments(@NonNull IBinder fragmentToken) {
        final TaskFragmentOperation operation = new TaskFragmentOperation.Builder(
                OP_TYPE_CLEAR_ADJACENT_TASK_FRAGMENTS)
                .build();
        return addTaskFragmentOperation(fragmentToken, operation);
    }

    /**
     * If `container` was brought to front as a transient-launch (eg. recents), this will reorder
     * the container back to where it was prior to the transient-launch. This way if a transient
+5 −0
Original line number Diff line number Diff line
@@ -239,6 +239,11 @@ class JetpackTaskFragmentOrganizer extends TaskFragmentOrganizer {

    void setAdjacentTaskFragments(@NonNull WindowContainerTransaction wct,
            @NonNull IBinder primary, @Nullable IBinder secondary, @Nullable SplitRule splitRule) {
        if (secondary == null) {
            wct.clearAdjacentTaskFragments(primary);
            return;
        }

        WindowContainerTransaction.TaskFragmentAdjacentParams adjacentParams = null;
        final boolean finishSecondaryWithPrimary =
                splitRule != null && SplitContainer.shouldFinishSecondaryWithPrimary(splitRule);
+44 −22
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import static android.app.ActivityManager.isStartResultSuccessful;
import static android.app.WindowConfiguration.WINDOWING_MODE_UNDEFINED;
import static android.app.WindowConfiguration.WINDOW_CONFIG_BOUNDS;
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_DELETE_TASK_FRAGMENT;
import static android.window.TaskFragmentOperation.OP_TYPE_REPARENT_ACTIVITY_TO_TASK_FRAGMENT;
@@ -1167,34 +1168,50 @@ class WindowOrganizerController extends IWindowOrganizerController.Stub
            }
            case OP_TYPE_SET_ADJACENT_TASK_FRAGMENTS: {
                final IBinder secondaryFragmentToken = operation.getSecondaryFragmentToken();
                final TaskFragment secondaryTaskFragment = secondaryFragmentToken != null
                        ? mLaunchTaskFragments.get(secondaryFragmentToken)
                        : null;
                final TaskFragment secondaryTaskFragment =
                        mLaunchTaskFragments.get(secondaryFragmentToken);
                if (secondaryTaskFragment == null) {
                    final Throwable exception = new IllegalArgumentException(
                            "SecondaryFragmentToken must be set for setAdjacentTaskFragments.");
                    sendTaskFragmentOperationFailure(organizer, errorCallbackToken, taskFragment,
                            opType, exception);
                    break;
                }
                if (taskFragment.getAdjacentTaskFragment() != secondaryTaskFragment) {
                    // Only have lifecycle effect if the adjacent changed.
                    taskFragment.setAdjacentTaskFragment(secondaryTaskFragment);
                    effects |= TRANSACT_EFFECTS_LIFECYCLE;

                // Clear the focused app if the focused app is no longer visible after reset the
                // adjacent TaskFragments.
                if (secondaryTaskFragment == null
                        && taskFragment.getDisplayContent().mFocusedApp != null
                        && taskFragment.hasChild(taskFragment.getDisplayContent().mFocusedApp)
                        && !taskFragment.shouldBeVisible(null /* starting */)) {
                    taskFragment.getDisplayContent().setFocusedApp(null);
                }

                final Bundle bundle = hop.getLaunchOptions();
                final WindowContainerTransaction.TaskFragmentAdjacentParams adjacentParams =
                        bundle != null ? new WindowContainerTransaction.TaskFragmentAdjacentParams(
                                bundle) : null;
                if (adjacentParams == null) {
                        bundle != null
                                ? new WindowContainerTransaction.TaskFragmentAdjacentParams(bundle)
                                : null;
                taskFragment.setDelayLastActivityRemoval(adjacentParams != null
                        && adjacentParams.shouldDelayPrimaryLastActivityRemoval());
                secondaryTaskFragment.setDelayLastActivityRemoval(adjacentParams != null
                        && adjacentParams.shouldDelaySecondaryLastActivityRemoval());
                break;
            }
            case OP_TYPE_CLEAR_ADJACENT_TASK_FRAGMENTS: {
                final TaskFragment adjacentTaskFragment = taskFragment.getAdjacentTaskFragment();
                if (adjacentTaskFragment == null) {
                    break;
                }
                taskFragment.resetAdjacentTaskFragment();
                effects |= TRANSACT_EFFECTS_LIFECYCLE;

                taskFragment.setDelayLastActivityRemoval(
                        adjacentParams.shouldDelayPrimaryLastActivityRemoval());
                if (secondaryTaskFragment != null) {
                    secondaryTaskFragment.setDelayLastActivityRemoval(
                            adjacentParams.shouldDelaySecondaryLastActivityRemoval());
                // Clear the focused app if the focused app is no longer visible after reset the
                // adjacent TaskFragments.
                final ActivityRecord focusedApp = taskFragment.getDisplayContent().mFocusedApp;
                final TaskFragment focusedTaskFragment = focusedApp != null
                        ? focusedApp.getTaskFragment()
                        : null;
                if ((focusedTaskFragment == taskFragment
                        || focusedTaskFragment == adjacentTaskFragment)
                        && !focusedTaskFragment.shouldBeVisible(null /* starting */)) {
                    focusedTaskFragment.getDisplayContent().setFocusedApp(null /* newFocus */);
                }
                break;
            }
@@ -1528,6 +1545,9 @@ class WindowOrganizerController extends IWindowOrganizerController.Stub
            throw new IllegalArgumentException("setAdjacentRootsHierarchyOp: Not created by"
                    + " organizer root1=" + root1 + " root2=" + root2);
        }
        if (root1.getAdjacentTaskFragment() == root2) {
            return TRANSACT_EFFECTS_NONE;
        }
        root1.setAdjacentTaskFragment(root2);
        return TRANSACT_EFFECTS_LIFECYCLE;
    }
@@ -1538,7 +1558,9 @@ class WindowOrganizerController extends IWindowOrganizerController.Stub
            throw new IllegalArgumentException("clearAdjacentRootsHierarchyOp: Not created by"
                    + " organizer root=" + root);
        }

        if (root.getAdjacentTaskFragment() == null) {
            return TRANSACT_EFFECTS_NONE;
        }
        root.resetAdjacentTaskFragment();
        return TRANSACT_EFFECTS_LIFECYCLE;
    }
Loading