OSDN Git Service

Cherrypick 6a5504 from master. do not merge.
authorXavier Ducrohet <xav@android.com>
Tue, 4 Oct 2011 20:32:24 +0000 (13:32 -0700)
committerXavier Ducrohet <xav@android.com>
Tue, 4 Oct 2011 22:55:55 +0000 (15:55 -0700)
Make source.prop more important than build.prop when parsing platforms.

Change-Id: I126d4ed06fd1aa5125add58c17c3cebc4ec6b780

files/devices.xml
sdkmanager/libs/sdklib/src/com/android/sdklib/SdkManager.java

index 6dc0a3f..9b90578 100644 (file)
         </d:config>
     </d:device>
 
+    <d:device name="4.7in WXGA">
+        <d:default>
+            <d:screen-size>normal</d:screen-size>
+            <d:screen-ratio>long</d:screen-ratio>
+            <d:screen-orientation>port</d:screen-orientation>
+            <d:pixel-density>xhdpi</d:pixel-density>
+            <d:touch-type>finger</d:touch-type>
+            <d:keyboard-state>keyssoft</d:keyboard-state>
+            <d:text-input-method>nokeys</d:text-input-method>
+            <d:nav-state>navexposed</d:nav-state>
+            <d:nav-method>nonav</d:nav-method>
+            <d:screen-dimension>
+                <d:size>1280</d:size>
+                <d:size>720</d:size>
+            </d:screen-dimension>
+            <d:xdpi>320</d:xdpi>
+            <d:ydpi>320</d:ydpi>
+        </d:default>
+
+        <d:config name="Portrait">
+            <d:screen-orientation>port</d:screen-orientation>
+        </d:config>
+        <d:config name="Landscape">
+            <d:screen-orientation>land</d:screen-orientation>
+        </d:config>
+    </d:device>
+
     <d:device name="5.1in WVGA">
         <d:default>
             <d:screen-size>large</d:screen-size>
index 8b54ccd..6decab0 100644 (file)
@@ -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<String, String> platformProp = new HashMap<String, String>();
+
+            // add all the property files
             Map<String, String> 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<String, String> 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<String, String> 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(),