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

Commit 99db1863 authored by Wale Ogunwale's avatar Wale Ogunwale
Browse files

Added support for pinned stack.

Used to support picture-in-picture use case for multi-window

Bug: 25006507
Change-Id: I3bef3f75e0c003f5974274294f1250171d424625
parent b6d8f81b
Loading
Loading
Loading
Loading
+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.
+3 −2
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ 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.view.View.MeasureSpec.AT_MOST;
import static android.view.View.MeasureSpec.EXACTLY;
import static android.view.View.MeasureSpec.getMode;
@@ -5408,7 +5409,7 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
     * @Return Returns true if the window should show a non client decor.
     **/
    private static boolean hasNonClientDecor(int workspaceId) {
        return workspaceId == FREEFORM_WORKSPACE_STACK_ID;
        return workspaceId == FREEFORM_WORKSPACE_STACK_ID || workspaceId == PINNED_STACK_ID;
    }

    /**
@@ -5417,7 +5418,7 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
     * @Return Returns true if the window should show a shadow.
     **/
    private static boolean nonClientDecorHasShadow(int workspaceId) {
        return workspaceId == FREEFORM_WORKSPACE_STACK_ID;
        return workspaceId == FREEFORM_WORKSPACE_STACK_ID || workspaceId == PINNED_STACK_ID;
    }

    @Override
