From 11b822d2a91ea17c34c0cb1c11e80a9a30d72864 Mon Sep 17 00:00:00 2001 From: Dianne Hackborn Date: Tue, 21 Jul 2009 20:03:02 -0700 Subject: [PATCH] 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. --- api/current.xml | 55 ++++++++---------- .../android/content/pm/ApplicationInfo.java | 32 ++++------- .../android/content/pm/PackageManager.java | 6 -- .../android/content/pm/PackageParser.java | 56 ++++--------------- .../content/res/CompatibilityInfo.java | 40 +++---------- core/res/res/values/attrs_manifest.xml | 27 ++------- core/res/res/values/public.xml | 2 +- .../guide/topics/resources/resources-i18n.jd | 43 +++++++------- .../android/server/PackageManagerService.java | 28 +++++++--- .../server/am/ActivityManagerService.java | 3 +- .../android/test/dpi/DpiTestActivity.java | 7 +-- 11 files changed, 104 insertions(+), 195 deletions(-) diff --git a/api/current.xml b/api/current.xml index 0e04f50a89a2f..46969e0ade2c1 100644 --- a/api/current.xml +++ b/api/current.xml @@ -2231,6 +2231,17 @@ visibility="public" > + + - - + + - - - - 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 densityList = pkg.supportsDensityList; - for (int i = 0; i < size; i++) { - densities[i] = densityList.get(i); - } + if (anyDensity < 0 || (anyDensity > 0 + && pkg.applicationInfo.targetSdkVersion + >= android.os.Build.VERSION_CODES.DONUT)) { + pkg.applicationInfo.flags |= ApplicationInfo.FLAG_SUPPORTS_SCREEN_DENSITIES; } - /** - * 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; - } - */ 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 supportsDensityList = new ArrayList(); - 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 517551ec8e149..e2abfd175a05b 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; } } diff --git a/core/res/res/values/attrs_manifest.xml b/core/res/res/values/attrs_manifest.xml index 75568e14507f1..48b565f598781 100644 --- a/core/res/res/values/attrs_manifest.xml +++ b/core/res/res/values/attrs_manifest.xml @@ -827,28 +827,6 @@ - - - - - - - - - - - - - + +