diff options
21 files changed, 313 insertions, 176 deletions
diff --git a/core/java/android/app/AppCompatTaskInfo.java b/core/java/android/app/AppCompatTaskInfo.java index a6d3f9dba080..81e9df66e18a 100644 --- a/core/java/android/app/AppCompatTaskInfo.java +++ b/core/java/android/app/AppCompatTaskInfo.java @@ -18,63 +18,21 @@ package android.app; import static android.app.TaskInfo.PROPERTY_VALUE_UNSET; +import android.annotation.IntDef; import android.annotation.NonNull; import android.annotation.Nullable; import android.os.Parcel; import android.os.Parcelable; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + /** * Stores App Compat information about a particular Task. * @hide */ public class AppCompatTaskInfo implements Parcelable { /** - * Whether the direct top activity is eligible for letterbox education. - */ - public boolean topActivityEligibleForLetterboxEducation; - - /** - * Whether the letterbox education is enabled. - */ - public boolean isLetterboxEducationEnabled; - - /** - * Whether the direct top activity is in size compat mode on foreground. - */ - public boolean topActivityInSizeCompat; - - /** - * Whether the double tap is enabled. - */ - public boolean isLetterboxDoubleTapEnabled; - - /** - * Whether the user aspect ratio settings button is enabled. - */ - public boolean topActivityEligibleForUserAspectRatioButton; - - /** - * Whether the user has forced the activity to be fullscreen through the user aspect ratio - * settings. - */ - public boolean isUserFullscreenOverrideEnabled; - - /** - * Whether the system has forced the activity to be fullscreen - */ - public boolean isSystemFullscreenOverrideEnabled; - - /** - * Hint about the letterbox state of the top activity. - */ - public boolean topActivityBoundsLetterboxed; - - /** - * Whether the update comes from a letterbox double-tap action from the user or not. - */ - public boolean isFromLetterboxDoubleTap; - - /** * If {@link #isLetterboxDoubleTapEnabled} it contains the current letterbox vertical position * or {@link TaskInfo#PROPERTY_VALUE_UNSET} otherwise. */ @@ -115,6 +73,57 @@ public class AppCompatTaskInfo implements Parcelable { */ public CameraCompatTaskInfo cameraCompatTaskInfo = CameraCompatTaskInfo.create(); + /** Constant indicating no top activity flag has been set. */ + private static final int FLAG_UNDEFINED = 0x0; + /** Constant base value for top activity flag. */ + private static final int FLAG_BASE = 0x1; + /** Top activity flag for whether letterbox education is enabled. */ + private static final int FLAG_LETTERBOX_EDU_ENABLED = FLAG_BASE; + /** Top activity flag for whether activity is eligible for letterbox education. */ + private static final int FLAG_ELIGIBLE_FOR_LETTERBOX_EDU = FLAG_BASE << 1; + /** Top activity flag for whether activity bounds are letterboxed. */ + private static final int FLAG_LETTERBOXED = FLAG_BASE << 2; + /** Top activity flag for whether activity is in size compat mode. */ + private static final int FLAG_IN_SIZE_COMPAT = FLAG_BASE << 3; + /** Top activity flag for whether letterbox double tap is enabled. */ + private static final int FLAG_LETTERBOX_DOUBLE_TAP_ENABLED = FLAG_BASE << 4; + /** Top activity flag for whether the update comes from a letterbox double tap action. */ + private static final int FLAG_IS_FROM_LETTERBOX_DOUBLE_TAP = FLAG_BASE << 5; + /** Top activity flag for whether activity is eligible for user aspect ratio button. */ + private static final int FLAG_ELIGIBLE_FOR_USER_ASPECT_RATIO_BUTTON = FLAG_BASE << 6; + /** Top activity flag for whether has activity has been overridden to fullscreen by system. */ + private static final int FLAG_FULLSCREEN_OVERRIDE_SYSTEM = FLAG_BASE << 7; + /** Top activity flag for whether has activity has been overridden to fullscreen by user. */ + private static final int FLAG_FULLSCREEN_OVERRIDE_USER = FLAG_BASE << 8; + + @Retention(RetentionPolicy.SOURCE) + @IntDef(flag = true, value = { + FLAG_UNDEFINED, + FLAG_BASE, + FLAG_LETTERBOX_EDU_ENABLED, + FLAG_ELIGIBLE_FOR_LETTERBOX_EDU, + FLAG_LETTERBOXED, + FLAG_IN_SIZE_COMPAT, + FLAG_LETTERBOX_DOUBLE_TAP_ENABLED, + FLAG_IS_FROM_LETTERBOX_DOUBLE_TAP, + FLAG_ELIGIBLE_FOR_USER_ASPECT_RATIO_BUTTON, + FLAG_FULLSCREEN_OVERRIDE_SYSTEM, + FLAG_FULLSCREEN_OVERRIDE_USER + }) + public @interface TopActivityFlag {} + + @TopActivityFlag + private int mTopActivityFlags; + + @TopActivityFlag + private static final int FLAGS_ORGANIZER_INTERESTED = FLAG_IS_FROM_LETTERBOX_DOUBLE_TAP + | FLAG_ELIGIBLE_FOR_USER_ASPECT_RATIO_BUTTON | FLAG_FULLSCREEN_OVERRIDE_SYSTEM + | FLAG_FULLSCREEN_OVERRIDE_USER; + + @TopActivityFlag + private static final int FLAGS_COMPAT_UI_INTERESTED = FLAGS_ORGANIZER_INTERESTED + | FLAG_IN_SIZE_COMPAT | FLAG_ELIGIBLE_FOR_LETTERBOX_EDU | FLAG_LETTERBOX_EDU_ENABLED; + private AppCompatTaskInfo() { // Do nothing } @@ -150,9 +159,8 @@ public class AppCompatTaskInfo implements Parcelable { * @return {@code true} if the task has some compat ui. */ public boolean hasCompatUI() { - return topActivityInSizeCompat || topActivityEligibleForLetterboxEducation - || isLetterboxDoubleTapEnabled - || topActivityEligibleForUserAspectRatioButton; + return isTopActivityInSizeCompat() || eligibleForLetterboxEducation() + || isLetterboxDoubleTapEnabled() || eligibleForUserAspectRatioButton(); } /** @@ -163,6 +171,142 @@ public class AppCompatTaskInfo implements Parcelable { } /** + * @return {@code true} if the letterbox education is enabled. + */ + public boolean isLetterboxEducationEnabled() { + return isTopActivityFlagEnabled(FLAG_LETTERBOX_EDU_ENABLED); + } + + /** + * Sets the top activity flag for whether letterbox education is enabled. + */ + public void setLetterboxEducationEnabled(boolean enable) { + setTopActivityFlag(FLAG_LETTERBOX_EDU_ENABLED, enable); + } + + /** + * @return {@code true} if the direct top activity is eligible for letterbox education. + */ + public boolean eligibleForLetterboxEducation() { + return isTopActivityFlagEnabled(FLAG_ELIGIBLE_FOR_LETTERBOX_EDU); + } + + /** + * Sets the top activity flag to be eligible for letterbox education. + */ + public void setEligibleForLetterboxEducation(boolean enable) { + setTopActivityFlag(FLAG_ELIGIBLE_FOR_LETTERBOX_EDU, enable); + } + + /** + * @return {@code true} if the direct top activity is eligible for the user aspect ratio + * settings button. + */ + public boolean eligibleForUserAspectRatioButton() { + return isTopActivityFlagEnabled(FLAG_ELIGIBLE_FOR_USER_ASPECT_RATIO_BUTTON); + } + + /** + * Sets the top activity flag to be eligible for the user aspect ratio settings button. + */ + public void setEligibleForUserAspectRatioButton(boolean enable) { + setTopActivityFlag(FLAG_ELIGIBLE_FOR_USER_ASPECT_RATIO_BUTTON, enable); + } + + /** + * @return {@code true} if double tap to reposition letterboxed app is enabled. + */ + public boolean isLetterboxDoubleTapEnabled() { + return isTopActivityFlagEnabled(FLAG_LETTERBOX_DOUBLE_TAP_ENABLED); + } + + /** + * Sets the top activity flag to enable double tap to reposition letterboxed app. + */ + public void setLetterboxDoubleTapEnabled(boolean enable) { + setTopActivityFlag(FLAG_LETTERBOX_DOUBLE_TAP_ENABLED, enable); + } + + /** + * @return {@code true} if the update comes from a letterbox double-tap action from the user. + */ + public boolean isFromLetterboxDoubleTap() { + return isTopActivityFlagEnabled(FLAG_IS_FROM_LETTERBOX_DOUBLE_TAP); + } + + /** + * Sets the top activity flag for whether the update comes from a letterbox double-tap action + * from the user. + */ + public void setIsFromLetterboxDoubleTap(boolean enable) { + setTopActivityFlag(FLAG_IS_FROM_LETTERBOX_DOUBLE_TAP, enable); + } + + /** + * @return {@code true} if the user has forced the activity to be fullscreen through the + * user aspect ratio settings. + */ + public boolean isUserFullscreenOverrideEnabled() { + return isTopActivityFlagEnabled(FLAG_FULLSCREEN_OVERRIDE_USER); + } + + /** + * Sets the top activity flag for whether the user has forced the activity to be fullscreen + * through the user aspect ratio settings. + */ + public void setUserFullscreenOverrideEnabled(boolean enable) { + setTopActivityFlag(FLAG_FULLSCREEN_OVERRIDE_USER, enable); + } + + /** + * @return {@code true} if the system has forced the activity to be fullscreen. + */ + public boolean isSystemFullscreenOverrideEnabled() { + return isTopActivityFlagEnabled(FLAG_FULLSCREEN_OVERRIDE_SYSTEM); + } + + /** + * Sets the top activity flag for whether the system has forced the activity to be fullscreen. + */ + public void setSystemFullscreenOverrideEnabled(boolean enable) { + setTopActivityFlag(FLAG_FULLSCREEN_OVERRIDE_SYSTEM, enable); + } + + /** + * @return {@code true} if the direct top activity is in size compat mode on foreground. + */ + public boolean isTopActivityInSizeCompat() { + return isTopActivityFlagEnabled(FLAG_IN_SIZE_COMPAT); + } + + /** + * Sets the top activity flag for whether the direct top activity is in size compat mode + * on foreground. + */ + public void setTopActivityInSizeCompat(boolean enable) { + setTopActivityFlag(FLAG_IN_SIZE_COMPAT, enable); + } + + /** + * @return {@code true} if the top activity bounds are letterboxed. + */ + public boolean isTopActivityLetterboxed() { + return isTopActivityFlagEnabled(FLAG_LETTERBOXED); + } + + /** + * Sets the top activity flag for whether the top activity bounds are letterboxed. + */ + public void setTopActivityLetterboxed(boolean enable) { + setTopActivityFlag(FLAG_LETTERBOXED, enable); + } + + /** Clear all top activity flags and set to false. */ + public void clearTopActivityFlags() { + mTopActivityFlags = FLAG_UNDEFINED; + } + + /** * @return {@code true} if the app compat parameters that are important for task organizers * are equal. */ @@ -170,9 +314,8 @@ public class AppCompatTaskInfo implements Parcelable { if (that == null) { return false; } - return isFromLetterboxDoubleTap == that.isFromLetterboxDoubleTap - && topActivityEligibleForUserAspectRatioButton - == that.topActivityEligibleForUserAspectRatioButton + return (mTopActivityFlags & FLAGS_ORGANIZER_INTERESTED) + == (that.mTopActivityFlags & FLAGS_ORGANIZER_INTERESTED) && topActivityLetterboxVerticalPosition == that.topActivityLetterboxVerticalPosition && topActivityLetterboxWidth == that.topActivityLetterboxWidth && topActivityLetterboxHeight == that.topActivityLetterboxHeight @@ -180,8 +323,6 @@ public class AppCompatTaskInfo implements Parcelable { && topActivityLetterboxAppHeight == that.topActivityLetterboxAppHeight && topActivityLetterboxHorizontalPosition == that.topActivityLetterboxHorizontalPosition - && isUserFullscreenOverrideEnabled == that.isUserFullscreenOverrideEnabled - && isSystemFullscreenOverrideEnabled == that.isSystemFullscreenOverrideEnabled && cameraCompatTaskInfo.equalsForTaskOrganizer(that.cameraCompatTaskInfo); } @@ -192,13 +333,8 @@ public class AppCompatTaskInfo implements Parcelable { if (that == null) { return false; } - return topActivityInSizeCompat == that.topActivityInSizeCompat - && isFromLetterboxDoubleTap == that.isFromLetterboxDoubleTap - && topActivityEligibleForUserAspectRatioButton - == that.topActivityEligibleForUserAspectRatioButton - && topActivityEligibleForLetterboxEducation - == that.topActivityEligibleForLetterboxEducation - && isLetterboxEducationEnabled == that.isLetterboxEducationEnabled + return (mTopActivityFlags & FLAGS_COMPAT_UI_INTERESTED) + == (that.mTopActivityFlags & FLAGS_COMPAT_UI_INTERESTED) && topActivityLetterboxVerticalPosition == that.topActivityLetterboxVerticalPosition && topActivityLetterboxHorizontalPosition == that.topActivityLetterboxHorizontalPosition @@ -206,8 +342,6 @@ public class AppCompatTaskInfo implements Parcelable { && topActivityLetterboxHeight == that.topActivityLetterboxHeight && topActivityLetterboxAppWidth == that.topActivityLetterboxAppWidth && topActivityLetterboxAppHeight == that.topActivityLetterboxAppHeight - && isUserFullscreenOverrideEnabled == that.isUserFullscreenOverrideEnabled - && isSystemFullscreenOverrideEnabled == that.isSystemFullscreenOverrideEnabled && cameraCompatTaskInfo.equalsForCompatUi(that.cameraCompatTaskInfo); } @@ -215,21 +349,13 @@ public class AppCompatTaskInfo implements Parcelable { * Reads the AppCompatTaskInfo from a parcel. */ void readFromParcel(Parcel source) { - isLetterboxEducationEnabled = source.readBoolean(); - topActivityInSizeCompat = source.readBoolean(); - topActivityEligibleForLetterboxEducation = source.readBoolean(); - isLetterboxDoubleTapEnabled = source.readBoolean(); - topActivityEligibleForUserAspectRatioButton = source.readBoolean(); - topActivityBoundsLetterboxed = source.readBoolean(); - isFromLetterboxDoubleTap = source.readBoolean(); + mTopActivityFlags = source.readInt(); topActivityLetterboxVerticalPosition = source.readInt(); topActivityLetterboxHorizontalPosition = source.readInt(); topActivityLetterboxWidth = source.readInt(); topActivityLetterboxHeight = source.readInt(); topActivityLetterboxAppWidth = source.readInt(); topActivityLetterboxAppHeight = source.readInt(); - isUserFullscreenOverrideEnabled = source.readBoolean(); - isSystemFullscreenOverrideEnabled = source.readBoolean(); cameraCompatTaskInfo = source.readTypedObject(CameraCompatTaskInfo.CREATOR); } @@ -238,35 +364,25 @@ public class AppCompatTaskInfo implements Parcelable { */ @Override public void writeToParcel(Parcel dest, int flags) { - dest.writeBoolean(isLetterboxEducationEnabled); - dest.writeBoolean(topActivityInSizeCompat); - dest.writeBoolean(topActivityEligibleForLetterboxEducation); - dest.writeBoolean(isLetterboxDoubleTapEnabled); - dest.writeBoolean(topActivityEligibleForUserAspectRatioButton); - dest.writeBoolean(topActivityBoundsLetterboxed); - dest.writeBoolean(isFromLetterboxDoubleTap); + dest.writeInt(mTopActivityFlags); dest.writeInt(topActivityLetterboxVerticalPosition); dest.writeInt(topActivityLetterboxHorizontalPosition); dest.writeInt(topActivityLetterboxWidth); dest.writeInt(topActivityLetterboxHeight); dest.writeInt(topActivityLetterboxAppWidth); dest.writeInt(topActivityLetterboxAppHeight); - dest.writeBoolean(isUserFullscreenOverrideEnabled); - dest.writeBoolean(isSystemFullscreenOverrideEnabled); dest.writeTypedObject(cameraCompatTaskInfo, flags); } @Override public String toString() { - return "AppCompatTaskInfo { topActivityInSizeCompat=" + topActivityInSizeCompat - + " topActivityEligibleForLetterboxEducation= " - + topActivityEligibleForLetterboxEducation - + "isLetterboxEducationEnabled= " + isLetterboxEducationEnabled - + " isLetterboxDoubleTapEnabled= " + isLetterboxDoubleTapEnabled - + " topActivityEligibleForUserAspectRatioButton= " - + topActivityEligibleForUserAspectRatioButton - + " topActivityBoundsLetterboxed= " + topActivityBoundsLetterboxed - + " isFromLetterboxDoubleTap= " + isFromLetterboxDoubleTap + return "AppCompatTaskInfo { topActivityInSizeCompat=" + isTopActivityInSizeCompat() + + " eligibleForLetterboxEducation= " + eligibleForLetterboxEducation() + + " isLetterboxEducationEnabled= " + isLetterboxEducationEnabled() + + " isLetterboxDoubleTapEnabled= " + isLetterboxDoubleTapEnabled() + + " eligibleForUserAspectRatioButton= " + eligibleForUserAspectRatioButton() + + " topActivityBoundsLetterboxed= " + isTopActivityLetterboxed() + + " isFromLetterboxDoubleTap= " + isFromLetterboxDoubleTap() + " topActivityLetterboxVerticalPosition= " + topActivityLetterboxVerticalPosition + " topActivityLetterboxHorizontalPosition= " + topActivityLetterboxHorizontalPosition @@ -274,9 +390,17 @@ public class AppCompatTaskInfo implements Parcelable { + " topActivityLetterboxHeight=" + topActivityLetterboxHeight + " topActivityLetterboxAppWidth=" + topActivityLetterboxAppWidth + " topActivityLetterboxAppHeight=" + topActivityLetterboxAppHeight - + " isUserFullscreenOverrideEnabled=" + isUserFullscreenOverrideEnabled - + " isSystemFullscreenOverrideEnabled=" + isSystemFullscreenOverrideEnabled + + " isUserFullscreenOverrideEnabled=" + isUserFullscreenOverrideEnabled() + + " isSystemFullscreenOverrideEnabled=" + isSystemFullscreenOverrideEnabled() + " cameraCompatTaskInfo=" + cameraCompatTaskInfo.toString() + "}"; } + + private void setTopActivityFlag(@TopActivityFlag int flag, boolean enable) { + mTopActivityFlags = enable ? (mTopActivityFlags | flag) : (mTopActivityFlags & ~flag); + } + + private boolean isTopActivityFlagEnabled(@TopActivityFlag int flag) { + return (mTopActivityFlags & flag) == flag; + } } diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/back/CrossActivityBackAnimation.kt b/libs/WindowManager/Shell/src/com/android/wm/shell/back/CrossActivityBackAnimation.kt index 4e0c82b9628f..c7e8df980a8b 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/back/CrossActivityBackAnimation.kt +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/back/CrossActivityBackAnimation.kt @@ -170,7 +170,7 @@ abstract class CrossActivityBackAnimation( initialTouchPos.set(backMotionEvent.touchX, backMotionEvent.touchY) transaction.setAnimationTransaction() - isLetterboxed = closingTarget!!.taskInfo.appCompatTaskInfo.topActivityBoundsLetterboxed + isLetterboxed = closingTarget!!.taskInfo.appCompatTaskInfo.isTopActivityLetterboxed enteringHasSameLetterbox = isLetterboxed && closingTarget!!.localBounds.equals(enteringTarget!!.localBounds) diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/compatui/CompatUIController.java b/libs/WindowManager/Shell/src/com/android/wm/shell/compatui/CompatUIController.java index c02c9cf3fd72..7c0455e17cf2 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/compatui/CompatUIController.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/compatui/CompatUIController.java @@ -238,7 +238,7 @@ public class CompatUIController implements OnDisplaysChangedListener, public void onCompatInfoChanged(@NonNull CompatUIInfo compatUIInfo) { final TaskInfo taskInfo = compatUIInfo.getTaskInfo(); final ShellTaskOrganizer.TaskListener taskListener = compatUIInfo.getListener(); - if (taskInfo != null && !taskInfo.appCompatTaskInfo.topActivityInSizeCompat) { + if (taskInfo != null && !taskInfo.appCompatTaskInfo.isTopActivityInSizeCompat()) { mSetOfTaskIdsShowingRestartDialog.remove(taskInfo.taskId); } @@ -256,16 +256,16 @@ public class CompatUIController implements OnDisplaysChangedListener, // basically cancel all the onboarding flow. We don't have to ignore events in case // the app is in size compat mode. if (mIsFirstReachabilityEducationRunning) { - if (!taskInfo.appCompatTaskInfo.isFromLetterboxDoubleTap - && !taskInfo.appCompatTaskInfo.topActivityInSizeCompat) { + if (!taskInfo.appCompatTaskInfo.isFromLetterboxDoubleTap() + && !taskInfo.appCompatTaskInfo.isTopActivityInSizeCompat()) { return; } mIsFirstReachabilityEducationRunning = false; } - if (taskInfo.appCompatTaskInfo.topActivityBoundsLetterboxed) { - if (taskInfo.appCompatTaskInfo.isLetterboxEducationEnabled) { + if (taskInfo.appCompatTaskInfo.isTopActivityLetterboxed()) { + if (taskInfo.appCompatTaskInfo.isLetterboxEducationEnabled()) { createOrUpdateLetterboxEduLayout(taskInfo, taskListener); - } else if (!taskInfo.appCompatTaskInfo.isFromLetterboxDoubleTap) { + } else if (!taskInfo.appCompatTaskInfo.isFromLetterboxDoubleTap()) { // In this case the app is letterboxed and the letterbox education // is disabled. In this case we need to understand if it's the first // time we show the reachability education. When this is happening @@ -282,7 +282,7 @@ public class CompatUIController implements OnDisplaysChangedListener, // We activate the first reachability education if the double-tap is enabled. // If the double tap is not enabled (e.g. thin letterbox) we just set the value // of the education being seen. - if (taskInfo.appCompatTaskInfo.isLetterboxDoubleTapEnabled) { + if (taskInfo.appCompatTaskInfo.isLetterboxDoubleTapEnabled()) { mIsFirstReachabilityEducationRunning = true; createOrUpdateReachabilityEduLayout(taskInfo, taskListener); return; @@ -293,7 +293,7 @@ public class CompatUIController implements OnDisplaysChangedListener, createOrUpdateCompatLayout(taskInfo, taskListener); createOrUpdateRestartDialogLayout(taskInfo, taskListener); if (mCompatUIConfiguration.getHasSeenLetterboxEducation(taskInfo.userId)) { - if (taskInfo.appCompatTaskInfo.isLetterboxDoubleTapEnabled) { + if (taskInfo.appCompatTaskInfo.isLetterboxDoubleTapEnabled()) { createOrUpdateReachabilityEduLayout(taskInfo, taskListener); } // The user aspect ratio button should not be handled when a new TaskInfo is @@ -305,7 +305,7 @@ public class CompatUIController implements OnDisplaysChangedListener, } return; } - if (!taskInfo.appCompatTaskInfo.isFromLetterboxDoubleTap) { + if (!taskInfo.appCompatTaskInfo.isFromLetterboxDoubleTap()) { createOrUpdateUserAspectRatioSettingsLayout(taskInfo, taskListener); } } diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/compatui/CompatUIWindowManager.java b/libs/WindowManager/Shell/src/com/android/wm/shell/compatui/CompatUIWindowManager.java index 271c07d4011d..8ce7837e451f 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/compatui/CompatUIWindowManager.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/compatui/CompatUIWindowManager.java @@ -82,7 +82,7 @@ class CompatUIWindowManager extends CompatUIWindowManagerAbstract { onRestartButtonClicked) { super(context, taskInfo, syncQueue, taskListener, displayLayout); mCallback = callback; - mHasSizeCompat = taskInfo.appCompatTaskInfo.topActivityInSizeCompat; + mHasSizeCompat = taskInfo.appCompatTaskInfo.isTopActivityInSizeCompat(); if (DESKTOP_WINDOWING_MODE.isEnabled(mContext) && DesktopModeFlags.DYNAMIC_INITIAL_BOUNDS.isEnabled(context)) { // Don't show the SCM button for freeform tasks @@ -138,7 +138,7 @@ class CompatUIWindowManager extends CompatUIWindowManagerAbstract { public boolean updateCompatInfo(TaskInfo taskInfo, ShellTaskOrganizer.TaskListener taskListener, boolean canShow) { final boolean prevHasSizeCompat = mHasSizeCompat; - mHasSizeCompat = taskInfo.appCompatTaskInfo.topActivityInSizeCompat; + mHasSizeCompat = taskInfo.appCompatTaskInfo.isTopActivityInSizeCompat(); if (DESKTOP_WINDOWING_MODE.isEnabled(mContext) && DesktopModeFlags.DYNAMIC_INITIAL_BOUNDS.isEnabled(mContext)) { // Don't show the SCM button for freeform tasks diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/compatui/LetterboxEduWindowManager.java b/libs/WindowManager/Shell/src/com/android/wm/shell/compatui/LetterboxEduWindowManager.java index 623feada0172..234703277c7d 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/compatui/LetterboxEduWindowManager.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/compatui/LetterboxEduWindowManager.java @@ -104,7 +104,7 @@ class LetterboxEduWindowManager extends CompatUIWindowManagerAbstract { mDockStateReader = dockStateReader; mCompatUIConfiguration = compatUIConfiguration; mEligibleForLetterboxEducation = - taskInfo.appCompatTaskInfo.topActivityEligibleForLetterboxEducation; + taskInfo.appCompatTaskInfo.eligibleForLetterboxEducation(); } @Override @@ -205,8 +205,7 @@ class LetterboxEduWindowManager extends CompatUIWindowManagerAbstract { @Override public boolean updateCompatInfo(TaskInfo taskInfo, ShellTaskOrganizer.TaskListener taskListener, boolean canShow) { - mEligibleForLetterboxEducation = - taskInfo.appCompatTaskInfo.topActivityEligibleForLetterboxEducation; + mEligibleForLetterboxEducation = taskInfo.appCompatTaskInfo.eligibleForLetterboxEducation(); return super.updateCompatInfo(taskInfo, taskListener, canShow); } diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/compatui/ReachabilityEduWindowManager.java b/libs/WindowManager/Shell/src/com/android/wm/shell/compatui/ReachabilityEduWindowManager.java index 07082a558744..06f2dd1a3b17 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/compatui/ReachabilityEduWindowManager.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/compatui/ReachabilityEduWindowManager.java @@ -91,7 +91,7 @@ class ReachabilityEduWindowManager extends CompatUIWindowManagerAbstract { Function<Integer, Integer> disappearTimeSupplier) { super(context, taskInfo, syncQueue, taskListener, displayLayout); final AppCompatTaskInfo appCompatTaskInfo = taskInfo.appCompatTaskInfo; - mIsLetterboxDoubleTapEnabled = appCompatTaskInfo.isLetterboxDoubleTapEnabled; + mIsLetterboxDoubleTapEnabled = appCompatTaskInfo.isLetterboxDoubleTapEnabled(); mLetterboxVerticalPosition = appCompatTaskInfo.topActivityLetterboxVerticalPosition; mLetterboxHorizontalPosition = appCompatTaskInfo.topActivityLetterboxHorizontalPosition; mTopActivityLetterboxWidth = appCompatTaskInfo.topActivityLetterboxWidth; @@ -148,12 +148,12 @@ class ReachabilityEduWindowManager extends CompatUIWindowManagerAbstract { final int prevTopActivityLetterboxWidth = mTopActivityLetterboxWidth; final int prevTopActivityLetterboxHeight = mTopActivityLetterboxHeight; final AppCompatTaskInfo appCompatTaskInfo = taskInfo.appCompatTaskInfo; - mIsLetterboxDoubleTapEnabled = appCompatTaskInfo.isLetterboxDoubleTapEnabled; + mIsLetterboxDoubleTapEnabled = appCompatTaskInfo.isLetterboxDoubleTapEnabled(); mLetterboxVerticalPosition = appCompatTaskInfo.topActivityLetterboxVerticalPosition; mLetterboxHorizontalPosition = appCompatTaskInfo.topActivityLetterboxHorizontalPosition; mTopActivityLetterboxWidth = appCompatTaskInfo.topActivityLetterboxWidth; mTopActivityLetterboxHeight = appCompatTaskInfo.topActivityLetterboxHeight; - mHasUserDoubleTapped = appCompatTaskInfo.isFromLetterboxDoubleTap; + mHasUserDoubleTapped = appCompatTaskInfo.isFromLetterboxDoubleTap(); if (!super.updateCompatInfo(taskInfo, taskListener, canShow)) { return false; diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/compatui/UserAspectRatioSettingsWindowManager.java b/libs/WindowManager/Shell/src/com/android/wm/shell/compatui/UserAspectRatioSettingsWindowManager.java index 8fb4bdbea933..3f67172ca636 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/compatui/UserAspectRatioSettingsWindowManager.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/compatui/UserAspectRatioSettingsWindowManager.java @@ -238,14 +238,14 @@ class UserAspectRatioSettingsWindowManager extends CompatUIWindowManagerAbstract // App is not visibly letterboxed if it covers status bar/bottom insets or matches the // stable bounds, so don't show the button if (stableBounds.height() <= letterboxHeight && stableBounds.width() <= letterboxWidth - && !taskInfo.isUserFullscreenOverrideEnabled) { + && !taskInfo.isUserFullscreenOverrideEnabled()) { return false; } - return taskInfo.topActivityEligibleForUserAspectRatioButton - && (taskInfo.topActivityBoundsLetterboxed - || taskInfo.isUserFullscreenOverrideEnabled) - && !taskInfo.isSystemFullscreenOverrideEnabled + return taskInfo.eligibleForUserAspectRatioButton() + && (taskInfo.isTopActivityLetterboxed() + || taskInfo.isUserFullscreenOverrideEnabled()) + && !taskInfo.isSystemFullscreenOverrideEnabled() && Intent.ACTION_MAIN.equals(intent.getAction()) && intent.hasCategory(Intent.CATEGORY_LAUNCHER) && (!mUserAspectRatioButtonShownChecker.get() || isShowingButton()); diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopModeUtils.kt b/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopModeUtils.kt index 026094cd6f2a..3e7b4fe89b45 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopModeUtils.kt +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopModeUtils.kt @@ -146,7 +146,7 @@ fun maximizeSizeGivenAspectRatio( fun calculateAspectRatio(taskInfo: RunningTaskInfo): Float { val appLetterboxWidth = taskInfo.appCompatTaskInfo.topActivityLetterboxAppWidth val appLetterboxHeight = taskInfo.appCompatTaskInfo.topActivityLetterboxAppHeight - if (taskInfo.appCompatTaskInfo.topActivityBoundsLetterboxed) { + if (taskInfo.appCompatTaskInfo.isTopActivityLetterboxed) { return maxOf(appLetterboxWidth, appLetterboxHeight) / minOf(appLetterboxWidth, appLetterboxHeight).toFloat() } @@ -200,7 +200,7 @@ fun TaskInfo.hasPortraitTopActivity(): Boolean { } // Then check if the activity is portrait when letterboxed - appCompatTaskInfo.topActivityBoundsLetterboxed -> appCompatTaskInfo.isTopActivityPillarboxed + appCompatTaskInfo.isTopActivityLetterboxed -> appCompatTaskInfo.isTopActivityPillarboxed // Then check if the activity is portrait appBounds != null -> appBounds.height() > appBounds.width() diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/ShellTaskOrganizerTests.java b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/ShellTaskOrganizerTests.java index 716a148175df..413e49562435 100644 --- a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/ShellTaskOrganizerTests.java +++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/ShellTaskOrganizerTests.java @@ -365,7 +365,7 @@ public class ShellTaskOrganizerTests extends ShellTestCase { final RunningTaskInfo taskInfo1 = createTaskInfo(/* taskId= */ 12, WINDOWING_MODE_FULLSCREEN); taskInfo1.displayId = DEFAULT_DISPLAY; - taskInfo1.appCompatTaskInfo.topActivityInSizeCompat = false; + taskInfo1.appCompatTaskInfo.setTopActivityInSizeCompat(false); final TrackingTaskListener taskListener = new TrackingTaskListener(); mOrganizer.addListenerForType(taskListener, TASK_LISTENER_TYPE_FULLSCREEN); mOrganizer.onTaskAppeared(taskInfo1, /* leash= */ null); @@ -378,7 +378,7 @@ public class ShellTaskOrganizerTests extends ShellTestCase { final RunningTaskInfo taskInfo2 = createTaskInfo(taskInfo1.taskId, taskInfo1.getWindowingMode()); taskInfo2.displayId = taskInfo1.displayId; - taskInfo2.appCompatTaskInfo.topActivityInSizeCompat = true; + taskInfo2.appCompatTaskInfo.setTopActivityInSizeCompat(true); taskInfo2.isVisible = true; mOrganizer.onTaskInfoChanged(taskInfo2); verifyOnCompatInfoChangedInvokedWith(taskInfo2, taskListener); @@ -388,7 +388,7 @@ public class ShellTaskOrganizerTests extends ShellTestCase { final RunningTaskInfo taskInfo3 = createTaskInfo(taskInfo1.taskId, taskInfo1.getWindowingMode()); taskInfo3.displayId = taskInfo1.displayId; - taskInfo3.appCompatTaskInfo.topActivityInSizeCompat = true; + taskInfo3.appCompatTaskInfo.setTopActivityInSizeCompat(true); taskInfo3.isVisible = false; mOrganizer.onTaskInfoChanged(taskInfo3); verifyOnCompatInfoChangedInvokedWith(taskInfo3, null /* taskListener */); @@ -403,7 +403,7 @@ public class ShellTaskOrganizerTests extends ShellTestCase { final RunningTaskInfo taskInfo1 = createTaskInfo(/* taskId= */ 12, WINDOWING_MODE_FULLSCREEN); taskInfo1.displayId = DEFAULT_DISPLAY; - taskInfo1.appCompatTaskInfo.topActivityEligibleForLetterboxEducation = false; + taskInfo1.appCompatTaskInfo.setEligibleForLetterboxEducation(false); final TrackingTaskListener taskListener = new TrackingTaskListener(); mOrganizer.addListenerForType(taskListener, TASK_LISTENER_TYPE_FULLSCREEN); mOrganizer.onTaskAppeared(taskInfo1, /* leash= */ null); @@ -418,7 +418,7 @@ public class ShellTaskOrganizerTests extends ShellTestCase { final RunningTaskInfo taskInfo2 = createTaskInfo(taskInfo1.taskId, WINDOWING_MODE_FULLSCREEN); taskInfo2.displayId = taskInfo1.displayId; - taskInfo2.appCompatTaskInfo.topActivityEligibleForLetterboxEducation = true; + taskInfo2.appCompatTaskInfo.setEligibleForLetterboxEducation(true); taskInfo2.isVisible = true; mOrganizer.onTaskInfoChanged(taskInfo2); verifyOnCompatInfoChangedInvokedWith(taskInfo2, taskListener); @@ -428,7 +428,7 @@ public class ShellTaskOrganizerTests extends ShellTestCase { final RunningTaskInfo taskInfo3 = createTaskInfo(taskInfo1.taskId, WINDOWING_MODE_FULLSCREEN); taskInfo3.displayId = taskInfo1.displayId; - taskInfo3.appCompatTaskInfo.topActivityEligibleForLetterboxEducation = true; + taskInfo3.appCompatTaskInfo.setEligibleForLetterboxEducation(true); taskInfo3.isVisible = false; mOrganizer.onTaskInfoChanged(taskInfo3); verifyOnCompatInfoChangedInvokedWith(taskInfo3, null /* taskListener */); diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/compatui/CompatUIControllerTest.java b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/compatui/CompatUIControllerTest.java index 77e22cd17f6f..de1659b1a163 100644 --- a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/compatui/CompatUIControllerTest.java +++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/compatui/CompatUIControllerTest.java @@ -681,7 +681,7 @@ public class CompatUIControllerTest extends ShellTestCase { @Test public void testLetterboxEduLayout_notCreatedWhenLetterboxEducationIsDisabled() { TaskInfo taskInfo = createTaskInfo(DISPLAY_ID, TASK_ID, /* hasSizeCompat= */ true); - taskInfo.appCompatTaskInfo.isLetterboxEducationEnabled = false; + taskInfo.appCompatTaskInfo.setLetterboxEducationEnabled(false); mController.onCompatInfoChanged(new CompatUIInfo(taskInfo, mMockTaskListener)); @@ -705,12 +705,12 @@ public class CompatUIControllerTest extends ShellTestCase { RunningTaskInfo taskInfo = new RunningTaskInfo(); taskInfo.taskId = taskId; taskInfo.displayId = displayId; - taskInfo.appCompatTaskInfo.topActivityInSizeCompat = hasSizeCompat; + taskInfo.appCompatTaskInfo.setTopActivityInSizeCompat(hasSizeCompat); taskInfo.isVisible = isVisible; taskInfo.isFocused = isFocused; taskInfo.isTopActivityTransparent = isTopActivityTransparent; - taskInfo.appCompatTaskInfo.isLetterboxEducationEnabled = true; - taskInfo.appCompatTaskInfo.topActivityBoundsLetterboxed = true; + taskInfo.appCompatTaskInfo.setLetterboxEducationEnabled(true); + taskInfo.appCompatTaskInfo.setTopActivityLetterboxed(true); return taskInfo; } } diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/compatui/CompatUILayoutTest.java b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/compatui/CompatUILayoutTest.java index 3b93861d6cd2..e5d1919decf4 100644 --- a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/compatui/CompatUILayoutTest.java +++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/compatui/CompatUILayoutTest.java @@ -146,7 +146,7 @@ public class CompatUILayoutTest extends ShellTestCase { private static TaskInfo createTaskInfo(boolean hasSizeCompat) { ActivityManager.RunningTaskInfo taskInfo = new ActivityManager.RunningTaskInfo(); taskInfo.taskId = TASK_ID; - taskInfo.appCompatTaskInfo.topActivityInSizeCompat = hasSizeCompat; + taskInfo.appCompatTaskInfo.setTopActivityInSizeCompat(hasSizeCompat); taskInfo.appCompatTaskInfo.topActivityLetterboxHeight = 1000; taskInfo.appCompatTaskInfo.topActivityLetterboxWidth = 1000; taskInfo.configuration.windowConfiguration.setBounds(new Rect(0, 0, 2000, 2000)); diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/compatui/CompatUIWindowManagerTest.java b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/compatui/CompatUIWindowManagerTest.java index c5033f3ae64b..1c0175603df9 100644 --- a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/compatui/CompatUIWindowManagerTest.java +++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/compatui/CompatUIWindowManagerTest.java @@ -446,7 +446,7 @@ public class CompatUIWindowManagerTest extends ShellTestCase { private static TaskInfo createTaskInfo(boolean hasSizeCompat) { ActivityManager.RunningTaskInfo taskInfo = new ActivityManager.RunningTaskInfo(); taskInfo.taskId = TASK_ID; - taskInfo.appCompatTaskInfo.topActivityInSizeCompat = hasSizeCompat; + taskInfo.appCompatTaskInfo.setTopActivityInSizeCompat(hasSizeCompat); taskInfo.configuration.uiMode &= ~Configuration.UI_MODE_TYPE_DESK; // Letterboxed activity that takes half the screen should show size compat restart button taskInfo.appCompatTaskInfo.topActivityLetterboxHeight = 1000; diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/compatui/LetterboxEduWindowManagerTest.java b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/compatui/LetterboxEduWindowManagerTest.java index b5664ac113fa..7617269cf5d3 100644 --- a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/compatui/LetterboxEduWindowManagerTest.java +++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/compatui/LetterboxEduWindowManagerTest.java @@ -499,7 +499,7 @@ public class LetterboxEduWindowManagerTest extends ShellTestCase { ActivityManager.RunningTaskInfo taskInfo = new ActivityManager.RunningTaskInfo(); taskInfo.userId = userId; taskInfo.taskId = TASK_ID; - taskInfo.appCompatTaskInfo.topActivityEligibleForLetterboxEducation = eligible; + taskInfo.appCompatTaskInfo.setEligibleForLetterboxEducation(eligible); taskInfo.configuration.windowConfiguration.setBounds(bounds); return taskInfo; } diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/compatui/UserAspectRatioSettingsLayoutTest.java b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/compatui/UserAspectRatioSettingsLayoutTest.java index 7a641960a2c5..e8e68bdbd940 100644 --- a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/compatui/UserAspectRatioSettingsLayoutTest.java +++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/compatui/UserAspectRatioSettingsLayoutTest.java @@ -155,7 +155,7 @@ public class UserAspectRatioSettingsLayoutTest extends ShellTestCase { private static TaskInfo createTaskInfo(boolean hasSizeCompat) { ActivityManager.RunningTaskInfo taskInfo = new ActivityManager.RunningTaskInfo(); taskInfo.taskId = TASK_ID; - taskInfo.appCompatTaskInfo.topActivityInSizeCompat = hasSizeCompat; + taskInfo.appCompatTaskInfo.setTopActivityInSizeCompat(hasSizeCompat); taskInfo.realActivity = new ComponentName("com.mypackage.test", "TestActivity"); return taskInfo; } diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/compatui/UserAspectRatioSettingsWindowManagerTest.java b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/compatui/UserAspectRatioSettingsWindowManagerTest.java index 9f288cc4bd93..9f86d49b52c4 100644 --- a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/compatui/UserAspectRatioSettingsWindowManagerTest.java +++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/compatui/UserAspectRatioSettingsWindowManagerTest.java @@ -317,7 +317,7 @@ public class UserAspectRatioSettingsWindowManagerTest extends ShellTestCase { // layout should be inflated taskInfo.appCompatTaskInfo.topActivityLetterboxHeight = stableBounds.height(); taskInfo.appCompatTaskInfo.topActivityLetterboxWidth = stableBounds.width(); - taskInfo.appCompatTaskInfo.isUserFullscreenOverrideEnabled = true; + taskInfo.appCompatTaskInfo.setUserFullscreenOverrideEnabled(true); mWindowManager.updateCompatInfo(taskInfo, mTaskListener, /* canShow= */ true); @@ -482,9 +482,9 @@ public class UserAspectRatioSettingsWindowManagerTest extends ShellTestCase { boolean topActivityBoundsLetterboxed, String action, String category) { ActivityManager.RunningTaskInfo taskInfo = new ActivityManager.RunningTaskInfo(); taskInfo.taskId = TASK_ID; - taskInfo.appCompatTaskInfo.topActivityEligibleForUserAspectRatioButton = - eligibleForUserAspectRatioButton; - taskInfo.appCompatTaskInfo.topActivityBoundsLetterboxed = topActivityBoundsLetterboxed; + taskInfo.appCompatTaskInfo.setEligibleForUserAspectRatioButton( + eligibleForUserAspectRatioButton); + taskInfo.appCompatTaskInfo.setTopActivityLetterboxed(topActivityBoundsLetterboxed); taskInfo.configuration.uiMode &= ~Configuration.UI_MODE_TYPE_DESK; taskInfo.realActivity = new ComponentName("com.mypackage.test", "TestActivity"); taskInfo.baseIntent = new Intent(action).addCategory(category); diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopTasksControllerTest.kt b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopTasksControllerTest.kt index 76939f61832f..92f705097c33 100644 --- a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopTasksControllerTest.kt +++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopTasksControllerTest.kt @@ -2734,18 +2734,16 @@ class DesktopTasksControllerTest : ShellTestCase() { if (deviceOrientation == ORIENTATION_LANDSCAPE && screenOrientation == SCREEN_ORIENTATION_PORTRAIT) { // Letterbox to portrait size - appCompatTaskInfo.topActivityBoundsLetterboxed = true + appCompatTaskInfo.setTopActivityLetterboxed(true) appCompatTaskInfo.topActivityLetterboxAppWidth = 1200 appCompatTaskInfo.topActivityLetterboxAppHeight = 1600 } else if (deviceOrientation == ORIENTATION_PORTRAIT && screenOrientation == SCREEN_ORIENTATION_LANDSCAPE) { // Letterbox to landscape size - appCompatTaskInfo.topActivityBoundsLetterboxed = true + appCompatTaskInfo.setTopActivityLetterboxed(true) appCompatTaskInfo.topActivityLetterboxAppWidth = 1600 appCompatTaskInfo.topActivityLetterboxAppHeight = 1200 } - } else { - appCompatTaskInfo.topActivityBoundsLetterboxed = false } if (deviceOrientation == ORIENTATION_LANDSCAPE) { diff --git a/services/core/java/com/android/server/wm/AppCompatUtils.java b/services/core/java/com/android/server/wm/AppCompatUtils.java index a5db9044ecee..0244d27f4363 100644 --- a/services/core/java/com/android/server/wm/AppCompatUtils.java +++ b/services/core/java/com/android/server/wm/AppCompatUtils.java @@ -115,8 +115,8 @@ class AppCompatUtils { static void fillAppCompatTaskInfo(@NonNull Task task, @NonNull TaskInfo info, @Nullable ActivityRecord top) { final AppCompatTaskInfo appCompatTaskInfo = info.appCompatTaskInfo; - appCompatTaskInfo.cameraCompatTaskInfo.freeformCameraCompatMode = - CameraCompatTaskInfo.CAMERA_COMPAT_FREEFORM_NONE; + clearAppCompatTaskInfo(appCompatTaskInfo); + if (top == null) { return; } @@ -125,24 +125,28 @@ class AppCompatUtils { final boolean isTopActivityResumed = top.getOrganizedTask() == task && top.isState(RESUMED); final boolean isTopActivityVisible = top.getOrganizedTask() == task && top.isVisible(); // Whether the direct top activity is in size compat mode. - appCompatTaskInfo.topActivityInSizeCompat = isTopActivityVisible && top.inSizeCompatMode(); - if (appCompatTaskInfo.topActivityInSizeCompat + appCompatTaskInfo.setTopActivityInSizeCompat( + isTopActivityVisible && top.inSizeCompatMode()); + if (appCompatTaskInfo.isTopActivityInSizeCompat() && top.mWmService.mAppCompatConfiguration.isTranslucentLetterboxingEnabled()) { // We hide the restart button in case of transparent activities. - appCompatTaskInfo.topActivityInSizeCompat = top.fillsParent(); + appCompatTaskInfo.setTopActivityInSizeCompat(top.fillsParent()); } // Whether the direct top activity is eligible for letterbox education. - appCompatTaskInfo.topActivityEligibleForLetterboxEducation = isTopActivityResumed - && top.isEligibleForLetterboxEducation(); - appCompatTaskInfo.isLetterboxEducationEnabled = top.mLetterboxUiController - .isLetterboxEducationEnabled(); + appCompatTaskInfo.setEligibleForLetterboxEducation( + isTopActivityResumed && top.isEligibleForLetterboxEducation()); + appCompatTaskInfo.setLetterboxEducationEnabled(top.mLetterboxUiController + .isLetterboxEducationEnabled()); + + final AppCompatAspectRatioOverrides aspectRatioOverrides = + top.mAppCompatController.getAppCompatAspectRatioOverrides(); + appCompatTaskInfo.setUserFullscreenOverrideEnabled( + aspectRatioOverrides.shouldApplyUserFullscreenOverride()); + appCompatTaskInfo.setSystemFullscreenOverrideEnabled( + aspectRatioOverrides.isSystemOverrideToFullscreenEnabled()); - appCompatTaskInfo.isUserFullscreenOverrideEnabled = top.mAppCompatController - .getAppCompatAspectRatioOverrides().shouldApplyUserFullscreenOverride(); - appCompatTaskInfo.isSystemFullscreenOverrideEnabled = top.mAppCompatController - .getAppCompatAspectRatioOverrides().isSystemOverrideToFullscreenEnabled(); + appCompatTaskInfo.setIsFromLetterboxDoubleTap(reachabilityOverrides.isFromDoubleTap()); - appCompatTaskInfo.isFromLetterboxDoubleTap = reachabilityOverrides.isFromDoubleTap(); final Rect bounds = top.getBounds(); final Rect appBounds = getAppBounds(top); appCompatTaskInfo.topActivityLetterboxWidth = bounds.width(); @@ -152,16 +156,16 @@ class AppCompatUtils { // We need to consider if letterboxed or pillarboxed. // TODO(b/336807329) Encapsulate reachability logic - appCompatTaskInfo.isLetterboxDoubleTapEnabled = reachabilityOverrides - .isLetterboxDoubleTapEducationEnabled(); - if (appCompatTaskInfo.isLetterboxDoubleTapEnabled) { + appCompatTaskInfo.setLetterboxDoubleTapEnabled(reachabilityOverrides + .isLetterboxDoubleTapEducationEnabled()); + if (appCompatTaskInfo.isLetterboxDoubleTapEnabled()) { if (appCompatTaskInfo.isTopActivityPillarboxed()) { if (reachabilityOverrides.allowHorizontalReachabilityForThinLetterbox()) { // Pillarboxed. appCompatTaskInfo.topActivityLetterboxHorizontalPosition = reachabilityOverrides.getLetterboxPositionForHorizontalReachability(); } else { - appCompatTaskInfo.isLetterboxDoubleTapEnabled = false; + appCompatTaskInfo.setLetterboxDoubleTapEnabled(false); } } else { if (reachabilityOverrides.allowVerticalReachabilityForThinLetterbox()) { @@ -169,15 +173,15 @@ class AppCompatUtils { appCompatTaskInfo.topActivityLetterboxVerticalPosition = reachabilityOverrides.getLetterboxPositionForVerticalReachability(); } else { - appCompatTaskInfo.isLetterboxDoubleTapEnabled = false; + appCompatTaskInfo.setLetterboxDoubleTapEnabled(false); } } } - appCompatTaskInfo.topActivityEligibleForUserAspectRatioButton = - !info.isTopActivityTransparent && !appCompatTaskInfo.topActivityInSizeCompat - && top.mAppCompatController.getAppCompatAspectRatioOverrides() - .shouldEnableUserAspectRatioSettings(); - appCompatTaskInfo.topActivityBoundsLetterboxed = top.areBoundsLetterboxed(); + final boolean eligibleForAspectRatioButton = + !info.isTopActivityTransparent && !appCompatTaskInfo.isTopActivityInSizeCompat() + && aspectRatioOverrides.shouldEnableUserAspectRatioSettings(); + appCompatTaskInfo.setEligibleForUserAspectRatioButton(eligibleForAspectRatioButton); + appCompatTaskInfo.setTopActivityLetterboxed(top.areBoundsLetterboxed()); appCompatTaskInfo.cameraCompatTaskInfo.freeformCameraCompatMode = top.mAppCompatController .getAppCompatCameraOverrides().getFreeformCameraCompatMode(); } @@ -207,4 +211,16 @@ class AppCompatUtils { } return "UNKNOWN_REASON"; } + + private static void clearAppCompatTaskInfo(@NonNull AppCompatTaskInfo info) { + info.topActivityLetterboxVerticalPosition = TaskInfo.PROPERTY_VALUE_UNSET; + info.topActivityLetterboxHorizontalPosition = TaskInfo.PROPERTY_VALUE_UNSET; + info.topActivityLetterboxWidth = TaskInfo.PROPERTY_VALUE_UNSET; + info.topActivityLetterboxHeight = TaskInfo.PROPERTY_VALUE_UNSET; + info.topActivityLetterboxAppHeight = TaskInfo.PROPERTY_VALUE_UNSET; + info.topActivityLetterboxAppWidth = TaskInfo.PROPERTY_VALUE_UNSET; + info.cameraCompatTaskInfo.freeformCameraCompatMode = + CameraCompatTaskInfo.CAMERA_COMPAT_FREEFORM_NONE; + info.clearTopActivityFlags(); + } } diff --git a/services/core/java/com/android/server/wm/DesktopModeBoundsCalculator.java b/services/core/java/com/android/server/wm/DesktopModeBoundsCalculator.java index 3e55e2d9b25c..f566df5fd147 100644 --- a/services/core/java/com/android/server/wm/DesktopModeBoundsCalculator.java +++ b/services/core/java/com/android/server/wm/DesktopModeBoundsCalculator.java @@ -238,7 +238,7 @@ public final class DesktopModeBoundsCalculator { taskInfo.appCompatTaskInfo.topActivityLetterboxAppWidth; final int appLetterboxHeight = taskInfo.appCompatTaskInfo.topActivityLetterboxAppHeight; - if (appCompatTaskInfo.topActivityBoundsLetterboxed) { + if (appCompatTaskInfo.isTopActivityLetterboxed()) { desiredAspectRatio = (float) Math.max(appLetterboxWidth, appLetterboxHeight) / Math.min(appLetterboxWidth, appLetterboxHeight); } else { diff --git a/services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java b/services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java index 3e68b6b7bbe3..aa997ac42c66 100644 --- a/services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java @@ -889,7 +889,7 @@ public class SizeCompatTests extends WindowTestsBase { verify(mTask).onSizeCompatActivityChanged(); ActivityManager.RunningTaskInfo taskInfo = mTask.getTaskInfo(); - assertTrue(taskInfo.appCompatTaskInfo.topActivityInSizeCompat); + assertTrue(taskInfo.appCompatTaskInfo.isTopActivityInSizeCompat()); // Make the activity resizable again by restarting it clearInvocations(mTask); @@ -904,7 +904,7 @@ public class SizeCompatTests extends WindowTestsBase { verify(mTask).onSizeCompatActivityChanged(); taskInfo = mTask.getTaskInfo(); - assertFalse(taskInfo.appCompatTaskInfo.topActivityInSizeCompat); + assertFalse(taskInfo.appCompatTaskInfo.isTopActivityInSizeCompat()); } @Test @@ -922,7 +922,7 @@ public class SizeCompatTests extends WindowTestsBase { verify(mTask).onSizeCompatActivityChanged(); ActivityManager.RunningTaskInfo taskInfo = mTask.getTaskInfo(); - assertTrue(taskInfo.appCompatTaskInfo.topActivityInSizeCompat); + assertTrue(taskInfo.appCompatTaskInfo.isTopActivityInSizeCompat()); // Create another Task to hold another size compat activity. clearInvocations(mTask); @@ -942,7 +942,7 @@ public class SizeCompatTests extends WindowTestsBase { verify(mTask, never()).onSizeCompatActivityChanged(); taskInfo = secondTask.getTaskInfo(); - assertTrue(taskInfo.appCompatTaskInfo.topActivityInSizeCompat); + assertTrue(taskInfo.appCompatTaskInfo.isTopActivityInSizeCompat()); } @Test @@ -4744,7 +4744,7 @@ public class SizeCompatTests extends WindowTestsBase { assertTrue(mActivity.inSizeCompatMode()); assertEquals(mActivity.getState(), PAUSED); assertTrue(mActivity.isVisible()); - assertTrue(mTask.getTaskInfo().appCompatTaskInfo.topActivityInSizeCompat); + assertTrue(mTask.getTaskInfo().appCompatTaskInfo.isTopActivityInSizeCompat()); } /** diff --git a/services/tests/wmtests/src/com/android/server/wm/TaskTests.java b/services/tests/wmtests/src/com/android/server/wm/TaskTests.java index a232ff0dfcb6..0a592f2ae92a 100644 --- a/services/tests/wmtests/src/com/android/server/wm/TaskTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/TaskTests.java @@ -635,27 +635,27 @@ public class TaskTests extends WindowTestsBase { // The button should be eligible to be displayed assertTrue(task.getTaskInfo() - .appCompatTaskInfo.topActivityEligibleForUserAspectRatioButton); + .appCompatTaskInfo.eligibleForUserAspectRatioButton()); // When shouldApplyUserMinAspectRatioOverride is disable the button is not enabled doReturn(false).when( root.mAppCompatController.getAppCompatAspectRatioOverrides()) .shouldEnableUserAspectRatioSettings(); assertFalse(task.getTaskInfo() - .appCompatTaskInfo.topActivityEligibleForUserAspectRatioButton); + .appCompatTaskInfo.eligibleForUserAspectRatioButton()); doReturn(true).when(root.mAppCompatController .getAppCompatAspectRatioOverrides()).shouldEnableUserAspectRatioSettings(); // When in size compat mode the button is not enabled doReturn(true).when(root).inSizeCompatMode(); assertFalse(task.getTaskInfo() - .appCompatTaskInfo.topActivityEligibleForUserAspectRatioButton); + .appCompatTaskInfo.eligibleForUserAspectRatioButton()); doReturn(false).when(root).inSizeCompatMode(); // When the top activity is transparent, the button is not enabled doReturn(false).when(root).fillsParent(); assertFalse(task.getTaskInfo() - .appCompatTaskInfo.topActivityEligibleForUserAspectRatioButton); + .appCompatTaskInfo.eligibleForUserAspectRatioButton()); doReturn(true).when(root).fillsParent(); } diff --git a/services/tests/wmtests/src/com/android/server/wm/WindowOrganizerTests.java b/services/tests/wmtests/src/com/android/server/wm/WindowOrganizerTests.java index fb81a52bce85..2b611b754edd 100644 --- a/services/tests/wmtests/src/com/android/server/wm/WindowOrganizerTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/WindowOrganizerTests.java @@ -1708,7 +1708,7 @@ public class WindowOrganizerTests extends WindowTestsBase { verify(organizer).onTaskInfoChanged(infoCaptor.capture()); RunningTaskInfo info = infoCaptor.getValue(); assertEquals(rootTask.mTaskId, info.taskId); - assertTrue(info.appCompatTaskInfo.topActivityInSizeCompat); + assertTrue(info.appCompatTaskInfo.isTopActivityInSizeCompat()); // Ensure task info show top activity that is not visible as not in size compat. clearInvocations(organizer); @@ -1718,7 +1718,7 @@ public class WindowOrganizerTests extends WindowTestsBase { verify(organizer).onTaskInfoChanged(infoCaptor.capture()); info = infoCaptor.getValue(); assertEquals(rootTask.mTaskId, info.taskId); - assertFalse(info.appCompatTaskInfo.topActivityInSizeCompat); + assertFalse(info.appCompatTaskInfo.isTopActivityInSizeCompat()); // Ensure task info show non size compat top activity as not in size compat. clearInvocations(organizer); @@ -1729,7 +1729,7 @@ public class WindowOrganizerTests extends WindowTestsBase { verify(organizer).onTaskInfoChanged(infoCaptor.capture()); info = infoCaptor.getValue(); assertEquals(rootTask.mTaskId, info.taskId); - assertFalse(info.appCompatTaskInfo.topActivityInSizeCompat); + assertFalse(info.appCompatTaskInfo.isTopActivityInSizeCompat()); } @Test |