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

Commit 7c200e5b authored by Diego Vela's avatar Diego Vela Committed by Android (Google) Code Review
Browse files

Merge "Revert "Use same display for activities in same process.""

parents b64df77f 672feaf7
Loading
Loading
Loading
Loading
+0 −12
Original line number Diff line number Diff line
@@ -7508,10 +7508,6 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        return (config.uiMode & UI_MODE_TYPE_MASK) == UI_MODE_TYPE_VR_HEADSET;
    }

    String getProcessName() {
        return info.applicationInfo.processName;
    }

    int getUid() {
        return info.applicationInfo.uid;
    }
@@ -7524,14 +7520,6 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        return app != null ? app.getPid() : 0;
    }

    int getLaunchedFromPid() {
        return launchedFromPid;
    }

    int getLaunchedFromUid() {
        return launchedFromUid;
    }

    /**
     * Determines whether this ActivityRecord can turn the screen on. It checks whether the flag
     * {@link ActivityRecord#getTurnScreenOnFlag} is set and checks whether the ActivityRecord
+2 −2
Original line number Diff line number Diff line
@@ -1807,7 +1807,7 @@ class ActivityStarter {
        }

        mSupervisor.getLaunchParamsController().calculate(targetTask, r.info.windowLayout, r,
                sourceRecord, mOptions, PHASE_BOUNDS, mLaunchParams, mRequest);
                sourceRecord, mOptions, PHASE_BOUNDS, mLaunchParams);
        mPreferredTaskDisplayArea = mLaunchParams.hasPreferredTaskDisplayArea()
                ? mLaunchParams.mPreferredTaskDisplayArea
                : mRootWindowContainer.getDefaultTaskDisplayArea();
@@ -2177,7 +2177,7 @@ class ActivityStarter {
        // Preferred display id is the only state we need for now and it could be updated again
        // after we located a reusable task (which might be resided in another display).
        mSupervisor.getLaunchParamsController().calculate(inTask, r.info.windowLayout, r,
                sourceRecord, options, PHASE_DISPLAY, mLaunchParams, mRequest);
                sourceRecord, options, PHASE_DISPLAY, mLaunchParams);
        mPreferredTaskDisplayArea = mLaunchParams.hasPreferredTaskDisplayArea()
                ? mLaunchParams.mPreferredTaskDisplayArea
                : mRootWindowContainer.getDefaultTaskDisplayArea();
+7 −12
Original line number Diff line number Diff line
@@ -19,7 +19,6 @@ package com.android.server.wm;
import static android.app.WindowConfiguration.WINDOWING_MODE_UNDEFINED;
import static android.view.Display.INVALID_DISPLAY;

import static com.android.server.wm.ActivityStarter.Request;
import static com.android.server.wm.LaunchParamsController.LaunchParamsModifier.PHASE_BOUNDS;
import static com.android.server.wm.LaunchParamsController.LaunchParamsModifier.RESULT_CONTINUE;
import static com.android.server.wm.LaunchParamsController.LaunchParamsModifier.RESULT_DONE;
@@ -74,10 +73,9 @@ class LaunchParamsController {
     * @param source    The {@link ActivityRecord} from which activity was started from.
     * @param options   The {@link ActivityOptions} specified for the activity.
     * @param result    The resulting params.
     * @param request   The optional request from the activity starter.
     */
    void calculate(Task task, WindowLayout layout, ActivityRecord activity, ActivityRecord source,
            ActivityOptions options, int phase, LaunchParams result, @Nullable Request request) {
    void calculate(Task task, WindowLayout layout, ActivityRecord activity,
                   ActivityRecord source, ActivityOptions options, int phase, LaunchParams result) {
        result.reset();

        if (task != null || activity != null) {
@@ -93,7 +91,7 @@ class LaunchParamsController {
            final LaunchParamsModifier modifier = mModifiers.get(i);

            switch(modifier.onCalculate(task, layout, activity, source, options, phase, mTmpCurrent,
                    mTmpResult, request)) {
                    mTmpResult)) {
                case RESULT_SKIP:
                    // Do not apply any results when we are told to skip
                    continue;
@@ -130,8 +128,7 @@ class LaunchParamsController {

    boolean layoutTask(Task task, WindowLayout layout, ActivityRecord activity,
            ActivityRecord source, ActivityOptions options) {
        calculate(task, layout, activity, source, options, PHASE_BOUNDS, mTmpParams,
                null /* request */);
        calculate(task, layout, activity, source, options, PHASE_BOUNDS, mTmpParams);

        // No changes, return.
        if (mTmpParams.isEmpty()) {
@@ -308,17 +305,15 @@ class LaunchParamsController {
         *                      launched should have this be non-null.
         * @param source        the Activity that launched a new task. Could be {@code null}.
         * @param options       {@link ActivityOptions} used to start the activity with.
         * @param phase         the calculation phase, see {@link Phase}
         * @param phase         the calculation phase, see {@link LaunchParamsModifier.Phase}
         * @param currentParams launching params after the process of last {@link
         *                      LaunchParamsModifier}.
         * @param outParams     the result params to be set.
         * @param request       Optional data to give more context on the launch
         * @return see {@link LaunchParamsModifier.Result}
         */
        @Result
        int onCalculate(@Nullable Task task, WindowLayout layout, ActivityRecord activity,
        int onCalculate(Task task, WindowLayout layout, ActivityRecord activity,
                ActivityRecord source, ActivityOptions options, @Phase int phase,
                LaunchParams currentParams, LaunchParams outParams,
                @Nullable Request request);
                LaunchParams currentParams, LaunchParams outParams);
    }
}
+12 −62
Original line number Diff line number Diff line
@@ -35,7 +35,6 @@ import static android.util.DisplayMetrics.DENSITY_DEFAULT;
import static android.view.Display.DEFAULT_DISPLAY;
import static android.view.Display.INVALID_DISPLAY;

import static com.android.server.wm.ActivityStarter.Request;
import static com.android.server.wm.ActivityTaskManagerDebugConfig.TAG_ATM;
import static com.android.server.wm.ActivityTaskManagerDebugConfig.TAG_WITH_CLASS_NAME;

@@ -99,25 +98,23 @@ class TaskLaunchParamsModifier implements LaunchParamsModifier {
            ActivityRecord source, ActivityOptions options, LaunchParams currentParams,
            LaunchParams outParams) {
        return onCalculate(task, layout, activity, source, options, PHASE_BOUNDS, currentParams,
                outParams, null);
                outParams);
    }

    @Override
    public int onCalculate(@Nullable Task task, @NonNull ActivityInfo.WindowLayout layout,
            @NonNull ActivityRecord activity, @Nullable ActivityRecord source,
            ActivityOptions options, int phase, LaunchParams currentParams, LaunchParams outParams,
            @Nullable Request request) {
    public int onCalculate(Task task, ActivityInfo.WindowLayout layout,
                           ActivityRecord activity, ActivityRecord source, ActivityOptions options,
                           int phase, LaunchParams currentParams, LaunchParams outParams) {
        initLogBuilder(task, activity);
        final int result = calculate(task, layout, activity, source, options, phase, currentParams,
                outParams, request);
                outParams);
        outputLog();
        return result;
    }

    private int calculate(@Nullable Task task, @NonNull ActivityInfo.WindowLayout layout,
            @NonNull ActivityRecord activity, @Nullable ActivityRecord source,
            ActivityOptions options, int phase, LaunchParams currentParams, LaunchParams outParams,
            @Nullable Request request) {
    private int calculate(Task task, ActivityInfo.WindowLayout layout,
            ActivityRecord activity, ActivityRecord source, ActivityOptions options, int phase,
            LaunchParams currentParams, LaunchParams outParams) {
        final ActivityRecord root;
        if (task != null) {
            root = task.getRootActivity() == null ? activity : task.getRootActivity();
@@ -140,7 +137,7 @@ class TaskLaunchParamsModifier implements LaunchParamsModifier {

        // STEP 1: Determine the display area to launch the activity/task.
        final TaskDisplayArea taskDisplayArea = getPreferredLaunchTaskDisplayArea(task,
                options, source, currentParams, activity, request);
                options, source, currentParams);
        outParams.mPreferredTaskDisplayArea = taskDisplayArea;
        // TODO(b/152116619): Update the usages of display to use taskDisplayArea below.
        final DisplayContent display = taskDisplayArea.mDisplayContent;
@@ -300,8 +297,7 @@ class TaskLaunchParamsModifier implements LaunchParamsModifier {
    }

    private TaskDisplayArea getPreferredLaunchTaskDisplayArea(@Nullable Task task,
            @Nullable ActivityOptions options, ActivityRecord source, LaunchParams currentParams,
            @NonNull ActivityRecord activityRecord, @Nullable Request request) {
            @Nullable ActivityOptions options, ActivityRecord source, LaunchParams currentParams) {
        TaskDisplayArea taskDisplayArea = null;

        final WindowContainerToken optionLaunchTaskDisplayAreaToken = options != null
@@ -372,7 +368,7 @@ class TaskLaunchParamsModifier implements LaunchParamsModifier {
            taskDisplayArea = currentParams.mPreferredTaskDisplayArea;
        }

        // Re-route to default display if the device didn't declare support for multi-display
        // Fallback to default display if the device didn't declare support for multi-display
        if (taskDisplayArea != null && !mSupervisor.mService.mSupportsMultiDisplay
                && taskDisplayArea.getDisplayId() != DEFAULT_DISPLAY) {
            taskDisplayArea = mSupervisor.mRootWindowContainer.getDefaultTaskDisplayArea();
@@ -380,53 +376,7 @@ class TaskLaunchParamsModifier implements LaunchParamsModifier {

        return (taskDisplayArea != null)
                ? taskDisplayArea
                : getFallbackDisplayAreaForActivity(activityRecord, request);
    }

    /**
     * Calculate the default display area for a task. We attempt to put the activity within the
     * same display area if possible. The strategy is to find the display in the following order:
     *
     * <ol>
     *     <li>The default is to launch the new activity in the same display area as the current top
     *     running activity in its process</li>
     *     <li>The display area of the top activity from the launching process will be used</li>
     *     <li>The display area of the top activity from the real launching process will be used
     *     </li>
     *     <li>Default display area from the associated root window container.</li>
     * </ol>
     * @param activityRecord the activity being started
     * @param request optional {@link Request} made to start the activity record
     * @return {@link TaskDisplayArea} to house the task
     */
    private TaskDisplayArea getFallbackDisplayAreaForActivity(
            @NonNull ActivityRecord activityRecord, @Nullable Request request) {
        WindowProcessController controllerFromProcess = mSupervisor.mService.getProcessController(
                activityRecord.getProcessName(), activityRecord.getUid());
        final TaskDisplayArea displayAreaForRecord = controllerFromProcess == null ? null
                : controllerFromProcess.getTopActivityDisplayArea();
        if (displayAreaForRecord != null) {
            return displayAreaForRecord;
        }

        WindowProcessController controllerFromLaunchingRecord = mSupervisor.mService
                .getProcessController(activityRecord.launchedFromPid,
                        activityRecord.launchedFromUid);
        final TaskDisplayArea displayAreaForLaunchingRecord = controllerFromLaunchingRecord == null
                ? null : controllerFromLaunchingRecord.getTopActivityDisplayArea();
        if (displayAreaForLaunchingRecord != null) {
            return displayAreaForLaunchingRecord;
        }

        WindowProcessController controllerFromRealRequest = request == null ? null : mSupervisor
                .mService.getProcessController(request.realCallingPid, request.realCallingUid);
        final TaskDisplayArea displayAreaFromRealSource = controllerFromRealRequest == null ? null
                : controllerFromRealRequest.getTopActivityDisplayArea();
        if (displayAreaFromRealSource != null) {
            return displayAreaFromRealSource;
        }

        return mSupervisor.mRootWindowContainer.getDefaultTaskDisplayArea();
                : mSupervisor.mRootWindowContainer.getDefaultTaskDisplayArea();
    }

    private boolean canInheritWindowingModeFromSource(@NonNull DisplayContent display,
+0 −22
Original line number Diff line number Diff line
@@ -705,28 +705,6 @@ public class WindowProcessController extends ConfigurationContainer<Configuratio
        return mHasActivities || mHasRecentTasks;
    }

    @Nullable
    TaskDisplayArea getTopActivityDisplayArea() {
        if (mActivities.isEmpty()) {
            return null;
        }

        int topActivityIndex = mActivities.size() - 1;
        ActivityRecord topRecord = mActivities.get(topActivityIndex);
        TaskDisplayArea displayArea = topRecord.getDisplayArea();

        for (int index = topActivityIndex - 1; index >= 0; --index) {
            ActivityRecord nextRecord = mActivities.get(index);
            TaskDisplayArea nextDisplayArea = nextRecord.getDisplayArea();
            if (nextRecord.compareTo(topRecord) > 0 && nextDisplayArea != null) {
                topRecord = nextRecord;
                displayArea = nextDisplayArea;
            }
        }

        return displayArea;
    }

    private boolean hasActivityInVisibleTask() {
        for (int i = mActivities.size() - 1; i >= 0; --i) {
            Task task = mActivities.get(i).getTask();
Loading