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

Commit 7a486619 authored by Louis Chang's avatar Louis Chang Committed by Android (Google) Code Review
Browse files

Merge "No longer checking realCallingUid in #getLaunchRootTask"

parents c1311ae4 9a110a9c
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -2924,7 +2924,7 @@ class ActivityStarter {
        final boolean onTop =
                (aOptions == null || !aOptions.getAvoidMoveToFront()) && !mLaunchTaskBehind;
        return mRootWindowContainer.getLaunchRootTask(r, aOptions, task, mSourceRootTask, onTop,
                mLaunchParams, launchFlags, mRequest.realCallingPid, mRequest.realCallingUid);
                mLaunchParams, launchFlags);
    }

    private boolean isLaunchModeOneOf(int mode1, int mode2) {
+3 −9
Original line number Diff line number Diff line
@@ -2765,8 +2765,7 @@ class RootWindowContainer extends WindowContainer<DisplayContent>
    Task getLaunchRootTask(@Nullable ActivityRecord r, @Nullable ActivityOptions options,
            @Nullable Task candidateTask, boolean onTop) {
        return getLaunchRootTask(r, options, candidateTask, null /* sourceTask */, onTop,
                null /* launchParams */, 0 /* launchFlags */, -1 /* no realCallingPid */,
                -1 /* no realCallingUid */);
                null /* launchParams */, 0 /* launchFlags */);
    }

    /**
@@ -2785,8 +2784,7 @@ class RootWindowContainer extends WindowContainer<DisplayContent>
    Task getLaunchRootTask(@Nullable ActivityRecord r,
            @Nullable ActivityOptions options, @Nullable Task candidateTask,
            @Nullable Task sourceTask, boolean onTop,
            @Nullable LaunchParamsController.LaunchParams launchParams, int launchFlags,
            int realCallingPid, int realCallingUid) {
            @Nullable LaunchParamsController.LaunchParams launchParams, int launchFlags) {
        int taskId = INVALID_TASK_ID;
        int displayId = INVALID_DISPLAY;
        TaskDisplayArea taskDisplayArea = null;
@@ -2835,11 +2833,7 @@ class RootWindowContainer extends WindowContainer<DisplayContent>

        if (taskDisplayArea != null) {
            final int tdaDisplayId = taskDisplayArea.getDisplayId();
            final boolean canLaunchOnDisplayFromStartRequest =
                    realCallingPid != 0 && realCallingUid > 0 && r != null
                            && mTaskSupervisor.canPlaceEntityOnDisplay(tdaDisplayId,
                            realCallingPid, realCallingUid, r.info);
            if (canLaunchOnDisplayFromStartRequest || canLaunchOnDisplay(r, tdaDisplayId)) {
            if (canLaunchOnDisplay(r, tdaDisplayId)) {
                if (r != null) {
                    final Task result = getValidLaunchRootTaskInTaskDisplayArea(
                            taskDisplayArea, r, candidateTask, options, launchParams);
+1 −1
Original line number Diff line number Diff line
@@ -340,7 +340,7 @@ public class ActivityStarterTests extends WindowTestsBase {
            doReturn(stack).when(mRootWindowContainer)
                    .getLaunchRootTask(any(), any(), any(), anyBoolean());
            doReturn(stack).when(mRootWindowContainer).getLaunchRootTask(any(), any(), any(), any(),
                    anyBoolean(), any(), anyInt(), anyInt(), anyInt());
                    anyBoolean(), any(), anyInt());
        }

        // Set up mock package manager internal and make sure no unmocked methods are called
+0 −34
Original line number Diff line number Diff line
@@ -25,7 +25,6 @@ import static android.app.WindowConfiguration.WINDOWING_MODE_MULTI_WINDOW;
import static android.app.WindowConfiguration.WINDOWING_MODE_PINNED;
import static android.content.pm.ActivityInfo.FLAG_ALWAYS_FOCUSABLE;
import static android.view.Display.DEFAULT_DISPLAY;
import static android.view.Display.TYPE_VIRTUAL;
import static android.window.DisplayAreaOrganizer.FEATURE_VENDOR_FIRST;

import static com.android.dx.mockito.inline.extended.ExtendedMockito.doNothing;
@@ -935,39 +934,6 @@ public class RootWindowContainerTests extends WindowTestsBase {
        assertEquals(infoFake1.activityInfo.name, resolvedInfo.first.name);
    }

    /**
     * Test that {@link RootWindowContainer#getLaunchRootTask} with the real caller id will get the
     * expected root task when requesting the activity launch on the secondary display.
     */
    @Test
    public void testGetLaunchRootTaskWithRealCallerId() {
        // Create a non-system owned virtual display.
        final TestDisplayContent secondaryDisplay =
                new TestDisplayContent.Builder(mAtm, 1000, 1500)
                        .setType(TYPE_VIRTUAL).setOwnerUid(100).build();

        // Create an activity with specify the original launch pid / uid.
        final ActivityRecord r = new ActivityBuilder(mAtm).setLaunchedFromPid(200)
                .setLaunchedFromUid(200).build();

        // Simulate ActivityStarter to find a launch root task for requesting the activity to launch
        // on the secondary display with realCallerId.
        final ActivityOptions options = ActivityOptions.makeBasic();
        options.setLaunchDisplayId(secondaryDisplay.mDisplayId);
        options.setLaunchWindowingMode(WINDOWING_MODE_FULLSCREEN);
        doReturn(true).when(mSupervisor).canPlaceEntityOnDisplay(secondaryDisplay.mDisplayId,
                300 /* test realCallerPid */, 300 /* test realCallerUid */, r.info);
        final Task result = mRootWindowContainer.getLaunchRootTask(r, options,
                null /* task */, null /* sourceTask */, true /* onTop */, null /* launchParams */,
                0 /* launchFlags */, 300 /* test realCallerPid */,
                300 /* test realCallerUid */);

        // Assert that the root task is returned as expected.
        assertNotNull(result);
        assertEquals("The display ID of the root task should same as secondary display ",
                secondaryDisplay.mDisplayId, result.getDisplayId());
    }

    @Test
    public void testGetValidLaunchRootTaskOnDisplayWithCandidateRootTask() {
        // Create a root task with an activity on secondary display.