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.
This commit is contained in:
Dianne Hackborn
2009-07-21 20:03:02 -07:00
parent 59c25cbaf0
commit 11b822d2a9
11 changed files with 104 additions and 195 deletions

View File

@ -2231,6 +2231,17 @@
visibility="public" visibility="public"
> >
</field> </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" <field name="apiKey"
type="int" type="int"
transient="false" transient="false"
@ -3078,17 +3089,6 @@
visibility="public" visibility="public"
> >
</field> </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" <field name="dependency"
type="int" type="int"
transient="false" transient="false"
@ -35540,6 +35540,17 @@
visibility="public" visibility="public"
> >
</field> </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" <field name="FLAG_SUPPORTS_SMALL_SCREENS"
type="int" type="int"
transient="false" transient="false"
@ -35695,17 +35706,6 @@
visibility="public" visibility="public"
> >
</field> </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" <field name="targetSdkVersion"
type="int" type="int"
transient="false" transient="false"
@ -37604,17 +37604,6 @@
visibility="public" visibility="public"
> >
</field> </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" <field name="GET_UNINSTALLED_PACKAGES"
type="int" type="int"
transient="false" transient="false"

View File

@ -168,20 +168,21 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable {
*/ */
public static final int FLAG_RESIZEABLE_FOR_SCREENS = 1<<12; 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 * Value for {@link #flags}: this is false if the application has set
* its android:allowBackup to false, true otherwise. * its android:allowBackup to false, true otherwise.
* *
* {@hide} * {@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 * Flags associated with the application. Any combination of
@ -227,13 +228,6 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable {
*/ */
public int uid; 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 * 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 * 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 + "enabled=" + enabled);
pw.println(prefix + "manageSpaceActivityName="+manageSpaceActivityName); pw.println(prefix + "manageSpaceActivityName="+manageSpaceActivityName);
pw.println(prefix + "description=0x"+Integer.toHexString(descriptionRes)); pw.println(prefix + "description=0x"+Integer.toHexString(descriptionRes));
pw.println(prefix + "supportsDensities=" + supportsDensities);
super.dumpBack(pw, prefix); super.dumpBack(pw, prefix);
} }
@ -314,7 +307,6 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable {
enabled = orig.enabled; enabled = orig.enabled;
manageSpaceActivityName = orig.manageSpaceActivityName; manageSpaceActivityName = orig.manageSpaceActivityName;
descriptionRes = orig.descriptionRes; descriptionRes = orig.descriptionRes;
supportsDensities = orig.supportsDensities;
} }
@ -346,7 +338,6 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable {
dest.writeString(manageSpaceActivityName); dest.writeString(manageSpaceActivityName);
dest.writeString(backupAgentName); dest.writeString(backupAgentName);
dest.writeInt(descriptionRes); dest.writeInt(descriptionRes);
dest.writeIntArray(supportsDensities);
} }
public static final Parcelable.Creator<ApplicationInfo> CREATOR public static final Parcelable.Creator<ApplicationInfo> CREATOR
@ -377,7 +368,6 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable {
manageSpaceActivityName = source.readString(); manageSpaceActivityName = source.readString();
backupAgentName = source.readString(); backupAgentName = source.readString();
descriptionRes = source.readInt(); descriptionRes = source.readInt();
supportsDensities = source.createIntArray();
} }
/** /**
@ -408,7 +398,7 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable {
*/ */
public void disableCompatibilityMode() { public void disableCompatibilityMode() {
flags |= (FLAG_SUPPORTS_LARGE_SCREENS | FLAG_SUPPORTS_NORMAL_SCREENS | flags |= (FLAG_SUPPORTS_LARGE_SCREENS | FLAG_SUPPORTS_NORMAL_SCREENS |
FLAG_SUPPORTS_SMALL_SCREENS | FLAG_RESIZEABLE_FOR_SCREENS); FLAG_SUPPORTS_SMALL_SCREENS | FLAG_RESIZEABLE_FOR_SCREENS |
supportsDensities = ANY_DENSITIES_ARRAY; FLAG_SUPPORTS_SCREEN_DENSITIES);
} }
} }

