[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
This commit is contained in:
Chalard Jean
2018-06-07 18:02:37 +09:00
parent 7d97afc73f
commit 777e2e59e6
2 changed files with 24 additions and 24 deletions

View File

@@ -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());
}
}

View File

@@ -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;
}
}
}