Merge "Added StackId object for checking what features a stack supports"
This commit is contained in:
committed by
Android (Google) Code Review
commit
02a5a6bb9b
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
@@ -16,11 +16,8 @@
|
||||
|
||||
package com.android.internal.policy;
|
||||
|
||||
import static android.app.ActivityManager.FIRST_DYNAMIC_STACK_ID;
|
||||
import static android.app.ActivityManager.FREEFORM_WORKSPACE_STACK_ID;
|
||||
import static android.app.ActivityManager.FULLSCREEN_WORKSPACE_STACK_ID;
|
||||
import static android.app.ActivityManager.INVALID_STACK_ID;
|
||||
import static android.app.ActivityManager.PINNED_STACK_ID;
|
||||
import static android.app.ActivityManager.StackId.FULLSCREEN_WORKSPACE_STACK_ID;
|
||||
import static android.app.ActivityManager.StackId.INVALID_STACK_ID;
|
||||
import static android.view.View.MeasureSpec.AT_MOST;
|
||||
import static android.view.View.MeasureSpec.EXACTLY;
|
||||
import static android.view.View.MeasureSpec.getMode;
|
||||
@@ -30,6 +27,7 @@ import static android.view.WindowManager.LayoutParams.*;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.animation.ObjectAnimator;
|
||||
import android.app.ActivityManager.StackId;
|
||||
import android.app.ActivityManagerNative;
|
||||
import android.app.SearchManager;
|
||||
import android.os.Build;
|
||||
@@ -737,9 +735,9 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
|
||||
if (mWorkspaceId != workspaceId) {
|
||||
mWorkspaceId = workspaceId;
|
||||
// We might have to change the kind of surface before we do anything else.
|
||||
mNonClientDecorView.phoneWindowUpdated(hasNonClientDecor(mWorkspaceId),
|
||||
nonClientDecorHasShadow(mWorkspaceId));
|
||||
mDecor.enableNonClientDecor(hasNonClientDecor(workspaceId));
|
||||
mNonClientDecorView.phoneWindowUpdated(StackId.hasWindowDecor(mWorkspaceId),
|
||||
StackId.hasWindowShadow(mWorkspaceId));
|
||||
mDecor.enableNonClientDecor(StackId.hasWindowDecor(workspaceId));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3735,7 +3733,7 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
|
||||
* @return Returns true when the window has a shadow created by the non client decor.
|
||||
**/
|
||||
private boolean windowHasShadow() {
|
||||
return windowHasNonClientDecor() && nonClientDecorHasShadow(mWindow.mWorkspaceId);
|
||||
return windowHasNonClientDecor() && StackId.hasWindowShadow(mWindow.mWorkspaceId);
|
||||
}
|
||||
|
||||
void setWindow(PhoneWindow phoneWindow) {
|
||||
@@ -4234,7 +4232,7 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
|
||||
mWorkspaceId = getWorkspaceId();
|
||||
// Only a non floating application window on one of the allowed workspaces can get a non
|
||||
// client decor.
|
||||
if (!isFloating() && isApplication && mWorkspaceId < FIRST_DYNAMIC_STACK_ID) {
|
||||
if (!isFloating() && isApplication && StackId.isStaticStack(mWorkspaceId)) {
|
||||
// Dependent on the brightness of the used title we either use the
|
||||
// dark or the light button frame.
|
||||
if (nonClientDecorView == null) {
|
||||
@@ -4250,12 +4248,13 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
|
||||
R.layout.non_client_decor_light, null);
|
||||
}
|
||||
}
|
||||
nonClientDecorView.setPhoneWindow(this, hasNonClientDecor(mWorkspaceId),
|
||||
nonClientDecorHasShadow(mWorkspaceId), getResizingBackgroundDrawable(),
|
||||
nonClientDecorView.setPhoneWindow(this, StackId.hasWindowDecor(mWorkspaceId),
|
||||
StackId.hasWindowShadow(mWorkspaceId), getResizingBackgroundDrawable(),
|
||||
mDecor.getContext().getDrawable(R.drawable.non_client_decor_title_focused));
|
||||
}
|
||||
// Tell the decor if it has a visible non client decor.
|
||||
mDecor.enableNonClientDecor(nonClientDecorView != null && hasNonClientDecor(mWorkspaceId));
|
||||
mDecor.enableNonClientDecor(
|
||||
nonClientDecorView != null&& StackId.hasWindowDecor(mWorkspaceId));
|
||||
|
||||
return nonClientDecorView;
|
||||
}
|
||||
@@ -5428,24 +5427,6 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
|
||||
return workspaceId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if the window should show a non client decor for the workspace it is in.
|
||||
* @param workspaceId The Id of the workspace which contains this window.
|
||||
* @Return Returns true if the window should show a non client decor.
|
||||
**/
|
||||
private static boolean hasNonClientDecor(int workspaceId) {
|
||||
return workspaceId == FREEFORM_WORKSPACE_STACK_ID;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if the window should show a shadow or not, dependent on the workspace.
|
||||
* @param workspaceId The Id of the workspace which contains this window.
|
||||
* @Return Returns true if the window should show a shadow.
|
||||
**/
|
||||
private static boolean nonClientDecorHasShadow(int workspaceId) {
|
||||
return workspaceId == FREEFORM_WORKSPACE_STACK_ID || workspaceId == PINNED_STACK_ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTheme(int resid) {
|
||||
mTheme = resid;
|
||||
|
||||
@@ -16,8 +16,9 @@
|
||||
|
||||
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;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Looper;
|
||||
@@ -332,8 +333,7 @@ public class NonClientDecorView extends LinearLayout
|
||||
Window.WindowControllerCallback callback = mOwner.getWindowControllerCallback();
|
||||
if (callback != null) {
|
||||
try {
|
||||
callback.changeWindowStack(
|
||||
android.app.ActivityManager.FULLSCREEN_WORKSPACE_STACK_ID);
|
||||
callback.changeWindowStack(FULLSCREEN_WORKSPACE_STACK_ID);
|
||||
} catch (RemoteException ex) {
|
||||
Log.e(TAG, "Cannot change task workspace.");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user