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

Commit 11b822d2 authored by Dianne Hackborn's avatar Dianne Hackborn
Browse files

Simplify density compatibility to a boolean.

Instead of a list, we now just have a single boolean indicating whether an
application is density aware, and this set set to true by default as of
Donut.
parent 59c25cba
Loading
Loading
Loading
Loading
+22 −33
Original line number Diff line number Diff line
@@ -2231,6 +2231,17 @@
 visibility="public"
>
</field>
<field name="anyDensity"
 type="int"
 transient="false"
 volatile="false"
 value="16843372"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="apiKey"
 type="int"
 transient="false"
@@ -3078,17 +3089,6 @@
 visibility="public"
>
</field>
<field name="density"
 type="int"
 transient="false"
 volatile="false"
 value="16843372"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="dependency"
 type="int"
 transient="false"
@@ -35540,6 +35540,17 @@
 visibility="public"
>
</field>
<field name="FLAG_SUPPORTS_SCREEN_DENSITIES"
 type="int"
 transient="false"
 volatile="false"
 value="8192"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="FLAG_SUPPORTS_SMALL_SCREENS"
 type="int"
 transient="false"
@@ -35695,17 +35706,6 @@
 visibility="public"
>
</field>
<field name="supportsDensities"
 type="int[]"
 transient="false"
 volatile="false"
 value="null"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="targetSdkVersion"
 type="int"
 transient="false"
@@ -37604,17 +37604,6 @@
 visibility="public"
>
</field>
<field name="GET_SUPPORTS_DENSITIES"
 type="int"
 transient="false"
 volatile="false"
 value="32768"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="GET_UNINSTALLED_PACKAGES"
 type="int"
 transient="false"
