diff --git a/tools/sdkmanager/app/src/com/android/sdkmanager/Main.java b/tools/sdkmanager/app/src/com/android/sdkmanager/Main.java index 26af49824..1836d330b 100644 --- a/tools/sdkmanager/app/src/com/android/sdkmanager/Main.java +++ b/tools/sdkmanager/app/src/com/android/sdkmanager/Main.java @@ -386,9 +386,11 @@ class Main { if (target.isPlatform()) { mSdkLog.printf(" Type: Platform\n"); mSdkLog.printf(" API level: %d\n", target.getApiVersionNumber()); + mSdkLog.printf(" Revision: %d\n", target.getRevision()); } else { mSdkLog.printf(" Type: Add-On\n"); mSdkLog.printf(" Vendor: %s\n", target.getVendor()); + mSdkLog.printf(" Revision: %d\n", target.getRevision()); if (target.getDescription() != null) { mSdkLog.printf(" Description: %s\n", target.getDescription()); } diff --git a/tools/sdkmanager/libs/sdklib/src/com/android/sdklib/AddOnTarget.java b/tools/sdkmanager/libs/sdklib/src/com/android/sdklib/AddOnTarget.java index c02c2478a..3ac0d1acd 100644 --- a/tools/sdkmanager/libs/sdklib/src/com/android/sdklib/AddOnTarget.java +++ b/tools/sdkmanager/libs/sdklib/src/com/android/sdklib/AddOnTarget.java @@ -68,6 +68,7 @@ final class AddOnTarget implements IAndroidTarget { private final PlatformTarget mBasePlatform; private final String mName; private final String mVendor; + private final int mRevision; private final String mDescription; private String[] mSkins; private String mDefaultSkin; @@ -79,12 +80,13 @@ final class AddOnTarget implements IAndroidTarget { * @param location the OS path location of the add-on * @param name the name of the add-on * @param vendor the vendor name of the add-on + * @param revision the revision of the add-on * @param description the add-on description * @param libMap A map containing the optional libraries. The map key is the fully-qualified * library name. The value is a 2 string array with the .jar filename, and the description. * @param basePlatform the platform the add-on is extending. */ - AddOnTarget(String location, String name, String vendor, String description, + AddOnTarget(String location, String name, String vendor, int revision, String description, Map libMap, PlatformTarget basePlatform) { if (location.endsWith(File.separator) == false) { location = location + File.separator; @@ -93,6 +95,7 @@ final class AddOnTarget implements IAndroidTarget { mLocation = location; mName = name; mVendor = vendor; + mRevision = revision; mDescription = description; mBasePlatform = basePlatform; @@ -144,6 +147,10 @@ final class AddOnTarget implements IAndroidTarget { return mBasePlatform.getApiVersionNumber(); } + public int getRevision() { + return mRevision; + } + public boolean isPlatform() { return false; } diff --git a/tools/sdkmanager/libs/sdklib/src/com/android/sdklib/IAndroidTarget.java b/tools/sdkmanager/libs/sdklib/src/com/android/sdklib/IAndroidTarget.java index d98834029..f64b7ead5 100644 --- a/tools/sdkmanager/libs/sdklib/src/com/android/sdklib/IAndroidTarget.java +++ b/tools/sdkmanager/libs/sdklib/src/com/android/sdklib/IAndroidTarget.java @@ -76,10 +76,15 @@ public interface IAndroidTarget extends Comparable { */ public final static int NO_USB_ID = 0; + /** An optional library provided by an Android Target */ public interface IOptionalLibrary { + /** The name of the library, as used in the manifest (<uses-library>). */ String getName(); + /** The file name of the jar file. */ String getJarName(); + /** Absolute OS path to the jar file. */ String getJarPath(); + /** Description of the library. */ String getDescription(); } @@ -123,6 +128,9 @@ public interface IAndroidTarget extends Comparable { */ String getApiVersionName(); + /** Returns the revision number for the target. */ + int getRevision(); + /** * Returns true if the target is a standard Android platform. */ diff --git a/tools/sdkmanager/libs/sdklib/src/com/android/sdklib/PlatformTarget.java b/tools/sdkmanager/libs/sdklib/src/com/android/sdklib/PlatformTarget.java index bbb3cd7c0..ae621f3b8 100644 --- a/tools/sdkmanager/libs/sdklib/src/com/android/sdklib/PlatformTarget.java +++ b/tools/sdkmanager/libs/sdklib/src/com/android/sdklib/PlatformTarget.java @@ -35,12 +35,13 @@ final class PlatformTarget implements IAndroidTarget { private final String mName; private final int mApiVersionNumber; private final String mApiVersionName; + private final int mRevision; private final Map mProperties; private final Map mPaths = new HashMap(); private String[] mSkins; PlatformTarget(String location, Map properties, - int apiNumber, String apiName) { + int apiNumber, String apiName, int revision) { mName = String.format(PLATFORM_NAME, apiName); if (location.endsWith(File.separator) == false) { location = location + File.separator; @@ -49,6 +50,7 @@ final class PlatformTarget implements IAndroidTarget { mProperties = Collections.unmodifiableMap(properties); mApiVersionNumber = apiNumber; mApiVersionName = apiName; + mRevision = revision; // pre-build the path to the platform components mPaths.put(ANDROID_JAR, mLocation + SdkConstants.FN_FRAMEWORK_LIBRARY); @@ -128,6 +130,10 @@ final class PlatformTarget implements IAndroidTarget { return mApiVersionName; } + public int getRevision() { + return mRevision; + } + public boolean isPlatform() { return true; } diff --git a/tools/sdkmanager/libs/sdklib/src/com/android/sdklib/SdkManager.java b/tools/sdkmanager/libs/sdklib/src/com/android/sdklib/SdkManager.java index ebafa7766..7a0b06ba9 100644 --- a/tools/sdkmanager/libs/sdklib/src/com/android/sdklib/SdkManager.java +++ b/tools/sdkmanager/libs/sdklib/src/com/android/sdklib/SdkManager.java @@ -43,6 +43,7 @@ public final class SdkManager { public final static String PROP_VERSION_SDK = "ro.build.version.sdk"; public final static String PROP_VERSION_RELEASE = "ro.build.version.release"; + public final static String PROP_VERSION_REVISION = "ro.build.version.incremental"; private final static String ADDON_NAME = "name"; private final static String ADDON_VENDOR = "vendor"; @@ -51,6 +52,8 @@ public final class SdkManager { private final static String ADDON_LIBRARIES = "libraries"; private final static String ADDON_DEFAULT_SKIN = "skin"; private final static String ADDON_USB_VENDOR = "usb-vendor"; + private final static String ADDON_REVISION = "revision"; + private final static String ADDON_REVISION_OLD = "version"; private final static Pattern PATTERN_PROP = Pattern.compile( "^([a-zA-Z0-9._-]+)\\s*=\\s*(.*)\\s*$"); @@ -58,6 +61,9 @@ public final class SdkManager { private final static Pattern PATTERN_LIB_DATA = Pattern.compile( "^([a-zA-Z0-9._-]+\\.jar);(.*)$", Pattern.CASE_INSENSITIVE); + private final static Pattern PATTERN_LOCAL_BUILD_PATTERN = Pattern.compile( + "^\\S+\\.\\S+\\.(\\d+)\\.\\d+$"); + // usb ids are 16-bit hexadecimal values. private final static Pattern PATTERN_USB_IDS = Pattern.compile( "^0x[a-f0-9]{4}$", Pattern.CASE_INSENSITIVE); @@ -234,36 +240,97 @@ public final class SdkManager { if (map != null) { // look for some specific values in the map. - try { - String apiNumber = map.get(PROP_VERSION_SDK); - String apiName = map.get(PROP_VERSION_RELEASE); - if (apiNumber != null && apiName != null) { - // api number and name looks valid, perform a few more checks - if (checkPlatformContent(platform, log) == false) { - return null; - } - // create the target. - PlatformTarget target = new PlatformTarget( - platform.getAbsolutePath(), - map, - Integer.parseInt(apiNumber), - apiName); - - // need to parse the skins. - String[] skins = parseSkinFolder(target.getPath(IAndroidTarget.SKINS)); - target.setSkins(skins); - - return target; - } - } catch (NumberFormatException e) { - // looks like apiNumber does not parse to a number. - // Ignore this platform. + String apiName = map.get(PROP_VERSION_RELEASE); + if (apiName == null) { if (log != null) { log.error(null, - "Ignoring platform '%1$s': %2$s is not a valid number in %3$s.", + "Ignoring platform '%1$s': %2$s is missing from '%3$s'", + platform.getName(), PROP_VERSION_RELEASE, SdkConstants.FN_BUILD_PROP); + } + return null; + } + + int apiNumber; + String stringValue = map.get(PROP_VERSION_SDK); + if (stringValue == null) { + if (log != null) { + log.error(null, + "Ignoring platform '%1$s': %2$s is missing from '%3$s'", platform.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. + if (log != null) { + log.error(null, + "Ignoring platform '%1$s': %2$s is not a valid number in %3$s.", + platform.getName(), PROP_VERSION_SDK, SdkConstants.FN_BUILD_PROP); + } + return null; + } } + + int revision = 1; + stringValue = map.get(PROP_VERSION_REVISION); + if (stringValue == null) { + if (log != null) { + log.error(null, + "Ignoring platform '%1$s': %2$s is missing from '%3$s'", + platform.getName(), PROP_VERSION_REVISION, SdkConstants.FN_BUILD_PROP); + } + return null; + } else { + try { + revision = Integer.parseInt(stringValue); + } catch (NumberFormatException e) { + // looks like the revision does not parse to a number. + // we look if it's a local build in the format + // ...