diff options
Diffstat (limited to 'core/java/android/net/ConnectivityManager.java')
-rw-r--r-- | core/java/android/net/ConnectivityManager.java | 39 |
1 files changed, 23 insertions, 16 deletions
diff --git a/core/java/android/net/ConnectivityManager.java b/core/java/android/net/ConnectivityManager.java index d8c3361..1c67f31 100644 --- a/core/java/android/net/ConnectivityManager.java +++ b/core/java/android/net/ConnectivityManager.java @@ -1904,9 +1904,6 @@ public class ConnectivityManager { * * @return {@link ProxyInfo} for the current global HTTP proxy or {@code null} * if no global HTTP proxy is set. - * - * <p>This method requires the caller to hold the permission - * {@link android.Manifest.permission#ACCESS_NETWORK_STATE}. * @hide */ public ProxyInfo getGlobalProxy() { @@ -1918,6 +1915,28 @@ public class ConnectivityManager { } /** + * Retrieve the global HTTP proxy, or if no global HTTP proxy is set, a + * network-specific HTTP proxy. If {@code network} is null, the + * network-specific proxy returned is the proxy of the default active + * network. + * + * @return {@link ProxyInfo} for the current global HTTP proxy, or if no + * global HTTP proxy is set, {@code ProxyInfo} for {@code network}, + * or when {@code network} is {@code null}, + * the {@code ProxyInfo} for the default active network. Returns + * {@code null} when no proxy applies or the caller doesn't have + * permission to use {@code network}. + * @hide + */ + public ProxyInfo getProxyForNetwork(Network network) { + try { + return mService.getProxyForNetwork(network); + } catch (RemoteException e) { + return null; + } + } + + /** * Get the current default HTTP proxy settings. If a global proxy is set it will be returned, * otherwise if this process is bound to a {@link Network} using * {@link #bindProcessToNetwork} then that {@code Network}'s proxy is returned, otherwise @@ -1927,19 +1946,7 @@ public class ConnectivityManager { * HTTP proxy is active. */ public ProxyInfo getDefaultProxy() { - final Network network = getBoundNetworkForProcess(); - if (network != null) { - final ProxyInfo globalProxy = getGlobalProxy(); - if (globalProxy != null) return globalProxy; - final LinkProperties lp = getLinkProperties(network); - if (lp != null) return lp.getHttpProxy(); - return null; - } - try { - return mService.getDefaultProxy(); - } catch (RemoteException e) { - return null; - } + return getProxyForNetwork(getBoundNetworkForProcess()); } /** |