SDK Updater: update all existing local archives, license click through.

This commit is contained in:
Raphael
2009-06-13 22:42:31 -07:00
parent 31d55c618e
commit e073146af3
11 changed files with 788 additions and 50 deletions

View File

@@ -190,6 +190,9 @@ public class AddonPackage extends Package {
String name = String.format("%s-%d", getName(), getApiLevel()); // $NON-NLS-1$
// FIXME this will fail if the name is not ASCII compatible. This could easily
// happen: a Chinese or Japanese name etc for example,
// to name a few.
name = name.toLowerCase();
name = name.replaceAll("[^a-zA-Z0-9_-]+", "_"); // $NON-NLS-1$
name = name.replaceAll("_+", "_"); // $NON-NLS-1$
@@ -199,4 +202,26 @@ public class AddonPackage extends Package {
// TODO find similar existing addon in addons folder
return folder;
}
/**
* Computes whether the given addon package is a suitable update for the current package.
* The base method checks the class type.
* The addon package also tests that the name is the same and the revision number is greater.
* <p/>
* An update is just that: a new package that supersedes the current one. If the new
* package has the same revision as the current one, it's not an update.
*
* @param replacementPackage The potential replacement package.
* @return True if the replacement package is a suitable update for this one.
*/
@Override
public boolean canBeUpdatedBy(Package replacementPackage) {
if (!super.canBeUpdatedBy(replacementPackage)) {
return false;
}
AddonPackage newPkg = (AddonPackage) replacementPackage;
return newPkg.getName().equalsIgnoreCase(this.getName()) &&
newPkg.getRevision() > this.getRevision();
}
}

View File

@@ -104,4 +104,27 @@ public class DocPackage extends Package {
public File getInstallFolder(String osSdkRoot) {
return new File(osSdkRoot, SdkConstants.FD_DOCS);
}
/**
* Computes whether the given doc package is a suitable update for the current package.
* The base method checks the class type.
* The doc package also tests the API level and revision number: the revision number must
* always be bumped. The API level can be the same or greater.
* <p/>
* An update is just that: a new package that supersedes the current one. If the new
* package has the same revision as the current one, it's not an update.
*
* @param replacementPackage The potential replacement package.
* @return True if the replacement package is a suitable update for this one.
*/
@Override
public boolean canBeUpdatedBy(Package replacementPackage) {
if (!super.canBeUpdatedBy(replacementPackage)) {
return false;
}
DocPackage newPkg = (DocPackage) replacementPackage;
return newPkg.getRevision() > this.getRevision() &&
newPkg.getApiLevel() >= this.getApiLevel();
}
}

View File

@@ -202,6 +202,23 @@ public abstract class Package implements IDescription {
*/
public abstract File getInstallFolder(String osSdkRoot);
/**
* Computes whether the given package is a suitable update for the current package.
* The base class method only checks that the {@link Package} class type is the same.
* Derived classes must add more specific checks, including the revision number.
* <p/>
* An update is just that: a new package that supersedes the current one. If the new
* package has the same revision as the current one, it's not an update.
*
* @param replacementPackage The potential replacement package.
* @return True if the replacement package is a suitable update for this one.
*/
public boolean canBeUpdatedBy(Package replacementPackage) {
return replacementPackage != null &&
replacementPackage.getClass() == this.getClass() &&
replacementPackage.getRevision() > this.getRevision();
}
//---
/**

View File

@@ -111,4 +111,28 @@ public class PlatformPackage extends Package {
// TODO find similar existing platform in platforms folder
return folder;
}
/**
* Computes whether the given platform package is a suitable update for the current package.
* The base method checks the class type.
* The platform package also tests that the version and API level are the same and
* the revision number is greater
* <p/>
* An update is just that: a new package that supersedes the current one. If the new
* package has the same revision as the current one, it's not an update.
*
* @param replacementPackage The potential replacement package.
* @return True if the replacement package is a suitable update for this one.
*/
@Override
public boolean canBeUpdatedBy(Package replacementPackage) {
if (!super.canBeUpdatedBy(replacementPackage)) {
return false;
}
PlatformPackage newPkg = (PlatformPackage) replacementPackage;
return newPkg.getVersion().equalsIgnoreCase(this.getVersion()) &&
newPkg.getApiLevel() == this.getApiLevel() &&
newPkg.getRevision() > this.getRevision();
}
}

View File

@@ -28,10 +28,16 @@ public class RepoSources {
public RepoSources() {
}
/**
* Adds a new source to the Sources list.
*/
public void add(RepoSource source) {
mSources.add(source);
}
/**
* Returns the sources list array. This is never null.
*/
public ArrayList<RepoSource> getSources() {
return mSources;
}

View File

@@ -88,4 +88,25 @@ public class ToolPackage extends Package {
public File getInstallFolder(String osSdkRoot) {
return new File(osSdkRoot, SdkConstants.FD_TOOLS);
}
/**
* Computes whether the given tools package is a suitable update for the current package.
* The base method checks the class type.
* The tools package also tests that the revision number is greater.
* <p/>
* An update is just that: a new package that supersedes the current one. If the new
* package has the same revision as the current one, it's not an update.
*
* @param replacementPackage The potential replacement package.
* @return True if the replacement package is a suitable update for this one.
*/
@Override
public boolean canBeUpdatedBy(Package replacementPackage) {
if (!super.canBeUpdatedBy(replacementPackage)) {
return false;
}
ToolPackage newPkg = (ToolPackage) replacementPackage;
return newPkg.getRevision() > this.getRevision();
}
}