OSDN Git Service

Allow resizeableActivity to be specified at the application level
authorWale Ogunwale <ogunwale@google.com>
Sat, 30 Jan 2016 21:01:33 +0000 (13:01 -0800)
committerWale Ogunwale <ogunwale@google.com>
Sat, 30 Jan 2016 21:01:33 +0000 (13:01 -0800)
Makes it easier for developers to set a state for all their activities
vs. doing it individually.

Bug: 26508215
Change-Id: I8d546487b6461a03f75cce7760522e7af9fc2740

core/java/android/content/pm/ApplicationInfo.java
core/java/android/content/pm/PackageParser.java
core/res/res/values/attrs_manifest.xml

index 654396b..1b12230 100644 (file)
@@ -515,6 +515,14 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable {
     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}
      */
index 970a0b5..09b85c9 100644 (file)
@@ -84,6 +84,7 @@ import static android.content.pm.ActivityInfo.RESIZE_MODE_RESIZEABLE;
 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 @@ public class PackageParser {
             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 @@ public class PackageParser {
 
             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;
index c86874f..c744bbd 100644 (file)
         <attr name="extractNativeLibs" />
         <attr name="forceDeviceEncrypted" format="boolean" />
         <attr name="encryptionAware" />
+        <attr name="resizeableActivity" />
     </declare-styleable>
     <!-- The <code>permission</code> tag declares a security permission that can be
          used to control access from other packages to specific components or