summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteve Kondik <shade@chemlab.org>2010-09-03 21:32:44 +0000
committerGerrit Code Review <gerrit2@cyanogenmod.teamdouche.net>2010-09-03 21:32:44 +0000
commit096ab5eb459e0b65010246ccd25bcdc8e1e36e89 (patch)
tree3c4dfa437ff4e9c5f27dbe9ca4c13fe9966a2fe6
parent2620358ffb58a2347b904f5c8adc23179168e977 (diff)
parented99b80128f1aea8889a24f96ac33c5de0faef3a (diff)
downloadframeworks_base-096ab5eb459e0b65010246ccd25bcdc8e1e36e89.zip
frameworks_base-096ab5eb459e0b65010246ccd25bcdc8e1e36e89.tar.gz
frameworks_base-096ab5eb459e0b65010246ccd25bcdc8e1e36e89.tar.bz2
Merge "Framework fixes required to work with the fixed wifi proxy settings." into froyo
-rw-r--r--core/java/android/net/Proxy.java78
-rw-r--r--core/java/android/provider/Settings.java8
2 files changed, 77 insertions, 9 deletions
diff --git a/core/java/android/net/Proxy.java b/core/java/android/net/Proxy.java
index 963ccae..370b755 100644
--- a/core/java/android/net/Proxy.java
+++ b/core/java/android/net/Proxy.java
@@ -99,6 +99,61 @@ final public class Proxy {
}
/**
+ * Return the proxy host set by the user.
+ * @param ctx A Context used to get the settings for the proxy host.
+ * @return String containing the host name. If the user did not set a host
+ * name it returns the default host. A null value means that no
+ * host is to be used.
+ * WIFI addition by Revoked test
+ */
+ static final public String getWifiHost(Context ctx) {
+ ContentResolver contentResolver = ctx.getContentResolver();
+ Assert.assertNotNull(contentResolver);
+ String host = Settings.Secure.getString(
+ contentResolver,
+ Settings.Secure.HTTP_PROXY_WIFI);
+ if (host != null && !host.equals("")) {
+ int i = host.indexOf(':');
+ if (i == -1) {
+ if (DEBUG) {
+ Assert.assertTrue(host.length() == 0);
+ }
+ return null;
+ }
+ return host.substring(0, i);
+ }
+ return null;
+ }
+
+ /**
+ * Return the proxy port set by the user.
+ * @param ctx A Context used to get the settings for the proxy port.
+ * @return The port number to use or -1 if no proxy is to be used.
+ * WIFI addition by Revoked test
+ */
+ static final public int getWifiPort(Context ctx) {
+ ContentResolver contentResolver = ctx.getContentResolver();
+ Assert.assertNotNull(contentResolver);
+ String host = Settings.Secure.getString(
+ contentResolver,
+ Settings.Secure.HTTP_PROXY_WIFI);
+ if (host != null) {
+ int i = host.indexOf(':');
+ if (i == -1) {
+ if (DEBUG) {
+ Assert.assertTrue(host.length() == 0);
+ }
+ return -1;
+ }
+ if (DEBUG) {
+ Assert.assertTrue(i < host.length());
+ }
+ return Integer.parseInt(host.substring(i+1));
+ }
+ return 0;
+ }
+
+ /**
* Return the default proxy host specified by the carrier.
* @return String containing the host name or null if there is no proxy for
* this carrier.
@@ -132,7 +187,7 @@ final public class Proxy {
/**
* Returns the preferred proxy to be used by clients. This is a wrapper
* around {@link android.net.Proxy#getHost()}. No proxy will be returned
- * for localhost, and Settings.Secure.HTTP_PROXY_WIFI_ONLY will be checked
+ * for localhost, and Settings.Secure.HTTP_PROXY_WIFI_ON will be checked
* if the user is on wifi.
*
* @param context the context which will be passed to
@@ -147,14 +202,22 @@ final public class Proxy {
*/
static final public HttpHost getPreferredHttpHost(Context context,
String url) {
+
+ String proxyHost = null;
+ int proxyPort = 0;
+
if (!isLocalHost(url)) {
- if (isProxyForWifiOnly(context) && !isNetworkWifi(context)) {
- return null;
+ if (!isNetworkWifi(context)) {
+ proxyHost = Proxy.getHost(context);
+ proxyPort = Proxy.getPort(context);
+ }
+ else if (isProxyForWifiOn(context) && isNetworkWifi(context)) {
+ proxyHost = Proxy.getWifiHost(context);
+ proxyPort = Proxy.getWifiPort(context);
}
- final String proxyHost = Proxy.getHost(context);
if (proxyHost != null) {
- return new HttpHost(proxyHost, Proxy.getPort(context), "http");
+ return new HttpHost(proxyHost, proxyPort, "http");
}
}
@@ -210,10 +273,11 @@ final public class Proxy {
* @return if we should only proxy while on wifi
* @hide
*/
- static final public boolean isProxyForWifiOnly(Context ctx) {
+ static final public boolean isProxyForWifiOn(Context ctx) {
boolean ret = Settings.Secure.getInt(ctx.getContentResolver(),
- Settings.Secure.HTTP_PROXY_WIFI_ONLY, 1) != 0;
+ Settings.Secure.HTTP_PROXY_WIFI_ON, 1) != 0;
return ret;
}
};
+
diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java
index bfa3ff6..9e31905 100644
--- a/core/java/android/provider/Settings.java
+++ b/core/java/android/provider/Settings.java
@@ -2855,10 +2855,14 @@ public final class Settings {
public static final String HTTP_PROXY = "http_proxy";
/**
- * If proxy should be active on wifi only
+ * If proxy should be active on wifi
* @hide
*/
- public static final String HTTP_PROXY_WIFI_ONLY = "http_proxy_wifi_only";
+ public static final String HTTP_PROXY_WIFI_ON = "http_proxy_wifi_on";
+ /**
+ * Initialise necessary variables for wifi proxy support.
+ */
+ public static final String HTTP_PROXY_WIFI = "http_proxy_wifi";
/**
* Whether the package installer should allow installation of apps downloaded from