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
This commit is contained in:
Wale Ogunwale
2015-12-02 19:46:29 -08:00
parent 10ad84a17d
commit 2998eef694
5 changed files with 12 additions and 10 deletions

View File

@@ -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);

View File

@@ -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;
}

View File

@@ -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);
}

View File

@@ -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) {

View File

@@ -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
}