diff options
| -rw-r--r-- | api/current.xml | 21 | ||||
| -rw-r--r-- | core/java/android/content/pm/ApplicationInfo.java | 14 | ||||
| -rw-r--r-- | core/java/android/content/pm/PackageParser.java | 3 | ||||
| -rw-r--r-- | core/java/android/content/res/CompatibilityInfo.java | 31 | ||||
| -rw-r--r-- | core/res/res/values/attrs_manifest.xml | 11 | ||||
| -rw-r--r-- | core/res/res/values/public.xml | 1 | 
6 files changed, 75 insertions, 6 deletions
diff --git a/api/current.xml b/api/current.xml index 7670bc935193..83e571d14071 100644 --- a/api/current.xml +++ b/api/current.xml @@ -5889,6 +5889,17 @@   visibility="public"  >  </field> +<field name="largestWidthLimitDp" + type="int" + transient="false" + volatile="false" + value="16843622" + static="true" + final="true" + deprecated="not deprecated" + visibility="public" +> +</field>  <field name="launchMode"   type="int"   transient="false" @@ -58742,6 +58753,16 @@   visibility="public"  >  </field> +<field name="largestWidthLimitDp" + type="int" + transient="false" + volatile="false" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +</field>  <field name="manageSpaceActivityName"   type="java.lang.String"   transient="false" diff --git a/core/java/android/content/pm/ApplicationInfo.java b/core/java/android/content/pm/ApplicationInfo.java index ab31865d653b..2bd632d5f917 100644 --- a/core/java/android/content/pm/ApplicationInfo.java +++ b/core/java/android/content/pm/ApplicationInfo.java @@ -337,6 +337,14 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable {      public int compatibleWidthLimitDp = 0;      /** +     * The maximum smallest screen width the application will work on.  If 0, +     * nothing has been specified.  Comes from +     * {@link android.R.styleable#AndroidManifestSupportsScreens_largestWidthLimitDp +     * android:largestWidthLimitDp} attribute of the <supports-screens> tag. +     */ +    public int largestWidthLimitDp = 0; + +    /**       * Full path to the location of this package.       */      public String sourceDir; @@ -418,7 +426,8 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable {          pw.println(prefix + "uid=" + uid + " flags=0x" + Integer.toHexString(flags)                  + " theme=0x" + Integer.toHexString(theme));          pw.println(prefix + "requiresSmallestWidthDp=" + requiresSmallestWidthDp -                + " compatibleWidthLimitDp=" + compatibleWidthLimitDp); +                + " compatibleWidthLimitDp=" + compatibleWidthLimitDp +                + " largestWidthLimitDp=" + largestWidthLimitDp);          pw.println(prefix + "sourceDir=" + sourceDir);          if (sourceDir == null) {              if (publicSourceDir != null) { @@ -480,6 +489,7 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable {          flags = orig.flags;          requiresSmallestWidthDp = orig.requiresSmallestWidthDp;          compatibleWidthLimitDp = orig.compatibleWidthLimitDp; +        largestWidthLimitDp = orig.largestWidthLimitDp;          sourceDir = orig.sourceDir;          publicSourceDir = orig.publicSourceDir;          nativeLibraryDir = orig.nativeLibraryDir; @@ -515,6 +525,7 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable {          dest.writeInt(flags);          dest.writeInt(requiresSmallestWidthDp);          dest.writeInt(compatibleWidthLimitDp); +        dest.writeInt(largestWidthLimitDp);          dest.writeString(sourceDir);          dest.writeString(publicSourceDir);          dest.writeString(nativeLibraryDir); @@ -550,6 +561,7 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable {          flags = source.readInt();          requiresSmallestWidthDp = source.readInt();          compatibleWidthLimitDp = source.readInt(); +        largestWidthLimitDp = source.readInt();          sourceDir = source.readString();          publicSourceDir = source.readString();          nativeLibraryDir = source.readString(); diff --git a/core/java/android/content/pm/PackageParser.java b/core/java/android/content/pm/PackageParser.java index 9b4ff754ec3d..98ce8aacb330 100644 --- a/core/java/android/content/pm/PackageParser.java +++ b/core/java/android/content/pm/PackageParser.java @@ -999,6 +999,9 @@ public class PackageParser {                  pkg.applicationInfo.compatibleWidthLimitDp = sa.getInteger(                          com.android.internal.R.styleable.AndroidManifestSupportsScreens_compatibleWidthLimitDp,                          0); +                pkg.applicationInfo.largestWidthLimitDp = sa.getInteger( +                        com.android.internal.R.styleable.AndroidManifestSupportsScreens_largestWidthLimitDp, +                        0);                  // This is a trick to get a boolean and still able to detect                  // if a value was actually set. diff --git a/core/java/android/content/res/CompatibilityInfo.java b/core/java/android/content/res/CompatibilityInfo.java index 0d2e567a0917..b686e54c03f7 100644 --- a/core/java/android/content/res/CompatibilityInfo.java +++ b/core/java/android/content/res/CompatibilityInfo.java @@ -96,21 +96,42 @@ public class CompatibilityInfo implements Parcelable {              boolean forceCompat) {          int compatFlags = 0; -        if (appInfo.requiresSmallestWidthDp != 0 || appInfo.compatibleWidthLimitDp != 0) { +        if (appInfo.requiresSmallestWidthDp != 0 || appInfo.compatibleWidthLimitDp != 0 +                || appInfo.largestWidthLimitDp != 0) {              // New style screen requirements spec.              int required = appInfo.requiresSmallestWidthDp != 0                      ? appInfo.requiresSmallestWidthDp                      : appInfo.compatibleWidthLimitDp; +            if (required == 0) { +                required = appInfo.largestWidthLimitDp; +            }              int compat = appInfo.compatibleWidthLimitDp != 0 -                    ? appInfo.compatibleWidthLimitDp -                    : appInfo.requiresSmallestWidthDp; +                    ? appInfo.compatibleWidthLimitDp : required;              if (compat < required)  {                  compat = required;              } - -            if (compat >= sw) { +            int largest = appInfo.largestWidthLimitDp; + +            if (required > DEFAULT_NORMAL_SHORT_DIMENSION) { +                // For now -- if they require a size larger than the only +                // size we can do in compatibility mode, then don't ever +                // allow the app to go in to compat mode.  Trying to run +                // it at a smaller size it can handle will make it far more +                // broken than running at a larger size than it wants or +                // thinks it can handle. +                compatFlags |= NEVER_NEEDS_COMPAT; +            } else if (largest != 0 && sw > largest) { +                // If the screen size is larger than the largest size the +                // app thinks it can work with, then always force it in to +                // compatibility mode. +                compatFlags |= NEEDS_SCREEN_COMPAT | ALWAYS_NEEDS_COMPAT; +            } else if (compat >= sw) { +                // The screen size is something the app says it was designed +                // for, so never do compatibility mode.                  compatFlags |= NEVER_NEEDS_COMPAT;              } else if (forceCompat) { +                // The app may work better with or without compatibility mode. +                // Let the user decide.                  compatFlags |= NEEDS_SCREEN_COMPAT;              } diff --git a/core/res/res/values/attrs_manifest.xml b/core/res/res/values/attrs_manifest.xml index 41c4c292dd55..38790eaa9030 100644 --- a/core/res/res/values/attrs_manifest.xml +++ b/core/res/res/values/attrs_manifest.xml @@ -1035,6 +1035,17 @@               used with this attribute are 320 for a phone screen, 600 for a               7" tablet, and 720 for a 10" tablet. -->          <attr name="compatibleWidthLimitDp" format="integer" /> +        <!-- Starting with {@link android.os.Build.VERSION_CODES#HONEYCOMB_MR2}, +             this is the new way to specify the screens an application is +             compatible with.  This attribute provides the maximum +             "smallest screen width" (as per the -swNNNdp resource configuration) +             that the application can work well on.  If this value is smaller than +             the "smallest screen width" of the device it is running on, the +             application will be forced in to screen compatibility mode with +             no way for the user to turn it off.  Currently the compatibility mode +             only emulates phone screens, so even if this value is larger than 320 +             the width the app runs in will be a 320 phone dimension. --> +        <attr name="largestWidthLimitDp" format="integer" />          <!-- Indicates whether the application supports smaller screen form-factors.               A small screen is defined as one with a smaller aspect ratio than               the traditional HVGA screen; that is, for a portrait screen, less diff --git a/core/res/res/values/public.xml b/core/res/res/values/public.xml index 27ca95214666..85884b19a22a 100644 --- a/core/res/res/values/public.xml +++ b/core/res/res/values/public.xml @@ -1656,4 +1656,5 @@    <eat-comment />    <public type="attr" name="requiresSmallestWidthDp" id="0x01010364" />    <public type="attr" name="compatibleWidthLimitDp" /> +  <public type="attr" name="largestWidthLimitDp" />  </resources>  |