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

Commit 0b8da3d2 authored by Chris Li's avatar Chris Li Committed by Automerger Merge Worker
Browse files

Merge "Add TaskFragmentOrganizer#onActivityReparentToTask" into tm-dev am:...

Merge "Add TaskFragmentOrganizer#onActivityReparentToTask" into tm-dev am: 0b91be72 am: 06761358 am: 88d29695

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/17817304



Change-Id: Ic6c62f16e81fc868c0ffa3cc204e00e3153eeb1a
Ignore-AOSP-First: this is an automerge
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 5ce9924a 88d29695
Loading
Loading
Loading
Loading
+17 −0
Original line number Original line Diff line number Diff line
@@ -16,6 +16,7 @@


package android.window;
package android.window;


import android.content.Intent;
import android.content.res.Configuration;
import android.content.res.Configuration;
import android.os.Bundle;
import android.os.Bundle;
import android.os.IBinder;
import android.os.IBinder;
@@ -48,4 +49,20 @@ oneway interface ITaskFragmentOrganizer {
     *                          {@link TaskFragmentOrganizer#putExceptionInBundle}.
     *                          {@link TaskFragmentOrganizer#putExceptionInBundle}.
     */
     */
    void onTaskFragmentError(in IBinder errorCallbackToken, in Bundle exceptionBundle);
    void onTaskFragmentError(in IBinder errorCallbackToken, in Bundle exceptionBundle);

    /**
     * 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
     * Activity matches any split rule.
     *
     * @param taskId            The Task that the activity is reparented to.
     * @param activityIntent    The intent that the activity is original launched with.
     * @param activityToken     If the activity belongs to the same process as the organizer, this
     *                          will be the actual activity token; if the activity belongs to a
     *                          different process, the server will generate a temporary token that
     *                          the organizer can use to reparent the activity through
     *                          {@link WindowContainerTransaction} if needed.
     */
    void onActivityReparentToTask(int taskId, in Intent activityIntent, in IBinder activityToken);
}
}
+27 −0
Original line number Original line Diff line number Diff line
@@ -19,6 +19,7 @@ package android.window;
import android.annotation.CallSuper;
import android.annotation.CallSuper;
import android.annotation.NonNull;
import android.annotation.NonNull;
import android.annotation.TestApi;
import android.annotation.TestApi;
import android.content.Intent;
import android.content.res.Configuration;
import android.content.res.Configuration;
import android.os.Bundle;
import android.os.Bundle;
import android.os.IBinder;
import android.os.IBinder;
@@ -154,6 +155,24 @@ public class TaskFragmentOrganizer extends WindowOrganizer {
    public void onTaskFragmentError(
    public void onTaskFragmentError(
            @NonNull IBinder errorCallbackToken, @NonNull Throwable exception) {}
            @NonNull IBinder errorCallbackToken, @NonNull Throwable exception) {}


    /**
     * 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
     * Activity matches any split rule.
     *
     * @param taskId            The Task that the activity is reparented to.
     * @param activityIntent    The intent that the activity is original launched with.
     * @param activityToken     If the activity belongs to the same process as the organizer, this
     *                          will be the actual activity token; if the activity belongs to a
     *                          different process, the server will generate a temporary token that
     *                          the organizer can use to reparent the activity through
     *                          {@link WindowContainerTransaction} if needed.
     * @hide
     */
    public void onActivityReparentToTask(int taskId, @NonNull Intent activityIntent,
            @NonNull IBinder activityToken) {}

    @Override
    @Override
    public void applyTransaction(@NonNull WindowContainerTransaction t) {
    public void applyTransaction(@NonNull WindowContainerTransaction t) {
        t.setTaskFragmentOrganizer(mInterface);
        t.setTaskFragmentOrganizer(mInterface);
@@ -203,6 +222,14 @@ public class TaskFragmentOrganizer extends WindowOrganizer {
                    errorCallbackToken,
                    errorCallbackToken,
                    (Throwable) exceptionBundle.getSerializable(KEY_ERROR_CALLBACK_EXCEPTION)));
                    (Throwable) exceptionBundle.getSerializable(KEY_ERROR_CALLBACK_EXCEPTION)));
        }
        }

        @Override
        public void onActivityReparentToTask(int taskId, @NonNull Intent activityIntent,
                @NonNull IBinder activityToken) {
            mExecutor.execute(
                    () -> TaskFragmentOrganizer.this.onActivityReparentToTask(
                            taskId, activityIntent, activityToken));
        }
    };
    };


    private final TaskFragmentOrganizerToken mToken = new TaskFragmentOrganizerToken(mInterface);
    private final TaskFragmentOrganizerToken mToken = new TaskFragmentOrganizerToken(mInterface);