+4 −2
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import static android.app.ActivityManager.FREEFORM_WORKSPACE_STACK_ID;
import static android.app.ActivityManager.FULLSCREEN_WORKSPACE_STACK_ID;
import static android.app.ActivityManager.HOME_STACK_ID;
import static android.app.ActivityManager.INVALID_STACK_ID;
import static android.app.ActivityManager.PINNED_STACK_ID;
import static android.app.ActivityManager.RESIZE_MODE_PRESERVE_WINDOW;
import static android.content.pm.PackageManager.PERMISSION_GRANTED;
import static com.android.internal.util.XmlUtils.readBooleanAttribute;
@@ -8638,9 +8639,10 @@ public final class ActivityManagerService extends ActivityManagerNative
                // - a non-null bounds on a non-freeform (fullscreen OR docked) task moves
                //   that task to freeform
                // - otherwise the task is not moved
                // Note it's not allowed to resize a home stack task, or a docked task.
                // Note it's not allowed to resize a home, docked, or pinned stack task.
                int stackId = task.stack.mStackId;
                if (stackId == HOME_STACK_ID || stackId == DOCKED_STACK_ID) {
                if (stackId == HOME_STACK_ID || stackId == DOCKED_STACK_ID
                        || stackId == PINNED_STACK_ID) {
                    throw new IllegalArgumentException("trying to resizeTask on a "
                            + "home or docked task");
                }
+21 −12
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import static android.app.ActivityManager.FREEFORM_WORKSPACE_STACK_ID;
import static android.app.ActivityManager.FULLSCREEN_WORKSPACE_STACK_ID;
import static android.app.ActivityManager.HOME_STACK_ID;
import static android.app.ActivityManager.LAST_STATIC_STACK_ID;
import static android.app.ActivityManager.PINNED_STACK_ID;
import static android.content.pm.ActivityInfo.FLAG_SHOW_FOR_ALL_USERS;

import static com.android.server.am.ActivityManagerDebugConfig.*;
@@ -253,6 +254,9 @@ final class ActivityStack {

    private final LaunchingTaskPositioner mTaskPositioner;

    // If the bounds of task contained in this stack should be persisted across power cycles.
    final boolean mPersistTaskBounds;

    static final int PAUSE_TIMEOUT_MSG = ActivityManagerService.FIRST_ACTIVITY_STACK_MSG + 1;
    static final int DESTROY_TIMEOUT_MSG = ActivityManagerService.FIRST_ACTIVITY_STACK_MSG + 2;
    static final int LAUNCH_TICK_MSG = ActivityManagerService.FIRST_ACTIVITY_STACK_MSG + 3;
@@ -354,10 +358,6 @@ final class ActivityStack {
        return count;
    }

    int numTasks() {
        return mTaskHistory.size();
    }

    ActivityStack(ActivityStackSupervisor.ActivityContainer activityContainer,
            RecentTasks recentTasks) {
        mActivityContainer = activityContainer;
@@ -370,6 +370,7 @@ final class ActivityStack {
        mRecentTasks = recentTasks;
        mTaskPositioner = mStackId == FREEFORM_WORKSPACE_STACK_ID
                ? new LaunchingTaskPositioner() : null;
        mPersistTaskBounds = mStackId != DOCKED_STACK_ID && mStackId != PINNED_STACK_ID;
    }

    void attachDisplay(ActivityStackSupervisor.ActivityDisplay activityDisplay, boolean onTop) {
@@ -1306,6 +1307,11 @@ final class ActivityStack {
            return true;
        }

        if (mStackId == PINNED_STACK_ID) {
            // Pinned stack is always visible if it exist.
            return true;
        }

        final int stackIndex = mStacks.indexOf(this);

        if (stackIndex == mStacks.size() - 1) {
@@ -1328,8 +1334,9 @@ final class ActivityStack {
        }

        final int belowFocusedIndex = mStacks.indexOf(focusedStack) - 1;
        if (focusedStackId == DOCKED_STACK_ID && stackIndex == belowFocusedIndex) {
            // Stacks directly behind the docked stack are always visible.
        if ((focusedStackId == DOCKED_STACK_ID || focusedStackId == PINNED_STACK_ID)
                && stackIndex == belowFocusedIndex) {
            // Stacks directly behind the docked or pinned stack are always visible.
            return true;
        }

@@ -1343,9 +1350,10 @@ final class ActivityStack {
            }
            if (belowFocusedIndex >= 0) {
                final ActivityStack stack = mStacks.get(belowFocusedIndex);
                if (stack.mStackId == DOCKED_STACK_ID && stackIndex == (belowFocusedIndex - 1)) {
                    // The stack behind the docked stack is also visible so we can have a complete
                    // backdrop to the translucent activity when the docked stack is up.
                if ((stack.mStackId == DOCKED_STACK_ID || stack.mStackId == PINNED_STACK_ID)
                        && stackIndex == (belowFocusedIndex - 1)) {
                    // The stack behind the docked or pinned stack is also visible so we can have a
                    // complete backdrop to the translucent activity when the docked stack is up.
                    return true;
                }
            }
@@ -2784,9 +2792,10 @@ final class ActivityStack {
            final String myReason = reason + " adjustFocus";
            if (next != r) {
                if (next != null && (mStackId == FREEFORM_WORKSPACE_STACK_ID
                        || mStackId == DOCKED_STACK_ID)) {
                    // For freeform and docked stacks we always keep the focus within the stack as
                    // long as there is a running activity in the stack that we can adjust focus to.
                        || mStackId == DOCKED_STACK_ID || mStackId == PINNED_STACK_ID)) {
                    // For freeform, docked, and pinned stacks we always keep the focus within the
                    // stack as long as there is a running activity in the stack that we can adjust
                    // focus to.
                    mService.setFocusedActivityLocked(next, myReason);
                    return;
                } else {
+3 −2
Original line number Diff line number Diff line
@@ -3293,7 +3293,8 @@ public final class ActivityStackSupervisor implements DisplayListener {
            return;
        }
        final String reason = "moveTaskToStack";
        if (stackId == DOCKED_STACK_ID || stackId == FULLSCREEN_WORKSPACE_STACK_ID) {
        if (stackId == DOCKED_STACK_ID || stackId == PINNED_STACK_ID
                || stackId == FULLSCREEN_WORKSPACE_STACK_ID) {
            // We are about to relaunch the activity because its configuration changed due to
            // being maximized, i.e. size change. The activity will first remove the old window
            // and then add a new one. This call will tell window manager about this, so it can
@@ -3314,7 +3315,7 @@ public final class ActivityStackSupervisor implements DisplayListener {
                && task.mBounds == null && task.mLastNonFullscreenBounds != null) {
            resizeTaskLocked(task, task.mLastNonFullscreenBounds,
                    RESIZE_MODE_SYSTEM, !PRESERVE_WINDOWS);
        } else if (stackId == DOCKED_STACK_ID) {
        } else if (stackId == DOCKED_STACK_ID || stackId == PINNED_STACK_ID) {
            resizeTaskLocked(task, stack.mBounds,
                    RESIZE_MODE_SYSTEM, !PRESERVE_WINDOWS);
        }
Loading