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

Commit 5247523c authored by Wale Ogunwale's avatar Wale Ogunwale Committed by Android (Google) Code Review
Browse files

Merge "Don't set incorrect stack bounds when rotating screen in docked mode"

parents 9ba60c94 ffc11bb7
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -2033,7 +2033,7 @@ public class Am extends BaseCommand {
        }

        try {
            mAm.resizeStack(stackId, bounds);
            mAm.resizeStack(stackId, bounds, false);
            Thread.sleep(delayMs);
        } catch (RemoteException e) {
            showError("Error: resizing stack " + e);
@@ -2127,8 +2127,8 @@ public class Am extends BaseCommand {
            }

            // Resize stacks
            mAm.resizeStack(currentStackInfo.stackId, currentStackBounds);
            mAm.resizeStack(newStackInfo.stackId, newStackBounds);
            mAm.resizeStack(currentStackInfo.stackId, currentStackBounds, false);
            mAm.resizeStack(newStackInfo.stackId, newStackBounds, false);
        } catch (RemoteException e) {
        }
    }
+6 −3
Original line number Diff line number Diff line
@@ -757,9 +757,10 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM

        case RESIZE_STACK_TRANSACTION: {
            data.enforceInterface(IActivityManager.descriptor);
            int stackId = data.readInt();
            final int stackId = data.readInt();
            Rect r = Rect.CREATOR.createFromParcel(data);
            resizeStack(stackId, r);
            final boolean allowResizeInDockedMode = data.readInt() == 1;
            resizeStack(stackId, r, allowResizeInDockedMode);
            reply.writeNoException();
            return true;
        }
@@ -3554,13 +3555,15 @@ class ActivityManagerProxy implements IActivityManager
        reply.recycle();
    }
    @Override
    public void resizeStack(int stackId, Rect r) throws RemoteException
    public void resizeStack(int stackId, Rect r, boolean allowResizeInDockedMode)
            throws RemoteException
    {
        Parcel data = Parcel.obtain();
        Parcel reply = Parcel.obtain();
        data.writeInterfaceToken(IActivityManager.descriptor);
        data.writeInt(stackId);
        r.writeToParcel(data, 0);
        data.writeInt(allowResizeInDockedMode ? 1 : 0);
        mRemote.transact(RESIZE_STACK_TRANSACTION, data, reply, 0);
        reply.readException();
        data.recycle();
+1 −1
Original line number Diff line number Diff line
@@ -143,7 +143,7 @@ public interface IActivityManager extends IInterface {
    public void moveTaskToStack(int taskId, int stackId, boolean toTop) throws RemoteException;
    public void moveTaskToDockedStack(int taskId, int createMode, boolean toTop)
            throws RemoteException;
    public void resizeStack(int stackId, Rect bounds) throws RemoteException;
    public void resizeStack(int stackId, Rect bounds, boolean allowResizeInDockedMode) throws RemoteException;
    public void positionTaskInStack(int taskId, int stackId, int position) throws RemoteException;
    public List<StackInfo> getAllStackInfos() throws RemoteException;
    public StackInfo getStackInfo(int stackId) throws RemoteException;
+3 −2
Original line number Diff line number Diff line
@@ -9161,13 +9161,14 @@ public final class ActivityManagerService extends ActivityManagerNative
    }
    @Override
    public void resizeStack(int stackId, Rect bounds) {
    public void resizeStack(int stackId, Rect bounds, boolean allowResizeInDockedMode) {
        enforceCallingPermission(android.Manifest.permission.MANAGE_ACTIVITY_STACKS,
                "resizeStack()");
        long ident = Binder.clearCallingIdentity();
        try {
            synchronized (this) {
                mStackSupervisor.resizeStackLocked(stackId, bounds, !PRESERVE_WINDOWS);
                mStackSupervisor.resizeStackLocked(
                        stackId, bounds, !PRESERVE_WINDOWS, allowResizeInDockedMode);
            }
        } finally {
            Binder.restoreCallingIdentity(ident);
+14 −14
Original line number Diff line number Diff line
@@ -2973,13 +2973,21 @@ public final class ActivityStackSupervisor implements DisplayListener {
        }
    }

    void resizeStackLocked(int stackId, Rect bounds, boolean preserveWindows) {
    void resizeStackLocked(int stackId, Rect bounds, boolean preserveWindows,
            boolean allowResizeInDockedMode) {
        final ActivityStack stack = getStack(stackId);
        if (stack == null) {
            Slog.w(TAG, "resizeStack: stackId " + stackId + " not found.");
            return;
        }

        if (!allowResizeInDockedMode
                && stackId != DOCKED_STACK_ID && getStack(DOCKED_STACK_ID) != null) {
            // If the docked stack exist we don't allow resizes of stacks not caused by the docked
            // stack size changing so things don't get out of sync.
            return;
        }

        Trace.traceBegin(TRACE_TAG_ACTIVITY_MANAGER, "am.resizeStack_" + stackId);

        ActivityRecord r = stack.topRunningActivityLocked();
@@ -3014,7 +3022,7 @@ public final class ActivityStackSupervisor implements DisplayListener {
                // docked stack tasks to the fullscreen stack.
                for (int i = FIRST_STATIC_STACK_ID; i <= LAST_STATIC_STACK_ID; i++) {
                    if (i != DOCKED_STACK_ID && getStack(i) != null) {
                        resizeStackLocked(i, null, preserveWindows);
                        resizeStackLocked(i, null, preserveWindows, true);
                    }
                }

@@ -3029,23 +3037,15 @@ public final class ActivityStackSupervisor implements DisplayListener {
            } else {
                // Docked stacks occupy a dedicated region on screen so the size of all other
                // static stacks need to be adjusted so they don't overlap with the docked stack.
                final int leftChange = stack.mBounds.left - bounds.left;
                final int rightChange = stack.mBounds.right - bounds.right;
                final int topChange = stack.mBounds.top - bounds.top;
                final int bottomChange = stack.mBounds.bottom - bounds.bottom;
                // We get the bounds to use from window manager which has been adjusted for any
                // screen controls and is also the same for all stacks.
                mWindowManager.getStackDockedModeBounds(HOME_STACK_ID, tempRect);

                for (int i = FIRST_STATIC_STACK_ID; i <= LAST_STATIC_STACK_ID; i++) {
                    if (i != DOCKED_STACK_ID) {
                        ActivityStack otherStack = getStack(i);
                        if (otherStack != null) {
                            tempRect.set(otherStack.mBounds);
                            // We adjust the opposing sides of the other stacks to
                            // the side in the dock stack that changed.
                            tempRect.left -= rightChange;
                            tempRect.right -= leftChange;
                            tempRect.top -= bottomChange;
                            tempRect.bottom -= topChange;
                            resizeStackLocked(i, tempRect, PRESERVE_WINDOWS);
                            resizeStackLocked(i, tempRect, PRESERVE_WINDOWS, true);
                        }
                    }
                }
Loading