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

Commit 69d19ffd authored by Louis Chang's avatar Louis Chang
Browse files

Relax the result-to restriction if activity is finishing

Because the finishing activity won't get the results anyway.

Though, the caller activity was using start-for-result to
start a singleTask activity of another app on the
caller's task.

Bug: 236668365
Bug: 241071379
Test: atest TaskFragmentTest
Change-Id: I94e1f0aab35ceec341dc9acb3b9f749ef9c0cf21
parent 0dfdd607
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -586,7 +586,10 @@ class TaskFragment extends WindowContainer<WindowContainer> {
        }

        // Cannot embed activity across TaskFragments for activity result.
        if (a.resultTo != null && a.resultTo.getTaskFragment() != this) {
        // If the activity that started for result is finishing, it's likely that this start mode
        // is used to place an activity in the same task. Since the finishing activity won't be
        // able to get the results, so it's OK to embed in a different TaskFragment.
        if (a.resultTo != null && !a.resultTo.finishing && a.resultTo.getTaskFragment() != this) {
            return EMBEDDING_DISALLOWED_NEW_TASK_FRAGMENT;
        }

+5 −0
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ import static com.android.dx.mockito.inline.extended.ExtendedMockito.never;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.spyOn;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.verify;
import static com.android.server.wm.ActivityRecord.State.RESUMED;
import static com.android.server.wm.TaskFragment.EMBEDDING_ALLOWED;
import static com.android.server.wm.TaskFragment.EMBEDDING_DISALLOWED_MIN_DIMENSION_VIOLATION;
import static com.android.server.wm.TaskFragment.EMBEDDING_DISALLOWED_NEW_TASK_FRAGMENT;
import static com.android.server.wm.TaskFragment.EMBEDDING_DISALLOWED_UNTRUSTED_HOST;
@@ -468,6 +469,10 @@ public class TaskFragmentTest extends WindowTestsBase {
        newActivity.resultTo = activity;
        assertEquals(EMBEDDING_DISALLOWED_NEW_TASK_FRAGMENT,
                newTaskFragment.isAllowedToEmbedActivity(newActivity));

        // Allow embedding if the resultTo activity is finishing.
        activity.finishing = true;
        assertEquals(EMBEDDING_ALLOWED, newTaskFragment.isAllowedToEmbedActivity(newActivity));
    }

    @Test