SDK Updater: properly update/install doc.
This contains the following changes: - a new interface IPackageVersion for all Package classes that can provide an AndroidVersion getVersion(). - fixes the "update sdk" where the local repo has no doc by suggesting to install the most up-to-date doc. - fixes a bad cast in the UpdaterLogic. - normalizes the long descriptions but adding the revision if not present. - fixes an edge case when displaying the very long description of the docs package, i.e. need to indicate it is upgraded due to a version change. SDK BUG 2192352 Change-Id: I87eda018b450ca9973e4f3b55caef964c0b31480
This commit is contained in:
@@ -35,7 +35,7 @@ import java.util.Properties;
|
||||
/**
|
||||
* Represents an add-on XML node in an SDK repository.
|
||||
*/
|
||||
public class AddonPackage extends Package {
|
||||
public class AddonPackage extends Package implements IPackageVersion {
|
||||
|
||||
private static final String PROP_NAME = "Addon.Name"; //$NON-NLS-1$
|
||||
private static final String PROP_VENDOR = "Addon.Vendor"; //$NON-NLS-1$
|
||||
@@ -209,7 +209,11 @@ public class AddonPackage extends Package {
|
||||
s = getShortDescription();
|
||||
}
|
||||
|
||||
s += String.format(".\nRequires SDK Platform Android API %1$s.",
|
||||
if (s.indexOf("revision") == -1) {
|
||||
s += String.format("\nRevision %1$d", getRevision());
|
||||
}
|
||||
|
||||
s += String.format("\nRequires SDK Platform Android API %1$s",
|
||||
mVersion.getApiString());
|
||||
return s;
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ import java.util.Properties;
|
||||
/**
|
||||
* Represents a doc XML node in an SDK repository.
|
||||
*/
|
||||
public class DocPackage extends Package {
|
||||
public class DocPackage extends Package implements IPackageVersion {
|
||||
|
||||
private final AndroidVersion mVersion;
|
||||
|
||||
@@ -126,8 +126,8 @@ public class DocPackage extends Package {
|
||||
s = getShortDescription();
|
||||
}
|
||||
|
||||
if (!s.endsWith(".")) {
|
||||
s += ".";
|
||||
if (s.indexOf("revision") == -1) {
|
||||
s += String.format("\nRevision %1$d", getRevision());
|
||||
}
|
||||
|
||||
return s;
|
||||
|
||||
@@ -165,13 +165,15 @@ public class ExtraPackage extends MinToolsPackage {
|
||||
public String getLongDescription() {
|
||||
String s = getDescription();
|
||||
if (s == null || s.length() == 0) {
|
||||
s = String.format("Extra %1$s package, revision %2$d",
|
||||
getPath(),
|
||||
getRevision());
|
||||
s = String.format("Extra %1$s package", getPath());
|
||||
}
|
||||
|
||||
if (s.indexOf("revision") == -1) {
|
||||
s += String.format("\nRevision %1$d", getRevision());
|
||||
}
|
||||
|
||||
if (getMinToolsRevision() != MIN_TOOLS_REV_NOT_SPECIFIED) {
|
||||
s += String.format(".\nRequires tools revision %1$d.", getMinToolsRevision());
|
||||
s += String.format("\nRequires tools revision %1$d", getMinToolsRevision());
|
||||
}
|
||||
|
||||
return s;
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright (C) 2009 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.sdklib.internal.repository;
|
||||
|
||||
import com.android.sdklib.AndroidVersion;
|
||||
|
||||
/**
|
||||
* Interface for packages that provide an {@link AndroidVersion}.
|
||||
*/
|
||||
public interface IPackageVersion {
|
||||
|
||||
/**
|
||||
* Returns the version, for platform, add-on and doc packages.
|
||||
* Can be 0 if this is a local package of unknown api-level.
|
||||
*/
|
||||
public abstract AndroidVersion getVersion();
|
||||
}
|
||||
@@ -33,7 +33,7 @@ import java.util.Properties;
|
||||
/**
|
||||
* Represents a platform XML node in an SDK repository.
|
||||
*/
|
||||
public class PlatformPackage extends MinToolsPackage {
|
||||
public class PlatformPackage extends MinToolsPackage implements IPackageVersion {
|
||||
|
||||
protected static final String PROP_VERSION = "Platform.Version"; //$NON-NLS-1$
|
||||
|
||||
@@ -145,8 +145,8 @@ public class PlatformPackage extends MinToolsPackage {
|
||||
s = getShortDescription();
|
||||
}
|
||||
|
||||
if (!s.endsWith(".")) {
|
||||
s += ".";
|
||||
if (s.indexOf("revision") == -1) {
|
||||
s += String.format("\nRevision %1$d", getRevision());
|
||||
}
|
||||
|
||||
return s;
|
||||
|
||||
@@ -78,7 +78,16 @@ public class ToolPackage extends Package {
|
||||
/** Returns a long description for an {@link IDescription}. */
|
||||
@Override
|
||||
public String getLongDescription() {
|
||||
return getShortDescription() + ".";
|
||||
String s = getDescription();
|
||||
if (s == null || s.length() == 0) {
|
||||
s = getShortDescription();
|
||||
}
|
||||
|
||||
if (s.indexOf("revision") == -1) {
|
||||
s += String.format("\nRevision %1$d", getRevision());
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user