diff options
author | Dianne Hackborn <hackbod@google.com> | 2009-07-21 20:03:02 -0700 |
---|---|---|
committer | Dianne Hackborn <hackbod@google.com> | 2009-07-22 11:58:31 -0700 |
commit | 11b822d2a91ea17c34c0cb1c11e80a9a30d72864 (patch) | |
tree | 7eec5218c6831641b406f1b969841314f452adbb /core/java/android | |
parent | 59c25cbaf0dd690e503b881392510127441d9074 (diff) | |
download | frameworks_base-11b822d2a91ea17c34c0cb1c11e80a9a30d72864.zip frameworks_base-11b822d2a91ea17c34c0cb1c11e80a9a30d72864.tar.gz frameworks_base-11b822d2a91ea17c34c0cb1c11e80a9a30d72864.tar.bz2 |
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.
Diffstat (limited to 'core/java/android')
-rw-r--r-- | core/java/android/content/pm/ApplicationInfo.java | 32 | ||||
-rw-r--r-- | core/java/android/content/pm/PackageManager.java | 6 | ||||
-rw-r--r-- | core/java/android/content/pm/PackageParser.java | 56 | ||||
-rw-r--r-- | core/java/android/content/res/CompatibilityInfo.java | 40 |
4 files changed, 29 insertions, 105 deletions
diff --git a/core/java/android/content/pm/ApplicationInfo.java b/core/java/android/content/pm/ApplicationInfo.java index 4a3137f..9ca11cd 100644 --- a/core/java/android/content/pm/ApplicationInfo.java +++ b/core/java/android/content/pm/ApplicationInfo.java @@ -169,21 +169,22 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable { public static final int FLAG_RESIZEABLE_FOR_SCREENS = 1<<12; /** + * 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_SUPPORTS_SCREEN_DENSITIES = 1<<13; + + /** * Value for {@link #flags}: this is false if the application has set * its android:allowBackup to false, true otherwise. * * {@hide} */ - public static final int FLAG_ALLOW_BACKUP = 1<<13; + public static final int FLAG_ALLOW_BACKUP = 1<<14; /** - * Indicates that the application supports any densities; - * {@hide} - */ - public static final int ANY_DENSITY = -1; - static final int[] ANY_DENSITIES_ARRAY = { ANY_DENSITY }; - - /** * Flags associated with the application. Any combination of * {@link #FLAG_SYSTEM}, {@link #FLAG_DEBUGGABLE}, {@link #FLAG_HAS_CODE}, * {@link #FLAG_PERSISTENT}, {@link #FLAG_FACTORY_TEST}, and @@ -228,13 +229,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 * version. Will be {@link android.os.Build.VERSION_CODES#CUR_DEVELOPMENT} @@ -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); } } diff --git a/core/java/android/content/pm/PackageManager.java b/core/java/android/content/pm/PackageManager.java index 941ca9e..67bd1ac 100644 --- a/core/java/android/content/pm/PackageManager.java +++ b/core/java/android/content/pm/PackageManager.java @@ -165,12 +165,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 * matching. This is a synonym for including the CATEGORY_DEFAULT in your diff --git a/core/java/android/content/pm/PackageParser.java b/core/java/android/content/pm/PackageParser.java index 93ba959..33f4b52 100644 --- a/core/java/android/content/pm/PackageParser.java +++ b/core/java/android/content/pm/PackageParser.java @@ -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(); } diff --git a/core/java/android/content/res/CompatibilityInfo.java b/core/java/android/content/res/CompatibilityInfo.java index 517551e..e2abfd1 100644 --- a/core/java/android/content/res/CompatibilityInfo.java +++ b/core/java/android/content/res/CompatibilityInfo.java @@ -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; - } - - applicationInvertedScale = 1.0f / applicationScale; - if (applicationScale != 1.0f) { + applicationScale = DisplayMetrics.DENSITY_DEVICE + / (float) DisplayMetrics.DENSITY_DEFAULT; + applicationInvertedScale = 1.0f / applicationScale; mCompatibilityFlags |= SCALING_REQUIRED; } } |