diff options
| author | Chris Li <lihongyu@google.com> | 2020-09-14 12:45:11 -0700 |
|---|---|---|
| committer | Chris Li <lihongyu@google.com> | 2020-09-22 17:01:39 -0700 |
| commit | 3dbefb99c4669b4e8a0b28296ac18d8064213ea0 (patch) | |
| tree | 2500a73b396d034ba79c4a43750a68de07340bff /core/java | |
| parent | f747948b6d1fc080bcd11c83555eaafd4ed7441d (diff) | |
Add option to always ignore orientation request
(2/n Orientation on DisplayAreaGroup)
When the option is set to true, the TDA will ignore all the
fixed-orientation request from apps.
This can be used on duo display device, so that the logical display will
not be rotated when launching a fixed-orientation app on one of the
display.
Bug: 155431879
Test: manual: test with dual-display-area policy
Test: atest WmTests:TaskDisplayAreaTests
Test: atest WmTests:WindowOrganizerTests
Change-Id: I3f0ea1415523926195b51fe28744974a9b64d803
Diffstat (limited to 'core/java')
| -rw-r--r-- | core/java/android/window/WindowContainerTransaction.java | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/core/java/android/window/WindowContainerTransaction.java b/core/java/android/window/WindowContainerTransaction.java index 8be37e9e492d..ba901549f2b5 100644 --- a/core/java/android/window/WindowContainerTransaction.java +++ b/core/java/android/window/WindowContainerTransaction.java @@ -238,6 +238,22 @@ public final class WindowContainerTransaction implements Parcelable { } /** + * Sets whether a container should ignore the orientation request from apps below it. It + * currently only applies to {@link com.android.server.wm.TaskDisplayArea}. When {@code false}, + * it may rotate based on the orientation request; When {@code true}, it can never specify + * orientation, but shows the fixed-orientation apps in the letterbox. + * @hide + */ + @NonNull + public WindowContainerTransaction setIgnoreOrientationRequest( + @NonNull WindowContainerToken container, boolean ignoreOrientationRequest) { + Change chg = getOrCreateChange(container.asBinder()); + chg.mIgnoreOrientationRequest = ignoreOrientationRequest; + chg.mChangeMask |= Change.CHANGE_IGNORE_ORIENTATION_REQUEST; + return this; + } + + /** * Reparents a container into another one. The effect of a {@code null} parent can vary. For * example, reparenting a stack to {@code null} will reparent it to its display. * @@ -341,10 +357,12 @@ public final class WindowContainerTransaction implements Parcelable { public static final int CHANGE_PIP_CALLBACK = 1 << 2; public static final int CHANGE_HIDDEN = 1 << 3; public static final int CHANGE_BOUNDS_TRANSACTION_RECT = 1 << 4; + public static final int CHANGE_IGNORE_ORIENTATION_REQUEST = 1 << 5; private final Configuration mConfiguration = new Configuration(); private boolean mFocusable = true; private boolean mHidden = false; + private boolean mIgnoreOrientationRequest = false; private int mChangeMask = 0; private @ActivityInfo.Config int mConfigSetMask = 0; private @WindowConfiguration.WindowConfig int mWindowSetMask = 0; @@ -362,6 +380,7 @@ public final class WindowContainerTransaction implements Parcelable { mConfiguration.readFromParcel(in); mFocusable = in.readBoolean(); mHidden = in.readBoolean(); + mIgnoreOrientationRequest = in.readBoolean(); mChangeMask = in.readInt(); mConfigSetMask = in.readInt(); mWindowSetMask = in.readInt(); @@ -404,6 +423,9 @@ public final class WindowContainerTransaction implements Parcelable { if ((other.mChangeMask & CHANGE_HIDDEN) != 0) { mHidden = other.mHidden; } + if ((other.mChangeMask & CHANGE_IGNORE_ORIENTATION_REQUEST) != 0) { + mIgnoreOrientationRequest = other.mIgnoreOrientationRequest; + } mChangeMask |= other.mChangeMask; if (other.mActivityWindowingMode >= 0) { mActivityWindowingMode = other.mActivityWindowingMode; @@ -445,6 +467,15 @@ public final class WindowContainerTransaction implements Parcelable { return mHidden; } + /** Gets the requested state of whether to ignore orientation request. */ + public boolean getIgnoreOrientationRequest() { + if ((mChangeMask & CHANGE_IGNORE_ORIENTATION_REQUEST) == 0) { + throw new RuntimeException("IgnoreOrientationRequest not set. " + + "Check CHANGE_IGNORE_ORIENTATION_REQUEST first"); + } + return mIgnoreOrientationRequest; + } + public int getChangeMask() { return mChangeMask; } @@ -509,6 +540,9 @@ public final class WindowContainerTransaction implements Parcelable { if (mBoundsChangeTransaction != null) { sb.append("hasBoundsTransaction,"); } + if ((mChangeMask & CHANGE_IGNORE_ORIENTATION_REQUEST) != 0) { + sb.append("ignoreOrientationRequest:" + mIgnoreOrientationRequest + ","); + } sb.append("}"); return sb.toString(); } @@ -518,6 +552,7 @@ public final class WindowContainerTransaction implements Parcelable { mConfiguration.writeToParcel(dest, flags); dest.writeBoolean(mFocusable); dest.writeBoolean(mHidden); + dest.writeBoolean(mIgnoreOrientationRequest); dest.writeInt(mChangeMask); dest.writeInt(mConfigSetMask); dest.writeInt(mWindowSetMask); |
