Merge change 8064 into donut
* changes: Generalize usage of AndroidVersion instead of Api level in the SDK packages.
This commit is contained in:
@@ -45,13 +45,29 @@ public class AndroidVersion {
|
|||||||
private final int mApiLevel;
|
private final int mApiLevel;
|
||||||
private final String mCodename;
|
private final String mCodename;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates an {@link AndroidVersion} with the given api level and codename.
|
||||||
|
*/
|
||||||
public AndroidVersion(int apiLevel, String codename) {
|
public AndroidVersion(int apiLevel, String codename) {
|
||||||
mApiLevel = apiLevel;
|
mApiLevel = apiLevel;
|
||||||
mCodename = codename;
|
mCodename = codename;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AndroidVersion(Properties properties) {
|
/**
|
||||||
throw new UnsupportedOperationException("TODO");
|
* Creates an {@link AndroidVersion} from {@link Properties}, with default values if the
|
||||||
|
* {@link Properties} object doesn't contain the expected values.
|
||||||
|
* <p/>The {@link Properties} is expected to have been filled with
|
||||||
|
* {@link #saveProperties(Properties)}.
|
||||||
|
*/
|
||||||
|
public AndroidVersion(Properties properties, int defaultApiLevel, String defaultCodeName) {
|
||||||
|
if (properties == null) {
|
||||||
|
mApiLevel = defaultApiLevel;
|
||||||
|
mCodename = defaultCodeName;
|
||||||
|
} else {
|
||||||
|
mApiLevel = Integer.parseInt(properties.getProperty(PROP_API_LEVEL,
|
||||||
|
Integer.toString(defaultApiLevel)));
|
||||||
|
mCodename = properties.getProperty(PROP_CODENAME, defaultCodeName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void saveProperties(Properties props) {
|
public void saveProperties(Properties props) {
|
||||||
|
|||||||
@@ -168,10 +168,9 @@ public class AddonPackage extends Package {
|
|||||||
return mName;
|
return mName;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns the api-level, an int > 0, for platform, add-on and doc packages. */
|
/** Returns the version, for platform, add-on and doc packages. */
|
||||||
public int getApiLevel() {
|
public AndroidVersion getVersion() {
|
||||||
// FIXME: return the AndroidVersion instead.
|
return mVersion;
|
||||||
return mVersion.getApiLevel();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns the libs defined in this add-on. Can be an empty array but not null. */
|
/** Returns the libs defined in this add-on. Can be an empty array but not null. */
|
||||||
@@ -185,7 +184,7 @@ public class AddonPackage extends Package {
|
|||||||
return String.format("%1$s by %2$s for Android API %3$d",
|
return String.format("%1$s by %2$s for Android API %3$d",
|
||||||
getName(),
|
getName(),
|
||||||
getVendor(),
|
getVendor(),
|
||||||
getApiLevel());
|
mVersion.getApiLevel());
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns a long description for an {@link IDescription}. */
|
/** Returns a long description for an {@link IDescription}. */
|
||||||
@@ -230,7 +229,7 @@ public class AddonPackage extends Package {
|
|||||||
String name = suggestedDir;
|
String name = suggestedDir;
|
||||||
|
|
||||||
if (suggestedDir == null || suggestedDir.length() == 0) {
|
if (suggestedDir == null || suggestedDir.length() == 0) {
|
||||||
name = String.format("addon-%s-%s-%d", getName(), getVendor(), getApiLevel()); //$NON-NLS-1$
|
name = String.format("addon-%s-%s-%d", getName(), getVendor(), mVersion.getApiLevel()); //$NON-NLS-1$
|
||||||
name = name.toLowerCase();
|
name = name.toLowerCase();
|
||||||
name = name.replaceAll("[^a-z0-9_-]+", "_"); //$NON-NLS-1$ //$NON-NLS-2$
|
name = name.replaceAll("[^a-z0-9_-]+", "_"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
name = name.replaceAll("_+", "_"); //$NON-NLS-1$ //$NON-NLS-2$
|
name = name.replaceAll("_+", "_"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
@@ -272,6 +271,7 @@ public class AddonPackage extends Package {
|
|||||||
String newId = newPkg.getName() + "+" + newPkg.getVendor(); //$NON-NLS-1$
|
String newId = newPkg.getName() + "+" + newPkg.getVendor(); //$NON-NLS-1$
|
||||||
|
|
||||||
return thisId.equalsIgnoreCase(newId) &&
|
return thisId.equalsIgnoreCase(newId) &&
|
||||||
newPkg.getRevision() > this.getRevision();
|
mVersion.getApiLevel() == newPkg.getVersion().getApiLevel() &&
|
||||||
|
newPkg.getRevision() > this.getRevision();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package com.android.sdklib.internal.repository;
|
package com.android.sdklib.internal.repository;
|
||||||
|
|
||||||
|
import com.android.sdklib.AndroidVersion;
|
||||||
import com.android.sdklib.SdkConstants;
|
import com.android.sdklib.SdkConstants;
|
||||||
import com.android.sdklib.SdkManager;
|
import com.android.sdklib.SdkManager;
|
||||||
import com.android.sdklib.internal.repository.Archive.Arch;
|
import com.android.sdklib.internal.repository.Archive.Arch;
|
||||||
@@ -33,9 +34,7 @@ import java.util.Properties;
|
|||||||
*/
|
*/
|
||||||
public class DocPackage extends Package {
|
public class DocPackage extends Package {
|
||||||
|
|
||||||
private static final String PROP_API_LEVEL = "Doc.ApiLevel"; //$NON-NLS-1$
|
private final AndroidVersion mVersion;
|
||||||
|
|
||||||
private final int mApiLevel;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new doc package from the attributes and elements of the given XML node.
|
* Creates a new doc package from the attributes and elements of the given XML node.
|
||||||
@@ -44,7 +43,13 @@ public class DocPackage extends Package {
|
|||||||
*/
|
*/
|
||||||
DocPackage(RepoSource source, Node packageNode, Map<String,String> licenses) {
|
DocPackage(RepoSource source, Node packageNode, Map<String,String> licenses) {
|
||||||
super(source, packageNode, licenses);
|
super(source, packageNode, licenses);
|
||||||
mApiLevel = XmlParserUtils.getXmlInt(packageNode, SdkRepository.NODE_API_LEVEL, 0);
|
|
||||||
|
int apiLevel = XmlParserUtils.getXmlInt (packageNode, SdkRepository.NODE_API_LEVEL, 0);
|
||||||
|
String codeName = XmlParserUtils.getXmlString(packageNode, SdkRepository.NODE_CODENAME);
|
||||||
|
if (codeName.length() == 0) {
|
||||||
|
codeName = null;
|
||||||
|
}
|
||||||
|
mVersion = new AndroidVersion(apiLevel, codeName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -55,6 +60,7 @@ public class DocPackage extends Package {
|
|||||||
DocPackage(RepoSource source,
|
DocPackage(RepoSource source,
|
||||||
Properties props,
|
Properties props,
|
||||||
int apiLevel,
|
int apiLevel,
|
||||||
|
String codename,
|
||||||
int revision,
|
int revision,
|
||||||
String license,
|
String license,
|
||||||
String description,
|
String description,
|
||||||
@@ -71,8 +77,7 @@ public class DocPackage extends Package {
|
|||||||
archiveOs,
|
archiveOs,
|
||||||
archiveArch,
|
archiveArch,
|
||||||
archiveOsPath);
|
archiveOsPath);
|
||||||
mApiLevel = Integer.parseInt(
|
mVersion = new AndroidVersion(props, apiLevel, codename);
|
||||||
getProperty(props, PROP_API_LEVEL, Integer.toString(apiLevel)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -83,20 +88,23 @@ public class DocPackage extends Package {
|
|||||||
void saveProperties(Properties props) {
|
void saveProperties(Properties props) {
|
||||||
super.saveProperties(props);
|
super.saveProperties(props);
|
||||||
|
|
||||||
props.setProperty(PROP_API_LEVEL, Integer.toString(mApiLevel));
|
mVersion.saveProperties(props);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns the api-level, an int > 0, for platform, add-on and doc packages.
|
/** Returns the version, for platform, add-on and doc packages.
|
||||||
* Can be 0 if this is a local package of unknown api-level. */
|
* Can be 0 if this is a local package of unknown api-level. */
|
||||||
public int getApiLevel() {
|
public AndroidVersion getVersion() {
|
||||||
return mApiLevel;
|
return mVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns a short description for an {@link IDescription}. */
|
/** Returns a short description for an {@link IDescription}. */
|
||||||
@Override
|
@Override
|
||||||
public String getShortDescription() {
|
public String getShortDescription() {
|
||||||
if (mApiLevel != 0) {
|
if (mVersion.isPreview()) {
|
||||||
return String.format("Documentation for Android SDK, API %1$d", mApiLevel);
|
return String.format("Documentation for Android '%1$s' Preview SDK",
|
||||||
|
mVersion.getCodename());
|
||||||
|
} else if (mVersion.getApiLevel() != 0) {
|
||||||
|
return String.format("Documentation for Android SDK, API %1$d", mVersion.getApiLevel());
|
||||||
} else {
|
} else {
|
||||||
return String.format("Documentation for Android SDK");
|
return String.format("Documentation for Android SDK");
|
||||||
}
|
}
|
||||||
@@ -147,6 +155,6 @@ public class DocPackage extends Package {
|
|||||||
|
|
||||||
DocPackage newPkg = (DocPackage) replacementPackage;
|
DocPackage newPkg = (DocPackage) replacementPackage;
|
||||||
return newPkg.getRevision() > this.getRevision() &&
|
return newPkg.getRevision() > this.getRevision() &&
|
||||||
newPkg.getApiLevel() >= this.getApiLevel();
|
newPkg.getVersion().equals(this.getVersion());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -212,6 +212,7 @@ public class LocalSdkParser {
|
|||||||
null, //source
|
null, //source
|
||||||
props, //properties
|
props, //properties
|
||||||
0, //apiLevel
|
0, //apiLevel
|
||||||
|
null, // codename
|
||||||
0, //revision
|
0, //revision
|
||||||
null, //license
|
null, //license
|
||||||
null, //description
|
null, //description
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ public class PlatformPackage extends Package {
|
|||||||
super(source, packageNode, licenses);
|
super(source, packageNode, licenses);
|
||||||
mVersionName = XmlParserUtils.getXmlString(packageNode, SdkRepository.NODE_VERSION);
|
mVersionName = XmlParserUtils.getXmlString(packageNode, SdkRepository.NODE_VERSION);
|
||||||
int apiLevel = XmlParserUtils.getXmlInt (packageNode, SdkRepository.NODE_API_LEVEL, 0);
|
int apiLevel = XmlParserUtils.getXmlInt (packageNode, SdkRepository.NODE_API_LEVEL, 0);
|
||||||
String codeName = XmlParserUtils.getXmlString(packageNode, SdkRepository.NODE_API_CODENAME);
|
String codeName = XmlParserUtils.getXmlString(packageNode, SdkRepository.NODE_CODENAME);
|
||||||
if (codeName.length() == 0) {
|
if (codeName.length() == 0) {
|
||||||
codeName = null;
|
codeName = null;
|
||||||
}
|
}
|
||||||
@@ -95,10 +95,9 @@ public class PlatformPackage extends Package {
|
|||||||
return mVersionName;
|
return mVersionName;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns the api-level, an int > 0, for platform, add-on and doc packages. */
|
/** Returns the package version, for platform, add-on and doc packages. */
|
||||||
public int getApiLevel() {
|
public AndroidVersion getVersion() {
|
||||||
// FIXME: return the AndroidVersion instead.
|
return mVersion;
|
||||||
return mVersion.getApiLevel();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns a short description for an {@link IDescription}. */
|
/** Returns a short description for an {@link IDescription}. */
|
||||||
@@ -111,7 +110,7 @@ public class PlatformPackage extends Package {
|
|||||||
|
|
||||||
return String.format("SDK Platform Android %1$s, API %2$d",
|
return String.format("SDK Platform Android %1$s, API %2$d",
|
||||||
getVersionName(),
|
getVersionName(),
|
||||||
getApiLevel());
|
mVersion.getApiLevel());
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns a long description for an {@link IDescription}. */
|
/** Returns a long description for an {@link IDescription}. */
|
||||||
@@ -174,7 +173,7 @@ public class PlatformPackage extends Package {
|
|||||||
|
|
||||||
PlatformPackage newPkg = (PlatformPackage) replacementPackage;
|
PlatformPackage newPkg = (PlatformPackage) replacementPackage;
|
||||||
return newPkg.getVersionName().equalsIgnoreCase(this.getVersionName()) &&
|
return newPkg.getVersionName().equalsIgnoreCase(this.getVersionName()) &&
|
||||||
newPkg.getApiLevel() == this.getApiLevel() &&
|
newPkg.getVersion().equals(this.getVersion()) &&
|
||||||
newPkg.getRevision() > this.getRevision();
|
newPkg.getRevision() > this.getRevision();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,8 +63,8 @@ public class SdkRepository {
|
|||||||
public static final String NODE_VERSION = "version"; //$NON-NLS-1$
|
public static final String NODE_VERSION = "version"; //$NON-NLS-1$
|
||||||
/** The api-level, an int > 0, for platform, add-on and doc packages. */
|
/** The api-level, an int > 0, for platform, add-on and doc packages. */
|
||||||
public static final String NODE_API_LEVEL = "api-level"; //$NON-NLS-1$
|
public static final String NODE_API_LEVEL = "api-level"; //$NON-NLS-1$
|
||||||
/** The api-codename, a string, for platform packages. */
|
/** The codename, a string, for platform packages. */
|
||||||
public static final String NODE_API_CODENAME = "api-codename"; //$NON-NLS-1$
|
public static final String NODE_CODENAME = "codename"; //$NON-NLS-1$
|
||||||
/** The vendor, a string, for add-on packages. */
|
/** The vendor, a string, for add-on packages. */
|
||||||
public static final String NODE_VENDOR = "vendor"; //$NON-NLS-1$
|
public static final String NODE_VENDOR = "vendor"; //$NON-NLS-1$
|
||||||
/** The name, a string, for add-on packages or for libraries. */
|
/** The name, a string, for add-on packages or for libraries. */
|
||||||
|
|||||||
@@ -53,7 +53,7 @@
|
|||||||
<!-- The Android API Level for the platform. An int > 0. -->
|
<!-- The Android API Level for the platform. An int > 0. -->
|
||||||
<xsd:element name="api-level" type="xsd:positiveInteger" />
|
<xsd:element name="api-level" type="xsd:positiveInteger" />
|
||||||
<!-- The optional codename for this platform, if it's a preview. -->
|
<!-- The optional codename for this platform, if it's a preview. -->
|
||||||
<xsd:element name="api-codename" type="xsd:string" minOccurs="0" />
|
<xsd:element name="codename" type="xsd:string" minOccurs="0" />
|
||||||
|
|
||||||
<!-- The revision, an int > 0, incremented each time a new
|
<!-- The revision, an int > 0, incremented each time a new
|
||||||
package is generated. -->
|
package is generated. -->
|
||||||
@@ -158,6 +158,8 @@
|
|||||||
<xsd:all>
|
<xsd:all>
|
||||||
<!-- The Android API Level for the documentation. An int > 0. -->
|
<!-- The Android API Level for the documentation. An int > 0. -->
|
||||||
<xsd:element name="api-level" type="xsd:positiveInteger" />
|
<xsd:element name="api-level" type="xsd:positiveInteger" />
|
||||||
|
<!-- The optional codename for this doc, if it's a preview. -->
|
||||||
|
<xsd:element name="codename" type="xsd:string" minOccurs="0" />
|
||||||
|
|
||||||
<!-- The revision, an int > 0, incremented each time a new
|
<!-- The revision, an int > 0, incremented each time a new
|
||||||
package is generated. -->
|
package is generated. -->
|
||||||
|
|||||||
@@ -16,8 +16,6 @@
|
|||||||
|
|
||||||
package com.android.sdklib.repository;
|
package com.android.sdklib.repository;
|
||||||
|
|
||||||
import com.android.sdklib.SdkConstants;
|
|
||||||
|
|
||||||
import org.xml.sax.ErrorHandler;
|
import org.xml.sax.ErrorHandler;
|
||||||
import org.xml.sax.SAXException;
|
import org.xml.sax.SAXException;
|
||||||
import org.xml.sax.SAXParseException;
|
import org.xml.sax.SAXParseException;
|
||||||
|
|||||||
@@ -160,7 +160,7 @@
|
|||||||
<sdk:platform>
|
<sdk:platform>
|
||||||
<sdk:version>Pastry</sdk:version>
|
<sdk:version>Pastry</sdk:version>
|
||||||
<sdk:api-level>5</sdk:api-level>
|
<sdk:api-level>5</sdk:api-level>
|
||||||
<sdk:api-codename>Pastry</sdk:api-codename>
|
<sdk:codename>Pastry</sdk:codename>
|
||||||
<sdk:revision>3</sdk:revision>
|
<sdk:revision>3</sdk:revision>
|
||||||
<sdk:uses-license ref="license1" />
|
<sdk:uses-license ref="license1" />
|
||||||
<sdk:description>Preview version for Pastry</sdk:description>
|
<sdk:description>Preview version for Pastry</sdk:description>
|
||||||
|
|||||||
@@ -785,7 +785,6 @@ public final class AvdSelector {
|
|||||||
mDetailsButton.setEnabled(hasSelection);
|
mDetailsButton.setEnabled(hasSelection);
|
||||||
mStartButton.setEnabled(mOsSdkPath != null &&
|
mStartButton.setEnabled(mOsSdkPath != null &&
|
||||||
hasSelection &&
|
hasSelection &&
|
||||||
selection != null &&
|
|
||||||
selection.getStatus() == AvdStatus.OK);
|
selection.getStatus() == AvdStatus.OK);
|
||||||
|
|
||||||
if (mDeleteButton != null) {
|
if (mDeleteButton != null) {
|
||||||
@@ -793,7 +792,6 @@ public final class AvdSelector {
|
|||||||
}
|
}
|
||||||
if (mUpdateButton != null) {
|
if (mUpdateButton != null) {
|
||||||
mUpdateButton.setEnabled(hasSelection &&
|
mUpdateButton.setEnabled(hasSelection &&
|
||||||
selection != null &&
|
|
||||||
selection.getStatus() == AvdStatus.ERROR_IMAGE_DIR);
|
selection.getStatus() == AvdStatus.ERROR_IMAGE_DIR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user