summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/java/android/content/pm/ActivityInfo.java13
-rw-r--r--libs/WindowManager/Shell/shared/src/com/android/wm/shell/shared/desktopmode/DesktopModeCompatPolicy.kt8
-rw-r--r--libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/shared/desktopmode/DesktopModeCompatPolicyTest.kt11
3 files changed, 30 insertions, 2 deletions
diff --git a/core/java/android/content/pm/ActivityInfo.java b/core/java/android/content/pm/ActivityInfo.java
index 37f3f17ebe42..e6450606d450 100644
--- a/core/java/android/content/pm/ActivityInfo.java
+++ b/core/java/android/content/pm/ActivityInfo.java
@@ -1643,6 +1643,19 @@ public class ActivityInfo extends ComponentInfo implements Parcelable {
public static final long OVERRIDE_ENABLE_INSETS_DECOUPLED_CONFIGURATION = 327313645L;
/**
+ * When the override is enabled, the activity receives configuration coupled with caption bar
+ * insets. Normally, caption bar insets are decoupled from configuration.
+ *
+ * <p>Override applies only if the activity targets SDK level 34 or earlier version.
+ *
+ * @hide
+ */
+ @ChangeId
+ @Overridable
+ @Disabled
+ public static final long OVERRIDE_EXCLUDE_CAPTION_INSETS_FROM_APP_BOUNDS = 388014743L;
+
+ /**
* Optional set of a certificates identifying apps that are allowed to embed this activity. From
* the "knownActivityEmbeddingCerts" attribute.
*/
diff --git a/libs/WindowManager/Shell/shared/src/com/android/wm/shell/shared/desktopmode/DesktopModeCompatPolicy.kt b/libs/WindowManager/Shell/shared/src/com/android/wm/shell/shared/desktopmode/DesktopModeCompatPolicy.kt
index f234ff5c2c84..c545d3001cc7 100644
--- a/libs/WindowManager/Shell/shared/src/com/android/wm/shell/shared/desktopmode/DesktopModeCompatPolicy.kt
+++ b/libs/WindowManager/Shell/shared/src/com/android/wm/shell/shared/desktopmode/DesktopModeCompatPolicy.kt
@@ -21,6 +21,7 @@ import android.content.Context
import android.content.pm.ActivityInfo
import android.content.pm.ActivityInfo.INSETS_DECOUPLED_CONFIGURATION_ENFORCED
import android.content.pm.ActivityInfo.OVERRIDE_ENABLE_INSETS_DECOUPLED_CONFIGURATION
+import android.content.pm.ActivityInfo.OVERRIDE_EXCLUDE_CAPTION_INSETS_FROM_APP_BOUNDS
import android.window.DesktopModeFlags
import com.android.internal.R
import com.android.window.flags.Flags
@@ -59,13 +60,16 @@ class DesktopModeCompatPolicy(private val context: Context) {
* The treatment is enabled when all the of the following is true:
* * Any flags to forcibly consume caption insets are enabled.
* * Top activity have configuration coupled with insets.
- * * Task is not resizeable.
+ * * Task is not resizeable or [ActivityInfo.OVERRIDE_EXCLUDE_CAPTION_INSETS_FROM_APP_BOUNDS]
+ * is enabled.
*/
fun shouldExcludeCaptionFromAppBounds(taskInfo: TaskInfo): Boolean =
Flags.excludeCaptionFromAppBounds()
&& isAnyForceConsumptionFlagsEnabled()
&& taskInfo.topActivityInfo?.let {
- isInsetsCoupledWithConfiguration(it) && !taskInfo.isResizeable
+ isInsetsCoupledWithConfiguration(it) && (!taskInfo.isResizeable || it.isChangeEnabled(
+ OVERRIDE_EXCLUDE_CAPTION_INSETS_FROM_APP_BOUNDS
+ ))
} ?: false
/**
diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/shared/desktopmode/DesktopModeCompatPolicyTest.kt b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/shared/desktopmode/DesktopModeCompatPolicyTest.kt
index 55e9de5eff5f..ae1e4e0fbbc1 100644
--- a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/shared/desktopmode/DesktopModeCompatPolicyTest.kt
+++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/shared/desktopmode/DesktopModeCompatPolicyTest.kt
@@ -181,6 +181,17 @@ class DesktopModeCompatPolicyTest : ShellTestCase() {
)
}
+
+ @Test
+ @EnableFlags(Flags.FLAG_EXCLUDE_CAPTION_FROM_APP_BOUNDS)
+ @DisableCompatChanges(ActivityInfo.INSETS_DECOUPLED_CONFIGURATION_ENFORCED)
+ @EnableCompatChanges(ActivityInfo.OVERRIDE_EXCLUDE_CAPTION_INSETS_FROM_APP_BOUNDS)
+ fun testShouldExcludeCaptionFromAppBounds_resizeable_overridden_true() {
+ assertTrue(desktopModeCompatPolicy.shouldExcludeCaptionFromAppBounds(
+ setUpFreeformTask().apply { isResizeable = true })
+ )
+ }
+
fun setUpFreeformTask(): TaskInfo =
createFreeformTask().apply {
val componentName =