View File

@ -164,12 +164,6 @@ public abstract class PackageManager {
*/ */
public static final int GET_CONFIGURATIONS = 0x00004000; 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 * Resolution and querying flag: if set, only filters that support the
* {@link android.content.Intent#CATEGORY_DEFAULT} will be considered for * {@link android.content.Intent#CATEGORY_DEFAULT} will be considered for

View File

@ -675,6 +675,7 @@ public class PackageParser {
int supportsNormalScreens = 1; int supportsNormalScreens = 1;
int supportsLargeScreens = 1; int supportsLargeScreens = 1;
int resizeable = 1; int resizeable = 1;
int anyDensity = 1;
int outerDepth = parser.getDepth(); int outerDepth = parser.getDepth();
while ((type=parser.next()) != parser.END_DOCUMENT while ((type=parser.next()) != parser.END_DOCUMENT
@ -854,21 +855,6 @@ public class PackageParser {
XmlUtils.skipCurrentTag(parser); 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")) { } else if (tagName.equals("supports-screens")) {
sa = res.obtainAttributes(attrs, sa = res.obtainAttributes(attrs,
com.android.internal.R.styleable.AndroidManifestSupportsScreens); com.android.internal.R.styleable.AndroidManifestSupportsScreens);
@ -887,6 +873,9 @@ public class PackageParser {
resizeable = sa.getInteger( resizeable = sa.getInteger(
com.android.internal.R.styleable.AndroidManifestSupportsScreens_resizeable, com.android.internal.R.styleable.AndroidManifestSupportsScreens_resizeable,
supportsLargeScreens); supportsLargeScreens);
anyDensity = sa.getInteger(
com.android.internal.R.styleable.AndroidManifestSupportsScreens_anyDensity,
anyDensity);
sa.recycle(); sa.recycle();
@ -962,7 +951,7 @@ public class PackageParser {
if (supportsSmallScreens < 0 || (supportsSmallScreens > 0 if (supportsSmallScreens < 0 || (supportsSmallScreens > 0
&& pkg.applicationInfo.targetSdkVersion && pkg.applicationInfo.targetSdkVersion
>= android.os.Build.VERSION_CODES.CUR_DEVELOPMENT)) { >= android.os.Build.VERSION_CODES.DONUT)) {
pkg.applicationInfo.flags |= ApplicationInfo.FLAG_SUPPORTS_SMALL_SCREENS; pkg.applicationInfo.flags |= ApplicationInfo.FLAG_SUPPORTS_SMALL_SCREENS;
} }
if (supportsNormalScreens != 0) { if (supportsNormalScreens != 0) {
@ -970,32 +959,19 @@ public class PackageParser {
} }
if (supportsLargeScreens < 0 || (supportsLargeScreens > 0 if (supportsLargeScreens < 0 || (supportsLargeScreens > 0
&& pkg.applicationInfo.targetSdkVersion && pkg.applicationInfo.targetSdkVersion
>= android.os.Build.VERSION_CODES.CUR_DEVELOPMENT)) { >= android.os.Build.VERSION_CODES.DONUT)) {
pkg.applicationInfo.flags |= ApplicationInfo.FLAG_SUPPORTS_LARGE_SCREENS; pkg.applicationInfo.flags |= ApplicationInfo.FLAG_SUPPORTS_LARGE_SCREENS;
} }
if (resizeable < 0 || (resizeable > 0 if (resizeable < 0 || (resizeable > 0
&& pkg.applicationInfo.targetSdkVersion && pkg.applicationInfo.targetSdkVersion
>= android.os.Build.VERSION_CODES.CUR_DEVELOPMENT)) { >= android.os.Build.VERSION_CODES.DONUT)) {
pkg.applicationInfo.flags |= ApplicationInfo.FLAG_RESIZEABLE_FOR_SCREENS; pkg.applicationInfo.flags |= ApplicationInfo.FLAG_RESIZEABLE_FOR_SCREENS;
} }
int densities[] = null; if (anyDensity < 0 || (anyDensity > 0
int size = pkg.supportsDensityList.size(); && pkg.applicationInfo.targetSdkVersion
if (size > 0) { >= android.os.Build.VERSION_CODES.DONUT)) {
densities = pkg.supportsDensities = new int[size]; pkg.applicationInfo.flags |= ApplicationInfo.FLAG_SUPPORTS_SCREEN_DENSITIES;
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;
}
*/
return pkg; return pkg;
} }
@ -2446,9 +2422,6 @@ public class PackageParser {
// We store the application meta-data independently to avoid multiple unwanted references // We store the application meta-data independently to avoid multiple unwanted references
public Bundle mAppMetaData = null; 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. // If this is a 3rd party app, this is the path of the zip file.
public String mPath; public String mPath;
@ -2630,10 +2603,6 @@ public class PackageParser {
&& p.usesLibraryFiles != null) { && p.usesLibraryFiles != null) {
return true; return true;
} }
if ((flags & PackageManager.GET_SUPPORTS_DENSITIES) != 0
&& p.supportsDensities != null) {
return true;
}
return false; return false;
} }
@ -2656,9 +2625,6 @@ public class PackageParser {
if ((flags & PackageManager.GET_SHARED_LIBRARY_FILES) != 0) { if ((flags & PackageManager.GET_SHARED_LIBRARY_FILES) != 0) {
ai.sharedLibraryFiles = p.usesLibraryFiles; ai.sharedLibraryFiles = p.usesLibraryFiles;
} }
if ((flags & PackageManager.GET_SUPPORTS_DENSITIES) != 0) {
ai.supportsDensities = p.supportsDensities;
}
if (!sCompatibilityModeEnabled) { if (!sCompatibilityModeEnabled) {
ai.disableCompatibilityMode(); ai.disableCompatibilityMode();
} }

View File

@ -131,41 +131,15 @@ public class CompatibilityInfo {
mCompatibilityFlags |= EXPANDABLE | CONFIGURED_EXPANDABLE; mCompatibilityFlags |= EXPANDABLE | CONFIGURED_EXPANDABLE;
} }
float packageDensityScale = -1.0f; if ((appInfo.flags & ApplicationInfo.FLAG_SUPPORTS_SCREEN_DENSITIES) != 0) {
int packageDensity = 0; applicationDensity = DisplayMetrics.DENSITY_DEVICE;
if (appInfo.supportsDensities != null) { applicationScale = 1.0f;
int minDiff = Integer.MAX_VALUE; applicationInvertedScale = 1.0f;
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;
} else { } else {
applicationDensity = DisplayMetrics.DENSITY_DEFAULT; applicationDensity = DisplayMetrics.DENSITY_DEFAULT;
applicationScale = applicationScale = DisplayMetrics.DENSITY_DEVICE
DisplayMetrics.DENSITY_DEVICE / (float) DisplayMetrics.DENSITY_DEFAULT; / (float) DisplayMetrics.DENSITY_DEFAULT;
}
applicationInvertedScale = 1.0f / applicationScale; applicationInvertedScale = 1.0f / applicationScale;
if (applicationScale != 1.0f) {
mCompatibilityFlags |= SCALING_REQUIRED; mCompatibilityFlags |= SCALING_REQUIRED;
} }
} }

View File

@ -827,28 +827,6 @@
<attr name="name" /> <attr name="name" />
</declare-styleable> </declare-styleable>
<!-- The <code>supports-density</code> specifies a screen density that this
package supports. Application can specify multiple densities it supports.
<p>This appears as a child tag of the
{@link #AndroidManifest manifest} tag. -->
<declare-styleable name="AndroidManifestSupportsDensity" parent="AndroidManifest">
<!-- Required value of the density in dip (device independent pixel).
You should use one of the pre-defined constants for the standard
screen densities defined here.
-->
<attr name="density" format="integer">
<!-- A low density screen, such as a QVGA or WQVGA screen in a
typical hand-held phone. The constant for this is 120. -->
<enum name="low" value="120" />
<!-- A medium density screen, such as an HVGA screen in a
typical hand-held phone. The constant for this is 160. -->
<enum name="medium" value="160" />
<!-- A high density screen, such as a VGA or WVGA screen in a
typical hand-held phone. The constant for this is 240. -->
<enum name="high" value="240" />
</attr>
</declare-styleable>
<!-- The <code>supports-screens</code> specifies the screen dimensions an <!-- The <code>supports-screens</code> specifies the screen dimensions an
application supports. By default a modern application supports all application supports. By default a modern application supports all
screen sizes and must explicitly disable certain screen sizes here; screen sizes and must explicitly disable certain screen sizes here;
@ -892,6 +870,11 @@
set for you automatically based on whether you are targeting set for you automatically based on whether you are targeting
a newer platform that supports more screens. --> a newer platform that supports more screens. -->
<attr name="resizeable" format="boolean" /> <attr name="resizeable" format="boolean" />
<!-- Indicates whether the application can accommodate any screen
density. Older applications are assumed to not be able to,
new ones able to. You can explicitly supply your abilities
here. -->
<attr name="anyDensity" format="boolean" />
</declare-styleable> </declare-styleable>
<!-- Private tag to declare system protected broadcast actions. <!-- Private tag to declare system protected broadcast actions.

View File

@ -1093,7 +1093,7 @@
<public type="attr" name="tension" id="0x0101026a" /> <public type="attr" name="tension" id="0x0101026a" />
<public type="attr" name="extraTension" /> <public type="attr" name="extraTension" />
<public type="attr" name="density" /> <public type="attr" name="anyDensity" />
<public type="attr" name="searchSuggestThreshold" /> <public type="attr" name="searchSuggestThreshold" />
<public type="attr" name="includeInGlobalSearch" /> <public type="attr" name="includeInGlobalSearch" />
<public type="attr" name="onClick" /> <public type="attr" name="onClick" />

View File

@ -465,37 +465,37 @@ MyApp/
</tr> </tr>
<tr> <tr>
<td>MCC and MNC</td> <td>MCC and MNC</td>
<td>The mobile country code optionally followed by mobile network code <td><p>The mobile country code optionally followed by mobile network code
from the SIM in the device. For example from the SIM in the device. For example
<code>mcc310</code> (U.S. on any carrier); <code>mcc310</code> (U.S. on any carrier);
<code>mcc310-mnc004</code> (U.S., Verizon brand); <code>mcc310-mnc004</code> (U.S., Verizon brand);
<code>mcc208-mnc00</code> (France, Orange brand); <code>mcc208-mnc00</code> (France, Orange brand);
<code>mcc234-mnc00</code> (U.K., BT brand). <code>mcc234-mnc00</code> (U.K., BT brand).
<p> </p><p>
If the device uses a radio connection (GSM phone), the MCC will come If the device uses a radio connection (GSM phone), the MCC will come
from the SIM, and the MNC will come from the network to which the from the SIM, and the MNC will come from the network to which the
device is attached. You might sometimes use the MCC alone, for example device is attached. You might sometimes use the MCC alone, for example
to include country-specific legal resources in your application. If to include country-specific legal resources in your application. If
your application specifies resources for a MCC/MNC combination, those your application specifies resources for a MCC/MNC combination, those
resources can only be used if both the MCC and the MNC match. </td> resources can only be used if both the MCC and the MNC match. </p></td>
</tr> </tr>
<tr> <tr>
<td>Language and region</td> <td>Language and region</td>
<td>The two letter <a href="http://www.loc.gov/standards/iso639-2/php/code_list.php">ISO <td><p>The two letter <a href="http://www.loc.gov/standards/iso639-2/php/code_list.php">ISO
639-1</a> language code optionally followed by a two letter 639-1</a> language code optionally followed by a two letter
<a href="http://www.iso.org/iso/en/prods-services/iso3166ma/02iso-3166-code-lists/list-en1.html">ISO <a href="http://www.iso.org/iso/en/prods-services/iso3166ma/02iso-3166-code-lists/list-en1.html">ISO
3166-1-alpha-2</a> region code (preceded by lowercase &quot;r&quot;). For example 3166-1-alpha-2</a> region code (preceded by lowercase &quot;r&quot;). For example
<code>fr</code>, <code>en-rUS</code>, <code>fr-rFR</code>, <code>es-rES</code>. <code>fr</code>, <code>en-rUS</code>, <code>fr-rFR</code>, <code>es-rES</code>.
<p> </p><p>
The codes are <em>not</em> case-sensitive; the r prefix is used to The codes are <em>not</em> case-sensitive; the r prefix is used to
distinguish the region portion. distinguish the region portion.
You cannot specify a region alone, but you can specify a language alone, You cannot specify a region alone, but you can specify a language alone,
for example <code>en</code>, <code>fr</code>, <code>es</code>. </td> for example <code>en</code>, <code>fr</code>, <code>es</code>.</p> </td>
</tr> </tr>
<tr> <tr>
<td>Screen dimensions</td> <td>Screen dimensions</td>
<td><code>small</code>, <code>normal</code>, <code>large</code> <td><p><code>small</code>, <code>normal</code>, <code>large</code>
<p> </p><p>
Specify that the resource is for a particular class of screen. Specify that the resource is for a particular class of screen.
The meanings of these are:</p> The meanings of these are:</p>
<ul> <ul>
@ -517,27 +517,27 @@ MyApp/
</tr> </tr>
<tr> <tr>
<td>Wider/taller screens</td> <td>Wider/taller screens</td>
<td><code>long</code>, <code>notlong</code> <td><p><code>long</code>, <code>notlong</code>
<p> </p><p>
Specify that the resource is for a taller/wider than traditional Specify that the resource is for a taller/wider than traditional
screen. This is based purely on the aspect ration of the screen: screen. This is based purely on the aspect ration of the screen:
QVGA, HVGA, and VGA are notlong; WQVGA, WVGA, FWVGA are long. Note QVGA, HVGA, and VGA are notlong; WQVGA, WVGA, FWVGA are long. Note
that long may mean either wide or tall, depending on the current that long may mean either wide or tall, depending on the current
orientation. orientation.</p>
</td> </td>
</tr> </tr>
<tr> <tr>
<td>Screen orientation</td> <td>Screen orientation</td>
<td><code>port</code>, <code>land</code>, <code>square</code> <td><p><code>port</code>, <code>land</code>, <code>square</code>
<p> </p><p>
Specifies that the resource is for a screen that is tall (port) Specifies that the resource is for a screen that is tall (port)
or wide (land); square is not currently used. or wide (land); square is not currently used.</p>
</td> </td>
</tr> </tr>
<tr> <tr>
<td>Screen pixel density</td> <td>Screen pixel density</td>
<td><code>ldpi</code>, <code>mdpi</code>, <code>hdpi</code>, <code>nodpi</code> <td><p><code>ldpi</code>, <code>mdpi</code>, <code>hdpi</code>, <code>nodpi</code>
<p> </p><p>
Specifies the screen density the resource is defined for. The medium Specifies the screen density the resource is defined for. The medium
density of traditional HVGA screens (mdpi) is defined to be approximately density of traditional HVGA screens (mdpi) is defined to be approximately
160dpi; low density (ldpi) is 120, and high density (hdpi) is 240. There 160dpi; low density (ldpi) is 120, and high density (hdpi) is 240. There
@ -545,7 +545,7 @@ MyApp/
in ldpi would be 12x12 is mdpi and 16x16 in hdpi. The special in ldpi would be 12x12 is mdpi and 16x16 in hdpi. The special
<code>nodpi</code> density can be used with bitmap resources to prevent <code>nodpi</code> density can be used with bitmap resources to prevent
them from being scaled at load time to match the device density. them from being scaled at load time to match the device density.
<p> </p><p>
When Android selects which resource files to use, When Android selects which resource files to use,
it handles screen density differently than the other qualifiers. it handles screen density differently than the other qualifiers.
In step 1 of <a href="#best-match">How Android finds the best In step 1 of <a href="#best-match">How Android finds the best
@ -553,10 +553,11 @@ MyApp/
be a match. In step 4, if the qualifier being considered is screen be a match. In step 4, if the qualifier being considered is screen
density, Android will select the best final match at that point, density, Android will select the best final match at that point,
without any need to move on to step 5. without any need to move on to step 5.
<p> </p><p>
You can also specify explicit densities like <code>92dpi</code> You can also specify explicit densities like <code>92dpi</code>
or <code>108dpi</code>, but these are not fully supported by the or <code>108dpi</code>, but these are not fully supported by the
system so should not be used. system so should not be used.
</p>
</td> </td>
</tr> </tr>
<tr> <tr>
@ -565,9 +566,9 @@ MyApp/
</tr> </tr>
<tr> <tr>
<td>Whether the keyboard is available to the user</td> <td>Whether the keyboard is available to the user</td>
<td><code>keysexposed</code>, <code>keyshidden</code>, <code>keyssoft</code> <td><p><code>keysexposed</code>, <code>keyshidden</code>, <code>keyssoft</code>
<p> </p><p>
If your application has specific resources that should only be used with a soft keyboard, use the <code>keyssoft</code> value. If no <code>keyssoft</code> resources are available (only <code>keysexposed</code> and <code>keyshidden</code>) and the device shows a soft keyboard, the system will use <code>keysexposed</code> resources. </td> If your application has specific resources that should only be used with a soft keyboard, use the <code>keyssoft</code> value. If no <code>keyssoft</code> resources are available (only <code>keysexposed</code> and <code>keyshidden</code>) and the device shows a soft keyboard, the system will use <code>keysexposed</code> resources.</p> </td>
</tr> </tr>
<tr> <tr>
<td>Primary text input method</td> <td>Primary text input method</td>

View File

@ -4902,26 +4902,40 @@ class PackageManagerService extends IPackageManager.Stub {
if (ps.pkg != null) { if (ps.pkg != null) {
pw.print(" dataDir="); pw.println(ps.pkg.applicationInfo.dataDir); pw.print(" dataDir="); pw.println(ps.pkg.applicationInfo.dataDir);
pw.print(" targetSdk="); pw.println(ps.pkg.applicationInfo.targetSdkVersion); pw.print(" targetSdk="); pw.println(ps.pkg.applicationInfo.targetSdkVersion);
pw.print(" densities="); pw.println(ps.pkg.supportsDensityList); pw.print(" supportsScreens=[");
ArrayList<String> screens = new ArrayList<String>(); boolean first = true;
if ((ps.pkg.applicationInfo.flags & if ((ps.pkg.applicationInfo.flags &
ApplicationInfo.FLAG_SUPPORTS_NORMAL_SCREENS) != 0) { ApplicationInfo.FLAG_SUPPORTS_NORMAL_SCREENS) != 0) {
screens.add("medium"); if (!first) pw.print(", ");
first = false;
pw.print("medium");
} }
if ((ps.pkg.applicationInfo.flags & if ((ps.pkg.applicationInfo.flags &
ApplicationInfo.FLAG_SUPPORTS_LARGE_SCREENS) != 0) { ApplicationInfo.FLAG_SUPPORTS_LARGE_SCREENS) != 0) {
screens.add("large"); if (!first) pw.print(", ");
first = false;
pw.print("large");
} }
if ((ps.pkg.applicationInfo.flags & if ((ps.pkg.applicationInfo.flags &
ApplicationInfo.FLAG_SUPPORTS_SMALL_SCREENS) != 0) { ApplicationInfo.FLAG_SUPPORTS_SMALL_SCREENS) != 0) {
screens.add("small,"); if (!first) pw.print(", ");
first = false;
pw.print("small");
} }
if ((ps.pkg.applicationInfo.flags & if ((ps.pkg.applicationInfo.flags &
ApplicationInfo.FLAG_RESIZEABLE_FOR_SCREENS) != 0) { ApplicationInfo.FLAG_RESIZEABLE_FOR_SCREENS) != 0) {
screens.add("resizeable,"); if (!first) pw.print(", ");
first = false;
pw.print("resizeable");
} }
pw.print(" supportsScreens="); pw.println(screens); if ((ps.pkg.applicationInfo.flags &
ApplicationInfo.FLAG_SUPPORTS_SCREEN_DENSITIES) != 0) {
if (!first) pw.print(", ");
first = false;
pw.print("anyDensity");
} }
}
pw.println("]");
pw.print(" timeStamp="); pw.println(ps.getTimeStampStr()); pw.print(" timeStamp="); pw.println(ps.getTimeStampStr());
pw.print(" signatures="); pw.println(ps.signatures); pw.print(" signatures="); pw.println(ps.signatures);
pw.print(" permissionsFixed="); pw.print(ps.permissionsFixed); pw.print(" permissionsFixed="); pw.print(ps.permissionsFixed);

View File

@ -184,8 +184,7 @@ public final class ActivityManagerService extends ActivityManagerNative implemen
static final int LOG_BOOT_PROGRESS_ENABLE_SCREEN = 3050; static final int LOG_BOOT_PROGRESS_ENABLE_SCREEN = 3050;
// The flags that are set for all calls we make to the package manager. // The flags that are set for all calls we make to the package manager.
static final int STOCK_PM_FLAGS = PackageManager.GET_SHARED_LIBRARY_FILES static final int STOCK_PM_FLAGS = PackageManager.GET_SHARED_LIBRARY_FILES;
| PackageManager.GET_SUPPORTS_DENSITIES;
private static final String SYSTEM_SECURE = "ro.secure"; private static final String SYSTEM_SECURE = "ro.secure";

View File

@ -52,14 +52,13 @@ public class DpiTestActivity extends Activity {
// be doing it. // be doing it.
Application app = ActivityThread.currentActivityThread().getApplication(); Application app = ActivityThread.currentActivityThread().getApplication();
ApplicationInfo ai = app.getPackageManager().getApplicationInfo( ApplicationInfo ai = app.getPackageManager().getApplicationInfo(
"com.google.android.test.dpi", "com.google.android.test.dpi", 0);
PackageManager.GET_SUPPORTS_DENSITIES);
if (noCompat) { if (noCompat) {
ai.flags |= ApplicationInfo.FLAG_SUPPORTS_LARGE_SCREENS ai.flags |= ApplicationInfo.FLAG_SUPPORTS_LARGE_SCREENS
| ApplicationInfo.FLAG_SUPPORTS_NORMAL_SCREENS | ApplicationInfo.FLAG_SUPPORTS_NORMAL_SCREENS
| ApplicationInfo.FLAG_SUPPORTS_SMALL_SCREENS | ApplicationInfo.FLAG_SUPPORTS_SMALL_SCREENS
| ApplicationInfo.FLAG_RESIZEABLE_FOR_SCREENS; | ApplicationInfo.FLAG_RESIZEABLE_FOR_SCREENS
ai.supportsDensities = new int[] { ApplicationInfo.ANY_DENSITY }; | ApplicationInfo.FLAG_SUPPORTS_SCREEN_DENSITIES;
app.getResources().setCompatibilityInfo(new CompatibilityInfo(ai)); app.getResources().setCompatibilityInfo(new CompatibilityInfo(ai));
} }
} catch (PackageManager.NameNotFoundException e) { } catch (PackageManager.NameNotFoundException e) {