+11 −21
Original line number Diff line number Diff line
@@ -169,19 +169,20 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable {
    public static final int FLAG_RESIZEABLE_FOR_SCREENS = 1<<12;
    
    /**
     * Value for {@link #flags}: this is false if the application has set
     * its android:allowBackup to false, true otherwise.
     * 
     * {@hide}
     * Value for {@link #flags}: true when the application knows how to
     * accomodate different screen densities.  Corresponds to
     * {@link android.R.styleable#AndroidManifestSupportsScreens_anyDensity
     * android:anyDensity}.
     */
    public static final int FLAG_ALLOW_BACKUP = 1<<13;
    public static final int FLAG_SUPPORTS_SCREEN_DENSITIES = 1<<13;
    
    /**
     * Indicates that the application supports any densities;
     * Value for {@link #flags}: this is false if the application has set
     * its android:allowBackup to false, true otherwise.
     * 
     * {@hide}
     */
    public static final int ANY_DENSITY = -1;
    static final int[] ANY_DENSITIES_ARRAY = { ANY_DENSITY };
    public static final int FLAG_ALLOW_BACKUP = 1<<14;
    
    /**
     * Flags associated with the application.  Any combination of
@@ -227,13 +228,6 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable {
     */
    public int uid;
    
    /**
     * The list of densities in DPI that application supprots. This
     * field is only set if the {@link PackageManager#GET_SUPPORTS_DENSITIES} flag was
     * used when retrieving the structure.
     */
    public int[] supportsDensities;

    /**
     * The minimum SDK version this application targets.  It may run on earilier
     * versions, but it knows how to work with any new behavior added at this
@@ -267,7 +261,6 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable {
        pw.println(prefix + "enabled=" + enabled);
        pw.println(prefix + "manageSpaceActivityName="+manageSpaceActivityName);
        pw.println(prefix + "description=0x"+Integer.toHexString(descriptionRes));
        pw.println(prefix + "supportsDensities=" + supportsDensities);
        super.dumpBack(pw, prefix);
    }
    
@@ -314,7 +307,6 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable {
        enabled = orig.enabled;
        manageSpaceActivityName = orig.manageSpaceActivityName;
        descriptionRes = orig.descriptionRes;
        supportsDensities = orig.supportsDensities;
    }


@@ -346,7 +338,6 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable {
        dest.writeString(manageSpaceActivityName);
        dest.writeString(backupAgentName);
        dest.writeInt(descriptionRes);
        dest.writeIntArray(supportsDensities);
    }

    public static final Parcelable.Creator<ApplicationInfo> CREATOR
@@ -377,7 +368,6 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable {
        manageSpaceActivityName = source.readString();
        backupAgentName = source.readString();
        descriptionRes = source.readInt();
        supportsDensities = source.createIntArray();
    }

    /**
@@ -408,7 +398,7 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable {
     */
    public void disableCompatibilityMode() {
        flags |= (FLAG_SUPPORTS_LARGE_SCREENS | FLAG_SUPPORTS_NORMAL_SCREENS |
                FLAG_SUPPORTS_SMALL_SCREENS | FLAG_RESIZEABLE_FOR_SCREENS);
        supportsDensities = ANY_DENSITIES_ARRAY;
                FLAG_SUPPORTS_SMALL_SCREENS | FLAG_RESIZEABLE_FOR_SCREENS |
                FLAG_SUPPORTS_SCREEN_DENSITIES);
    }
}
+0 −6
Original line number Diff line number Diff line
@@ -164,12 +164,6 @@ public abstract class PackageManager {
     */
    public static final int GET_CONFIGURATIONS = 0x00004000;

    /**
     * {@link ApplicationInfo} flag: return the
     * {@link ApplicationInfo#supportsDensities} that the package supports.
     */
    public static final int GET_SUPPORTS_DENSITIES    = 0x00008000;

    /**
     * Resolution and querying flag: if set, only filters that support the
     * {@link android.content.Intent#CATEGORY_DEFAULT} will be considered for
+11 −45
Original line number Diff line number Diff line
@@ -675,6 +675,7 @@ public class PackageParser {
        int supportsNormalScreens = 1;
        int supportsLargeScreens = 1;
        int resizeable = 1;
        int anyDensity = 1;
        
        int outerDepth = parser.getDepth();
        while ((type=parser.next()) != parser.END_DOCUMENT
@@ -854,21 +855,6 @@ public class PackageParser {

                XmlUtils.skipCurrentTag(parser);

            } else if (tagName.equals("supports-density")) {
                sa = res.obtainAttributes(attrs,
                        com.android.internal.R.styleable.AndroidManifestSupportsDensity);

                int density = sa.getInteger(
                        com.android.internal.R.styleable.AndroidManifestSupportsDensity_density, -1);

                sa.recycle();

                if (density != -1 && !pkg.supportsDensityList.contains(density)) {
                    pkg.supportsDensityList.add(density);
                }

                XmlUtils.skipCurrentTag(parser);

            } else if (tagName.equals("supports-screens")) {
                sa = res.obtainAttributes(attrs,
                        com.android.internal.R.styleable.AndroidManifestSupportsScreens);
@@ -887,6 +873,9 @@ public class PackageParser {
                resizeable = sa.getInteger(
                        com.android.internal.R.styleable.AndroidManifestSupportsScreens_resizeable,
                        supportsLargeScreens);
                anyDensity = sa.getInteger(
                        com.android.internal.R.styleable.AndroidManifestSupportsScreens_anyDensity,
                        anyDensity);

                sa.recycle();
                
@@ -962,7 +951,7 @@ public class PackageParser {
        
        if (supportsSmallScreens < 0 || (supportsSmallScreens > 0
                && pkg.applicationInfo.targetSdkVersion
                        >= android.os.Build.VERSION_CODES.CUR_DEVELOPMENT)) {
                        >= android.os.Build.VERSION_CODES.DONUT)) {
            pkg.applicationInfo.flags |= ApplicationInfo.FLAG_SUPPORTS_SMALL_SCREENS;
        }
        if (supportsNormalScreens != 0) {
@@ -970,32 +959,19 @@ public class PackageParser {
        }
        if (supportsLargeScreens < 0 || (supportsLargeScreens > 0
                && pkg.applicationInfo.targetSdkVersion
                        >= android.os.Build.VERSION_CODES.CUR_DEVELOPMENT)) {
                        >= android.os.Build.VERSION_CODES.DONUT)) {
            pkg.applicationInfo.flags |= ApplicationInfo.FLAG_SUPPORTS_LARGE_SCREENS;
        }
        if (resizeable < 0 || (resizeable > 0
                && pkg.applicationInfo.targetSdkVersion
                        >= android.os.Build.VERSION_CODES.CUR_DEVELOPMENT)) {
                        >= android.os.Build.VERSION_CODES.DONUT)) {
            pkg.applicationInfo.flags |= ApplicationInfo.FLAG_RESIZEABLE_FOR_SCREENS;
        }
        int densities[] = null;
        int size = pkg.supportsDensityList.size();
        if (size > 0) {
            densities = pkg.supportsDensities = new int[size];
            List<Integer> densityList = pkg.supportsDensityList;
            for (int i = 0; i < size; i++) {
                densities[i] = densityList.get(i);
            }
        }
        /**
         * TODO: enable this before code freeze. b/1967935
         * *
        if ((densities == null || densities.length == 0)
                && (pkg.applicationInfo.targetSdkVersion
                        >= android.os.Build.VERSION_CODES.CUR_DEVELOPMENT)) {
            pkg.supportsDensities = ApplicationInfo.ANY_DENSITIES_ARRAY;
        if (anyDensity < 0 || (anyDensity > 0
                && pkg.applicationInfo.targetSdkVersion
                        >= android.os.Build.VERSION_CODES.DONUT)) {
            pkg.applicationInfo.flags |= ApplicationInfo.FLAG_SUPPORTS_SCREEN_DENSITIES;
        }
         */

        return pkg;
    }
