From 6aa7a7e3ea2e2ba8ab3558134f0e5d81c59326a2 Mon Sep 17 00:00:00 2001 From: Xavier Ducrohet Date: Tue, 4 Oct 2011 13:32:24 -0700 Subject: [PATCH] Cherrypick 6a5504 from master. do not merge. Make source.prop more important than build.prop when parsing platforms. Change-Id: I126d4ed06fd1aa5125add58c17c3cebc4ec6b780 --- files/devices.xml | 27 +++ .../sdklib/src/com/android/sdklib/SdkManager.java | 197 ++++++++++----------- 2 files changed, 125 insertions(+), 99 deletions(-) diff --git a/files/devices.xml b/files/devices.xml index 6dc0a3fef..9b90578ee 100644 --- a/files/devices.xml +++ b/files/devices.xml @@ -261,6 +261,33 @@ + + + normal + long + port + xhdpi + finger + keyssoft + nokeys + navexposed + nonav + + 1280 + 720 + + 320 + 320 + + + + port + + + land + + + large diff --git a/sdkmanager/libs/sdklib/src/com/android/sdklib/SdkManager.java b/sdkmanager/libs/sdklib/src/com/android/sdklib/SdkManager.java index 8b54ccd77..6decab0d1 100644 --- a/sdkmanager/libs/sdklib/src/com/android/sdklib/SdkManager.java +++ b/sdkmanager/libs/sdklib/src/com/android/sdklib/SdkManager.java @@ -344,127 +344,126 @@ public class SdkManager { private static PlatformTarget loadPlatform(String sdkOsPath, File platformFolder, ISdkLog log) { FileWrapper buildProp = new FileWrapper(platformFolder, SdkConstants.FN_BUILD_PROP); + FileWrapper sourcePropFile = new FileWrapper(platformFolder, SdkConstants.FN_SOURCE_PROP); - if (buildProp.isFile()) { + if (buildProp.isFile() && sourcePropFile.isFile()) { + Map platformProp = new HashMap(); + + // add all the property files Map map = ProjectProperties.parsePropertyFile(buildProp, log); + if (map != null) { + platformProp.putAll(map); + } + map = ProjectProperties.parsePropertyFile(sourcePropFile, log); if (map != null) { - // look for some specific values in the map. + platformProp.putAll(map); + } - // version string - String apiName = map.get(PROP_VERSION_RELEASE); - if (apiName == null) { - log.warning( - "Ignoring platform '%1$s': %2$s is missing from '%3$s'", - platformFolder.getName(), PROP_VERSION_RELEASE, - SdkConstants.FN_BUILD_PROP); - return null; + FileWrapper sdkPropFile = new FileWrapper(platformFolder, SdkConstants.FN_SDK_PROP); + if (sdkPropFile.isFile()) { // obsolete platforms don't have this. + map = ProjectProperties.parsePropertyFile(sdkPropFile, log); + if (map != null) { + platformProp.putAll(map); } + } + + // look for some specific values in the map. - // api level - int apiNumber; - String stringValue = map.get(PROP_VERSION_SDK); - if (stringValue == null) { + // api level + int apiNumber; + String stringValue = platformProp.get(PROP_VERSION_SDK); + if (stringValue == null) { + log.warning( + "Ignoring platform '%1$s': %2$s is missing from '%3$s'", + platformFolder.getName(), PROP_VERSION_SDK, + SdkConstants.FN_BUILD_PROP); + return null; + } else { + try { + apiNumber = Integer.parseInt(stringValue); + } catch (NumberFormatException e) { + // looks like apiNumber does not parse to a number. + // Ignore this platform. log.warning( - "Ignoring platform '%1$s': %2$s is missing from '%3$s'", + "Ignoring platform '%1$s': %2$s is not a valid number in %3$s.", platformFolder.getName(), PROP_VERSION_SDK, SdkConstants.FN_BUILD_PROP); return null; - } else { - try { - apiNumber = Integer.parseInt(stringValue); - } catch (NumberFormatException e) { - // looks like apiNumber does not parse to a number. - // Ignore this platform. - log.warning( - "Ignoring platform '%1$s': %2$s is not a valid number in %3$s.", - platformFolder.getName(), PROP_VERSION_SDK, - SdkConstants.FN_BUILD_PROP); - return null; - } } + } - // codename (optional) - String apiCodename = map.get(PROP_VERSION_CODENAME); - if (apiCodename != null && apiCodename.equals("REL")) { - apiCodename = null; // REL means it's a release version and therefore the - // codename is irrelevant at this point. - } - - // platform rev number & layoutlib version are extracted from the source.properties - // saved by the SDK Manager when installing the package. - - int revision = 1; - LayoutlibVersion layoutlibVersion = null; - - FileWrapper sourcePropFile = - new FileWrapper(platformFolder, SdkConstants.FN_SOURCE_PROP); + // codename (optional) + String apiCodename = platformProp.get(PROP_VERSION_CODENAME); + if (apiCodename != null && apiCodename.equals("REL")) { + apiCodename = null; // REL means it's a release version and therefore the + // codename is irrelevant at this point. + } - Map sourceProp = ProjectProperties.parsePropertyFile( - sourcePropFile, log); + // version string + String apiName = platformProp.get(PkgProps.PLATFORM_VERSION); + if (apiName == null) { + apiName = platformProp.get(PROP_VERSION_RELEASE); + } + if (apiName == null) { + log.warning( + "Ignoring platform '%1$s': %2$s is missing from '%3$s'", + platformFolder.getName(), PROP_VERSION_RELEASE, + SdkConstants.FN_BUILD_PROP); + return null; + } - if (sourceProp != null) { - try { - revision = Integer.parseInt(sourceProp.get(PkgProps.PKG_REVISION)); - } catch (NumberFormatException e) { - // do nothing, we'll keep the default value of 1. - } + // platform rev number & layoutlib version are extracted from the source.properties + // saved by the SDK Manager when installing the package. - try { - String propApi = sourceProp.get(PkgProps.LAYOUTLIB_API); - String propRev = sourceProp.get(PkgProps.LAYOUTLIB_REV); - int llApi = propApi == null ? LayoutlibVersion.NOT_SPECIFIED : - Integer.parseInt(propApi); - int llRev = propRev == null ? LayoutlibVersion.NOT_SPECIFIED : - Integer.parseInt(propRev); - if (llApi > LayoutlibVersion.NOT_SPECIFIED && - llRev >= LayoutlibVersion.NOT_SPECIFIED) { - layoutlibVersion = new LayoutlibVersion(llApi, llRev); - } - } catch (NumberFormatException e) { - // do nothing, we'll ignore the layoutlib version if it's invalid - } + int revision = 1; + LayoutlibVersion layoutlibVersion = null; + try { + revision = Integer.parseInt(platformProp.get(PkgProps.PKG_REVISION)); + } catch (NumberFormatException e) { + // do nothing, we'll keep the default value of 1. + } - map.putAll(sourceProp); + try { + String propApi = platformProp.get(PkgProps.LAYOUTLIB_API); + String propRev = platformProp.get(PkgProps.LAYOUTLIB_REV); + int llApi = propApi == null ? LayoutlibVersion.NOT_SPECIFIED : + Integer.parseInt(propApi); + int llRev = propRev == null ? LayoutlibVersion.NOT_SPECIFIED : + Integer.parseInt(propRev); + if (llApi > LayoutlibVersion.NOT_SPECIFIED && + llRev >= LayoutlibVersion.NOT_SPECIFIED) { + layoutlibVersion = new LayoutlibVersion(llApi, llRev); } + } catch (NumberFormatException e) { + // do nothing, we'll ignore the layoutlib version if it's invalid + } - // Ant properties - FileWrapper sdkPropFile = new FileWrapper(platformFolder, SdkConstants.FN_SDK_PROP); - Map antProp = null; - if (sdkPropFile.isFile()) { // obsolete platforms don't have this. - antProp = ProjectProperties.parsePropertyFile(sdkPropFile, log); - } + // api number and name look valid, perform a few more checks + if (checkPlatformContent(platformFolder, log) == false) { + return null; + } - if (antProp != null) { - map.putAll(antProp); - } + ISystemImage[] systemImages = + getPlatformSystemImages(sdkOsPath, platformFolder, apiNumber, apiCodename); + + // create the target. + PlatformTarget target = new PlatformTarget( + sdkOsPath, + platformFolder.getAbsolutePath(), + apiNumber, + apiCodename, + apiName, + revision, + layoutlibVersion, + systemImages, + platformProp); - // api number and name look valid, perform a few more checks - if (checkPlatformContent(platformFolder, log) == false) { - return null; - } + // need to parse the skins. + String[] skins = parseSkinFolder(target.getPath(IAndroidTarget.SKINS)); + target.setSkins(skins); - ISystemImage[] systemImages = - getPlatformSystemImages(sdkOsPath, platformFolder, apiNumber, apiCodename); - - // create the target. - PlatformTarget target = new PlatformTarget( - sdkOsPath, - platformFolder.getAbsolutePath(), - apiNumber, - apiCodename, - apiName, - revision, - layoutlibVersion, - systemImages, - map); - - // need to parse the skins. - String[] skins = parseSkinFolder(target.getPath(IAndroidTarget.SKINS)); - target.setSkins(skins); - - return target; - } + return target; } else { log.warning("Ignoring platform '%1$s': %2$s is missing.", //$NON-NLS-1$ platformFolder.getName(), -- 2.11.0