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

Commit 3382ab1f authored by Wale Ogunwale's avatar Wale Ogunwale
Browse files

Migrated some windowing methods from StackId to WindowConfiguration

First pass at transitioning away from using stack ids for windowing mode
to WindowConfiguration. Added some TODO that will require the introduction
of applicationType in WindowConfiguration before additional conversation
can be done.

Test: bit FrameworksServicesTests:com.android.server.wm.WindowConfigurationTests
Test: adb shell am instrument -w -e package com.android.server.wm com.android.frameworks.servicestests/android.support.test.runner.AndroidJUnitRunner
Test: go/wm-smoke
Change-Id: I2b315623faa16445a9f942e082089123842cb5a1
parent 6c008738
Loading
Loading
Loading
Loading
+2 −11
Original line number Diff line number Diff line
@@ -3203,9 +3203,8 @@ public class Activity extends ContextThemeWrapper


    /**
     * Moves the activity from
     * {@link android.app.ActivityManager.StackId#FREEFORM_WORKSPACE_STACK_ID} to
     * {@link android.app.ActivityManager.StackId#FULLSCREEN_WORKSPACE_STACK_ID} stack.
     * Moves the activity from {@link WindowConfiguration#WINDOWING_MODE_FREEFORM} windowing mode to
     * {@link WindowConfiguration#WINDOWING_MODE_FULLSCREEN}.
     *
     * @hide
     */
@@ -3214,14 +3213,6 @@ public class Activity extends ContextThemeWrapper
        ActivityManager.getService().exitFreeformMode(mToken);
    }

    /** Returns the current stack Id for the window.
     * @hide
     */
    @Override
    public int getWindowStackId() throws RemoteException {
        return ActivityManager.getService().getActivityStackId(mToken);
    }

    /**
     * Puts the activity in picture-in-picture mode if the activity supports.
     * @see android.R.attr#supportsPictureInPicture
+9 −88
Original line number Diff line number Diff line
@@ -699,45 +699,21 @@ public class ActivityManager {
        /** Start of ID range used by stacks that are created dynamically. */
        public static final int FIRST_DYNAMIC_STACK_ID = LAST_STATIC_STACK_ID + 1;

        // TODO: Figure-out a way to remove this.
        public static boolean isStaticStack(int stackId) {
            return stackId >= FIRST_STATIC_STACK_ID && stackId <= LAST_STATIC_STACK_ID;
        }

        // TODO: It seems this mostly means a stack on a secondary display now. Need to see if
        // there are other meanings. If not why not just use information from the display?
        public static boolean isDynamicStack(int stackId) {
            return stackId >= FIRST_DYNAMIC_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 stackId == FREEFORM_WORKSPACE_STACK_ID;
        }

        /**
         * Returns true if dynamic stacks are allowed to be visible behind the input stack.
         */
        // TODO: Figure-out a way to remove.
        public static boolean isDynamicStacksVisibleBehindAllowed(int stackId) {
            return stackId == PINNED_STACK_ID || stackId == ASSISTANT_STACK_ID;
        }