@@ -2446,9 +2422,6 @@ public class PackageParser {
        // We store the application meta-data independently to avoid multiple unwanted references
        public Bundle mAppMetaData = null;

        public final ArrayList<Integer> supportsDensityList = new ArrayList<Integer>();
        public int[] supportsDensities = null;

        // If this is a 3rd party app, this is the path of the zip file.
        public String mPath;

@@ -2630,10 +2603,6 @@ public class PackageParser {
                && p.usesLibraryFiles != null) {
            return true;
        }
        if ((flags & PackageManager.GET_SUPPORTS_DENSITIES) != 0
                && p.supportsDensities != null) {
            return true;
        }
        return false;
    }

@@ -2656,9 +2625,6 @@ public class PackageParser {
        if ((flags & PackageManager.GET_SHARED_LIBRARY_FILES) != 0) {
            ai.sharedLibraryFiles = p.usesLibraryFiles;
        }
        if ((flags & PackageManager.GET_SUPPORTS_DENSITIES) != 0) {
            ai.supportsDensities = p.supportsDensities;
        }
        if (!sCompatibilityModeEnabled) {
            ai.disableCompatibilityMode();
        }
+7 −33
Original line number Diff line number Diff line
@@ -131,41 +131,15 @@ public class CompatibilityInfo {
            mCompatibilityFlags |= EXPANDABLE | CONFIGURED_EXPANDABLE;
        }
        
        float packageDensityScale = -1.0f;
        int packageDensity = 0;
        if (appInfo.supportsDensities != null) {
            int minDiff = Integer.MAX_VALUE;
            for (int density : appInfo.supportsDensities) {
                if (density == ApplicationInfo.ANY_DENSITY) {
                    packageDensity = DisplayMetrics.DENSITY_DEVICE;
                    packageDensityScale = 1.0f;
                    break;
                }
                int tmpDiff = Math.abs(DisplayMetrics.DENSITY_DEVICE - density);
                if (tmpDiff == 0) {
                    packageDensity = DisplayMetrics.DENSITY_DEVICE;
                    packageDensityScale = 1.0f;
                    break;
                }
                // prefer higher density (appScale>1.0), unless that's only option.
                if (tmpDiff < minDiff && packageDensityScale < 1.0f) {
                    packageDensity = density;
                    packageDensityScale = DisplayMetrics.DENSITY_DEVICE / (float) density;
                    minDiff = tmpDiff;
                }
            }
        }
        if (packageDensityScale > 0.0f) {
            applicationDensity = packageDensity;
            applicationScale = packageDensityScale;
        if ((appInfo.flags & ApplicationInfo.FLAG_SUPPORTS_SCREEN_DENSITIES) != 0) {
            applicationDensity = DisplayMetrics.DENSITY_DEVICE;
            applicationScale = 1.0f;
            applicationInvertedScale = 1.0f;
        } else {
            applicationDensity = DisplayMetrics.DENSITY_DEFAULT;
            applicationScale =
                    DisplayMetrics.DENSITY_DEVICE / (float) DisplayMetrics.DENSITY_DEFAULT;
        }

            applicationScale = DisplayMetrics.DENSITY_DEVICE
                    / (float) DisplayMetrics.DENSITY_DEFAULT;
            applicationInvertedScale = 1.0f / applicationScale;
        if (applicationScale != 1.0f) {
            mCompatibilityFlags |= SCALING_REQUIRED;
        }
    }
Loading