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

Commit df6e980e authored by Dianne Hackborn's avatar Dianne Hackborn
Browse files

Add new supports-screens attributes for declaring the compatible screens.

Change-Id: I40d57e4354e48accc1027c9f90916ea73eb5190d
android:requiresSmallestWidthDp provides the smallest supported width.
android:compatibleWidthLimitDp provides the largest compatible width.
parent 7a09f72b
Loading
Loading
Loading
Loading
+43 −1
Original line number Diff line number Diff line
@@ -3128,6 +3128,17 @@
 visibility="public"
>
</field>
<field name="compatibleWidthLimitDp"
 type="int"
 transient="false"
 volatile="false"
 value="16843621"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="completionHint"
 type="int"
 transient="false"
@@ -7913,6 +7924,17 @@
 visibility="public"
>
</field>
<field name="requiresSmallestWidthDp"
 type="int"
 transient="false"
 volatile="false"
 value="16843620"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="resizeMode"
 type="int"
 transient="false"
@@ -58670,6 +58692,16 @@
 visibility="public"
>
</field>
<field name="compatibleWidthLimitDp"
 type="int"
 transient="false"
 volatile="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="dataDir"
 type="java.lang.String"
 transient="false"
@@ -58760,6 +58792,16 @@
 visibility="public"
>
</field>
<field name="requiresSmallestWidthDp"
 type="int"
 transient="false"
 volatile="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="sharedLibraryFiles"
 type="java.lang.String[]"
 transient="false"
@@ -221191,7 +221233,7 @@
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="ev" type="android.view.MotionEvent">
<parameter name="event" type="android.view.MotionEvent">
</parameter>
</method>
<method name="clear"
+1 −1
Original line number Diff line number Diff line
@@ -1525,7 +1525,7 @@ public final class ActivityThread {
        synchronized (this) {
            ContextImpl context = getSystemContext();
            context.init(new LoadedApk(this, "android", context, info,
                    new CompatibilityInfo(info, 0, false)), null, this);
                    new CompatibilityInfo(info, 0, 0, false)), null, this);
        }
    }

+24 −0
Original line number Diff line number Diff line
@@ -320,6 +320,22 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable {
     */
    public int flags = 0;
    
    /**
     * The required smallest screen width the application can run on.  If 0,
     * nothing has been specified.  Comes from
     * {@link android.R.styleable#AndroidManifestSupportsScreens_requiresSmallestWidthDp
     * android:requiresSmallestWidthDp} attribute of the &lt;supports-screens&gt; tag.
     */
    public int requiresSmallestWidthDp = 0;

    /**
     * The maximum smallest screen width the application is designed for.  If 0,
     * nothing has been specified.  Comes from
     * {@link android.R.styleable#AndroidManifestSupportsScreens_compatibleWidthLimitDp
     * android:compatibleWidthLimitDp} attribute of the &lt;supports-screens&gt; tag.
     */
    public int compatibleWidthLimitDp = 0;

    /**
     * Full path to the location of this package.
     */
@@ -401,6 +417,8 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable {
        pw.println(prefix + "taskAffinity=" + taskAffinity);
        pw.println(prefix + "uid=" + uid + " flags=0x" + Integer.toHexString(flags)
                + " theme=0x" + Integer.toHexString(theme));
        pw.println(prefix + "requiresSmallestWidthDp=" + requiresSmallestWidthDp
                + " compatibleWidthLimitDp=" + compatibleWidthLimitDp);
        pw.println(prefix + "sourceDir=" + sourceDir);
        if (sourceDir == null) {
            if (publicSourceDir != null) {
@@ -460,6 +478,8 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable {
        className = orig.className;
        theme = orig.theme;
        flags = orig.flags;
        requiresSmallestWidthDp = orig.requiresSmallestWidthDp;
        compatibleWidthLimitDp = orig.compatibleWidthLimitDp;
        sourceDir = orig.sourceDir;
        publicSourceDir = orig.publicSourceDir;
        nativeLibraryDir = orig.nativeLibraryDir;
@@ -493,6 +513,8 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable {
        dest.writeString(className);
        dest.writeInt(theme);
        dest.writeInt(flags);
        dest.writeInt(requiresSmallestWidthDp);
        dest.writeInt(compatibleWidthLimitDp);
        dest.writeString(sourceDir);
        dest.writeString(publicSourceDir);
        dest.writeString(nativeLibraryDir);
@@ -526,6 +548,8 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable {
        className = source.readString();
        theme = source.readInt();
        flags = source.readInt();
        requiresSmallestWidthDp = source.readInt();
        compatibleWidthLimitDp = source.readInt();
        sourceDir = source.readString();
        publicSourceDir = source.readString();
        nativeLibraryDir = source.readString();
+7 −0
Original line number Diff line number Diff line
@@ -993,6 +993,13 @@ public class PackageParser {
                sa = res.obtainAttributes(attrs,
                        com.android.internal.R.styleable.AndroidManifestSupportsScreens);

                pkg.applicationInfo.requiresSmallestWidthDp = sa.getInteger(
                        com.android.internal.R.styleable.AndroidManifestSupportsScreens_requiresSmallestWidthDp,
                        0);
                pkg.applicationInfo.compatibleWidthLimitDp = sa.getInteger(
                        com.android.internal.R.styleable.AndroidManifestSupportsScreens_compatibleWidthLimitDp,
                        0);

                // This is a trick to get a boolean and still able to detect
                // if a value was actually set.
                supportsSmallScreens = sa.getInteger(
+93 −67
Original line number Diff line number Diff line
@@ -110,9 +110,34 @@ public class CompatibilityInfo implements Parcelable {
     */
    public final float applicationInvertedScale;

    public CompatibilityInfo(ApplicationInfo appInfo, int screenLayout, boolean forceCompat) {
    public CompatibilityInfo(ApplicationInfo appInfo, int screenLayout, int sw,
            boolean forceCompat) {
        int compatFlags = 0;

        if (appInfo.requiresSmallestWidthDp != 0 || appInfo.compatibleWidthLimitDp != 0) {
            // New style screen requirements spec.
            int required = appInfo.requiresSmallestWidthDp != 0
                    ? appInfo.requiresSmallestWidthDp
                    : appInfo.compatibleWidthLimitDp;
            int compat = appInfo.compatibleWidthLimitDp != 0
                    ? appInfo.compatibleWidthLimitDp
                    : appInfo.requiresSmallestWidthDp;
            if (compat < required)  {
                compat = required;
            }

            if (compat >= sw) {
                compatFlags |= NEVER_COMPAT;
            } else if (forceCompat) {
                compatFlags |= NEEDS_SCREEN_COMPAT;
            }

            // Modern apps always support densities.
            applicationDensity = DisplayMetrics.DENSITY_DEVICE;
            applicationScale = 1.0f;
            applicationInvertedScale = 1.0f;

        } else {
            // We can't rely on the application always setting
            // FLAG_RESIZEABLE_FOR_SCREENS so will compute it based on various input.
            boolean anyResizeable = false;
@@ -191,6 +216,7 @@ public class CompatibilityInfo implements Parcelable {
                applicationInvertedScale = 1.0f / applicationScale;
                compatFlags |= SCALING_REQUIRED;
            }
        }

        mCompatibilityFlags = compatFlags;
    }
Loading