@@ -746,6 +722,7 @@ public class ActivityManager {
         * Returns true if we try to maintain focus in the current stack when the top activity
         * finishes.
         */
        // TODO: Figure-out a way to remove. Probably isn't needed in the new world...
        public static boolean keepFocusInStackIfPossible(int stackId) {
            return stackId == FREEFORM_WORKSPACE_STACK_ID
                    || stackId == DOCKED_STACK_ID || stackId == PINNED_STACK_ID;
@@ -754,6 +731,7 @@ public class ActivityManager {
        /**
         * Returns true if Stack size is affected by the docked stack changing size.
         */
        // TODO: Figure-out a way to remove.
        public static boolean isResizeableByDockedStack(int stackId) {
            return isStaticStack(stackId) && stackId != DOCKED_STACK_ID
                    && stackId != PINNED_STACK_ID && stackId != ASSISTANT_STACK_ID;
@@ -763,6 +741,7 @@ public class ActivityManager {
         * Returns true if the size of tasks in the input stack are affected by the docked stack
         * changing size.
         */
        // TODO: What is the difference between this method and the one above??
        public static boolean isTaskResizeableByDockedStack(int stackId) {
            return isStaticStack(stackId) && stackId != FREEFORM_WORKSPACE_STACK_ID
                    && stackId != DOCKED_STACK_ID && stackId != PINNED_STACK_ID
@@ -787,16 +766,6 @@ public class ActivityManager {
                    || targetStackId == FREEFORM_WORKSPACE_STACK_ID;
        }

        /**
         * Return whether a stackId is a stack containing floating windows. Floating windows
         * are laid out differently as they are allowed to extend past the display bounds
         * without overscan insets.
         */
        public static boolean tasksAreFloating(int stackId) {
            return stackId == FREEFORM_WORKSPACE_STACK_ID
                || stackId == PINNED_STACK_ID;
        }

        /**
         * Return whether a stackId is a stack that be a backdrop to a translucent activity.  These
         * are generally fullscreen stacks.
@@ -820,21 +789,6 @@ public class ActivityManager {
                    || stackId == INVALID_STACK_ID;
        }

        /**
         * Returns true if the windows in the stack can receive input keys.
         */
        public static boolean canReceiveKeys(int stackId) {
            return stackId != PINNED_STACK_ID;
        }

        /**
         * Returns true if the stack can be visible above lockscreen.
         */
        public static boolean isAllowedOverLockscreen(int stackId) {
            return stackId == HOME_STACK_ID || stackId == FULLSCREEN_WORKSPACE_STACK_ID ||
                    stackId == ASSISTANT_STACK_ID;
        }

        /**
         * Returns true if activities from stasks in the given {@param stackId} are allowed to
         * enter picture-in-picture.
@@ -844,10 +798,6 @@ public class ActivityManager {
                    stackId != RECENTS_STACK_ID;
        }

        public static boolean isAlwaysOnTop(int stackId) {
            return stackId == PINNED_STACK_ID;
        }

        /**
         * Returns true if the top task in the task is allowed to return home when finished and
         * there are other tasks in the stack.
@@ -864,28 +814,13 @@ public class ActivityManager {
            return stackId == PINNED_STACK_ID;
        }

        /**
         * Returns true if any visible windows belonging to apps in this stack should be kept on
         * screen when the app is killed due to something like the low memory killer.
         */
        public static boolean keepVisibleDeadAppWindowOnScreen(int stackId) {
            return stackId != PINNED_STACK_ID;
        }

        /**
         * Returns true if the backdrop on the client side should match the frame of the window.
         * Returns false, if the backdrop should be fullscreen.
         */
        public static boolean useWindowFrameForBackdrop(int stackId) {
            return stackId == FREEFORM_WORKSPACE_STACK_ID || stackId == PINNED_STACK_ID;
        }

        /**
         * Returns true if a window from the specified stack with {@param stackId} are normally
         * fullscreen, i. e. they can become the top opaque fullscreen window, meaning that it
         * controls system bars, lockscreen occluded/dismissing state, screen rotation animation,
         * etc.
         */
        // TODO: What about the other side of docked stack if we move this to WindowConfiguration?
        public static boolean normallyFullscreenWindows(int stackId) {
            return stackId != PINNED_STACK_ID && stackId != FREEFORM_WORKSPACE_STACK_ID
                    && stackId != DOCKED_STACK_ID;
@@ -896,6 +831,7 @@ public class ActivityManager {
         * multi-window mode.
         * @see android.app.ActivityManager#supportsMultiWindow
         */
        // TODO: What about the other side of docked stack if we move this to WindowConfiguration?
        public static boolean isMultiWindowStack(int stackId) {
            return stackId == PINNED_STACK_ID || stackId == FREEFORM_WORKSPACE_STACK_ID
                    || stackId == DOCKED_STACK_ID;
@@ -908,21 +844,6 @@ public class ActivityManager {
            return stackId == HOME_STACK_ID || stackId == RECENTS_STACK_ID;
        }

        /**
         * Returns true if this stack may be scaled without resizing, and windows within may need
         * to be configured as such.
         */
        public static boolean windowsAreScaleable(int stackId) {
            return stackId == PINNED_STACK_ID;
        }

        /**
         * Returns true if windows in this stack should be given move animations by default.
         */
        public static boolean hasMovementAnimations(int stackId) {
            return stackId != PINNED_STACK_ID;
        }

        /** Returns true if the input stack and its content can affect the device orientation. */
        public static boolean canSpecifyOrientation(int stackId) {
            return stackId == HOME_STACK_ID
+0 −1
Original line number Diff line number Diff line
@@ -478,7 +478,6 @@ interface IActivityManager {
     * different stack.
     */
    void positionTaskInStack(int taskId, int stackId, int position);
    int getActivityStackId(in IBinder token);
    void exitFreeformMode(in IBinder token);
    void reportSizeConfigurations(in IBinder token, in int[] horizontalSizeConfiguration,
            in int[] verticalSizeConfigurations, in int[] smallestWidthConfigurations);
+84 −0
Original line number Diff line number Diff line
@@ -277,6 +277,90 @@ public class WindowConfiguration implements Parcelable, Comparable<WindowConfigu
                + " mWindowingMode=" + windowingModeToString(mWindowingMode) + "}";
    }

    /**
     * Returns true if the activities associated with this window configuration display a shadow
     * around their border.
     */
    public boolean hasWindowShadow() {
        return tasksAreFloating();
    }

    /**
     * Returns true if the activities associated with this window configuration display a decor
     * view.
     */
    public boolean hasWindowDecorCaption() {
        return mWindowingMode == WINDOWING_MODE_FREEFORM;
    }

    /**
     * Returns true if the tasks associated with this window configuration can be resized
     * independently of their parent container.
     */
    public boolean canResizeTask() {
        return mWindowingMode == WINDOWING_MODE_FREEFORM;
    }

    /** Returns true if the task bounds should persist across power cycles. */
    public boolean persistTaskBounds() {
        return mWindowingMode == WINDOWING_MODE_FREEFORM;
    }

    /**
     * Returns true if the tasks associated with this window configuration are floating.
     * Floating tasks are laid out differently as they are allowed to extend past the display bounds
     * without overscan insets.
     */
    public boolean tasksAreFloating() {
        return mWindowingMode == WINDOWING_MODE_FREEFORM || mWindowingMode == WINDOWING_MODE_PINNED;
    }

    /**
     * Returns true if the windows associated with this window configuration can receive input keys.
     */
    public boolean canReceiveKeys() {
        return mWindowingMode != WINDOWING_MODE_PINNED;
    }

    /**
     * Returns true if the container associated with this window configuration is always-on-top of
     * its siblings.
     */
    public boolean isAlwaysOnTop() {
        return mWindowingMode == WINDOWING_MODE_PINNED;
    }

    /**
     * Returns true if any visible windows belonging to apps with this window configuration should
     * be kept on screen when the app is killed due to something like the low memory killer.
     */
    public boolean keepVisibleDeadAppWindowOnScreen() {
        return mWindowingMode != WINDOWING_MODE_PINNED;
    }

    /**
     * Returns true if the backdrop on the client side should match the frame of the window.
     * Returns false, if the backdrop should be fullscreen.
     */
    public boolean useWindowFrameForBackdrop() {
        return mWindowingMode == WINDOWING_MODE_FREEFORM || mWindowingMode == WINDOWING_MODE_PINNED;
    }

    /**
     * Returns true if this container may be scaled without resizing, and windows within may need
     * to be configured as such.
     */
    public boolean windowsAreScaleable() {
        return mWindowingMode == WINDOWING_MODE_PINNED;
    }

    /**
     * Returns true if windows in this container should be given move animations by default.
     */
    public boolean hasMovementAnimations() {
        return mWindowingMode == WINDOWING_MODE_PINNED;
    }

    private static String windowingModeToString(@WindowingMode int windowingMode) {
        switch (windowingMode) {
            case WINDOWING_MODE_UNDEFINED: return "undefined";
+3 −5
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.StyleRes;
import android.annotation.SystemApi;
import android.app.WindowConfiguration;
import android.content.Context;
import android.content.pm.ActivityInfo;
import android.content.res.Configuration;
@@ -611,8 +612,8 @@ public abstract class Window {
    public interface WindowControllerCallback {
        /**
         * Moves the activity from
         * {@link android.app.ActivityManager.StackId#FREEFORM_WORKSPACE_STACK_ID} to
         * {@link android.app.ActivityManager.StackId#FULLSCREEN_WORKSPACE_STACK_ID} stack.
         * Moves the activity from {@link WindowConfiguration#WINDOWING_MODE_FREEFORM} windowing
         * mode to {@link WindowConfiguration#WINDOWING_MODE_FULLSCREEN}.
         */
        void exitFreeformMode() throws RemoteException;

@@ -622,9 +623,6 @@ public abstract class Window {
         */
        void enterPictureInPictureModeIfPossible();

        /** Returns the current stack Id for the window. */
        int getWindowStackId() throws RemoteException;

        /** Returns whether the window belongs to the task root. */
        boolean isTaskRoot();
    }
Loading