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

Commit 1ed0d89e authored by Wale Ogunwale's avatar Wale Ogunwale
Browse files

Inform activity manager of stack/task rotation bounds changes in WM

Change-Id: I342093d8af1d397ab4894146f9b288bdfdc464f0
parent f05de8f3
Loading
Loading
Loading
Loading
+10 −2
Original line number Original line Diff line number Diff line
@@ -476,20 +476,28 @@ public class ActivityManager {
     */
     */
    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
     * that the resize is from the window manager (instead of the user) due to a screen
     * rotation change.
     * @hide
     */
    public static final int RESIZE_MODE_SYSTEM_SCREEN_ROTATION = 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 initiated by the user (most likely via a drag action on the
     * that the resize is initiated by the user (most likely via a drag action on the
     * window's edge or corner).
     * window's edge or corner).
     * @hide
     * @hide
     */
     */
    public static final int RESIZE_MODE_USER   = 1;
    public static final int RESIZE_MODE_USER   = 2;


    /**
    /**
     * 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 be performed even if the bounds appears unchanged.
     * @hide
     * @hide
     */
     */
    public static final int RESIZE_MODE_FORCED = 2;
    public static final int RESIZE_MODE_FORCED = 3;


    /** @hide */
    /** @hide */
    public int getFrontActivityScreenCompatMode() {
    public int getFrontActivityScreenCompatMode() {
+3 −18
Original line number Original line Diff line number Diff line
@@ -3110,8 +3110,9 @@ 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 resizedByUser = resizeMode == RESIZE_MODE_USER;
                final boolean preserveWindow = !changedStacks &&
                final boolean preserveWindow = resizedByUser && !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);
@@ -4626,16 +4627,6 @@ public final class ActivityStackSupervisor implements DisplayListener {
            return mActivityDisplay != null;
            return mActivityDisplay != null;
        }
        }


        void getBounds(Point outBounds) {
            synchronized (mService) {
                    if (mActivityDisplay != null) {
                    mActivityDisplay.getBounds(outBounds);
                } else {
                    outBounds.set(0, 0);
                }
            }
        }

        // TODO: Make sure every change to ActivityRecord.visible results in a call to this.
        // TODO: Make sure every change to ActivityRecord.visible results in a call to this.
        void setVisible(boolean visible) {
        void setVisible(boolean visible) {
            if (mVisible != visible) {
            if (mVisible != visible) {
@@ -4807,12 +4798,6 @@ public final class ActivityStackSupervisor implements DisplayListener {
            mStacks.remove(stack);
            mStacks.remove(stack);
        }
        }


        void getBounds(Point bounds) {
            mDisplay.getDisplayInfo(mDisplayInfo);
            bounds.x = mDisplayInfo.appWidth;
            bounds.y = mDisplayInfo.appHeight;
        }

        void setVisibleBehindActivity(ActivityRecord r) {
        void setVisibleBehindActivity(ActivityRecord r) {
            mVisibleBehindActivity = r;
            mVisibleBehindActivity = r;
        }
        }
+9 −1
Original line number Original line Diff line number Diff line
@@ -17,9 +17,11 @@
package com.android.server.wm;
package com.android.server.wm;


import static android.app.ActivityManager.DOCKED_STACK_ID;
import static android.app.ActivityManager.DOCKED_STACK_ID;
import static android.app.ActivityManager.RESIZE_MODE_SYSTEM_SCREEN_ROTATION;
import static com.android.server.wm.WindowManagerService.TAG;
import static com.android.server.wm.WindowManagerService.TAG;
import static com.android.server.wm.WindowManagerService.DEBUG_RESIZE;
import static com.android.server.wm.WindowManagerService.DEBUG_RESIZE;
import static com.android.server.wm.WindowManagerService.DEBUG_STACK;
import static com.android.server.wm.WindowManagerService.DEBUG_STACK;
import static com.android.server.wm.WindowManagerService.H.RESIZE_TASK;
import static android.app.ActivityManager.FREEFORM_WORKSPACE_STACK_ID;
import static android.app.ActivityManager.FREEFORM_WORKSPACE_STACK_ID;


import android.content.res.Configuration;
import android.content.res.Configuration;
@@ -274,7 +276,13 @@ class Task implements DimLayer.DimLayerUser {
        // this happens, so update the task bounds so it stays in the same place.
        // this happens, so update the task bounds so it stays in the same place.
        mTmpRect2.set(mBounds);
        mTmpRect2.set(mBounds);
        displayContent.rotateBounds(mRotation, newRotation, mTmpRect2);
        displayContent.rotateBounds(mRotation, newRotation, mTmpRect2);
        setBounds(mTmpRect2, mOverrideConfig);
        if (setBounds(mTmpRect2, mOverrideConfig) != BOUNDS_CHANGE_NONE) {
            // Post message to inform activity manager of the bounds change simulating
            // a one-way call. We do this to prevent a deadlock between window manager
            // lock and activity manager lock been held.
            mService.mH.sendMessage(mService.mH.obtainMessage(
                            RESIZE_TASK, mTaskId, RESIZE_MODE_SYSTEM_SCREEN_ROTATION, mBounds));
        }
    }
    }


    /** Updates the dim layer bounds, recreating it if needed. */
    /** Updates the dim layer bounds, recreating it if needed. */
+11 −4
Original line number Original line Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.server.wm;


import static android.app.ActivityManager.*;
import static android.app.ActivityManager.*;
import static com.android.server.wm.WindowManagerService.DEBUG_TASK_MOVEMENT;
import static com.android.server.wm.WindowManagerService.DEBUG_TASK_MOVEMENT;
import static com.android.server.wm.WindowManagerService.H.RESIZE_STACK;
import static com.android.server.wm.WindowManagerService.TAG;
import static com.android.server.wm.WindowManagerService.TAG;


import android.annotation.IntDef;
import android.annotation.IntDef;
@@ -187,6 +188,9 @@ public class TaskStack implements DimLayer.DimLayerUser {


    void updateDisplayInfo(Rect bounds) {
    void updateDisplayInfo(Rect bounds) {
        if (mDisplayContent != null) {
        if (mDisplayContent != null) {
            for (int taskNdx = mTasks.size() - 1; taskNdx >= 0; --taskNdx) {
                mTasks.get(taskNdx).updateDisplayInfo(mDisplayContent);
            }
            if (bounds != null) {
            if (bounds != null) {
                setBounds(bounds);
                setBounds(bounds);
            } else if (mFullscreen) {
            } else if (mFullscreen) {
@@ -195,10 +199,13 @@ public class TaskStack implements DimLayer.DimLayerUser {
                TmpRect2.set(mBounds);
                TmpRect2.set(mBounds);
                mDisplayContent.rotateBounds(
                mDisplayContent.rotateBounds(
                        mRotation, mDisplayContent.getDisplayInfo().rotation, TmpRect2);
                        mRotation, mDisplayContent.getDisplayInfo().rotation, TmpRect2);
                setBounds(TmpRect2);
                if (setBounds(TmpRect2)) {
                    // Post message to inform activity manager of the bounds change simulating
                    // a one-way call. We do this to prevent a deadlock between window manager
                    // lock and activity manager lock been held.
                    mService.mH.sendMessage(
                            mService.mH.obtainMessage(RESIZE_STACK, mStackId, -1, mBounds));
                }
                }
            for (int taskNdx = mTasks.size() - 1; taskNdx >= 0; --taskNdx) {
                mTasks.get(taskNdx).updateDisplayInfo(mDisplayContent);
            }
            }
        }
        }
    }
    }
+19 −2
Original line number Original line Diff line number Diff line
@@ -7209,6 +7209,9 @@ public class WindowManagerService extends IWindowManager.Stub


        public static final int UPDATE_DOCKED_STACK_DIVIDER = 42;
        public static final int UPDATE_DOCKED_STACK_DIVIDER = 42;


        public static final int RESIZE_STACK = 43;
        public static final int RESIZE_TASK = 44;

        @Override
        @Override
        public void handleMessage(Message msg) {
        public void handleMessage(Message msg) {
            if (DEBUG_WINDOW_TRACE) {
            if (DEBUG_WINDOW_TRACE) {
@@ -7755,6 +7758,22 @@ public class WindowManagerService extends IWindowManager.Stub
                    }
                    }
                }
                }
                break;
                break;
                case RESIZE_TASK: {
                    try {
                        mActivityManager.resizeTask(msg.arg1, (Rect) msg.obj, msg.arg2);
                    } catch (RemoteException e) {
                        // This will not happen since we are in the same process.
                    }
                }
                break;
                case RESIZE_STACK: {
                    try {
                        mActivityManager.resizeStack(msg.arg1, (Rect) msg.obj);
                    } catch (RemoteException e) {
                        // This will not happen since we are in the same process.
                    }
                }
                break;
            }
            }
            if (DEBUG_WINDOW_TRACE) {
            if (DEBUG_WINDOW_TRACE) {
                Slog.v(TAG, "handleMessage: exit");
                Slog.v(TAG, "handleMessage: exit");
@@ -10083,8 +10102,6 @@ public class WindowManagerService extends IWindowManager.Stub
        @Override
        @Override
        public void saveLastInputMethodWindowForTransition() {
        public void saveLastInputMethodWindowForTransition() {
            synchronized (mWindowMap) {
            synchronized (mWindowMap) {
                // TODO(multidisplay): Pass in the displayID.
                DisplayContent displayContent = getDefaultDisplayContentLocked();
                if (mInputMethodWindow != null) {
                if (mInputMethodWindow != null) {
                    mPolicy.setLastInputMethodWindowLw(mInputMethodWindow, mInputMethodTarget);
                    mPolicy.setLastInputMethodWindowLw(mInputMethodWindow, mInputMethodTarget);
                }
                }