From 34230d8dd05143b85d520f5e34a5ea4f055e0e96 Mon Sep 17 00:00:00 2001 From: Tor Norbye Date: Thu, 31 May 2012 13:03:11 -0700 Subject: Fix bug in manifest metadata handler The ManifestInfo class keeps a cache of the manifest metadata, such as the package name, minSdkVersion, etc. However, the code which cached the minSdkVersion and targetSdkVersion fields was incorrectly placed inside an unrelated if-block, which meant that in some cases (in particular, manifests specifying a default theme) these fields would not get set, and the class would return an incorrect value of 1 for minSdkVersion, regardless of the actual value specified. Change-Id: I32423cad45c9f6f775b7334ee3fd9bd183497abd --- .../internal/editors/manifest/ManifestInfo.java | 26 ++++++++++------------ 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/manifest/ManifestInfo.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/manifest/ManifestInfo.java index 8479b0d..993b6fc 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/manifest/ManifestInfo.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/manifest/ManifestInfo.java @@ -226,7 +226,6 @@ public class ManifestInfo { } NodeList applications = root.getElementsByTagName(AndroidManifest.NODE_APPLICATION); - String defaultTheme = null; if (applications.getLength() > 0) { assert applications.getLength() == 1; Element application = (Element) applications.item(0); @@ -237,23 +236,22 @@ public class ManifestInfo { mApplicationLabel = application.getAttributeNS(NS_RESOURCES, ATTRIBUTE_LABEL); } - defaultTheme = application.getAttributeNS(NS_RESOURCES, ATTRIBUTE_THEME); + String defaultTheme = application.getAttributeNS(NS_RESOURCES, ATTRIBUTE_THEME); + if (defaultTheme != null && !defaultTheme.isEmpty()) { + // From manifest theme documentation: + // "If that attribute is also not set, the default system theme is used." + mManifestTheme = defaultTheme; + } } // Look up target SDK - if (defaultTheme == null || defaultTheme.length() == 0) { - // From manifest theme documentation: - // "If that attribute is also not set, the default system theme is used." - - NodeList usesSdks = root.getElementsByTagName(NODE_USES_SDK); - if (usesSdks.getLength() > 0) { - Element usesSdk = (Element) usesSdks.item(0); - mMinSdk = getApiVersion(usesSdk, ATTRIBUTE_MIN_SDK_VERSION, 1); - mTargetSdk = getApiVersion(usesSdk, ATTRIBUTE_TARGET_SDK_VERSION, mMinSdk); - } - } else { - mManifestTheme = defaultTheme; + NodeList usesSdks = root.getElementsByTagName(NODE_USES_SDK); + if (usesSdks.getLength() > 0) { + Element usesSdk = (Element) usesSdks.item(0); + mMinSdk = getApiVersion(usesSdk, ATTRIBUTE_MIN_SDK_VERSION, 1); + mTargetSdk = getApiVersion(usesSdk, ATTRIBUTE_TARGET_SDK_VERSION, mMinSdk); } + } catch (SAXException e) { AdtPlugin.log(e, "Malformed manifest"); } catch (Exception e) { -- cgit v1.1