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

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

Merge "Introducing windowing mode in WindowConfiguration."

parents e7169710 687b4273
Loading
Loading
Loading
Loading
+69 −4
Original line number Original line Diff line number Diff line
@@ -44,16 +44,43 @@ public class WindowConfiguration implements Parcelable, Comparable<WindowConfigu
     */
     */
    private Rect mAppBounds;
    private Rect mAppBounds;


    /** The current windowing mode of the configuration. */
    private @WindowingMode int mWindowingMode;

    /** Windowing mode is currently not defined. */
    public static final int WINDOWING_MODE_UNDEFINED = 0;
    /** Occupies the full area of the screen or the parent container. */
    public static final int WINDOWING_MODE_FULLSCREEN = 1;
    /** Always on-top (always visible). of other siblings in its parent container. */
    public static final int WINDOWING_MODE_PINNED = 2;
    /** Occupies a dedicated region of the screen or its parent container. */
    public static final int WINDOWING_MODE_DOCKED = 3;
    /** Can be freely resized within its parent container. */
    public static final int WINDOWING_MODE_FREEFORM = 4;

    @IntDef(value = {
            WINDOWING_MODE_UNDEFINED,
            WINDOWING_MODE_FULLSCREEN,
            WINDOWING_MODE_PINNED,
            WINDOWING_MODE_DOCKED,
            WINDOWING_MODE_FREEFORM,
    })
    @Retention(RetentionPolicy.SOURCE)
    public @interface WindowingMode {}

    /** Bit that indicates that the {@link #mAppBounds} changed. */
    public static final int WINDOW_CONFIG_APP_BOUNDS = 1 << 0;
    /** Bit that indicates that the {@link #mWindowingMode} changed. */
    public static final int WINDOW_CONFIG_WINDOWING_MODE = 1 << 1;

    @IntDef(flag = true,
    @IntDef(flag = true,
            value = {
            value = {
                    WINDOW_CONFIG_APP_BOUNDS,
                    WINDOW_CONFIG_APP_BOUNDS,
                    WINDOW_CONFIG_WINDOWING_MODE,
            })
            })
    @Retention(RetentionPolicy.SOURCE)
    @Retention(RetentionPolicy.SOURCE)
    public @interface WindowConfig {}
    public @interface WindowConfig {}


    /** Bit that indicates that the {@link #mAppBounds} changed. */
    public static final int WINDOW_CONFIG_APP_BOUNDS = 1 << 0;

    public WindowConfiguration() {
    public WindowConfiguration() {
        unset();
        unset();
    }
    }
@@ -69,10 +96,12 @@ public class WindowConfiguration implements Parcelable, Comparable<WindowConfigu
    @Override
    @Override
    public void writeToParcel(Parcel dest, int flags) {
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeParcelable(mAppBounds, flags);
        dest.writeParcelable(mAppBounds, flags);
        dest.writeInt(mWindowingMode);
    }
    }


    private void readFromParcel(Parcel source) {
    private void readFromParcel(Parcel source) {
        mAppBounds = source.readParcelable(Rect.class.getClassLoader());
        mAppBounds = source.readParcelable(Rect.class.getClassLoader());
        mWindowingMode = source.readInt();
    }
    }


    @Override
    @Override
@@ -125,8 +154,18 @@ public class WindowConfiguration implements Parcelable, Comparable<WindowConfigu
        return mAppBounds;
        return mAppBounds;
    }
    }


    public void setWindowingMode(@WindowingMode int windowingMode) {
        mWindowingMode = windowingMode;
    }

    @WindowingMode
    public int getWindowingMode() {
        return mWindowingMode;
    }

    public void setTo(WindowConfiguration other) {
    public void setTo(WindowConfiguration other) {
        setAppBounds(other.mAppBounds);
        setAppBounds(other.mAppBounds);
        setWindowingMode(other.mWindowingMode);
    }
    }


    /** Set this object to completely undefined. */
    /** Set this object to completely undefined. */
