From 3dbefb99c4669b4e8a0b28296ac18d8064213ea0 Mon Sep 17 00:00:00 2001 From: Chris Li Date: Mon, 14 Sep 2020 12:45:11 -0700 Subject: 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 --- .../android/window/WindowContainerTransaction.java | 35 ++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'core/java/android/window/WindowContainerTransaction.java') 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 @@ -237,6 +237,22 @@ public final class WindowContainerTransaction implements Parcelable { return this; } + /** + * 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); -- cgit v1.2.3