summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Glen Kuhne <kuh@google.com> 2017-01-17 21:38:25 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2017-01-17 21:38:29 +0000
commit3cdde18e3cc62f233d97c0889fc742f2a06fe7fd (patch)
tree1ea53cf1839d06a564eb312fbdda4faeffdac76e
parent1f6df68a90c6aa02ed21e8ed2753f9d2488880c8 (diff)
parent1375ede09255e04141f680c3e90526e9f34bf061 (diff)
Merge "Unhide WifiConfiguration proxy accessors"
-rw-r--r--api/current.txt2
-rw-r--r--api/system-current.txt2
-rw-r--r--api/test-current.txt2
-rw-r--r--wifi/java/android/net/wifi/WifiConfiguration.java43
-rw-r--r--wifi/java/android/net/wifi/WifiManager.java4
5 files changed, 49 insertions, 4 deletions
diff --git a/api/current.txt b/api/current.txt
index 2aa1a7e70b6f..b9cd7d0d3503 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -24997,7 +24997,9 @@ package android.net.wifi {
public class WifiConfiguration implements android.os.Parcelable {
ctor public WifiConfiguration();
method public int describeContents();
+ method public android.net.ProxyInfo getHttpProxy();
method public boolean isPasspoint();
+ method public void setHttpProxy(android.net.ProxyInfo);
method public void writeToParcel(android.os.Parcel, int);
field public java.lang.String BSSID;
field public java.lang.String FQDN;
diff --git a/api/system-current.txt b/api/system-current.txt
index 35fd747ae87f..75b0a34a101c 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -27348,9 +27348,11 @@ package android.net.wifi {
public class WifiConfiguration implements android.os.Parcelable {
ctor public WifiConfiguration();
method public int describeContents();
+ method public android.net.ProxyInfo getHttpProxy();
method public boolean hasNoInternetAccess();
method public boolean isNoInternetAccessExpected();
method public boolean isPasspoint();
+ method public void setHttpProxy(android.net.ProxyInfo);
method public void writeToParcel(android.os.Parcel, int);
field public java.lang.String BSSID;
field public java.lang.String FQDN;
diff --git a/api/test-current.txt b/api/test-current.txt
index 48c7009bfd74..de8602216f0e 100644
--- a/api/test-current.txt
+++ b/api/test-current.txt
@@ -25085,7 +25085,9 @@ package android.net.wifi {
public class WifiConfiguration implements android.os.Parcelable {
ctor public WifiConfiguration();
method public int describeContents();
+ method public android.net.ProxyInfo getHttpProxy();
method public boolean isPasspoint();
+ method public void setHttpProxy(android.net.ProxyInfo);
method public void writeToParcel(android.os.Parcel, int);
field public java.lang.String BSSID;
field public java.lang.String FQDN;
diff --git a/wifi/java/android/net/wifi/WifiConfiguration.java b/wifi/java/android/net/wifi/WifiConfiguration.java
index 958279badf75..3a4567112704 100644
--- a/wifi/java/android/net/wifi/WifiConfiguration.java
+++ b/wifi/java/android/net/wifi/WifiConfiguration.java
@@ -22,6 +22,7 @@ import android.net.IpConfiguration;
import android.net.IpConfiguration.ProxySettings;
import android.net.ProxyInfo;
import android.net.StaticIpConfiguration;
+import android.net.Uri;
import android.os.Parcel;
import android.os.Parcelable;
import android.os.UserHandle;
@@ -1805,14 +1806,48 @@ public class WifiConfiguration implements Parcelable {
mIpConfiguration.proxySettings = proxySettings;
}
- /** @hide */
+ /**
+ * Returns the HTTP proxy used by this object.
+ * @return a {@link ProxyInfo httpProxy} representing the proxy specified by this
+ * WifiConfiguration, or {@code null} if no proxy is specified.
+ */
public ProxyInfo getHttpProxy() {
- return mIpConfiguration.httpProxy;
+ if (mIpConfiguration.proxySettings == IpConfiguration.ProxySettings.NONE) {
+ return null;
+ }
+ return new ProxyInfo(mIpConfiguration.httpProxy);
}
- /** @hide */
+ /**
+ * Set the {@link ProxyInfo} for this WifiConfiguration.
+ * @param httpProxy {@link ProxyInfo} representing the httpProxy to be used by this
+ * WifiConfiguration. Setting this {@code null} will explicitly set no proxy,
+ * removing any proxy that was previously set.
+ * @exception throw IllegalArgumentException for invalid httpProxy
+ */
public void setHttpProxy(ProxyInfo httpProxy) {
- mIpConfiguration.httpProxy = httpProxy;
+ if (httpProxy == null) {
+ mIpConfiguration.setProxySettings(IpConfiguration.ProxySettings.NONE);
+ mIpConfiguration.setHttpProxy(null);
+ return;
+ }
+ ProxyInfo httpProxyCopy;
+ ProxySettings proxySettingCopy;
+ if (!Uri.EMPTY.equals(httpProxy.getPacFileUrl())) {
+ proxySettingCopy = IpConfiguration.ProxySettings.PAC;
+ // Construct a new PAC URL Proxy
+ httpProxyCopy = new ProxyInfo(httpProxy.getPacFileUrl(), httpProxy.getPort());
+ } else {
+ proxySettingCopy = IpConfiguration.ProxySettings.STATIC;
+ // Construct a new HTTP Proxy
+ httpProxyCopy = new ProxyInfo(httpProxy.getHost(), httpProxy.getPort(),
+ httpProxy.getExclusionListAsString());
+ }
+ if (!httpProxyCopy.isValid()) {
+ throw new IllegalArgumentException("Invalid ProxyInfo: " + httpProxyCopy.toString());
+ }
+ mIpConfiguration.setProxySettings(proxySettingCopy);
+ mIpConfiguration.setHttpProxy(httpProxyCopy);
}
/** @hide */
diff --git a/wifi/java/android/net/wifi/WifiManager.java b/wifi/java/android/net/wifi/WifiManager.java
index ab6b3e3f43c8..3b6e76f76677 100644
--- a/wifi/java/android/net/wifi/WifiManager.java
+++ b/wifi/java/android/net/wifi/WifiManager.java
@@ -791,6 +791,8 @@ public class WifiManager {
*
* @param config the set of variables that describe the configuration,
* contained in a {@link WifiConfiguration} object.
+ * If the {@link WifiConfiguration} has an Http Proxy set
+ * the calling app must be System, or be provisioned as the Profile or Device Owner.
* @return the ID of the newly created network description. This is used in
* other operations to specified the network to be acted upon.
* Returns {@code -1} on failure.
@@ -811,6 +813,8 @@ public class WifiManager {
* be sparse, so that only the items that are being changed
* are non-<code>null</code>. The {@code networkId} field
* must be set to the ID of the existing network being updated.
+ * If the {@link WifiConfiguration} has an Http Proxy set
+ * the calling app must be System, or be provisioned as the Profile or Device Owner.
* @return Returns the {@code networkId} of the supplied
* {@code WifiConfiguration} on success.
* <br/>