@@ -136,6 +175,7 @@ public class WindowConfiguration implements Parcelable, Comparable<WindowConfigu


    public void setToDefaults() {
    public void setToDefaults() {
        setAppBounds(null);
        setAppBounds(null);
        setWindowingMode(WINDOWING_MODE_UNDEFINED);
    }
    }


    /**
    /**
@@ -151,6 +191,11 @@ public class WindowConfiguration implements Parcelable, Comparable<WindowConfigu
            changed |= WINDOW_CONFIG_APP_BOUNDS;
            changed |= WINDOW_CONFIG_APP_BOUNDS;
            setAppBounds(delta.mAppBounds);
            setAppBounds(delta.mAppBounds);
        }
        }
        if (delta.mWindowingMode != WINDOWING_MODE_UNDEFINED
                && mWindowingMode != delta.mWindowingMode) {
            changed |= WINDOW_CONFIG_WINDOWING_MODE;
            setWindowingMode(delta.mWindowingMode);
        }
        return changed;
        return changed;
    }
    }


@@ -174,6 +219,11 @@ public class WindowConfiguration implements Parcelable, Comparable<WindowConfigu
            changes |= WINDOW_CONFIG_APP_BOUNDS;
            changes |= WINDOW_CONFIG_APP_BOUNDS;
        }
        }


        if ((compareUndefined || other.mWindowingMode != WINDOWING_MODE_UNDEFINED)
                && mWindowingMode != other.mWindowingMode) {
            changes |= WINDOW_CONFIG_WINDOWING_MODE;
        }

        return changes;
        return changes;
    }
    }


@@ -194,6 +244,8 @@ public class WindowConfiguration implements Parcelable, Comparable<WindowConfigu
            n = mAppBounds.bottom - that.mAppBounds.bottom;
            n = mAppBounds.bottom - that.mAppBounds.bottom;
            if (n != 0) return n;
            if (n != 0) return n;
        }
        }
        n = mWindowingMode - that.mWindowingMode;
        if (n != 0) return n;


        // if (n != 0) return n;
        // if (n != 0) return n;
        return n;
        return n;
@@ -215,11 +267,24 @@ public class WindowConfiguration implements Parcelable, Comparable<WindowConfigu
        if (mAppBounds != null) {
        if (mAppBounds != null) {
            result = 31 * result + mAppBounds.hashCode();
            result = 31 * result + mAppBounds.hashCode();
        }
        }
        result = 31 * result + mWindowingMode;
        return result;
        return result;
    }
    }


    @Override
    @Override
    public String toString() {
    public String toString() {
        return "{mAppBounds=" + mAppBounds + "}";
        return "{mAppBounds=" + mAppBounds
                + " mWindowingMode=" + windowingModeToString(mWindowingMode) + "}";
    }

    private static String windowingModeToString(@WindowingMode int windowingMode) {
        switch (windowingMode) {
            case WINDOWING_MODE_UNDEFINED: return "undefined";
            case WINDOWING_MODE_FULLSCREEN: return "fullscreen";
            case WINDOWING_MODE_PINNED: return "pinned";
            case WINDOWING_MODE_DOCKED: return "docked";
            case WINDOWING_MODE_FREEFORM: return "freeform";
        }
        return String.valueOf(windowingMode);
    }
    }
}
}
+7 −3
Original line number Original line Diff line number Diff line
@@ -460,14 +460,18 @@ class ActivityStack<T extends StackWindowController> extends ConfigurationContai
        mTaskPositioner = mStackId == FREEFORM_WORKSPACE_STACK_ID
        mTaskPositioner = mStackId == FREEFORM_WORKSPACE_STACK_ID
                ? new LaunchingTaskPositioner() : null;
                ? new LaunchingTaskPositioner() : null;
        mTmpRect2.setEmpty();
        mTmpRect2.setEmpty();
        final Configuration overrideConfig = getOverrideConfiguration();
        mWindowContainerController = createStackWindowController(display.mDisplayId, onTop,
        mWindowContainerController = createStackWindowController(display.mDisplayId, onTop,
                mTmpRect2);
                mTmpRect2, overrideConfig);
        onOverrideConfigurationChanged(overrideConfig);
        mStackSupervisor.mStacks.put(mStackId, this);
        mStackSupervisor.mStacks.put(mStackId, this);
        postAddToDisplay(display, mTmpRect2.isEmpty() ? null : mTmpRect2, onTop);
        postAddToDisplay(display, mTmpRect2.isEmpty() ? null : mTmpRect2, onTop);
    }
    }


    T createStackWindowController(int displayId, boolean onTop, Rect outBounds) {
    T createStackWindowController(int displayId, boolean onTop, Rect outBounds,
        return (T) new StackWindowController(mStackId, this, displayId, onTop, outBounds);
            Configuration outOverrideConfig) {
        return (T) new StackWindowController(mStackId, this, displayId, onTop, outBounds,
                outOverrideConfig);
    }
    }


    T getWindowContainerController() {
    T getWindowContainerController() {
+3 −2
Original line number Original line Diff line number Diff line
@@ -39,8 +39,9 @@ class PinnedActivityStack extends ActivityStack<PinnedStackWindowController>


    @Override
    @Override
    PinnedStackWindowController createStackWindowController(int displayId, boolean onTop,
    PinnedStackWindowController createStackWindowController(int displayId, boolean onTop,
            Rect outBounds) {
            Rect outBounds, Configuration outOverrideConfig) {
        return new PinnedStackWindowController(mStackId, this, displayId, onTop, outBounds);
        return new PinnedStackWindowController(mStackId, this, displayId, onTop, outBounds,
                outOverrideConfig);
    }
    }


    Rect getDefaultPictureInPictureBounds(float aspectRatio) {
    Rect getDefaultPictureInPictureBounds(float aspectRatio) {
+7 −0
Original line number Original line Diff line number Diff line
@@ -16,6 +16,7 @@


package com.android.server.wm;
package com.android.server.wm;


import android.app.WindowConfiguration;
import android.content.res.Configuration;
import android.content.res.Configuration;


/**
/**
@@ -109,6 +110,12 @@ public abstract class ConfigurationContainer<E extends ConfigurationContainer> {
        }
        }
    }
    }


    /** Sets the windowing mode for the configuration container. */
    void setWindowingMode(@WindowConfiguration.WindowingMode int windowingMode) {
        mOverrideConfiguration.windowConfiguration.setWindowingMode(windowingMode);
        onOverrideConfigurationChanged(mOverrideConfiguration);
    }

    /**
    /**
     * Must be called when new parent for the container was set.
     * Must be called when new parent for the container was set.
     */
     */
