diff options
author | Joe Baker-Malone <jbakermalone@google.com> | 2015-04-24 18:18:51 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2015-04-24 18:18:51 +0000 |
commit | 84f1479a7922dfb29b41cab9b19bd911fcbafb3a (patch) | |
tree | 17fc28b7c70bee10d15ae14528e209bc13c46cd0 | |
parent | 32c217b674214ab88bfccf44eddc322348287868 (diff) | |
parent | 74b183055bcfb68741c1d20e8f67ed9f73bcdb03 (diff) | |
download | base-84f1479a7922dfb29b41cab9b19bd911fcbafb3a.tar.gz |
am 74b18305: Merge "Adding support for the more generic PreciseRevision" into studio-1.3-dev automerge: f969ed7 automerge: c88c16e
* commit '74b183055bcfb68741c1d20e8f67ed9f73bcdb03':
Adding support for the more generic PreciseRevision
3 files changed, 49 insertions, 15 deletions
diff --git a/sdklib/src/main/java/com/android/sdklib/repository/descriptors/IPkgDesc.java b/sdklib/src/main/java/com/android/sdklib/repository/descriptors/IPkgDesc.java index 86fdd72c85..afba8465bd 100755 --- a/sdklib/src/main/java/com/android/sdklib/repository/descriptors/IPkgDesc.java +++ b/sdklib/src/main/java/com/android/sdklib/repository/descriptors/IPkgDesc.java @@ -23,6 +23,7 @@ import com.android.sdklib.repository.IListDescription; import com.android.sdklib.repository.License; import com.android.sdklib.repository.FullRevision; import com.android.sdklib.repository.MajorRevision; +import com.android.sdklib.repository.PreciseRevision; import java.io.File; @@ -80,6 +81,15 @@ public interface IPkgDesc extends Comparable<IPkgDesc>, IPkgCapabilities, IListD MajorRevision getMajorRevision(); /** + * Returns the package's revision or null. This will come from the {@link FullRevision} or + * {@link MajorRevision}, with the precision set as appropriate. + * @return A non-null value if {@link #hasMajorRevision()} or {@link #hasFullRevision()} + * is true; otherwise a null value. + */ + @Nullable + PreciseRevision getPreciseRevision(); + + /** * Returns the package's {@link AndroidVersion} or null. * @return A non-null value if {@link #hasAndroidVersion()} is true; otherwise a null value. */ diff --git a/sdklib/src/main/java/com/android/sdklib/repository/descriptors/PkgDesc.java b/sdklib/src/main/java/com/android/sdklib/repository/descriptors/PkgDesc.java index 68324c48a8..3e905a80c1 100755 --- a/sdklib/src/main/java/com/android/sdklib/repository/descriptors/PkgDesc.java +++ b/sdklib/src/main/java/com/android/sdklib/repository/descriptors/PkgDesc.java @@ -29,6 +29,7 @@ import com.android.sdklib.repository.FullRevision; import com.android.sdklib.repository.FullRevision.PreviewComparison; import com.android.sdklib.repository.MajorRevision; import com.android.sdklib.repository.NoPreviewRevision; +import com.android.sdklib.repository.PreciseRevision; import java.io.File; import java.util.Locale; @@ -187,6 +188,16 @@ public class PkgDesc implements IPkgDesc { @Nullable @Override + public final PreciseRevision getPreciseRevision() { + if (mMajorRevision == null) { + return new PreciseRevision(mFullRevision.getMajor(), mFullRevision.getMinor(), + mFullRevision.getMicro(), mFullRevision.getPreview()); + } + return new PreciseRevision(mMajorRevision.getMajor()); + } + + @Nullable + @Override public AndroidVersion getAndroidVersion() { return mAndroidVersion; } @@ -274,7 +285,7 @@ public class PkgDesc implements IPkgDesc { case PKG_ADDON: sb.append("addon-") - .append(((IPkgDescAddon) this).getName().getId()) + .append(((IPkgDescAddon)this).getName().getId()) .append('-') .append(getVendor().getId()) .append('-') diff --git a/sdklib/src/main/java/com/android/sdklib/repository/local/LocalPkgInfo.java b/sdklib/src/main/java/com/android/sdklib/repository/local/LocalPkgInfo.java index e6332f8806..4bdc308887 100755 --- a/sdklib/src/main/java/com/android/sdklib/repository/local/LocalPkgInfo.java +++ b/sdklib/src/main/java/com/android/sdklib/repository/local/LocalPkgInfo.java @@ -20,6 +20,7 @@ import com.android.annotations.NonNull; import com.android.annotations.Nullable; import com.android.sdklib.repository.IDescription; import com.android.sdklib.repository.IListDescription; +import com.android.sdklib.io.FileOp; import com.android.sdklib.repository.descriptors.IPkgDesc; import java.io.File; @@ -42,9 +43,7 @@ public abstract class LocalPkgInfo private String mLoadError; - protected LocalPkgInfo(@NonNull LocalSdk localSdk, - @NonNull File localDir, - @NonNull Properties sourceProps) { + protected LocalPkgInfo(@NonNull LocalSdk localSdk, @NonNull File localDir, @NonNull Properties sourceProps) { mLocalSdk = localSdk; mLocalDir = localDir; mSourceProperties = sourceProps; @@ -74,7 +73,9 @@ public abstract class LocalPkgInfo // ---- - /** Returns the {@link IPkgDesc} describing this package. */ + /** + * Returns the {@link IPkgDesc} describing this package. + */ @NonNull public abstract IPkgDesc getDesc(); @@ -93,7 +94,9 @@ public abstract class LocalPkgInfo return getDesc().compareTo(o.getDesc()); } - /** String representation for debugging purposes. */ + /** + * String representation for debugging purposes. + */ @Override public String toString() { StringBuilder builder = new StringBuilder(); @@ -112,8 +115,8 @@ public abstract class LocalPkgInfo public int hashCode() { final int prime = 31; int result = 1; - result = prime * result + ((getDesc() == null) ? 0 : getDesc().hashCode()); - result = prime * result + ((mLocalDir == null) ? 0 : mLocalDir.hashCode()); + result = prime * result + ((getDesc() == null) ? 0 : getDesc().hashCode()); + result = prime * result + ((mLocalDir == null) ? 0 : mLocalDir.hashCode()); result = prime * result + ((mSourceProperties == null) ? 0 : mSourceProperties.hashCode()); return result; } @@ -136,7 +139,7 @@ public abstract class LocalPkgInfo if (!(obj instanceof LocalPkgInfo)) { return false; } - LocalPkgInfo other = (LocalPkgInfo) obj; + LocalPkgInfo other = (LocalPkgInfo)obj; if (!getDesc().equals(other.getDesc())) { return false; @@ -145,14 +148,16 @@ public abstract class LocalPkgInfo if (other.mLocalDir != null) { return false; } - } else if (!mLocalDir.equals(other.mLocalDir)) { + } + else if (!mLocalDir.equals(other.mLocalDir)) { return false; } if (mSourceProperties == null) { if (other.mSourceProperties != null) { return false; } - } else if (!mSourceProperties.equals(other.mSourceProperties)) { + } + else if (!mSourceProperties.equals(other.mSourceProperties)) { return false; } return true; @@ -161,8 +166,9 @@ public abstract class LocalPkgInfo //---- Package Management ---- - /** A "broken" package is installed but is not fully operational. - * + /** + * A "broken" package is installed but is not fully operational. + * <p/> * For example an addon that lacks its underlying platform or a tool package * that lacks some of its binaries or essentially files. * <p/> @@ -173,11 +179,12 @@ public abstract class LocalPkgInfo return mLoadError != null; } - void appendLoadError(@NonNull String format, Object...params) { + void appendLoadError(@NonNull String format, Object... params) { String loadError = String.format(format, params); if (mLoadError == null) { mLoadError = loadError; - } else { + } + else { mLoadError = mLoadError + '\n' + loadError; } } @@ -222,6 +229,12 @@ public abstract class LocalPkgInfo return sb.toString(); } + /** + * Deletes the files in the SDK corresponding to this package. + */ + public void delete() { + new FileOp().deleteFileOrFolder(getLocalDir()); + } } |