diff options
| author | Kazuki Takise <takise@google.com> | 2018-05-31 15:32:19 +0900 |
|---|---|---|
| committer | Kazuki Takise <takise@google.com> | 2018-06-18 14:10:31 +0900 |
| commit | 148d00ac935a344ddc9385caaff80680a228516f (patch) | |
| tree | 7a36cfb5bcb39ef60d7454f6771ebcd393481ac1 /core/java/android/app/WindowConfiguration.java | |
| parent | 0287faf3486ab778b5abae8c626b0a96ecf33412 (diff) | |
Add always on top feature support
Add basic functionalities for always on top feature.
- Add a new flag to WindowConfiguration to represent a task wanting to
be on top.
- Update the logic on changing the z-order of windows to make sure
always on top windows are placed above other windows.
Bug: 69370884
Test: go/wm-smoke
Test: atest DisplayContentTests
Test: Used ArcCompanionLibDemo app to verify that when always-on-top is
set, the app is above the other Android apps and Chrome windows.
Change-Id: Ie8edeb8ceeed0b9ec154b6031ed6cbe7ecc65b12
Diffstat (limited to 'core/java/android/app/WindowConfiguration.java')
| -rw-r--r-- | core/java/android/app/WindowConfiguration.java | 51 |
1 files changed, 47 insertions, 4 deletions
diff --git a/core/java/android/app/WindowConfiguration.java b/core/java/android/app/WindowConfiguration.java index 21d6762666a0..09c7981d7056 100644 --- a/core/java/android/app/WindowConfiguration.java +++ b/core/java/android/app/WindowConfiguration.java @@ -59,6 +59,11 @@ public class WindowConfiguration implements Parcelable, Comparable<WindowConfigu /** The current windowing mode of the configuration. */ private @WindowingMode int mWindowingMode; + private int mFlags; + + /** Indicates that this window should always be on top of the other windows. */ + private static final int PFLAG_ALWAYS_ON_TOP = 1 << 0; + /** 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. */ @@ -136,13 +141,16 @@ public class WindowConfiguration implements Parcelable, Comparable<WindowConfigu /** Bit that indicates that the {@link #mActivityType} changed. * @hide */ public static final int WINDOW_CONFIG_ACTIVITY_TYPE = 1 << 3; - + /** Bit that indicates that the {@link #mFlags} changed. + * @hide */ + public static final int WINDOW_CONFIG_FLAGS = 1 << 4; /** @hide */ @IntDef(flag = true, prefix = { "WINDOW_CONFIG_" }, value = { WINDOW_CONFIG_BOUNDS, WINDOW_CONFIG_APP_BOUNDS, WINDOW_CONFIG_WINDOWING_MODE, - WINDOW_CONFIG_ACTIVITY_TYPE + WINDOW_CONFIG_ACTIVITY_TYPE, + WINDOW_CONFIG_FLAGS }) public @interface WindowConfig {} @@ -168,6 +176,7 @@ public class WindowConfiguration implements Parcelable, Comparable<WindowConfigu dest.writeParcelable(mAppBounds, flags); dest.writeInt(mWindowingMode); dest.writeInt(mActivityType); + dest.writeInt(mFlags); } private void readFromParcel(Parcel source) { @@ -175,6 +184,7 @@ public class WindowConfiguration implements Parcelable, Comparable<WindowConfigu mAppBounds = source.readParcelable(Rect.class.getClassLoader()); mWindowingMode = source.readInt(); mActivityType = source.readInt(); + mFlags = source.readInt(); } @Override @@ -222,6 +232,23 @@ public class WindowConfiguration implements Parcelable, Comparable<WindowConfigu setAppBounds(rect.left, rect.top, rect.right, rect.bottom); } + private void setFlags(int flags) { + mFlags = flags; + } + + /** + * Sets whether this window should be always on top. + * @param alwaysOnTop {@code true} to set window always on top, otherwise {@code false} + * @hide + */ + public void setAlwaysOnTop(boolean alwaysOnTop) { + if (alwaysOnTop) { + mFlags |= PFLAG_ALWAYS_ON_TOP; + } else { + mFlags &= ~PFLAG_ALWAYS_ON_TOP; + } + } + /** * @see #setAppBounds(Rect) * @see #getAppBounds() @@ -281,6 +308,7 @@ public class WindowConfiguration implements Parcelable, Comparable<WindowConfigu setAppBounds(other.mAppBounds); setWindowingMode(other.mWindowingMode); setActivityType(other.mActivityType); + setFlags(other.mFlags); } /** Set this object to completely undefined. @@ -295,6 +323,7 @@ public class WindowConfiguration implements Parcelable, Comparable<WindowConfigu setBounds(null); setWindowingMode(WINDOWING_MODE_UNDEFINED); setActivityType(ACTIVITY_TYPE_UNDEFINED); + setFlags(0); } /** @@ -312,6 +341,10 @@ public class WindowConfiguration implements Parcelable, Comparable<WindowConfigu changed |= WINDOW_CONFIG_BOUNDS; setBounds(delta.mBounds); } + if (delta.mFlags != mFlags) { + changed |= WINDOW_CONFIG_FLAGS; + setFlags(delta.mFlags); + } if (delta.mAppBounds != null && !delta.mAppBounds.equals(mAppBounds)) { changed |= WINDOW_CONFIG_APP_BOUNDS; setAppBounds(delta.mAppBounds); @@ -347,6 +380,10 @@ public class WindowConfiguration implements Parcelable, Comparable<WindowConfigu changes |= WINDOW_CONFIG_BOUNDS; } + if (mFlags != other.mFlags) { + changes |= WINDOW_CONFIG_FLAGS; + } + // Make sure that one of the values is not null and that they are not equal. if ((compareUndefined || other.mAppBounds != null) && mAppBounds != other.mAppBounds @@ -399,6 +436,9 @@ public class WindowConfiguration implements Parcelable, Comparable<WindowConfigu n = mActivityType - that.mActivityType; if (n != 0) return n; + n = mFlags - that.mFlags; + if (n != 0) return n; + // if (n != 0) return n; return n; } @@ -425,6 +465,7 @@ public class WindowConfiguration implements Parcelable, Comparable<WindowConfigu result = 31 * result + mWindowingMode; result = 31 * result + mActivityType; + result = 31 * result + mFlags; return result; } @@ -434,7 +475,9 @@ public class WindowConfiguration implements Parcelable, Comparable<WindowConfigu return "{ mBounds=" + mBounds + " mAppBounds=" + mAppBounds + " mWindowingMode=" + windowingModeToString(mWindowingMode) - + " mActivityType=" + activityTypeToString(mActivityType) + "}"; + + " mActivityType=" + activityTypeToString(mActivityType) + + " mFlags=0x" + Integer.toHexString(mFlags) + + "}"; } /** @@ -520,7 +563,7 @@ public class WindowConfiguration implements Parcelable, Comparable<WindowConfigu * @hide */ public boolean isAlwaysOnTop() { - return mWindowingMode == WINDOWING_MODE_PINNED; + return mWindowingMode == WINDOWING_MODE_PINNED || (mFlags & PFLAG_ALWAYS_ON_TOP) != 0; } /** |