+8 −2
Original line number Original line Diff line number Diff line
@@ -20,9 +20,12 @@ import static android.app.ActivityManager.StackId.DOCKED_STACK_ID;
import static android.app.ActivityManager.StackId.FREEFORM_WORKSPACE_STACK_ID;
import static android.app.ActivityManager.StackId.FREEFORM_WORKSPACE_STACK_ID;
import static android.app.ActivityManager.StackId.HOME_STACK_ID;
import static android.app.ActivityManager.StackId.HOME_STACK_ID;
import static android.app.ActivityManager.StackId.PINNED_STACK_ID;
import static android.app.ActivityManager.StackId.PINNED_STACK_ID;
import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN;
import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_BEHIND;
import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_BEHIND;
import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_UNSET;
import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_UNSET;
import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
import static android.content.res.Configuration.ORIENTATION_LANDSCAPE;
import static android.content.res.Configuration.ORIENTATION_PORTRAIT;
import static android.view.Display.DEFAULT_DISPLAY;
import static android.view.Display.DEFAULT_DISPLAY;
import static android.view.Display.FLAG_PRIVATE;
import static android.view.Display.FLAG_PRIVATE;
import static android.view.Surface.ROTATION_0;
import static android.view.Surface.ROTATION_0;
@@ -109,6 +112,7 @@ import static com.android.server.wm.proto.DisplayProto.STACKS;


import android.annotation.NonNull;
import android.annotation.NonNull;
import android.app.ActivityManager.StackId;
import android.app.ActivityManager.StackId;
import android.app.WindowConfiguration;
import android.content.res.CompatibilityInfo;
import android.content.res.CompatibilityInfo;
import android.content.res.Configuration;
import android.content.res.Configuration;
import android.graphics.Bitmap;
import android.graphics.Bitmap;
@@ -1191,8 +1195,10 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo


        final int dw = displayInfo.logicalWidth;
        final int dw = displayInfo.logicalWidth;
        final int dh = displayInfo.logicalHeight;
        final int dh = displayInfo.logicalHeight;
        config.orientation = (dw <= dh) ? Configuration.ORIENTATION_PORTRAIT :
        config.orientation = (dw <= dh) ? ORIENTATION_PORTRAIT : ORIENTATION_LANDSCAPE;
                Configuration.ORIENTATION_LANDSCAPE;
        // TODO: Probably best to set this based on some setting in the display content object,
        // so the display can be configured for things like fullscreen.
        config.windowConfiguration.setWindowingMode(WINDOWING_MODE_FULLSCREEN);


        config.screenWidthDp =
        config.screenWidthDp =
                (int)(mService.mPolicy.getConfigDisplayWidth(dw, dh, displayInfo.rotation,
                (int)(mService.mPolicy.getConfigDisplayWidth(dw, dh, displayInfo.rotation,
Loading