Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2762ff3d authored by Dianne Hackborn's avatar Dianne Hackborn
Browse files

Add new supports-screen API to set maximum allowed size.

Change-Id: I0a7cd4ba73a4c18558e6daee28963d5fd12c7978
parent e6676351
Loading
Loading
Loading
Loading
+21 −0
Original line number Diff line number Diff line
@@ -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"
+13 −1
Original line number Diff line number Diff line
@@ -336,6 +336,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 &lt;supports-screens&gt; tag.
     */
    public int largestWidthLimitDp = 0;

    /**
     * Full path to the location of this package.
     */
@@ -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();
+3 −0
Original line number Diff line number Diff line
@@ -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.
+26 −5
Original line number Diff line number Diff line
@@ -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;
            }
            int largest = appInfo.largestWidthLimitDp;

            if (compat >= sw) {
            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;
            }

+11 −0
Original line number Diff line number Diff line
@@ -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
Loading