+6 −0
Original line number Original line Diff line number Diff line
@@ -3031,6 +3031,12 @@
      "group": "WM_DEBUG_FOCUS_LIGHT",
      "group": "WM_DEBUG_FOCUS_LIGHT",
      "at": "com\/android\/server\/wm\/DisplayContent.java"
      "at": "com\/android\/server\/wm\/DisplayContent.java"
    },
    },
    "873160948": {
      "message": "Activity=%s reparent to taskId=%d",
      "level": "VERBOSE",
      "group": "WM_DEBUG_WINDOW_ORGANIZER",
      "at": "com\/android\/server\/wm\/TaskFragmentOrganizerController.java"
    },
    "873914452": {
    "873914452": {
      "message": "goodToGo()",
      "message": "goodToGo()",
      "level": "DEBUG",
      "level": "DEBUG",
+10 −0
Original line number Original line Diff line number Diff line
@@ -70,6 +70,8 @@ class JetpackTaskFragmentOrganizer extends TaskFragmentOrganizer {
        void onTaskFragmentVanished(@NonNull TaskFragmentInfo taskFragmentInfo);
        void onTaskFragmentVanished(@NonNull TaskFragmentInfo taskFragmentInfo);
        void onTaskFragmentParentInfoChanged(@NonNull IBinder fragmentToken,
        void onTaskFragmentParentInfoChanged(@NonNull IBinder fragmentToken,
                @NonNull Configuration parentConfig);
                @NonNull Configuration parentConfig);
        void onActivityReparentToTask(int taskId, @NonNull Intent activityIntent,
                @NonNull IBinder activityToken);
    }
    }


    /**
    /**
@@ -300,4 +302,12 @@ class JetpackTaskFragmentOrganizer extends TaskFragmentOrganizer {
            mCallback.onTaskFragmentParentInfoChanged(fragmentToken, parentConfig);
            mCallback.onTaskFragmentParentInfoChanged(fragmentToken, parentConfig);
        }
        }
    }
    }

    @Override
    public void onActivityReparentToTask(int taskId, @NonNull Intent activityIntent,
            @NonNull IBinder activityToken) {
        if (mCallback != null) {
            mCallback.onActivityReparentToTask(taskId, activityIntent, activityToken);
        }
    }
}
}
+13 −0
Original line number Original line Diff line number Diff line
@@ -222,6 +222,19 @@ public class SplitController implements JetpackTaskFragmentOrganizer.TaskFragmen
        }
        }
    }
    }


    @Override
    public void onActivityReparentToTask(int taskId, @NonNull Intent activityIntent,
            @NonNull IBinder activityToken) {
        // If the activity belongs to the current app process, we treat it as a new activity launch.
        final Activity activity = ActivityThread.currentActivityThread().getActivity(activityToken);
        if (activity != null) {
            onActivityCreated(activity);
            updateCallbackIfNecessary();
            return;
        }
        // TODO: handle for activity in other process.
    }

    /** Called on receiving {@link #onTaskFragmentVanished(TaskFragmentInfo)} for cleanup. */
    /** Called on receiving {@link #onTaskFragmentVanished(TaskFragmentInfo)} for cleanup. */
    private void cleanupTaskFragment(@NonNull IBinder taskFragmentToken) {
    private void cleanupTaskFragment(@NonNull IBinder taskFragmentToken) {
        for (int i = mTaskContainers.size() - 1; i >= 0; i--) {
        for (int i = mTaskContainers.size() - 1; i >= 0; i--) {
Loading