Only allow activities to move to full screen stack.
We allowed activities to move to any stack, but that's too much
freedom. Instead we only allow them to move from freeform stack to a
fullscreen stack.
Change-Id: I04de9bbf18cf4431d7bd34d6c727de82802661ef
diff --git a/core/java/android/app/Activity.java b/core/java/android/app/Activity.java
index 8346161..64642ac 100644
--- a/core/java/android/app/Activity.java
+++ b/core/java/android/app/Activity.java
@@ -62,7 +62,6 @@
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
-import android.graphics.Rect;
import android.media.AudioManager;
import android.media.session.MediaController;
import android.net.Uri;
@@ -2807,17 +2806,15 @@
/**
- * Called to move the window and its activity/task to a different stack container.
- * For example, a window can move between
- * {@link android.app.ActivityManager.StackId#FULLSCREEN_WORKSPACE_STACK_ID} stack and
- * {@link android.app.ActivityManager.StackId#FREEFORM_WORKSPACE_STACK_ID} stack.
+ * Moves the activity from
+ * {@link android.app.ActivityManager.StackId#FREEFORM_WORKSPACE_STACK_ID} to
+ * {@link android.app.ActivityManager.StackId#FULLSCREEN_WORKSPACE_STACK_ID} stack.
*
- * @param stackId stack Id to change to.
* @hide
*/
@Override
- public void changeWindowStack(int stackId) throws RemoteException {
- ActivityManagerNative.getDefault().moveActivityToStack(mToken, stackId);
+ public void exitFreeformMode() throws RemoteException {
+ ActivityManagerNative.getDefault().exitFreeformMode(mToken);
}
/** Returns the current stack Id for the window.
diff --git a/core/java/android/app/ActivityManagerNative.java b/core/java/android/app/ActivityManagerNative.java
index da21099..4bea112 100644
--- a/core/java/android/app/ActivityManagerNative.java
+++ b/core/java/android/app/ActivityManagerNative.java
@@ -2752,11 +2752,10 @@
reply.writeInt(stackId);
return true;
}
- case MOVE_ACTIVITY_TO_STACK_TRANSACTION: {
+ case EXIT_FREEFORM_MODE_TRANSACTION: {
data.enforceInterface(IActivityManager.descriptor);
IBinder token = data.readStrongBinder();
- int stackId = data.readInt();
- moveActivityToStack(token, stackId);
+ exitFreeformMode(token);
reply.writeNoException();
return true;
}
@@ -6457,13 +6456,12 @@
}
@Override
- public void moveActivityToStack(IBinder token, int stackId) throws RemoteException {
+ public void exitFreeformMode(IBinder token) throws RemoteException {
Parcel data = Parcel.obtain();
Parcel reply = Parcel.obtain();
data.writeInterfaceToken(IActivityManager.descriptor);
data.writeStrongBinder(token);
- data.writeInt(stackId);
- mRemote.transact(MOVE_ACTIVITY_TO_STACK_TRANSACTION, data, reply, 0);
+ mRemote.transact(EXIT_FREEFORM_MODE_TRANSACTION, data, reply, 0);
reply.readException();
data.recycle();
reply.recycle();
diff --git a/core/java/android/app/IActivityManager.java b/core/java/android/app/IActivityManager.java
index ceb14ad..8804c8b 100644
--- a/core/java/android/app/IActivityManager.java
+++ b/core/java/android/app/IActivityManager.java
@@ -564,7 +564,7 @@
public boolean stopBinderTrackingAndDump(ParcelFileDescriptor fd) throws RemoteException;
public int getActivityStackId(IBinder token) throws RemoteException;
- public void moveActivityToStack(IBinder token, int stackId) throws RemoteException;
+ public void exitFreeformMode(IBinder token) throws RemoteException;
public void suppressResizeConfigChanges(boolean suppress) throws RemoteException;
@@ -933,7 +933,7 @@
int STOP_BINDER_TRACKING_AND_DUMP_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 341;
int POSITION_TASK_IN_STACK_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 342;
int GET_ACTIVITY_STACK_ID_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 343;
- int MOVE_ACTIVITY_TO_STACK_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 344;
+ int EXIT_FREEFORM_MODE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 344;
int REPORT_SIZE_CONFIGURATIONS = IBinder.FIRST_CALL_TRANSACTION + 345;
int MOVE_TASK_TO_DOCKED_STACK_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 346;
int SUPPRESS_RESIZE_CONFIG_CHANGES_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 347;
diff --git a/core/java/android/view/Window.java b/core/java/android/view/Window.java
index d7a98ab..0b06d15 100644
--- a/core/java/android/view/Window.java
+++ b/core/java/android/view/Window.java
@@ -571,14 +571,11 @@
/** @hide */
public interface WindowControllerCallback {
/**
- * Called to move the window and its activity/task to a different stack container.
- * For example, a window can move between
- * {@link android.app.ActivityManager.StackId#FULLSCREEN_WORKSPACE_STACK_ID} stack and
- * {@link android.app.ActivityManager.StackId#FREEFORM_WORKSPACE_STACK_ID} stack.
- *
- * @param stackId stack Id to change to.
+ * Moves the activity from
+ * {@link android.app.ActivityManager.StackId#FREEFORM_WORKSPACE_STACK_ID} to
+ * {@link android.app.ActivityManager.StackId#FULLSCREEN_WORKSPACE_STACK_ID} stack.
*/
- void changeWindowStack(int stackId) throws RemoteException;
+ void exitFreeformMode() throws RemoteException;
/** Returns the current stack Id for the window. */
int getWindowStackId() throws RemoteException;
diff --git a/core/java/com/android/internal/widget/DecorCaptionView.java b/core/java/com/android/internal/widget/DecorCaptionView.java
index c3fe9e7..409a17f 100644
--- a/core/java/com/android/internal/widget/DecorCaptionView.java
+++ b/core/java/com/android/internal/widget/DecorCaptionView.java
@@ -16,8 +16,6 @@
package com.android.internal.widget;
-import static android.app.ActivityManager.StackId.FULLSCREEN_WORKSPACE_STACK_ID;
-
import android.content.Context;
import android.graphics.Color;
import android.graphics.Rect;
@@ -351,7 +349,7 @@
Window.WindowControllerCallback callback = mOwner.getWindowControllerCallback();
if (callback != null) {
try {
- callback.changeWindowStack(FULLSCREEN_WORKSPACE_STACK_ID);
+ callback.exitFreeformMode();
} catch (RemoteException ex) {
Log.e(TAG, "Cannot change task workspace.");
}