Added StackId object for checking what features a stack supports

Helps make the code easier to follow since we are no longer checking
multiple stack ids at various decision points.

Bug: 25282299
Change-Id: Ifa6864a1ef56ce2eca4c94f87a4e0b993de987cd
This commit is contained in:
Wale Ogunwale
2015-10-27 14:21:58 -07:00
parent c11f46f416
commit 3797c22ea1
24 changed files with 208 additions and 191 deletions

View File

@@ -2728,8 +2728,8 @@ public class Activity extends ContextThemeWrapper
/**
* 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#FULLSCREEN_WORKSPACE_STACK_ID} stack and
* {@link android.app.ActivityManager#FREEFORM_WORKSPACE_STACK_ID} stack.
* {@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.
* @hide

View File

@@ -73,7 +73,6 @@ import java.util.List;
*/
public class ActivityManager {
private static String TAG = "ActivityManager";
private static boolean localLOGV = false;
private static int gMaxRecentTasks = -1;
@@ -397,60 +396,112 @@ public class ActivityManager {
*/
public static final int COMPAT_MODE_TOGGLE = 2;
/**
* Invalid stack ID.
* @hide
*/
public static final int INVALID_STACK_ID = -1;
/** @hide */
public static class StackId {
/** Invalid stack ID. */
public static final int INVALID_STACK_ID = -1;
/**
* First static stack ID.
* @hide
*/
public static final int FIRST_STATIC_STACK_ID = 0;
/** First static stack ID. */
public static final int FIRST_STATIC_STACK_ID = 0;
/**
* Home activity stack ID.
* @hide
*/
public static final int HOME_STACK_ID = FIRST_STATIC_STACK_ID;
/** Home activity stack ID. */
public static final int HOME_STACK_ID = FIRST_STATIC_STACK_ID;
/**
* ID of stack where fullscreen activities are normally launched into.
* @hide
*/
public static final int FULLSCREEN_WORKSPACE_STACK_ID = 1;
/** ID of stack where fullscreen activities are normally launched into. */
public static final int FULLSCREEN_WORKSPACE_STACK_ID = 1;
/**
* ID of stack where freeform/resized activities are normally launched into.
* @hide
*/
public static final int FREEFORM_WORKSPACE_STACK_ID = FULLSCREEN_WORKSPACE_STACK_ID + 1;
/** ID of stack where freeform/resized activities are normally launched into. */
public static final int FREEFORM_WORKSPACE_STACK_ID = FULLSCREEN_WORKSPACE_STACK_ID + 1;
/**
* ID of stack that occupies a dedicated region of the screen.
* @hide
*/
public static final int DOCKED_STACK_ID = FREEFORM_WORKSPACE_STACK_ID + 1;
/** ID of stack that occupies a dedicated region of the screen. */
public static final int DOCKED_STACK_ID = FREEFORM_WORKSPACE_STACK_ID + 1;
/**
* ID of stack that always on top (always visible) when it exist.
* Mainly used for this in Picture-in-Picture mode.
* @hide
*/
public static final int PINNED_STACK_ID = DOCKED_STACK_ID + 1;
/** ID of stack that always on top (always visible) when it exist. */
public static final int PINNED_STACK_ID = DOCKED_STACK_ID + 1;
/**
* Last static stack stack ID.
* @hide
*/
public static final int LAST_STATIC_STACK_ID = PINNED_STACK_ID;
/** Last static stack stack ID. */
public static final int LAST_STATIC_STACK_ID = PINNED_STACK_ID;
/**
* Start of ID range used by stacks that are created dynamically.
* @hide
*/
public static final int FIRST_DYNAMIC_STACK_ID = LAST_STATIC_STACK_ID + 1;
/** Start of ID range used by stacks that are created dynamically. */
public static final int FIRST_DYNAMIC_STACK_ID = LAST_STATIC_STACK_ID + 1;
public static boolean isStaticStack(int stackId) {
return stackId >= FIRST_STATIC_STACK_ID && stackId <= LAST_STATIC_STACK_ID;
}
/**
* Returns true if the activities contained in the input stack display a shadow around
* their border.
*/
public static boolean hasWindowShadow(int stackId) {
return stackId == FREEFORM_WORKSPACE_STACK_ID || stackId == PINNED_STACK_ID;
}
/**
* Returns true if the activities contained in the input stack display a decor view.
*/
public static boolean hasWindowDecor(int stackId) {
return stackId == FREEFORM_WORKSPACE_STACK_ID;
}
/**
* Returns true if the tasks contained in the stack can be resized independently of the
* stack.
*/
public static boolean isTaskResizeAllowed(int stackId) {
return stackId == FREEFORM_WORKSPACE_STACK_ID;
}
/**
* Returns true if the task bounds should persist across power cycles.
*/
public static boolean persistTaskBounds(int stackId) {
return isStaticStack(stackId) &&
stackId != DOCKED_STACK_ID && stackId != PINNED_STACK_ID;
}
/**
* Returns true if dynamic stacks are allowed to be visible behind the input stack.
*/
public static boolean isDynamicStacksVisibleBehindAllowed(int stackId) {
return stackId == PINNED_STACK_ID;
}
/**
* Returns true if we try to maintain focus in the current stack when the top activity
* finishes.
*/
public static boolean keepFocusInStackIfPossible(int stackId) {
return stackId == FREEFORM_WORKSPACE_STACK_ID
|| stackId == DOCKED_STACK_ID || stackId == PINNED_STACK_ID;
}
/**
* Returns true if Stack size is affected by the docked stack changing size.
*/
public static boolean isResizeableByDockedStack(int stackId) {
return isStaticStack(stackId) &&
stackId != DOCKED_STACK_ID && stackId != PINNED_STACK_ID;
}
/**
* Returns true if the size of tasks in the input stack are affected by the docked stack
* changing size.
*/
public static boolean isTaskResizeableByDockedStack(int stackId) {
return isStaticStack(stackId) && stackId != FREEFORM_WORKSPACE_STACK_ID
&& stackId != DOCKED_STACK_ID && stackId != PINNED_STACK_ID;
}
/**
* Returns true if the windows of tasks being moved to this stack should be preserved so
* there isn't a display gap.
*/
public static boolean preserveWindowOnTaskMove(int stackId) {
return stackId == FULLSCREEN_WORKSPACE_STACK_ID
|| stackId == DOCKED_STACK_ID || stackId == PINNED_STACK_ID;
}
}
/**
* Input parameter to {@link android.app.IActivityManager#moveTaskToDockedStack} which

View File

@@ -552,8 +552,8 @@ public abstract class Window {
/**
* 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#FULLSCREEN_WORKSPACE_STACK_ID} stack and
* {@link android.app.ActivityManager#FREEFORM_WORKSPACE_STACK_ID} stack.
* {@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.
*/