[PT03] Move some more code into ProxyTracker.
Add finals and annotations. Remove comments that have lost their
context (they were in the context of disabling a permission check
that had been added, but constituted an API change that would not
serve any real purpose).
Test: runtest
Change-Id: I1f879b2c105d2127072b88233d72097a0d78fe14
diff --git a/services/core/java/com/android/server/ConnectivityService.java b/services/core/java/com/android/server/ConnectivityService.java
index 6988720..e8e8a39 100644
--- a/services/core/java/com/android/server/ConnectivityService.java
+++ b/services/core/java/com/android/server/ConnectivityService.java
@@ -3278,24 +3278,10 @@
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 @@
}
}
+ @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 @@
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 d1c2c26..5567aca 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 @@
// 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;
+ }
+ }
}