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

Commit b1e39972 authored by Riddle Hsu's avatar Riddle Hsu
Browse files

Make tf organizer process have visible state with visibile activity

This is similar to [1]. But even if the activity is not embedded, the
organizer process will still need to response for task fragment info
change. So if there is any visible activity on a task which is
associated with tf organizer, the organizer process also need to be
visible state to handle the event.

[1]: I57ef9ebe95e05842e7f325c1a4775e98c7eb57bd

Fix: 337784723
Test: atest TaskFragmentOrganizerControllerTest# \
            testOnActivityReparentedToTask_ \
            activityNotInOrganizerProcess_useTemporaryToken

Merged-In: I42c9cb2b95c5517370ef2d26b948b3f4e0db8ec4
Change-Id: I42c9cb2b95c5517370ef2d26b948b3f4e0db8ec4
(cherry picked from commit 65b9bff7)
parent 8346887e
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -364,6 +364,10 @@ class Task extends TaskFragment {
     * user wants to return to it. */
    private WindowProcessController mRootProcess;

    /** The TF host info are set once the task has ever added an organized task fragment. */
    int mTaskFragmentHostUid;
    String mTaskFragmentHostProcessName;

    /** Takes on same value as first root activity */
    boolean isPersistable = false;
    int maxRecents;
@@ -1468,6 +1472,11 @@ class Task extends TaskFragment {
        // passed from Task constructor.
        final TaskFragment childTaskFrag = child.asTaskFragment();
        if (childTaskFrag != null && childTaskFrag.asTask() == null) {
            if (childTaskFrag.mTaskFragmentOrganizerProcessName != null
                    && mTaskFragmentHostProcessName == null) {
                mTaskFragmentHostUid = childTaskFrag.mTaskFragmentOrganizerUid;
                mTaskFragmentHostProcessName = childTaskFrag.mTaskFragmentOrganizerProcessName;
            }
            childTaskFrag.setMinDimensions(mMinWidth, mMinHeight);

            // The starting window should keep covering its task when a pure TaskFragment is added
+10 −8
Original line number Diff line number Diff line
@@ -320,9 +320,9 @@ class TaskFragment extends WindowContainer<WindowContainer> {
    /** Organizer that organizing this TaskFragment. */
    @Nullable
    private ITaskFragmentOrganizer mTaskFragmentOrganizer;
    @VisibleForTesting

    int mTaskFragmentOrganizerUid = INVALID_UID;
    private @Nullable String mTaskFragmentOrganizerProcessName;
    @Nullable String mTaskFragmentOrganizerProcessName;

    /** Client assigned unique token for this TaskFragment if this is created by an organizer. */
    @Nullable
@@ -485,14 +485,16 @@ class TaskFragment extends WindowContainer<WindowContainer> {
     */
    @Nullable
    private WindowProcessController getOrganizerProcessIfDifferent(@Nullable ActivityRecord r) {
        if ((r == null || mTaskFragmentOrganizerProcessName == null)
                || (mTaskFragmentOrganizerProcessName.equals(r.processName)
                && mTaskFragmentOrganizerUid == r.getUid())) {
            // No organizer or the process is the same.
        final Task task = getTask();
        if (r == null || task == null || task.mTaskFragmentHostProcessName == null) {
            return null;
        }
        if (task.mTaskFragmentHostProcessName.equals(r.processName)
                && task.mTaskFragmentHostUid == r.getUid()) {
            return null;
        }
        return mAtmService.getProcessController(mTaskFragmentOrganizerProcessName,
                mTaskFragmentOrganizerUid);
        return mAtmService.getProcessController(task.mTaskFragmentHostProcessName,
                task.mTaskFragmentHostUid);
    }

    void setAnimationParams(@NonNull TaskFragmentAnimationParams animationParams) {
+10 −0
Original line number Diff line number Diff line
@@ -485,6 +485,16 @@ public class TaskFragmentOrganizerControllerTest extends WindowTestsBase {
        // Flush EVENT_APPEARED.
        mController.dispatchPendingEvents();

        // Even if the activity is not launched in an organized TaskFragment, it is still considered
        // as the remote activity to the organizer process. Because when the task becomes visible,
        // the organizer process needs to be interactive (unfrozen) to receive TaskFragment events.
        activity.setVisibleRequested(true);
        activity.setState(ActivityRecord.State.RESUMED, "test");
        assertTrue(organizerProc.hasVisibleActivities());
        activity.setVisibleRequested(false);
        activity.setState(ActivityRecord.State.STOPPED, "test");
        assertFalse(organizerProc.hasVisibleActivities());

        // Make sure the activity belongs to the same app, but it is in a different pid.
        activity.info.applicationInfo.uid = uid;
        doReturn(pid + 1).when(activity).getPid();