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

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

Merge "Apply TaskFragmentOrganizer changes in one WCT (1/2)" into tm-qpr-dev

parents 7ca34d30 e9a10374
Loading
Loading
Loading
Loading
+19 −4
Original line number Diff line number Diff line
@@ -147,13 +147,25 @@ public class TaskFragmentOrganizer extends WindowOrganizer {
        }
    }

    /** Called when a TaskFragment is created and organized by this organizer. */
    /**
     * Called when a TaskFragment is created and organized by this organizer.
     *
     * @param taskFragmentInfo  Info of the TaskFragment that is created.
     */
    public void onTaskFragmentAppeared(@NonNull TaskFragmentInfo taskFragmentInfo) {}

    /** Called when the status of an organized TaskFragment is changed. */
    /**
     * Called when the status of an organized TaskFragment is changed.
     *
     * @param taskFragmentInfo  Info of the TaskFragment that is changed.
     */
    public void onTaskFragmentInfoChanged(@NonNull TaskFragmentInfo taskFragmentInfo) {}

    /** Called when an organized TaskFragment is removed. */
    /**
     * Called when an organized TaskFragment is removed.
     *
     * @param taskFragmentInfo  Info of the TaskFragment that is removed.
     */
    public void onTaskFragmentVanished(@NonNull TaskFragmentInfo taskFragmentInfo) {}

    /**
@@ -176,6 +188,9 @@ public class TaskFragmentOrganizer extends WindowOrganizer {
     * For case like screen size change, it will trigger onTaskFragmentParentInfoChanged with new
     * Task bounds, but may not trigger onTaskFragmentInfoChanged because there can be an override
     * bounds.
     *
     * @param taskId    Id of the parent Task that is changed.
     * @param parentConfig  Config of the parent Task.
     * @hide
     */
    public void onTaskFragmentParentInfoChanged(int taskId, @NonNull Configuration parentConfig) {
@@ -226,7 +241,7 @@ public class TaskFragmentOrganizer extends WindowOrganizer {
    /**
     * Called when an Activity is reparented to the Task with organized TaskFragment. For example,
     * when an Activity enters and then exits Picture-in-picture, it will be reparented back to its
     * orginial Task. In this case, we need to notify the organizer so that it can check if the
     * original Task. In this case, we need to notify the organizer so that it can check if the
     * Activity matches any split rule.
     *
     * @param taskId            The Task that the activity is reparented to.
+32 −26
Original line number Diff line number Diff line
@@ -62,13 +62,18 @@ class JetpackTaskFragmentOrganizer extends TaskFragmentOrganizer {
     * Callback that notifies the controller about changes to task fragments.
     */
    interface TaskFragmentCallback {
        void onTaskFragmentAppeared(@NonNull TaskFragmentInfo taskFragmentInfo);
        void onTaskFragmentInfoChanged(@NonNull TaskFragmentInfo taskFragmentInfo);
        void onTaskFragmentVanished(@NonNull TaskFragmentInfo taskFragmentInfo);
        void onTaskFragmentParentInfoChanged(int taskId, @NonNull Configuration parentConfig);
        void onActivityReparentedToTask(int taskId, @NonNull Intent activityIntent,
                @NonNull IBinder activityToken);
        void onTaskFragmentError(@Nullable TaskFragmentInfo taskFragmentInfo, int opType);
        void onTaskFragmentAppeared(@NonNull WindowContainerTransaction wct,
                @NonNull TaskFragmentInfo taskFragmentInfo);
        void onTaskFragmentInfoChanged(@NonNull WindowContainerTransaction wct,
                @NonNull TaskFragmentInfo taskFragmentInfo);
        void onTaskFragmentVanished(@NonNull WindowContainerTransaction wct,
                @NonNull TaskFragmentInfo taskFragmentInfo);
        void onTaskFragmentParentInfoChanged(@NonNull WindowContainerTransaction wct,
                int taskId, @NonNull Configuration parentConfig);
        void onActivityReparentedToTask(@NonNull WindowContainerTransaction wct,
                int taskId, @NonNull Intent activityIntent, @NonNull IBinder activityToken);
        void onTaskFragmentError(@NonNull WindowContainerTransaction wct,
                @Nullable TaskFragmentInfo taskFragmentInfo, int opType);
    }

    /**
@@ -158,27 +163,16 @@ class JetpackTaskFragmentOrganizer extends TaskFragmentOrganizer {
        updateWindowingMode(wct, fragmentToken, WINDOWING_MODE_UNDEFINED);
    }

    /**
     * Expands an existing TaskFragment to fill parent.
     * @param fragmentToken token of an existing TaskFragment.
     */
    void expandTaskFragment(@NonNull IBinder fragmentToken) {
        WindowContainerTransaction wct = new WindowContainerTransaction();
        expandTaskFragment(wct, fragmentToken);
        applyTransaction(wct);
    }

    /**
     * Expands an Activity to fill parent by moving it to a new TaskFragment.
     * @param fragmentToken token to create new TaskFragment with.
     * @param activity      activity to move to the fill-parent TaskFragment.
     */
    void expandActivity(@NonNull IBinder fragmentToken, @NonNull Activity activity) {
        final WindowContainerTransaction wct = new WindowContainerTransaction();
    void expandActivity(@NonNull WindowContainerTransaction wct, @NonNull IBinder fragmentToken,
            @NonNull Activity activity) {
        createTaskFragmentAndReparentActivity(
                wct, fragmentToken, activity.getActivityToken(), new Rect(),
                WINDOWING_MODE_UNDEFINED, activity);
        applyTransaction(wct);
    }

    /**
@@ -278,43 +272,55 @@ class JetpackTaskFragmentOrganizer extends TaskFragmentOrganizer {

    @Override
    public void onTaskFragmentAppeared(@NonNull TaskFragmentInfo taskFragmentInfo) {
        final WindowContainerTransaction wct = new WindowContainerTransaction();
        final IBinder fragmentToken = taskFragmentInfo.getFragmentToken();
        mFragmentInfos.put(fragmentToken, taskFragmentInfo);
        mCallback.onTaskFragmentAppeared(taskFragmentInfo);
        mCallback.onTaskFragmentAppeared(wct, taskFragmentInfo);
        applyTransaction(wct);
    }

    @Override
    public void onTaskFragmentInfoChanged(@NonNull TaskFragmentInfo taskFragmentInfo) {
        final WindowContainerTransaction wct = new WindowContainerTransaction();
        final IBinder fragmentToken = taskFragmentInfo.getFragmentToken();
        mFragmentInfos.put(fragmentToken, taskFragmentInfo);
        mCallback.onTaskFragmentInfoChanged(taskFragmentInfo);
        mCallback.onTaskFragmentInfoChanged(wct, taskFragmentInfo);
        applyTransaction(wct);
    }

    @Override
    public void onTaskFragmentVanished(@NonNull TaskFragmentInfo taskFragmentInfo) {
        final WindowContainerTransaction wct = new WindowContainerTransaction();
        mFragmentInfos.remove(taskFragmentInfo.getFragmentToken());
        mCallback.onTaskFragmentVanished(taskFragmentInfo);
        mCallback.onTaskFragmentVanished(wct, taskFragmentInfo);
        applyTransaction(wct);
    }

    @Override
    public void onTaskFragmentParentInfoChanged(int taskId, @NonNull Configuration parentConfig) {
        mCallback.onTaskFragmentParentInfoChanged(taskId, parentConfig);
        final WindowContainerTransaction wct = new WindowContainerTransaction();
        mCallback.onTaskFragmentParentInfoChanged(wct, taskId, parentConfig);
        applyTransaction(wct);
    }

    @Override
    public void onActivityReparentedToTask(int taskId, @NonNull Intent activityIntent,
            @NonNull IBinder activityToken) {
        mCallback.onActivityReparentedToTask(taskId, activityIntent, activityToken);
        final WindowContainerTransaction wct = new WindowContainerTransaction();
        mCallback.onActivityReparentedToTask(wct, taskId, activityIntent, activityToken);
        applyTransaction(wct);
    }

    @Override
    public void onTaskFragmentError(@NonNull IBinder errorCallbackToken,
            @Nullable TaskFragmentInfo taskFragmentInfo,
            int opType, @NonNull Throwable exception) {
        final WindowContainerTransaction wct = new WindowContainerTransaction();
        if (taskFragmentInfo != null) {
            final IBinder fragmentToken = taskFragmentInfo.getFragmentToken();
            mFragmentInfos.put(fragmentToken, taskFragmentInfo);
        }
        mCallback.onTaskFragmentError(taskFragmentInfo, opType);
        mCallback.onTaskFragmentError(wct, taskFragmentInfo, opType);
        applyTransaction(wct);
    }
}
Loading