aboutsummaryrefslogtreecommitdiffstats
path: root/sdkmanager/libs/sdklib
diff options
context:
space:
mode:
authorRaphael Moll <ralf@android.com>2012-05-17 12:41:14 -0700
committerRaphael Moll <ralf@android.com>2012-05-17 12:41:14 -0700
commit0d08ce04d89f8ec44c3464af20ab0c00b85c64ff (patch)
tree7682c0e6e90a79f837a49f87a2f1d309b8470b18 /sdkmanager/libs/sdklib
parent7911fa1ef67338907a2fb22d4fdb4203930a4549 (diff)
downloadsdk-0d08ce04d89f8ec44c3464af20ab0c00b85c64ff.zip
sdk-0d08ce04d89f8ec44c3464af20ab0c00b85c64ff.tar.gz
sdk-0d08ce04d89f8ec44c3464af20ab0c00b85c64ff.tar.bz2
SDK Manager: do not erase default java http proxy properties.
If the sdk manager config file has no proxy port/host info, do not set the corresponding java properties to empty strings. This means if the sdk manager settings are empty, whatever is the default from Java OR from the Eclispe proxy settings will be used by the manager. Change-Id: I17bbc6faed4726fc4b6aa9b29ded7d698ed81283
Diffstat (limited to 'sdkmanager/libs/sdklib')
-rw-r--r--sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/UrlOpener.java46
-rwxr-xr-xsdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/sources/SdkSource.java8
2 files changed, 51 insertions, 3 deletions
diff --git a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/UrlOpener.java b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/UrlOpener.java
index 74b023e..84190e8 100644
--- a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/UrlOpener.java
+++ b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/UrlOpener.java
@@ -44,12 +44,16 @@ import java.io.FileNotFoundException;
import java.io.FilterInputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.net.Proxy;
import java.net.ProxySelector;
+import java.net.URI;
import java.net.URL;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Properties;
/**
* This class holds methods for adding URLs management.
@@ -57,6 +61,9 @@ import java.util.Map;
*/
public class UrlOpener {
+ private static final boolean DEBUG =
+ System.getenv("ANDROID_DEBUG_URL_OPENER") != null; //$NON-NLS-1$
+
public static class CanceledByUserException extends Exception {
private static final long serialVersionUID = -7669346110926032403L;
@@ -68,6 +75,24 @@ public class UrlOpener {
private static Map<String, UserCredentials> sRealmCache =
new HashMap<String, UserCredentials>();
+ static {
+ if (DEBUG) {
+ Properties props = System.getProperties();
+ for (String key : new String[] {
+ "http.proxyHost", //$NON-NLS-1$
+ "http.proxyPort", //$NON-NLS-1$
+ "https.proxyHost", //$NON-NLS-1$
+ "https.proxyPort" }) { //$NON-NLS-1$
+ String prop = props.getProperty(key);
+ if (prop != null) {
+ System.out.printf(
+ "SdkLib.UrlOpener Java.Prop %s='%s'\n", //$NON-NLS-1$
+ key, prop);
+ }
+ }
+ }
+ }
+
/**
* Opens a URL. It can be a simple URL or one which requires basic
* authentication.
@@ -166,6 +191,23 @@ public class UrlOpener {
httpClient.getParams().setParameter(AuthPNames.PROXY_AUTH_PREF, authpref);
httpClient.getParams().setParameter(AuthPNames.TARGET_AUTH_PREF, authpref);
+ if (DEBUG) {
+ try {
+ ProxySelector sel = routePlanner.getProxySelector();
+ if (sel != null) {
+ List<Proxy> list = sel.select(new URI(url));
+ System.out.printf(
+ "SdkLib.UrlOpener:\n Connect to: %s\n Proxy List: %s\n", //$NON-NLS-1$
+ url,
+ list == null ? "(null)" : Arrays.toString(list.toArray()));//$NON-NLS-1$
+ }
+ } catch (Exception e) {
+ System.out.printf(
+ "SdkLib.UrlOpener: Failed to get proxy info for %s: %s\n", //$NON-NLS-1$
+ url, e.toString());
+ }
+ }
+
boolean trying = true;
// loop while the response is being fetched
while (trying) {
@@ -173,6 +215,10 @@ public class UrlOpener {
HttpResponse response = httpClient.execute(httpGet, localContext);
int statusCode = response.getStatusLine().getStatusCode();
+ if (DEBUG) {
+ System.out.printf(" Status: %d", statusCode); //$NON-NLS-1$
+ }
+
// check whether any authentication is required
AuthState authenticationState = null;
if (statusCode == HttpStatus.SC_UNAUTHORIZED) {
diff --git a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/sources/SdkSource.java b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/sources/SdkSource.java
index 45646f0..c07715b 100755
--- a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/sources/SdkSource.java
+++ b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/sources/SdkSource.java
@@ -516,10 +516,12 @@ public abstract class SdkSource implements IDescription, Comparable<SdkSource> {
reason = "HTTPS SSL error. You might want to force download through HTTP in the settings.";
mFetchError += ": HTTPS SSL error";
} else if (exception[0].getMessage() != null) {
- reason = exception[0].getMessage();
+ reason =
+ exception[0].getClass().getSimpleName().replace("Exception", "") //$NON-NLS-1$ //$NON-NLS-2$
+ + ' '
+ + exception[0].getMessage();
} else {
- // We don't know what's wrong. Let's give the exception class at least.
- reason = String.format("Unknown (%1$s)", exception[0].getClass().getName());
+ reason = exception[0].toString();
}
monitor.logError("Failed to fetch URL %1$s, reason: %2$s", url, reason);