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

Commit 67b78a3d authored by Wale Ogunwale's avatar Wale Ogunwale Committed by Android (Google) Code Review
Browse files

Merge changes I8ac518ce,I8392b4c3,I3bef3f75

* changes:
  Support for activity to opt-in/out of PiP form of multi-window.
  API for moving top activity in a stack to pinned stack.
  Added support for pinned stack.
parents 82279696 b60692e3
Loading
Loading
Loading
Loading
+13 −12
Original line number Diff line number Diff line
@@ -321,7 +321,7 @@ package android {
    field public static final int buttonBarNeutralButtonStyle = 16843914; // 0x101048a
    field public static final int buttonBarPositiveButtonStyle = 16843913; // 0x1010489
    field public static final int buttonBarStyle = 16843566; // 0x101032e
    field public static final int buttonGravity = 16844030; // 0x10104fe
    field public static final int buttonGravity = 16844031; // 0x10104ff
    field public static final int buttonStyle = 16842824; // 0x1010048
    field public static final int buttonStyleInset = 16842826; // 0x101004a
    field public static final int buttonStyleSmall = 16842825; // 0x1010049
@@ -371,7 +371,7 @@ package android {
    field public static final int codes = 16843330; // 0x1010242
    field public static final int collapseColumns = 16843083; // 0x101014b
    field public static final int collapseContentDescription = 16843984; // 0x10104d0
    field public static final int collapseIcon = 16844031; // 0x10104ff
    field public static final int collapseIcon = 16844032; // 0x1010500
    field public static final int color = 16843173; // 0x10101a5
    field public static final int colorAccent = 16843829; // 0x1010435
    field public static final int colorActivatedHighlight = 16843664; // 0x1010390
@@ -412,7 +412,7 @@ package android {
    field public static final int contentInsetRight = 16843862; // 0x1010456
    field public static final int contentInsetStart = 16843859; // 0x1010453
    field public static final int contextClickable = 16844007; // 0x10104e7
    field public static final int contextPopupMenuStyle = 16844033; // 0x1010501
    field public static final int contextPopupMenuStyle = 16844034; // 0x1010502
    field public static final int controlX1 = 16843772; // 0x10103fc
    field public static final int controlX2 = 16843774; // 0x10103fe
    field public static final int controlY1 = 16843773; // 0x10103fd
@@ -780,7 +780,7 @@ package android {
    field public static final int layout_y = 16843136; // 0x1010180
    field public static final int left = 16843181; // 0x10101ad
    field public static final int letterSpacing = 16843958; // 0x10104b6
    field public static final int level = 16844032; // 0x1010500
    field public static final int level = 16844033; // 0x1010501
    field public static final int lineSpacingExtra = 16843287; // 0x1010217
    field public static final int lineSpacingMultiplier = 16843288; // 0x1010218
    field public static final int lines = 16843092; // 0x1010154
@@ -813,7 +813,7 @@ package android {
    field public static final int marqueeRepeatLimit = 16843293; // 0x101021d
    field public static final int matchOrder = 16843855; // 0x101044f
    field public static final int max = 16843062; // 0x1010136
    field public static final int maxButtonHeight = 16844029; // 0x10104fd
    field public static final int maxButtonHeight = 16844030; // 0x10104fe
    field public static final int maxDate = 16843584; // 0x1010340
    field public static final int maxEms = 16843095; // 0x1010157
    field public static final int maxHeight = 16843040; // 0x1010120
@@ -1174,6 +1174,7 @@ package android {
    field public static final int summaryOn = 16843247; // 0x10101ef
    field public static final int supportsAssist = 16844016; // 0x10104f0
    field public static final int supportsLaunchVoiceAssistFromKeyguard = 16844017; // 0x10104f1
    field public static final int supportsPictureInPicture = 16844024; // 0x10104f8
    field public static final int supportsRtl = 16843695; // 0x10103af
    field public static final int supportsSwitchingToNextInputMethod = 16843755; // 0x10103eb
    field public static final int supportsUploading = 16843419; // 0x101029b
@@ -1222,7 +1223,7 @@ package android {
    field public static final int textAppearanceListItemSmall = 16843679; // 0x101039f
    field public static final int textAppearanceMedium = 16842817; // 0x1010041
    field public static final int textAppearanceMediumInverse = 16842820; // 0x1010044
    field public static final int textAppearancePopupMenuHeader = 16844034; // 0x1010502
    field public static final int textAppearancePopupMenuHeader = 16844035; // 0x1010503
    field public static final int textAppearanceSearchResultSubtitle = 16843424; // 0x10102a0
    field public static final int textAppearanceSearchResultTitle = 16843425; // 0x10102a1
    field public static final int textAppearanceSmall = 16842818; // 0x1010042
@@ -1291,11 +1292,11 @@ package android {
    field public static final int tintMode = 16843771; // 0x10103fb
    field public static final int title = 16843233; // 0x10101e1
    field public static final int titleCondensed = 16843234; // 0x10101e2
    field public static final int titleMargin = 16844024; // 0x10104f8
    field public static final int titleMarginBottom = 16844028; // 0x10104fc
    field public static final int titleMarginEnd = 16844026; // 0x10104fa
    field public static final int titleMarginStart = 16844025; // 0x10104f9
    field public static final int titleMarginTop = 16844027; // 0x10104fb
    field public static final int titleMargin = 16844025; // 0x10104f9
    field public static final int titleMarginBottom = 16844029; // 0x10104fd
    field public static final int titleMarginEnd = 16844027; // 0x10104fb
    field public static final int titleMarginStart = 16844026; // 0x10104fa
    field public static final int titleMarginTop = 16844028; // 0x10104fc
    field public static final int titleTextAppearance = 16843822; // 0x101042e
    field public static final int titleTextColor = 16844003; // 0x10104e3
    field public static final int titleTextStyle = 16843512; // 0x10102f8
@@ -1395,7 +1396,7 @@ package android {
    field public static final int windowAllowReturnTransitionOverlap = 16843835; // 0x101043b
    field public static final int windowAnimationStyle = 16842926; // 0x10100ae
    field public static final int windowBackground = 16842836; // 0x1010054
    field public static final int windowBackgroundFallback = 16844035; // 0x1010503
    field public static final int windowBackgroundFallback = 16844036; // 0x1010504
    field public static final int windowClipToOutline = 16843947; // 0x10104ab
    field public static final int windowCloseOnTouchOutside = 16843611; // 0x101035b
    field public static final int windowContentOverlay = 16842841; // 0x1010059
+13 −12
Original line number Diff line number Diff line
@@ -413,7 +413,7 @@ package android {
    field public static final int buttonBarNeutralButtonStyle = 16843914; // 0x101048a
    field public static final int buttonBarPositiveButtonStyle = 16843913; // 0x1010489
    field public static final int buttonBarStyle = 16843566; // 0x101032e
    field public static final int buttonGravity = 16844030; // 0x10104fe
    field public static final int buttonGravity = 16844031; // 0x10104ff
    field public static final int buttonStyle = 16842824; // 0x1010048
    field public static final int buttonStyleInset = 16842826; // 0x101004a
    field public static final int buttonStyleSmall = 16842825; // 0x1010049
@@ -463,7 +463,7 @@ package android {
    field public static final int codes = 16843330; // 0x1010242
    field public static final int collapseColumns = 16843083; // 0x101014b
    field public static final int collapseContentDescription = 16843984; // 0x10104d0
    field public static final int collapseIcon = 16844031; // 0x10104ff
    field public static final int collapseIcon = 16844032; // 0x1010500
    field public static final int color = 16843173; // 0x10101a5
    field public static final int colorAccent = 16843829; // 0x1010435
    field public static final int colorActivatedHighlight = 16843664; // 0x1010390
@@ -504,7 +504,7 @@ package android {
    field public static final int contentInsetRight = 16843862; // 0x1010456
    field public static final int contentInsetStart = 16843859; // 0x1010453
    field public static final int contextClickable = 16844007; // 0x10104e7
    field public static final int contextPopupMenuStyle = 16844033; // 0x1010501
    field public static final int contextPopupMenuStyle = 16844034; // 0x1010502
    field public static final int controlX1 = 16843772; // 0x10103fc
    field public static final int controlX2 = 16843774; // 0x10103fe
    field public static final int controlY1 = 16843773; // 0x10103fd
@@ -872,7 +872,7 @@ package android {
    field public static final int layout_y = 16843136; // 0x1010180
    field public static final int left = 16843181; // 0x10101ad
    field public static final int letterSpacing = 16843958; // 0x10104b6
    field public static final int level = 16844032; // 0x1010500
    field public static final int level = 16844033; // 0x1010501
    field public static final int lineSpacingExtra = 16843287; // 0x1010217
    field public static final int lineSpacingMultiplier = 16843288; // 0x1010218
    field public static final int lines = 16843092; // 0x1010154
@@ -905,7 +905,7 @@ package android {
    field public static final int marqueeRepeatLimit = 16843293; // 0x101021d
    field public static final int matchOrder = 16843855; // 0x101044f
    field public static final int max = 16843062; // 0x1010136
    field public static final int maxButtonHeight = 16844029; // 0x10104fd
    field public static final int maxButtonHeight = 16844030; // 0x10104fe
    field public static final int maxDate = 16843584; // 0x1010340
    field public static final int maxEms = 16843095; // 0x1010157
    field public static final int maxHeight = 16843040; // 0x1010120
@@ -1270,6 +1270,7 @@ package android {
    field public static final int summaryOn = 16843247; // 0x10101ef
    field public static final int supportsAssist = 16844016; // 0x10104f0
    field public static final int supportsLaunchVoiceAssistFromKeyguard = 16844017; // 0x10104f1
    field public static final int supportsPictureInPicture = 16844024; // 0x10104f8
    field public static final int supportsRtl = 16843695; // 0x10103af
    field public static final int supportsSwitchingToNextInputMethod = 16843755; // 0x10103eb
    field public static final int supportsUploading = 16843419; // 0x101029b
@@ -1318,7 +1319,7 @@ package android {
    field public static final int textAppearanceListItemSmall = 16843679; // 0x101039f
    field public static final int textAppearanceMedium = 16842817; // 0x1010041
    field public static final int textAppearanceMediumInverse = 16842820; // 0x1010044
    field public static final int textAppearancePopupMenuHeader = 16844034; // 0x1010502
    field public static final int textAppearancePopupMenuHeader = 16844035; // 0x1010503
    field public static final int textAppearanceSearchResultSubtitle = 16843424; // 0x10102a0
    field public static final int textAppearanceSearchResultTitle = 16843425; // 0x10102a1
    field public static final int textAppearanceSmall = 16842818; // 0x1010042
@@ -1387,11 +1388,11 @@ package android {
    field public static final int tintMode = 16843771; // 0x10103fb
    field public static final int title = 16843233; // 0x10101e1
    field public static final int titleCondensed = 16843234; // 0x10101e2
    field public static final int titleMargin = 16844024; // 0x10104f8
    field public static final int titleMarginBottom = 16844028; // 0x10104fc
    field public static final int titleMarginEnd = 16844026; // 0x10104fa
    field public static final int titleMarginStart = 16844025; // 0x10104f9
    field public static final int titleMarginTop = 16844027; // 0x10104fb
    field public static final int titleMargin = 16844025; // 0x10104f9
    field public static final int titleMarginBottom = 16844029; // 0x10104fd
    field public static final int titleMarginEnd = 16844027; // 0x10104fb
    field public static final int titleMarginStart = 16844026; // 0x10104fa
    field public static final int titleMarginTop = 16844028; // 0x10104fc
    field public static final int titleTextAppearance = 16843822; // 0x101042e
    field public static final int titleTextColor = 16844003; // 0x10104e3
    field public static final int titleTextStyle = 16843512; // 0x10102f8
@@ -1491,7 +1492,7 @@ package android {
    field public static final int windowAllowReturnTransitionOverlap = 16843835; // 0x101043b
    field public static final int windowAnimationStyle = 16842926; // 0x10100ae
    field public static final int windowBackground = 16842836; // 0x1010054
    field public static final int windowBackgroundFallback = 16844035; // 0x1010503
    field public static final int windowBackgroundFallback = 16844036; // 0x1010504
    field public static final int windowClipToOutline = 16843947; // 0x10104ab
    field public static final int windowCloseOnTouchOutside = 16843611; // 0x101035b
    field public static final int windowContentOverlay = 16842841; // 0x1010059
+42 −75
Original line number Diff line number Diff line
@@ -154,7 +154,7 @@ public class Am extends BaseCommand {
                "       am stack movetask <TASK_ID> <STACK_ID> [true|false]\n" +
                "       am stack resize <STACK_ID> <LEFT,TOP,RIGHT,BOTTOM>\n" +
                "       am stack size-docked-stack-test: <STEP_SIZE> <l|t|r|b> [DELAY_MS]\n" +
                "       am stack split <STACK_ID> <v|h> [INTENT]\n" +
                "       am stack move-top-activity-to-pinned-stack: <STACK_ID> <LEFT,TOP,RIGHT,BOTTOM>\n" +
                "       am stack positiontask <TASK_ID> <STACK_ID> <POSITION>\n" +
                "       am stack list\n" +
                "       am stack info <STACK_ID>\n" +
@@ -297,11 +297,9 @@ public class Am extends BaseCommand {
                "   <STEP_SIZE> increments from the side <l>eft, <t>op, <r>ight, or <b>ottom\n" +
                "   applying the optional [DELAY_MS] between each step.\n" +
                "\n" +
                "am stack split: split <STACK_ID> into 2 stacks <v>ertically or <h>orizontally\n" +
                "   starting the new stack with [INTENT] if specified. If [INTENT] isn't\n" +
                "   specified and the current stack has more than one task, then the top task\n" +
                "   of the current task will be moved to the new stack. Command will also force\n" +
                "   all current tasks in both stacks to be resizeable.\n" +
                "am stack move-top-activity-to-pinned-stack: moves the top activity from\n" +
                "   <STACK_ID> to the pinned stack using <LEFT,TOP,RIGHT,BOTTOM> for the\n" +
                "   bounds of the pinned stack.\n" +
                "\n" +
                "am stack positiontask: place <TASK_ID> in <STACK_ID> at <POSITION>" +
                "\n" +
@@ -1954,25 +1952,34 @@ public class Am extends BaseCommand {

    private void runStack() throws Exception {
        String op = nextArgRequired();
        if (op.equals("start")) {
        switch (op) {
            case "start":
                runStackStart();
        } else if (op.equals("movetask")) {
                break;
            case "movetask":
                runStackMoveTask();
        } else if (op.equals("resize")) {
                break;
            case "resize":
                runStackResize();
        } else if (op.equals("positiontask")) {
                break;
            case "positiontask":
                runStackPositionTask();
        } else if (op.equals("list")) {
                break;
            case "list":
                runStackList();
        } else if (op.equals("info")) {
                break;
            case "info":
                runStackInfo();
        } else if (op.equals("split")) {
            runStackSplit();
        } else if (op.equals("size-docked-stack-test")) {
                break;
            case "move-top-activity-to-pinned-stack":
                runMoveTopActivityToPinnedStack();
                break;
            case "size-docked-stack-test":
                runStackSizeDockedStackTest();
        } else {
                break;
            default:
                showError("Error: unknown command '" + op + "'");
            return;
                break;
        }
    }

@@ -2072,61 +2079,21 @@ public class Am extends BaseCommand {
        }
    }

    private void runStackSplit() throws Exception {
        final int stackId = Integer.valueOf(nextArgRequired());
        final String splitDirection = nextArgRequired();
        Intent intent = null;
        try {
            intent = makeIntent(UserHandle.USER_CURRENT);
        } catch (IllegalArgumentException e) {
            // no intent supplied.
        }

        try {
            final StackInfo currentStackInfo = mAm.getStackInfo(stackId);
            // Calculate bounds for new and current stack.
            final Rect currentStackBounds = new Rect(currentStackInfo.bounds);
            final Rect newStackBounds = new Rect(currentStackInfo.bounds);
            if ("v".equals(splitDirection)) {
                currentStackBounds.right = newStackBounds.left = currentStackInfo.bounds.centerX();
            } else if ("h".equals(splitDirection)) {
                currentStackBounds.bottom = newStackBounds.top = currentStackInfo.bounds.centerY();
            } else {
                showError("Error: unknown split direction '" + splitDirection + "'");
    private void runMoveTopActivityToPinnedStack() throws Exception {
        int stackId = Integer.valueOf(nextArgRequired());
        final Rect bounds = getBounds();
        if (bounds == null) {
            System.err.println("Error: invalid input bounds");
            return;
        }

            // Create new stack
            IActivityContainer container = mAm.createStackOnDisplay(currentStackInfo.displayId);
            if (container == null) {
                showError("Error: Unable to create new stack...");
            }

            final int newStackId = container.getStackId();

            if (intent != null) {
                container.startActivity(intent);
            } else if (currentStackInfo.taskIds != null && currentStackInfo.taskIds.length > 1) {
                // Move top task over to new stack
                mAm.moveTaskToStack(currentStackInfo.taskIds[currentStackInfo.taskIds.length - 1],
                        newStackId, true);
            }

            final StackInfo newStackInfo = mAm.getStackInfo(newStackId);

            // Make all tasks in the stacks resizeable.
            for (int taskId : currentStackInfo.taskIds) {
                mAm.setTaskResizeable(taskId, true);
            }

            for (int taskId : newStackInfo.taskIds) {
                mAm.setTaskResizeable(taskId, true);
        try {
            if (!mAm.moveTopActivityToPinnedStack(stackId, bounds)) {
                showError("Didn't move top activity to pinned stack.");
            }

            // Resize stacks
            mAm.resizeStack(currentStackInfo.stackId, currentStackBounds, false);
            mAm.resizeStack(newStackInfo.stackId, newStackBounds, false);
        } catch (RemoteException e) {
            showError("Unable to move top activity: " + e);
            return;
        }
    }

+8 −1
Original line number Diff line number Diff line
@@ -433,11 +433,18 @@ public class ActivityManager {
     */
    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;

    /**
     * Last static stack stack ID.
     * @hide
     */
    public static final int LAST_STATIC_STACK_ID = DOCKED_STACK_ID;
    public static final int LAST_STATIC_STACK_ID = PINNED_STACK_ID;

    /**
     * Start of ID range used by stacks that are created dynamically.
+26 −0
Original line number Diff line number Diff line
@@ -755,6 +755,16 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM
            return true;
        }

        case MOVE_TOP_ACTIVITY_TO_PINNED_STACK: {
            data.enforceInterface(IActivityManager.descriptor);
            final int stackId = data.readInt();
            final Rect r = Rect.CREATOR.createFromParcel(data);
            final boolean res = moveTopActivityToPinnedStack(stackId, r);
            reply.writeNoException();
            reply.writeInt(res ? 1 : 0);
            return true;
        }

        case RESIZE_STACK_TRANSACTION: {
            data.enforceInterface(IActivityManager.descriptor);
            final int stackId = data.readInt();
@@ -3555,6 +3565,22 @@ class ActivityManagerProxy implements IActivityManager
        reply.recycle();
    }
    @Override
    public boolean moveTopActivityToPinnedStack(int stackId, Rect r)
        throws RemoteException
    {
        Parcel data = Parcel.obtain();
        Parcel reply = Parcel.obtain();
        data.writeInterfaceToken(IActivityManager.descriptor);
        data.writeInt(stackId);
        r.writeToParcel(data, 0);
        mRemote.transact(MOVE_TOP_ACTIVITY_TO_PINNED_STACK, data, reply, 0);
        reply.readException();
        final boolean res = reply.readInt() != 0;
        data.recycle();
        reply.recycle();
        return res;
    }
    @Override
    public void resizeStack(int stackId, Rect r, boolean allowResizeInDockedMode)
            throws RemoteException
    {
Loading