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

Commit 2998eef6 authored by Wale Ogunwale's avatar Wale Ogunwale
Browse files

Set proper stack in WM when activity is moved to stack in AM

When an activity is moved to a stack using the
ActivityStack#moveActivityToStack API a new task is created to
hold the activity in the stack. However, when the new task is
created in the window manager side it uses the stack id of the
previous stack the activity was in. We now pass the stack to use
from activity manager to window manager.

Bug: 25987309
Bug: 25961636
Change-Id: Iecc71f6d9b3e70a8d88e134b42f7532ba5327bad
parent 10ad84a1
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -110,11 +110,14 @@ interface IWindowManager
     *
     * @param token The token we are adding to the input task Id.
     * @param taskId The Id of the task we are adding the token to.
     * @param stackId Stack Id to create a new Task with the input task Id on
     *                if the task doesn't exist yet.
     * @param taskBounds Bounds to use when creating a new Task with the input task Id if
     *                   the task doesn't exist yet.
     * @param config Configuration that is being used with this task.
     */
    void setAppTask(IBinder token, int taskId, in Rect taskBounds, in Configuration config);
    void setAppTask(
            IBinder token, int taskId, int stackId, in Rect taskBounds, in Configuration config);
    void setAppOrientation(IApplicationToken token, int requestedOrientation);
    int getAppOrientation(IApplicationToken token);
    void setFocusedApp(IBinder token, boolean moveFocusNow);
+1 −1
Original line number Diff line number Diff line
@@ -4751,7 +4751,7 @@ final class ActivityStack {
        final Rect bounds = task.getLaunchBounds();
        task.updateOverrideConfiguration(bounds);
        mWindowManager.setAppTask(
                r.appToken, task.taskId, task.getLaunchBounds(), task.mOverrideConfig);
                r.appToken, task.taskId, mStackId, task.getLaunchBounds(), task.mOverrideConfig);
        mWindowManager.setTaskResizeable(task.taskId, task.mResizeable);
        r.taskConfigOverride = task.mOverrideConfig;
    }
+3 −3
Original line number Diff line number Diff line
@@ -3273,7 +3273,8 @@ public class WindowManagerService extends IWindowManager.Stub
    }

    @Override
    public void setAppTask(IBinder token, int taskId, Rect taskBounds, Configuration config) {
    public void setAppTask(
            IBinder token, int taskId, int stackId, Rect taskBounds, Configuration config) {
        if (!checkCallingPermission(android.Manifest.permission.MANAGE_APP_TOKENS,
                "setAppTask()")) {
            throw new SecurityException("Requires MANAGE_APP_TOKENS permission");
@@ -3291,8 +3292,7 @@ public class WindowManagerService extends IWindowManager.Stub
            Task newTask = mTaskIdToTask.get(taskId);
            if (newTask == null) {
                newTask = createTaskLocked(
                        taskId, oldTask.mStack.mStackId, oldTask.mUserId, atoken, taskBounds,
                        config);
                        taskId, stackId, oldTask.mUserId, atoken, taskBounds, config);
            }
            newTask.addAppToken(Integer.MAX_VALUE /* at top */, atoken);
        }
+3 −4
Original line number Diff line number Diff line
@@ -22,11 +22,10 @@ import android.os.RemoteException;
import android.os.ServiceManager;
import android.test.suitebuilder.annotation.SmallTest;
import android.view.IWindowManager;
import android.view.KeyEvent;
import android.view.MotionEvent;

import junit.framework.TestCase;

import static android.app.ActivityManager.StackId.INVALID_STACK_ID;

/**
 * TODO: Remove this. This is only a placeholder, need to implement this.
 */
@@ -104,7 +103,7 @@ public class WindowManagerPermissionTests extends TestCase {
        }

        try {
            mWm.setAppTask(null, 0, null, null);
            mWm.setAppTask(null, 0, INVALID_STACK_ID, null, null);
            fail("IWindowManager.setAppGroupId did not throw SecurityException as"
                    + " expected");
        } catch (SecurityException e) {
+1 −1
Original line number Diff line number Diff line
@@ -321,7 +321,7 @@ public class IWindowManagerImpl implements IWindowManager {
    }

    @Override
    public void setAppTask(IBinder arg0, int arg1, Rect arg2, Configuration arg3)
    public void setAppTask(IBinder arg0, int arg1, int arg2, Rect arg3, Configuration arg4)
            throws RemoteException {
        // TODO Auto-generated method stub
    }