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

Commit bff3aa26 authored by Chris Li's avatar Chris Li
Browse files

Ensure reparent activity TaskFragment is always within the same Task

Bug: 225371112
Test: pass existing
Change-Id: Ia754f5219db6ffaf02810a8339902ff4dba41739
parent c9ab8713
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -734,6 +734,12 @@ class WindowOrganizerController extends IWindowOrganizerController.Stub
                    sendTaskFragmentOperationFailure(organizer, errorCallbackToken, exception);
                    break;
                }
                if (parent.getTask() != activity.getTask()) {
                    final Throwable exception = new SecurityException("The reparented activity is"
                            + " not in the same Task as the target TaskFragment.");
                    sendTaskFragmentOperationFailure(organizer, errorCallbackToken, exception);
                    break;
                }
                activity.reparent(parent, POSITION_TOP);
                effects |= TRANSACT_EFFECTS_LIFECYCLE;
                break;
@@ -1542,6 +1548,12 @@ class WindowOrganizerController extends IWindowOrganizerController.Stub
            sendTaskFragmentOperationFailure(organizer, errorCallbackToken, exception);
            return;
        }
        if (newParentTF.getTask() != oldParent.getTask()) {
            final Throwable exception = new SecurityException(
                    "The new parent is not in the same Task as the old parent.");
            sendTaskFragmentOperationFailure(organizer, errorCallbackToken, exception);
            return;
        }
        while (oldParent.hasChild()) {
            oldParent.getChildAt(0).reparent(newParentTF, POSITION_TOP);
        }
+3 −2
Original line number Diff line number Diff line
@@ -511,11 +511,12 @@ public class TaskFragmentOrganizerControllerTest extends WindowTestsBase {
    @Test
    public void testApplyTransaction_reparentActivityToTaskFragment_triggerLifecycleUpdate()
            throws RemoteException {
        final ActivityRecord activity = createActivityRecord(mDefaultDisplay);
        final Task task = createTask(mDisplayContent);
        final ActivityRecord activity = createActivityRecord(task);
        mOrganizer.applyTransaction(mTransaction);
        mController.registerOrganizer(mIOrganizer);
        mTaskFragment = new TaskFragmentBuilder(mAtm)
                .setCreateParentTask()
                .setParentTask(task)
                .setFragmentToken(mFragmentToken)
                .build();
        mAtm.mWindowOrganizerController.mLaunchTaskFragments