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

Commit f98feb05 authored by Chong Zhang's avatar Chong Zhang Committed by Android (Google) Code Review
Browse files

Merge "Do not change task's stack in resizeTaskLocked"

parents 83fac6b0 6de2ae81
Loading
Loading
Loading
Loading
+25 −10
Original line number Original line Diff line number Diff line
@@ -468,36 +468,51 @@ public class ActivityManager {
     */
     */
    public static final int DOCKED_STACK_CREATE_MODE_BOTTOM_OR_RIGHT = 1;
    public static final int DOCKED_STACK_CREATE_MODE_BOTTOM_OR_RIGHT = 1;



    /**
    /**
     * Input parameter to {@link android.app.IActivityManager#resizeTask} which indicates
     * Input parameter to {@link android.app.IActivityManager#resizeTask} which indicates
     * that the resize is from the window manager (instead of the user).
     * that the resize doesn't need to preserve the window, and can be skipped if bounds
     * is unchanged. This mode is used by window manager in most cases.
     * @hide
     * @hide
     */
     */
    public static final int RESIZE_MODE_SYSTEM = 0;
    public static final int RESIZE_MODE_SYSTEM = 0;


    /**
    /**
     * Input parameter to {@link android.app.IActivityManager#resizeTask} which indicates
     * Input parameter to {@link android.app.IActivityManager#resizeTask} which indicates
     * that the resize is from the window manager (instead of the user) due to a screen
     * that the resize should preserve the window if possible.
     * rotation change.
     * @hide
     * @hide
     */
     */
    public static final int RESIZE_MODE_SYSTEM_SCREEN_ROTATION = 1;
    public static final int RESIZE_MODE_PRESERVE_WINDOW   = (0x1 << 0);


    /**
    /**
     * Input parameter to {@link android.app.IActivityManager#resizeTask} which indicates
     * Input parameter to {@link android.app.IActivityManager#resizeTask} which indicates
     * that the resize is initiated by the user (most likely via a drag action on the
     * that the resize should be performed even if the bounds appears unchanged.
     * window's edge or corner).
     * @hide
     */
    public static final int RESIZE_MODE_FORCED = (0x1 << 1);

    /**
     * Input parameter to {@link android.app.IActivityManager#resizeTask} used by window
     * manager during a screen rotation.
     * @hide
     * @hide
     */
     */
    public static final int RESIZE_MODE_USER   = 2;
    public static final int RESIZE_MODE_SYSTEM_SCREEN_ROTATION = RESIZE_MODE_PRESERVE_WINDOW;

    /**
     * Input parameter to {@link android.app.IActivityManager#resizeTask} used when the
     * resize is due to a drag action.
     * @hide
     */
    public static final int RESIZE_MODE_USER = RESIZE_MODE_PRESERVE_WINDOW;


    /**
    /**
     * Input parameter to {@link android.app.IActivityManager#resizeTask} which indicates
     * Input parameter to {@link android.app.IActivityManager#resizeTask} which indicates
     * that the resize should be performed even if the bounds appears unchanged.
     * that the resize should preserve the window if possible, and should not be skipped
     * even if the bounds is unchanged. Usually used to force a resizing when a drag action
     * is ending.
     * @hide
     * @hide
     */
     */
    public static final int RESIZE_MODE_FORCED = 3;
    public static final int RESIZE_MODE_USER_FORCED =
            RESIZE_MODE_PRESERVE_WINDOW | RESIZE_MODE_FORCED;


    /** @hide */
    /** @hide */
    public int getFrontActivityScreenCompatMode() {
    public int getFrontActivityScreenCompatMode() {
+29 −1
Original line number Original line Diff line number Diff line
@@ -20,8 +20,11 @@ import static android.Manifest.permission.INTERACT_ACROSS_USERS;
import static android.Manifest.permission.INTERACT_ACROSS_USERS_FULL;
import static android.Manifest.permission.INTERACT_ACROSS_USERS_FULL;
import static android.Manifest.permission.START_TASKS_FROM_RECENTS;
import static android.Manifest.permission.START_TASKS_FROM_RECENTS;
import static android.app.ActivityManager.DOCKED_STACK_ID;
import static android.app.ActivityManager.DOCKED_STACK_ID;
import static android.app.ActivityManager.FREEFORM_WORKSPACE_STACK_ID;
import static android.app.ActivityManager.FULLSCREEN_WORKSPACE_STACK_ID;
import static android.app.ActivityManager.HOME_STACK_ID;
import static android.app.ActivityManager.HOME_STACK_ID;
import static android.app.ActivityManager.INVALID_STACK_ID;
import static android.app.ActivityManager.INVALID_STACK_ID;
import static android.app.ActivityManager.RESIZE_MODE_PRESERVE_WINDOW;
import static android.content.pm.PackageManager.PERMISSION_GRANTED;
import static android.content.pm.PackageManager.PERMISSION_GRANTED;
import static com.android.internal.util.XmlUtils.readBooleanAttribute;
import static com.android.internal.util.XmlUtils.readBooleanAttribute;
import static com.android.internal.util.XmlUtils.readIntAttribute;
import static com.android.internal.util.XmlUtils.readIntAttribute;
@@ -8685,7 +8688,32 @@ public final class ActivityManagerService extends ActivityManagerNative
                    Slog.w(TAG, "resizeTask: taskId=" + taskId + " not found");
                    Slog.w(TAG, "resizeTask: taskId=" + taskId + " not found");
                    return;
                    return;
                }
                }
                mStackSupervisor.resizeTaskLocked(task, bounds, resizeMode);
                // Place the task in the right stack if it isn't there already based on
                // the requested bounds.
                // The stack transition logic is:
                // - a null bounds on a freeform task moves that task to fullscreen
                // - a non-null bounds on a non-freeform (fullscreen OR docked) task moves
                //   that task to freeform
                // - otherwise the task is not moved
                // Note it's not allowed to resize a home stack task, or a docked task.
                int stackId = task.stack.mStackId;
                if (stackId == HOME_STACK_ID || stackId == DOCKED_STACK_ID) {
                    throw new IllegalArgumentException("trying to resizeTask on a "
                            + "home or docked task");
                }
                if (bounds == null && stackId == FREEFORM_WORKSPACE_STACK_ID) {
                    stackId = FULLSCREEN_WORKSPACE_STACK_ID;
                } else if (bounds != null && stackId != FREEFORM_WORKSPACE_STACK_ID ) {
                    stackId = FREEFORM_WORKSPACE_STACK_ID;
                }
                boolean preserveWindow = (resizeMode & RESIZE_MODE_PRESERVE_WINDOW) != 0;
                if (stackId != task.stack.mStackId) {
                    mStackSupervisor.moveTaskToStackUncheckedLocked(
                            task, stackId, ON_TOP, !FORCE_FOCUS, "resizeTask");
                    preserveWindow = false;
                }
                mStackSupervisor.resizeTaskLocked(task, bounds, resizeMode, preserveWindow);
            }
            }
        } finally {
        } finally {
            Binder.restoreCallingIdentity(ident);
            Binder.restoreCallingIdentity(ident);
+13 −24
Original line number Original line Diff line number Diff line
@@ -3058,7 +3058,7 @@ public final class ActivityStackSupervisor implements DisplayListener {
        Trace.traceEnd(TRACE_TAG_ACTIVITY_MANAGER);
        Trace.traceEnd(TRACE_TAG_ACTIVITY_MANAGER);
    }
    }


    void resizeTaskLocked(TaskRecord task, Rect bounds, int resizeMode) {
    void resizeTaskLocked(TaskRecord task, Rect bounds, int resizeMode, boolean preserveWindow) {
        if (!task.mResizeable) {
        if (!task.mResizeable) {
            Slog.w(TAG, "resizeTask: task " + task + " not resizeable.");
            Slog.w(TAG, "resizeTask: task " + task + " not resizeable.");
            return;
            return;
@@ -3066,7 +3066,7 @@ public final class ActivityStackSupervisor implements DisplayListener {


        // If this is a forced resize, let it go through even if the bounds is not changing,
        // If this is a forced resize, let it go through even if the bounds is not changing,
        // as we might need a relayout due to surface size change (to/from fullscreen).
        // as we might need a relayout due to surface size change (to/from fullscreen).
        final boolean forced = (resizeMode == RESIZE_MODE_FORCED);
        final boolean forced = (resizeMode & RESIZE_MODE_FORCED) != 0;
        if (task.mBounds != null && task.mBounds.equals(bounds) && !forced) {
        if (task.mBounds != null && task.mBounds.equals(bounds) && !forced) {
            // Nothing to do here...
            // Nothing to do here...
            return;
            return;
@@ -3084,22 +3084,11 @@ public final class ActivityStackSupervisor implements DisplayListener {
            return;
            return;
        }
        }


        Trace.traceBegin(TRACE_TAG_ACTIVITY_MANAGER, "am.resizeTask_" + task.taskId);
        // Do not move the task to another stack here.
        // This method assumes that the task is already placed in the right stack.
        // we do not mess with that decision and we only do the resize!


        // The stack of a task is determined by its size (fullscreen vs non-fullscreen).
        Trace.traceBegin(TRACE_TAG_ACTIVITY_MANAGER, "am.resizeTask_" + task.taskId);
        // Place the task in the right stack if it isn't there already based on the requested
        // bounds.
        int stackId = task.stack.mStackId;
        if (bounds == null && stackId != FULLSCREEN_WORKSPACE_STACK_ID) {
            stackId = FULLSCREEN_WORKSPACE_STACK_ID;
        } else if (bounds != null
                && stackId != FREEFORM_WORKSPACE_STACK_ID && stackId != DOCKED_STACK_ID) {
            stackId = FREEFORM_WORKSPACE_STACK_ID;
        }
        final boolean changedStacks = stackId != task.stack.mStackId;
        if (changedStacks) {
            moveTaskToStackUncheckedLocked(task, stackId, ON_TOP, !FORCE_FOCUS, "resizeTask");
        }


        final Configuration overrideConfig =  task.updateOverrideConfiguration(bounds);
        final Configuration overrideConfig =  task.updateOverrideConfiguration(bounds);
        // This variable holds information whether the configuration didn't change in a signficant
        // This variable holds information whether the configuration didn't change in a signficant
@@ -3110,9 +3099,6 @@ public final class ActivityStackSupervisor implements DisplayListener {
            ActivityRecord r = task.topRunningActivityLocked(null);
            ActivityRecord r = task.topRunningActivityLocked(null);
            if (r != null) {
            if (r != null) {
                final ActivityStack stack = task.stack;
                final ActivityStack stack = task.stack;
                final boolean preserveWindow = !changedStacks &&
                        (resizeMode == RESIZE_MODE_USER
                        || resizeMode == RESIZE_MODE_SYSTEM_SCREEN_ROTATION);
                kept = stack.ensureActivityConfigurationLocked(r, 0, preserveWindow);
                kept = stack.ensureActivityConfigurationLocked(r, 0, preserveWindow);
                // All other activities must be made visible with their correct configuration.
                // All other activities must be made visible with their correct configuration.
                ensureActivitiesVisibleLocked(r, 0, !PRESERVE_WINDOWS);
                ensureActivitiesVisibleLocked(r, 0, !PRESERVE_WINDOWS);
@@ -3204,7 +3190,7 @@ public final class ActivityStackSupervisor implements DisplayListener {
     * @param reason Reason the task is been moved.
     * @param reason Reason the task is been moved.
     * @return The stack the task was moved to.
     * @return The stack the task was moved to.
     */
     */
    private ActivityStack moveTaskToStackUncheckedLocked(
    ActivityStack moveTaskToStackUncheckedLocked(
            TaskRecord task, int stackId, boolean toTop, boolean forceFocus, String reason) {
            TaskRecord task, int stackId, boolean toTop, boolean forceFocus, String reason) {
        final ActivityRecord r = task.getTopActivity();
        final ActivityRecord r = task.getTopActivity();
        final boolean wasFocused = isFrontStack(task.stack) && (topRunningActivityLocked() == r);
        final boolean wasFocused = isFrontStack(task.stack) && (topRunningActivityLocked() == r);
@@ -3261,12 +3247,15 @@ public final class ActivityStackSupervisor implements DisplayListener {


        // Make sure the task has the appropriate bounds/size for the stack it is in.
        // Make sure the task has the appropriate bounds/size for the stack it is in.
        if (stackId == FULLSCREEN_WORKSPACE_STACK_ID && task.mBounds != null) {
        if (stackId == FULLSCREEN_WORKSPACE_STACK_ID && task.mBounds != null) {
            resizeTaskLocked(task, stack.mBounds, RESIZE_MODE_SYSTEM);
            resizeTaskLocked(task, stack.mBounds,
                    RESIZE_MODE_SYSTEM, !PRESERVE_WINDOWS);
        } else if (stackId == FREEFORM_WORKSPACE_STACK_ID
        } else if (stackId == FREEFORM_WORKSPACE_STACK_ID
                && task.mBounds == null && task.mLastNonFullscreenBounds != null) {
                && task.mBounds == null && task.mLastNonFullscreenBounds != null) {
            resizeTaskLocked(task, task.mLastNonFullscreenBounds, RESIZE_MODE_SYSTEM);
            resizeTaskLocked(task, task.mLastNonFullscreenBounds,
                    RESIZE_MODE_SYSTEM, !PRESERVE_WINDOWS);
        } else if (stackId == DOCKED_STACK_ID) {
        } else if (stackId == DOCKED_STACK_ID) {
            resizeTaskLocked(task, stack.mBounds, RESIZE_MODE_SYSTEM);
            resizeTaskLocked(task, stack.mBounds,
                    RESIZE_MODE_SYSTEM, !PRESERVE_WINDOWS);
        }
        }


        // The task might have already been running and its visibility needs to be synchronized with
        // The task might have already been running and its visibility needs to be synchronized with
+2 −2
Original line number Original line Diff line number Diff line
@@ -19,8 +19,8 @@ package com.android.server.wm;
import static android.app.ActivityManager.DOCKED_STACK_CREATE_MODE_BOTTOM_OR_RIGHT;
import static android.app.ActivityManager.DOCKED_STACK_CREATE_MODE_BOTTOM_OR_RIGHT;
import static android.app.ActivityManager.DOCKED_STACK_CREATE_MODE_TOP_OR_LEFT;
import static android.app.ActivityManager.DOCKED_STACK_CREATE_MODE_TOP_OR_LEFT;
import static android.app.ActivityManager.FREEFORM_WORKSPACE_STACK_ID;
import static android.app.ActivityManager.FREEFORM_WORKSPACE_STACK_ID;
import static android.app.ActivityManager.RESIZE_MODE_FORCED;
import static android.app.ActivityManager.RESIZE_MODE_USER;
import static android.app.ActivityManager.RESIZE_MODE_USER;
import static android.app.ActivityManager.RESIZE_MODE_USER_FORCED;
import static android.content.res.Configuration.ORIENTATION_LANDSCAPE;
import static android.content.res.Configuration.ORIENTATION_LANDSCAPE;
import static android.os.Trace.TRACE_TAG_WINDOW_MANAGER;
import static android.os.Trace.TRACE_TAG_WINDOW_MANAGER;
import static com.android.server.wm.WindowManagerService.DEBUG_TASK_POSITIONING;
import static com.android.server.wm.WindowManagerService.DEBUG_TASK_POSITIONING;
@@ -179,7 +179,7 @@ class TaskPositioner implements DimLayer.DimLayerUser {
                            // We were using fullscreen surface during resizing. Request
                            // We were using fullscreen surface during resizing. Request
                            // resizeTask() one last time to restore surface to window size.
                            // resizeTask() one last time to restore surface to window size.
                            mService.mActivityManager.resizeTask(
                            mService.mActivityManager.resizeTask(
                                    mTask.mTaskId, mWindowDragBounds, RESIZE_MODE_FORCED);
                                    mTask.mTaskId, mWindowDragBounds, RESIZE_MODE_USER_FORCED);
                        }
                        }


                        if (mCurrentDimSide != CTRL_NONE) {
                        if (mCurrentDimSide != CTRL_NONE) {