Allow resizeableActivity to be specified at the application level
Makes it easier for developers to set a state for all their activities
vs. doing it individually.
Bug: 26508215
Change-Id: I8d546487b6461a03f75cce7760522e7af9fc2740
diff --git a/core/java/android/content/pm/ApplicationInfo.java b/core/java/android/content/pm/ApplicationInfo.java
index 654396b..1b122307 100644
--- a/core/java/android/content/pm/ApplicationInfo.java
+++ b/core/java/android/content/pm/ApplicationInfo.java
@@ -515,6 +515,14 @@
public static final int PRIVATE_FLAG_REQUIRED_FOR_SYSTEM_USER = 1 << 10;
/**
+ * When set, the activities associated with this application are resizeable by default.
+ * @see android.R.styleable#AndroidManifestActivity_resizeableActivity
+ *
+ * @hide
+ */
+ public static final int PRIVATE_FLAG_RESIZEABLE_ACTIVITIES = 1 << 11;
+
+ /**
* Private/hidden flags. See {@code PRIVATE_FLAG_...} constants.
* {@hide}
*/
diff --git a/core/java/android/content/pm/PackageParser.java b/core/java/android/content/pm/PackageParser.java
index 970a0b5..09b85c9 100644
--- a/core/java/android/content/pm/PackageParser.java
+++ b/core/java/android/content/pm/PackageParser.java
@@ -84,6 +84,7 @@
import static android.content.pm.ActivityInfo.RESIZE_MODE_RESIZEABLE_AND_PIPABLE;
import static android.content.pm.ActivityInfo.RESIZE_MODE_UNRESIZEABLE;
import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
+import static android.content.pm.ApplicationInfo.PRIVATE_FLAG_RESIZEABLE_ACTIVITIES;
import static android.content.pm.PackageManager.INSTALL_PARSE_FAILED_BAD_MANIFEST;
import static android.content.pm.PackageManager.INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME;
import static android.content.pm.PackageManager.INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING;
@@ -2642,6 +2643,11 @@
ai.privateFlags |= ApplicationInfo.PRIVATE_FLAG_ENCRYPTION_AWARE;
}
+ if (sa.getBoolean(R.styleable.AndroidManifestApplication_resizeableActivity,
+ owner.applicationInfo.targetSdkVersion >= Build.VERSION_CODES.N)) {
+ ai.privateFlags |= PRIVATE_FLAG_RESIZEABLE_ACTIVITIES;
+ }
+
String str;
str = sa.getNonConfigurationString(
com.android.internal.R.styleable.AndroidManifestApplication_permission, 0);
@@ -3232,7 +3238,10 @@
a.info.resizeMode = RESIZE_MODE_UNRESIZEABLE;
if (owner.applicationInfo.targetSdkVersion >= Build.VERSION_CODES.N) {
- if (sa.getBoolean(R.styleable.AndroidManifestActivity_resizeableActivity, true)) {
+ final boolean appDefault = (owner.applicationInfo.privateFlags
+ & PRIVATE_FLAG_RESIZEABLE_ACTIVITIES) != 0;
+ if (sa.getBoolean(
+ R.styleable.AndroidManifestActivity_resizeableActivity, appDefault)) {
if (sa.getBoolean(R.styleable.AndroidManifestActivity_supportsPictureInPicture,
false)) {
a.info.resizeMode = RESIZE_MODE_RESIZEABLE_AND_PIPABLE;