Merge "Ensure reparent activity TaskFragment is always within the same Task" into tm-dev
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user