From a0b46c9c441f017a2008ca8ee2c864987465996b Mon Sep 17 00:00:00 2001 From: Dianne Hackborn Date: Thu, 21 Oct 2010 15:32:06 -0700 Subject: [PATCH] Implement issue #3116702: New manifest tags for supported screen sizes Merged from GB. Change-Id: I94730b54bcacd083f77708e84c35f4932a7b9d2e --- api/current.xml | 199 ++++++++++-------- .../android/content/pm/PackageParser.java | 10 + core/java/android/util/DisplayMetrics.java | 5 + core/res/res/values/attrs_manifest.xml | 32 +++ core/res/res/values/public.xml | 2 + tests/DpiTest/AndroidManifest.xml | 6 + tools/aapt/Command.cpp | 59 +++++- 7 files changed, 221 insertions(+), 92 deletions(-) diff --git a/api/current.xml b/api/current.xml index 094888875ec81..3bf076a4699c0 100644 --- a/api/current.xml +++ b/api/current.xml @@ -1773,7 +1773,7 @@ type="int" transient="false" volatile="false" - value="16843511" + value="16843513" static="true" final="true" deprecated="not deprecated" @@ -1784,7 +1784,7 @@ type="int" transient="false" volatile="false" - value="16843480" + value="16843482" static="true" final="true" deprecated="not deprecated" @@ -1795,7 +1795,7 @@ type="int" transient="false" volatile="false" - value="16843520" + value="16843522" static="true" final="true" deprecated="not deprecated" @@ -1806,7 +1806,7 @@ type="int" transient="false" volatile="false" - value="16843519" + value="16843521" static="true" final="true" deprecated="not deprecated" @@ -1817,7 +1817,7 @@ type="int" transient="false" volatile="false" - value="16843521" + value="16843523" static="true" final="true" deprecated="not deprecated" @@ -1828,7 +1828,7 @@ type="int" transient="false" volatile="false" - value="16843490" + value="16843492" static="true" final="true" deprecated="not deprecated" @@ -1839,7 +1839,7 @@ type="int" transient="false" volatile="false" - value="16843489" + value="16843491" static="true" final="true" deprecated="not deprecated" @@ -1850,7 +1850,7 @@ type="int" transient="false" volatile="false" - value="16843527" + value="16843529" static="true" final="true" deprecated="not deprecated" @@ -1861,7 +1861,7 @@ type="int" transient="false" volatile="false" - value="16843493" + value="16843495" static="true" final="true" deprecated="not deprecated" @@ -1872,7 +1872,7 @@ type="int" transient="false" volatile="false" - value="16843523" + value="16843525" static="true" final="true" deprecated="not deprecated" @@ -1883,7 +1883,7 @@ type="int" transient="false" volatile="false" - value="16843494" + value="16843496" static="true" final="true" deprecated="not deprecated" @@ -1894,7 +1894,7 @@ type="int" transient="false" volatile="false" - value="16843547" + value="16843549" static="true" final="true" deprecated="not deprecated" @@ -1905,7 +1905,7 @@ type="int" transient="false" volatile="false" - value="16843546" + value="16843548" static="true" final="true" deprecated="not deprecated" @@ -1916,7 +1916,7 @@ type="int" transient="false" volatile="false" - value="16843548" + value="16843550" static="true" final="true" deprecated="not deprecated" @@ -1927,7 +1927,7 @@ type="int" transient="false" volatile="false" - value="16843522" + value="16843524" static="true" final="true" deprecated="not deprecated" @@ -1938,7 +1938,7 @@ type="int" transient="false" volatile="false" - value="16843528" + value="16843530" static="true" final="true" deprecated="not deprecated" @@ -1949,7 +1949,7 @@ type="int" transient="false" volatile="false" - value="16843529" + value="16843531" static="true" final="true" deprecated="not deprecated" @@ -2004,7 +2004,7 @@ type="int" transient="false" volatile="false" - value="16843466" + value="16843468" static="true" final="true" deprecated="not deprecated" @@ -2037,7 +2037,7 @@ type="int" transient="false" volatile="false" - value="16843545" + value="16843547" static="true" final="true" deprecated="not deprecated" @@ -2059,7 +2059,7 @@ type="int" transient="false" volatile="false" - value="16843541" + value="16843543" static="true" final="true" deprecated="not deprecated" @@ -2070,7 +2070,7 @@ type="int" transient="false" volatile="false" - value="16843478" + value="16843480" static="true" final="true" deprecated="not deprecated" @@ -2169,7 +2169,7 @@ type="int" transient="false" volatile="false" - value="16843487" + value="16843489" static="true" final="true" deprecated="not deprecated" @@ -2180,7 +2180,7 @@ type="int" transient="false" volatile="false" - value="16843518" + value="16843520" static="true" final="true" deprecated="not deprecated" @@ -2279,7 +2279,7 @@ type="int" transient="false" volatile="false" - value="16843472" + value="16843474" static="true" final="true" deprecated="not deprecated" @@ -2521,7 +2521,7 @@ type="int" transient="false" volatile="false" - value="16843536" + value="16843538" static="true" final="true" deprecated="not deprecated" @@ -2532,7 +2532,7 @@ type="int" transient="false" volatile="false" - value="16843535" + value="16843537" static="true" final="true" deprecated="not deprecated" @@ -2565,7 +2565,7 @@ type="int" transient="false" volatile="false" - value="16843544" + value="16843546" static="true" final="true" deprecated="not deprecated" @@ -2983,7 +2983,7 @@ type="int" transient="false" volatile="false" - value="16843475" + value="16843477" static="true" final="true" deprecated="not deprecated" @@ -3137,7 +3137,7 @@ type="int" transient="false" volatile="false" - value="16843484" + value="16843486" static="true" final="true" deprecated="not deprecated" @@ -3346,7 +3346,7 @@ type="int" transient="false" volatile="false" - value="16843540" + value="16843542" static="true" final="true" deprecated="not deprecated" @@ -3423,7 +3423,7 @@ type="int" transient="false" volatile="false" - value="16843482" + value="16843484" static="true" final="true" deprecated="not deprecated" @@ -3467,7 +3467,7 @@ type="int" transient="false" volatile="false" - value="16843543" + value="16843545" static="true" final="true" deprecated="not deprecated" @@ -3643,7 +3643,7 @@ type="int" transient="false" volatile="false" - value="16843488" + value="16843490" static="true" final="true" deprecated="not deprecated" @@ -4215,7 +4215,7 @@ type="int" transient="false" volatile="false" - value="16843501" + value="16843503" static="true" final="true" deprecated="not deprecated" @@ -4226,7 +4226,7 @@ type="int" transient="false" volatile="false" - value="16843505" + value="16843507" static="true" final="true" deprecated="not deprecated" @@ -4237,7 +4237,7 @@ type="int" transient="false" volatile="false" - value="16843506" + value="16843508" static="true" final="true" deprecated="not deprecated" @@ -4248,7 +4248,7 @@ type="int" transient="false" volatile="false" - value="16843507" + value="16843509" static="true" final="true" deprecated="not deprecated" @@ -4259,7 +4259,7 @@ type="int" transient="false" volatile="false" - value="16843508" + value="16843510" static="true" final="true" deprecated="not deprecated" @@ -4270,7 +4270,7 @@ type="int" transient="false" volatile="false" - value="16843503" + value="16843505" static="true" final="true" deprecated="not deprecated" @@ -4281,7 +4281,7 @@ type="int" transient="false" volatile="false" - value="16843504" + value="16843506" static="true" final="true" deprecated="not deprecated" @@ -4292,7 +4292,7 @@ type="int" transient="false" volatile="false" - value="16843509" + value="16843511" static="true" final="true" deprecated="not deprecated" @@ -4303,7 +4303,7 @@ type="int" transient="false" volatile="false" - value="16843510" + value="16843512" static="true" final="true" deprecated="not deprecated" @@ -4325,7 +4325,7 @@ type="int" transient="false" volatile="false" - value="16843470" + value="16843472" static="true" final="true" deprecated="not deprecated" @@ -4358,7 +4358,7 @@ type="int" transient="false" volatile="false" - value="16843473" + value="16843475" static="true" final="true" deprecated="not deprecated" @@ -4655,7 +4655,7 @@ type="int" transient="false" volatile="false" - value="16843485" + value="16843487" static="true" final="true" deprecated="not deprecated" @@ -4787,7 +4787,7 @@ type="int" transient="false" volatile="false" - value="16843526" + value="16843528" static="true" final="true" deprecated="not deprecated" @@ -4908,7 +4908,7 @@ type="int" transient="false" volatile="false" - value="16843514" + value="16843516" static="true" final="true" deprecated="not deprecated" @@ -4919,7 +4919,7 @@ type="int" transient="false" volatile="false" - value="16843512" + value="16843514" static="true" final="true" deprecated="not deprecated" @@ -4930,7 +4930,7 @@ type="int" transient="false" volatile="false" - value="16843513" + value="16843515" static="true" final="true" deprecated="not deprecated" @@ -5953,7 +5953,7 @@ type="int" transient="false" volatile="false" - value="16843516" + value="16843518" static="true" final="true" deprecated="not deprecated" @@ -5997,7 +5997,7 @@ type="int" transient="false" volatile="false" - value="16843537" + value="16843539" static="true" final="true" deprecated="not deprecated" @@ -6008,7 +6008,7 @@ type="int" transient="false" volatile="false" - value="16843531" + value="16843533" static="true" final="true" deprecated="not deprecated" @@ -6096,7 +6096,7 @@ type="int" transient="false" volatile="false" - value="16843539" + value="16843541" static="true" final="true" deprecated="not deprecated" @@ -6261,7 +6261,7 @@ type="int" transient="false" volatile="false" - value="16843486" + value="16843488" static="true" final="true" deprecated="not deprecated" @@ -6404,7 +6404,7 @@ type="int" transient="false" volatile="false" - value="16843481" + value="16843483" static="true" final="true" deprecated="not deprecated" @@ -6580,7 +6580,7 @@ type="int" transient="false" volatile="false" - value="16843500" + value="16843502" static="true" final="true" deprecated="not deprecated" @@ -6910,7 +6910,7 @@ type="int" transient="false" volatile="false" - value="16843532" + value="16843534" static="true" final="true" deprecated="not deprecated" @@ -7009,7 +7009,7 @@ type="int" transient="false" volatile="false" - value="16843492" + value="16843494" static="true" final="true" deprecated="not deprecated" @@ -7174,7 +7174,7 @@ type="int" transient="false" volatile="false" - value="16843499" + value="16843501" static="true" final="true" deprecated="not deprecated" @@ -7621,6 +7621,17 @@ visibility="public" > + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/core/res/res/values/public.xml b/core/res/res/values/public.xml index 5add8d6ab90a1..47bb5f88b0f67 100644 --- a/core/res/res/values/public.xml +++ b/core/res/res/values/public.xml @@ -1257,6 +1257,8 @@ + + diff --git a/tests/DpiTest/AndroidManifest.xml b/tests/DpiTest/AndroidManifest.xml index 68ecc6e89934a..a4d8c79731417 100644 --- a/tests/DpiTest/AndroidManifest.xml +++ b/tests/DpiTest/AndroidManifest.xml @@ -18,6 +18,12 @@ package="com.google.android.test.dpi"> + + + + + + diff --git a/tools/aapt/Command.cpp b/tools/aapt/Command.cpp index 4469e68420902..e9833c993c830 100644 --- a/tools/aapt/Command.cpp +++ b/tools/aapt/Command.cpp @@ -334,13 +334,15 @@ enum { REQ_FIVE_WAY_NAV_ATTR = 0x01010232, TARGET_SDK_VERSION_ATTR = 0x01010270, TEST_ONLY_ATTR = 0x01010272, - DENSITY_ATTR = 0x0101026c, + ANY_DENSITY_ATTR = 0x0101026c, GL_ES_VERSION_ATTR = 0x01010281, SMALL_SCREEN_ATTR = 0x01010284, NORMAL_SCREEN_ATTR = 0x01010285, LARGE_SCREEN_ATTR = 0x01010286, XLARGE_SCREEN_ATTR = 0x010102bf, REQUIRED_ATTR = 0x0101028e, + SCREEN_SIZE_ATTR = 0x010102ca, + SCREEN_DENSITY_ATTR = 0x010102cb, }; const char *getComponentName(String8 &pkgName, String8 &componentName) { @@ -357,6 +359,42 @@ const char *getComponentName(String8 &pkgName, String8 &componentName) { return retStr.string(); } +static void printCompatibleScreens(ResXMLTree& tree) { + size_t len; + ResXMLTree::event_code_t code; + int depth = 0; + bool first = true; + printf("compatible-screens:"); + while ((code=tree.next()) != ResXMLTree::END_DOCUMENT && code != ResXMLTree::BAD_DOCUMENT) { + if (code == ResXMLTree::END_TAG) { + depth--; + if (depth < 0) { + break; + } + continue; + } + if (code != ResXMLTree::START_TAG) { + continue; + } + depth++; + String8 tag(tree.getElementName(&len)); + if (tag == "screen") { + int32_t screenSize = getIntegerAttribute(tree, + SCREEN_SIZE_ATTR, NULL, -1); + int32_t screenDensity = getIntegerAttribute(tree, + SCREEN_DENSITY_ATTR, NULL, -1); + if (screenSize > 0 && screenDensity > 0) { + if (!first) { + printf(","); + } + first = false; + printf("'%d/%d'", screenSize, screenDensity); + } + } + } + printf("\n"); +} + /* * Handle the "dump" command, to extract select data from an archive. */ @@ -575,6 +613,7 @@ int doDump(Bundle* bundle) int normalScreen = 1; int largeScreen = 1; int xlargeScreen = 1; + int anyDensity = 1; String8 pkg; String8 activityName; String8 activityLabel; @@ -742,14 +781,6 @@ int doDump(Bundle* bundle) printf(" reqFiveWayNav='%d'", reqFiveWayNav); } printf("\n"); - } else if (tag == "supports-density") { - int32_t dens = getIntegerAttribute(tree, DENSITY_ATTR, &error); - if (error != "") { - fprintf(stderr, "ERROR getting 'android:density' attribute: %s\n", - error.string()); - goto bail; - } - printf("supports-density:'%d'\n", dens); } else if (tag == "supports-screens") { smallScreen = getIntegerAttribute(tree, SMALL_SCREEN_ATTR, NULL, 1); @@ -759,6 +790,8 @@ int doDump(Bundle* bundle) LARGE_SCREEN_ATTR, NULL, 1); xlargeScreen = getIntegerAttribute(tree, XLARGE_SCREEN_ATTR, NULL, 1); + anyDensity = getIntegerAttribute(tree, + ANY_DENSITY_ATTR, NULL, 1); } else if (tag == "uses-feature") { String8 name = getAttribute(tree, NAME_ATTR, &error); @@ -883,6 +916,9 @@ int doDump(Bundle* bundle) error.string()); goto bail; } + } else if (tag == "compatible-screens") { + printCompatibleScreens(tree); + depth--; } } else if (depth == 3 && withinApplication) { withinActivity = false; @@ -1109,6 +1145,9 @@ int doDump(Bundle* bundle) // Introduced in Honeycomb. xlargeScreen = targetSdk >= 10 ? -1 : 0; } + if (anyDensity > 0) { + anyDensity = targetSdk >= 4 ? -1 : 0; + } printf("supports-screens:"); if (smallScreen != 0) printf(" 'small'"); if (normalScreen != 0) printf(" 'normal'"); @@ -1116,6 +1155,8 @@ int doDump(Bundle* bundle) if (xlargeScreen != 0) printf(" 'xlarge'"); printf("\n"); + printf("supports-any-density: '%s'\n", anyDensity ? "true" : "false"); + printf("locales:"); Vector locales; res.getLocales(&locales);