aboutsummaryrefslogtreecommitdiffstats
path: root/sdkmanager/libs
diff options
context:
space:
mode:
authorRaphael <raphael@google.com>2012-03-06 18:34:50 -0800
committerRaphael <raphael@google.com>2012-03-06 18:41:13 -0800
commit53965f3f406f5a142b71753a4623a4d363795527 (patch)
tree425c8356d0f5b9a4b3fb61bfc5a51d5b75defdfc /sdkmanager/libs
parent8fca561846794680e582b2c1416ebda030a90f1a (diff)
downloadsdk-53965f3f406f5a142b71753a4623a4d363795527.zip
sdk-53965f3f406f5a142b71753a4623a4d363795527.tar.gz
sdk-53965f3f406f5a142b71753a4623a4d363795527.tar.bz2
SDK Manager: support platform previews.
This allows the SDK Manager to create a group for platform previews (api + codename) which is separate from the api it overrides. There's a latent issue with the fact that addons do not support codenames. This should only happen on nightly builds and not on officially released platforms though. Change-Id: Ic5095ece6ad9c978274801598aa1dc29c60974d8
Diffstat (limited to 'sdkmanager/libs')
-rwxr-xr-xsdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/sdkman2/PackagesDiffLogic.java33
-rwxr-xr-xsdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/sdkman2/PkgCategoryApi.java32
2 files changed, 36 insertions, 29 deletions
diff --git a/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/sdkman2/PackagesDiffLogic.java b/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/sdkman2/PackagesDiffLogic.java
index 944dffb..3d7cdb0 100755
--- a/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/sdkman2/PackagesDiffLogic.java
+++ b/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/sdkman2/PackagesDiffLogic.java
@@ -16,6 +16,7 @@
package com.android.sdkuilib.internal.repository.sdkman2;
+import com.android.sdklib.AndroidVersion;
import com.android.sdklib.IAndroidTarget;
import com.android.sdklib.SdkConstants;
import com.android.sdklib.internal.repository.ExtraPackage;
@@ -609,7 +610,7 @@ class PackagesDiffLogic {
// Sort by API
if (pkg instanceof IPackageVersion) {
- return ((IPackageVersion) pkg).getVersion().getApiLevel();
+ return ((IPackageVersion) pkg).getVersion();
} else if (pkg instanceof ToolPackage || pkg instanceof PlatformToolPackage) {
return PkgCategoryApi.KEY_TOOLS;
@@ -663,8 +664,11 @@ class PackagesDiffLogic {
// Create API category.
PkgCategory cat = null;
- assert catKey instanceof Integer;
- int apiKey = ((Integer) catKey).intValue();
+ assert catKey instanceof AndroidVersion;
+ AndroidVersion key = (AndroidVersion) catKey;
+
+ // We should not be trying to recreate the tools or extra categories.
+ assert !key.equals(PkgCategoryApi.KEY_TOOLS) && !key.equals(PkgCategoryApi.KEY_EXTRA);
// We need a label for the category.
// If we have an API level, try to get the info from the SDK Manager.
@@ -672,19 +676,16 @@ class PackagesDiffLogic {
// locally in the SDK Manager), it's OK we'll try to find the first platform
// package available.
String platformName = null;
- if (apiKey >= 1 && apiKey != PkgCategoryApi.KEY_TOOLS) {
- for (IAndroidTarget target :
- mUpdaterData.getSdkManager().getTargets()) {
- if (target.isPlatform() &&
- target.getVersion().getApiLevel() == apiKey) {
- platformName = target.getVersionName();
- break;
- }
+ for (IAndroidTarget target :
+ mUpdaterData.getSdkManager().getTargets()) {
+ if (target.isPlatform() && key.equals(target.getVersion())) {
+ platformName = target.getVersionName();
+ break;
}
}
cat = new PkgCategoryApi(
- apiKey,
+ key,
platformName,
mUpdaterData.getImageFactory().getImageByName(PackagesPage.ICON_CAT_PLATFORM));
@@ -710,9 +711,11 @@ class PackagesDiffLogic {
public int compare(PkgCategory cat1, PkgCategory cat2) {
assert cat1 instanceof PkgCategoryApi;
assert cat2 instanceof PkgCategoryApi;
- int api1 = ((Integer) cat1.getKey()).intValue();
- int api2 = ((Integer) cat2.getKey()).intValue();
- return api2 - api1;
+ assert cat1.getKey() instanceof AndroidVersion;
+ assert cat2.getKey() instanceof AndroidVersion;
+ AndroidVersion v1 = (AndroidVersion) cat1.getKey();
+ AndroidVersion v2 = (AndroidVersion) cat2.getKey();
+ return v2.compareTo(v1);
}
});
}
diff --git a/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/sdkman2/PkgCategoryApi.java b/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/sdkman2/PkgCategoryApi.java
index 570883c..5bb4917 100755
--- a/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/sdkman2/PkgCategoryApi.java
+++ b/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/sdkman2/PkgCategoryApi.java
@@ -16,6 +16,8 @@
package com.android.sdkuilib.internal.repository.sdkman2;
+import com.android.sdklib.AndroidVersion;
+
class PkgCategoryApi extends PkgCategory {
@@ -23,15 +25,17 @@ class PkgCategoryApi extends PkgCategory {
private String mPlatformName;
// When sorting by Source, key is the hash of the source's name.
- // When storing by API, key is the API level (>=1). Tools and extra have the
- // special values so they get naturally sorted the way we want them.
- // (Note: don't use max to avoid integers wrapping in comparisons. We can
+ // When storing by API, key is the AndroidVersion (API level >=1 + optional codename).
+ // We always want categories in order tools..platforms..extras; to achieve that tools
+ // and extras have the special values so they get "naturally" sorted the way we want
+ // them.
+ // (Note: don't use integer.max to avoid integers wrapping in comparisons. We can
// revisit the day we get 2^30 platforms.)
- public final static int KEY_TOOLS = Integer.MAX_VALUE / 2;
- public final static int KEY_EXTRA = -1;
+ public final static AndroidVersion KEY_TOOLS = new AndroidVersion(Integer.MAX_VALUE / 2, null);;
+ public final static AndroidVersion KEY_EXTRA = new AndroidVersion(-1, null);
- public PkgCategoryApi(int apiKey, String platformName, Object iconRef) {
- super(apiKey, null /*label*/, iconRef);
+ public PkgCategoryApi(AndroidVersion version, String platformName, Object iconRef) {
+ super(version, null /*label*/, iconRef);
setPlatformName(platformName);
}
@@ -48,13 +52,13 @@ class PkgCategoryApi extends PkgCategory {
}
public String getApiLabel() {
- int api = ((Integer) getKey()).intValue();
- if (api == KEY_TOOLS) {
+ AndroidVersion key = (AndroidVersion) getKey();
+ if (key.equals(KEY_TOOLS)) {
return "TOOLS"; //$NON-NLS-1$ // for internal debug use only
- } else if (api == KEY_EXTRA) {
+ } else if (key.equals(KEY_EXTRA)) {
return "EXTRAS"; //$NON-NLS-1$ // for internal debug use only
} else {
- return String.format("API %1$d", getKey());
+ return key.toString();
}
}
@@ -62,11 +66,11 @@ class PkgCategoryApi extends PkgCategory {
public String getLabel() {
String label = super.getLabel();
if (label == null) {
- int key = ((Integer) getKey()).intValue();
+ AndroidVersion key = (AndroidVersion) getKey();
- if (key == KEY_TOOLS) {
+ if (key.equals(KEY_TOOLS)) {
label = "Tools";
- } else if (key == KEY_EXTRA) {
+ } else if (key.equals(KEY_EXTRA)) {
label = "Extras";
} else {
if (mPlatformName != null) {