diff --git a/services/core/java/com/android/server/ConnectivityService.java b/services/core/java/com/android/server/ConnectivityService.java index 69887201fd..e8e8a39dee 100644 --- a/services/core/java/com/android/server/ConnectivityService.java +++ b/services/core/java/com/android/server/ConnectivityService.java @@ -3278,24 +3278,10 @@ public class ConnectivityService extends IConnectivityManager.Stub nai.networkMonitor.forceReevaluation(uid); } - private ProxyInfo getDefaultProxy() { - // this information is already available as a world read/writable jvm property - // so this API change wouldn't have a benefit. It also breaks the passing - // of proxy info to all the JVMs. - // enforceAccessPermission(); - synchronized (mProxyTracker.mProxyLock) { - ProxyInfo ret = mProxyTracker.mGlobalProxy; - if ((ret == null) && !mProxyTracker.mDefaultProxyDisabled) { - ret = mProxyTracker.mDefaultProxy; - } - return ret; - } - } - @Override public ProxyInfo getProxyForNetwork(Network network) { - if (network == null) return getDefaultProxy(); - final ProxyInfo globalProxy = getGlobalProxy(); + if (network == null) return mProxyTracker.getDefaultProxy(); + final ProxyInfo globalProxy = mProxyTracker.getGlobalProxy(); if (globalProxy != null) return globalProxy; if (!NetworkUtils.queryUserAccess(Binder.getCallingUid(), network.netId)) return null; // Don't call getLinkProperties() as it requires ACCESS_NETWORK_STATE permission, which @@ -3387,14 +3373,10 @@ public class ConnectivityService extends IConnectivityManager.Stub } } + @Override + @Nullable public ProxyInfo getGlobalProxy() { - // this information is already available as a world read/writable jvm property - // so this API change wouldn't have a benefit. It also breaks the passing - // of proxy info to all the JVMs. - // enforceAccessPermission(); - synchronized (mProxyTracker.mProxyLock) { - return mProxyTracker.mGlobalProxy; - } + return mProxyTracker.getGlobalProxy(); } private void handleApplyDefaultProxy(ProxyInfo proxy) { @@ -3443,7 +3425,7 @@ public class ConnectivityService extends IConnectivityManager.Stub ProxyInfo oldProxyInfo = oldLp == null ? null : oldLp.getHttpProxy(); if (!ProxyTracker.proxyInfoEqual(newProxyInfo, oldProxyInfo)) { - sendProxyBroadcast(getDefaultProxy()); + sendProxyBroadcast(mProxyTracker.getDefaultProxy()); } } diff --git a/services/core/java/com/android/server/connectivity/ProxyTracker.java b/services/core/java/com/android/server/connectivity/ProxyTracker.java index d1c2c26cdc..5567acafa2 100644 --- a/services/core/java/com/android/server/connectivity/ProxyTracker.java +++ b/services/core/java/com/android/server/connectivity/ProxyTracker.java @@ -73,4 +73,22 @@ public class ProxyTracker { // hosts even when PAC URLs are present to account for the legacy PAC resolver. return Objects.equals(pa, pb) && (pa == null || Objects.equals(pa.getHost(), pb.getHost())); } + + @Nullable + public ProxyInfo getDefaultProxy() { + // This information is already available as a world read/writable jvm property. + synchronized (mProxyLock) { + final ProxyInfo ret = mGlobalProxy; + if ((ret == null) && !mDefaultProxyDisabled) return mDefaultProxy; + return ret; + } + } + + @Nullable + public ProxyInfo getGlobalProxy() { + // This information is already available as a world read/writable jvm property. + synchronized (mProxyLock) { + return mGlobalProxy; + } + } }