Merge change 20196 into donut
* changes:
Split AdbWinApi.dll into two dlls to remove dependency on WINUSB.DLL
diff --git a/tools/sdkmanager/app/etc/android.bat b/tools/sdkmanager/app/etc/android.bat
index b19ce0a..032985d 100755
--- a/tools/sdkmanager/app/etc/android.bat
+++ b/tools/sdkmanager/app/etc/android.bat
@@ -43,9 +43,10 @@
set tmpdir=%TEMP%\temp-android-tool
xcopy lib\x86 %tmpdir%\lib\x86 /I /E /C /G /R /O /Y /Q > nul
- copy /B /D /Y lib\androidprefs.jar %tmpdir%\lib\ > nul
- copy /B /D /Y lib\org.eclipse.* %tmpdir%\lib\ > nul
- copy /B /D /Y lib\sdk* %tmpdir%\lib\ > nul
+ copy /B /D /Y lib\androidprefs.jar %tmpdir%\lib\ > nul
+ copy /B /D /Y lib\org.eclipse.* %tmpdir%\lib\ > nul
+ copy /B /D /Y lib\sdk* %tmpdir%\lib\ > nul
+ copy /B /D /Y lib\commons-compress* %tmpdir%\lib\ > nul
rem jarpath and swt_path are relative to PWD so we don't need to adjust them, just change dirs.
set toolsdir=%cd%
diff --git a/tools/sdkmanager/libs/sdklib/src/com/android/sdklib/AndroidVersion.java b/tools/sdkmanager/libs/sdklib/src/com/android/sdklib/AndroidVersion.java
index 61b348a..ef62f6e 100644
--- a/tools/sdkmanager/libs/sdklib/src/com/android/sdklib/AndroidVersion.java
+++ b/tools/sdkmanager/libs/sdklib/src/com/android/sdklib/AndroidVersion.java
@@ -174,7 +174,7 @@
} else if (obj instanceof String) {
// if we have a code name, this must match.
if (mCodename != null) {
- return mCodename.equals((String)obj);
+ return mCodename.equals(obj);
}
// else we try to convert to a int and compare to the api level
diff --git a/tools/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/AddonPackage.java b/tools/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/AddonPackage.java
index 4a19206..3c7b8c6 100755
--- a/tools/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/AddonPackage.java
+++ b/tools/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/AddonPackage.java
@@ -126,8 +126,12 @@
super.saveProperties(props);
mVersion.saveProperties(props);
- props.setProperty(PROP_NAME, mName);
- props.setProperty(PROP_VENDOR, mVendor);
+ if (mName != null) {
+ props.setProperty(PROP_NAME, mName);
+ }
+ if (mVendor != null) {
+ props.setProperty(PROP_VENDOR, mVendor);
+ }
}
/**
diff --git a/tools/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/Archive.java b/tools/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/Archive.java
index 3757b74..9fa614a 100755
--- a/tools/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/Archive.java
+++ b/tools/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/Archive.java
@@ -23,6 +23,7 @@
import org.apache.commons.compress.archivers.zip.ZipFile;
import java.io.File;
+import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
@@ -572,6 +573,10 @@
return true;
+ } catch (FileNotFoundException e) {
+ // The FNF message is just the URL. Make it a bit more useful.
+ monitor.setResult("File not found: %1$s", e.getMessage());
+
} catch (Exception e) {
monitor.setResult(e.getMessage());
@@ -723,8 +728,7 @@
byte[] buf = new byte[65536];
- Enumeration<ZipArchiveEntry> entries =
- (Enumeration<ZipArchiveEntry>)zipFile.getEntries();
+ Enumeration<ZipArchiveEntry> entries = zipFile.getEntries();
while (entries.hasMoreElements()) {
ZipArchiveEntry entry = entries.nextElement();
diff --git a/tools/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/DocPackage.java b/tools/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/DocPackage.java
index abd42fb..3bd731b 100755
--- a/tools/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/DocPackage.java
+++ b/tools/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/DocPackage.java
@@ -166,22 +166,25 @@
AndroidVersion replacementVersion = replacementDoc.getVersion();
- // the new doc is an update if the api level is higher
+ // the new doc is an update if the api level is higher (no matter the codename on either)
if (replacementVersion.getApiLevel() > mVersion.getApiLevel()) {
return UpdateInfo.UPDATE;
}
- // if it's the exactly same (including codename), we check the revision
- if (replacementVersion.equals(mVersion) &&
- replacementPackage.getRevision() > this.getRevision()) {
- return UpdateInfo.UPDATE;
- }
-
- // else we check if they have the same api level and the new one is a preview, in which
- // case it's also an update (since preview have the api level of the _previous_ version.
- if (replacementVersion.getApiLevel() == mVersion.getApiLevel() &&
- replacementVersion.isPreview()) {
- return UpdateInfo.UPDATE;
+ // Check if they're the same exact (api and codename)
+ if (replacementVersion.equals(mVersion)) {
+ // exact same version, so check the revision level
+ if (replacementPackage.getRevision() > this.getRevision()) {
+ return UpdateInfo.UPDATE;
+ }
+ } else {
+ // not the same version? we check if they have the same api level and the new one
+ // is a preview, in which case it's also an update (since preview have the api level
+ // of the _previous_ version.)
+ if (replacementVersion.getApiLevel() == mVersion.getApiLevel() &&
+ replacementVersion.isPreview()) {
+ return UpdateInfo.UPDATE;
+ }
}
// not an upgrade but not incompatible either.
diff --git a/tools/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/Package.java b/tools/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/Package.java
index 1fcd6b1..8d19c0f 100755
--- a/tools/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/Package.java
+++ b/tools/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/Package.java
@@ -145,9 +145,15 @@
*/
void saveProperties(Properties props) {
props.setProperty(PROP_REVISION, Integer.toString(mRevision));
- props.setProperty(PROP_LICENSE, mLicense);
- props.setProperty(PROP_DESC, mDescription);
- props.setProperty(PROP_DESC_URL, mDescUrl);
+ if (mLicense != null) {
+ props.setProperty(PROP_LICENSE, mLicense);
+ }
+ if (mDescription != null) {
+ props.setProperty(PROP_DESC, mDescription);
+ }
+ if (mDescUrl != null) {
+ props.setProperty(PROP_DESC_URL, mDescUrl);
+ }
if (mSource != null) {
props.setProperty(PROP_SOURCE_URL, mSource.getUrl());
@@ -326,7 +332,7 @@
* current one, it's not an update.
*
* @param replacementPackage The potential replacement package.
- * @return
+ * @return One of the {@link UpdateInfo} values.
*
* @see #sameItemAs(Package)
*/
diff --git a/tools/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/PlatformPackage.java b/tools/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/PlatformPackage.java
index 324f51d..c9a58f7 100755
--- a/tools/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/PlatformPackage.java
+++ b/tools/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/PlatformPackage.java
@@ -87,7 +87,9 @@
super.saveProperties(props);
mVersion.saveProperties(props);
- props.setProperty(PROP_VERSION, mVersionName);
+ if (mVersionName != null) {
+ props.setProperty(PROP_VERSION, mVersionName);
+ }
}
/** Returns the version, a string, for platform packages. */
diff --git a/tools/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/RepoSource.java b/tools/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/RepoSource.java
index 5de2e94..cd2bacb 100755
--- a/tools/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/RepoSource.java
+++ b/tools/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/RepoSource.java
@@ -47,7 +47,7 @@
*/
public class RepoSource implements IDescription {
- private final String mUrl;
+ private String mUrl;
private final boolean mUserSource;
private Package[] mPackages;
@@ -132,55 +132,51 @@
monitor.setDescription("Fetching %1$s", url);
monitor.incProgress(1);
- ByteArrayInputStream xml = null;
+ mFetchError = null;
+ Exception[] exception = new Exception[] { null };
+ ByteArrayInputStream xml = fetchUrl(url, exception);
+ boolean validated = false;
+ if (xml != null) {
+ monitor.setDescription("Validate XML");
+ validated = validateXml(xml, url, monitor);
+ }
- for (int tentative = 0; tentative < 2 && xml == null; tentative++) {
+ // If we failed the first time and the URL doesn't explicitly end with
+ // our filename, make another tentative after changing the URL.
+ if (!validated && !url.endsWith(SdkRepository.URL_DEFAULT_XML_FILE)) {
+ if (!url.endsWith("/")) { //$NON-NLS-1$
+ url += "/"; //$NON-NLS-1$
+ }
+ url += SdkRepository.URL_DEFAULT_XML_FILE;
- // reset fetch error and fetch
- mFetchError = null;
- xml = fetchUrl(url, monitor);
+ xml = fetchUrl(url, exception);
+ if (xml != null) {
+ validated = validateXml(xml, url, monitor);
+ }
- if (xml == null) {
- mDescription += String.format("\nFailed to fetch URL %1$s", url);
- mFetchError = "Failed to fetch URL";
- monitor.setResult("Failed to fetch URL %1$s", url);
- } else {
- // We got a document. It might not be XML or it might not be valid.
+ if (validated) {
+ // If the second tentative succeeded, indicate it in the console
+ // with the URL that worked.
+ monitor.setResult("Repository found at %1$s", url);
- monitor.setDescription("Validate XML");
+ // Keep the modified URL
+ mUrl = url;
+ }
+ }
- if (validateXml(xml, url, monitor)) {
- // We got a valid XML, keep it and use it.
+ if (!validated) {
+ mFetchError = "Failed to fetch URL";
- if (tentative > 0) {
- // If the second tentative succeeded, indicate it in the console,
- // otherwise the user will only see the first failure
- // message and will think the whole thing failed. This also
- // indicates we modifed the URL.
- monitor.setResult("Repository found instead at %1$s", url);
- }
- break;
- } else {
- mDescription += String.format("\nFailed to validate XML at %1$s", url);
- mFetchError = "Failed to validate XML";
- monitor.setResult("Failed to validate XML at %1$s", url);
-
- // forget this XML, it wasn't any good.
- xml = null;
+ String reason = "Unknown";
+ if (exception[0] != null) {
+ if (exception[0] instanceof FileNotFoundException) {
+ reason = "File not found";
+ } else if (exception[0].getMessage() != null) {
+ reason = exception[0].getMessage();
}
}
- // If we failed the first time and the URL doesn't explicitly end with
- // our filename, make another tentative. Otherwise abort.
- if (tentative == 0 && !url.endsWith(SdkRepository.URL_DEFAULT_XML_FILE)) {
- if (!url.endsWith("/")) { //$NON-NLS-1$
- url += "/"; //$NON-NLS-1$
- }
- url += SdkRepository.URL_DEFAULT_XML_FILE;
- } else {
- break;
- }
-
+ monitor.setResult("Failed to fetch URL %1$s, reason:", url, reason);
}
monitor.incProgress(1);
@@ -219,7 +215,7 @@
* Java URL Reader: http://java.sun.com/docs/books/tutorial/networking/urls/readingURL.html
* Java set Proxy: http://java.sun.com/docs/books/tutorial/networking/urls/_setProxy.html
*/
- private ByteArrayInputStream fetchUrl(String urlString, ITaskMonitor monitor) {
+ private ByteArrayInputStream fetchUrl(String urlString, Exception[] outException) {
URL url;
try {
url = new URL(urlString);
@@ -255,12 +251,8 @@
}
}
- } catch (FileNotFoundException e) {
- // The FNF message is just the URL. Make it a bit more useful.
- monitor.setResult("File not found: %1$s", e.getMessage());
-
} catch (IOException e) {
- monitor.setResult(e.getMessage());
+ outException[0] = e;
}
return null;
diff --git a/tools/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/UpdaterData.java b/tools/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/UpdaterData.java
index 321f5ca..6cae085 100755
--- a/tools/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/UpdaterData.java
+++ b/tools/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/UpdaterData.java
@@ -36,6 +36,8 @@
import org.eclipse.swt.widgets.Shell;
+import java.io.ByteArrayOutputStream;
+import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
@@ -304,8 +306,21 @@
} catch (Throwable t) {
// Display anything unexpected in the monitor.
- monitor.setResult("Unexpected Error: %1$s", t.getMessage());
+ String msg = t.getMessage();
+ if (msg != null) {
+ monitor.setResult("Unexpected Error installing '%1$s: %2$s",
+ archive.getParentPackage().getShortDescription(), msg);
+ } else {
+ // no error info? get the stack call to display it
+ // At least that'll give us a better bug report.
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ t.printStackTrace(new PrintStream(baos));
+ // and display it
+ monitor.setResult("Unexpected Error installing '%1$s\n%2$s",
+ archive.getParentPackage().getShortDescription(),
+ baos.toString());
+ }
} finally {
// Always move the progress bar to the desired position.
diff --git a/tools/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/UpdaterWindowImpl.java b/tools/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/UpdaterWindowImpl.java
index 0fbcc41..20f1abb 100755
--- a/tools/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/UpdaterWindowImpl.java
+++ b/tools/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/UpdaterWindowImpl.java
@@ -109,7 +109,7 @@
* Create contents of the window.
*/
protected void createContents() {
- mAndroidSdkUpdater = new Shell(mParentShell);
+ mAndroidSdkUpdater = new Shell(mParentShell, SWT.SHELL_TRIM);
mAndroidSdkUpdater.addDisposeListener(new DisposeListener() {
public void widgetDisposed(DisposeEvent e) {
onAndroidSdkUpdaterDispose(); //$hide$ (hide from SWT designer)