Send a proxy broadcast when apps moved from/to a VPN
When the apps moved from/to a VPN, a proxy broadcast is needed to inform the apps that the proxy might be changed since the default network satisfied by the apps might also changed. Since the framework does not track the defautlt network of every apps, thus, this is done when: 1. VPN connects/disconnects. 2. List of uids that apply to the VPN has changed. While 1 is already covered by the current design, the CL implements 2 in order to fulfill the case that different networks have different proxies. Bug: 178727215 Test: atest FrameworksNetTests Change-Id: Ifa103dd66394026d752b407a1bee740c9fcdad2b
This commit is contained in:
parent
9756b5d4f9
commit
53e8a267ab
1 changed files with 162 additions and 19 deletions
|
|
@ -7285,6 +7285,8 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||
mDnsManager.updateTransportsForNetwork(
|
||||
nai.network.getNetId(), newNc.getTransportTypes());
|
||||
}
|
||||
|
||||
maybeSendProxyBroadcast(nai, prevNc, newNc);
|
||||
}
|
||||
|
||||
/** Convenience method to update the capabilities for a given network. */
|
||||
|
|
@ -7373,6 +7375,30 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||
maybeCloseSockets(nai, ranges, exemptUids);
|
||||
}
|
||||
|
||||
private boolean isProxySetOnAnyDefaultNetwork() {
|
||||
ensureRunningOnConnectivityServiceThread();
|
||||
for (final NetworkRequestInfo nri : mDefaultNetworkRequests) {
|
||||
final NetworkAgentInfo nai = nri.getSatisfier();
|
||||
if (nai != null && nai.linkProperties.getHttpProxy() != null) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void maybeSendProxyBroadcast(NetworkAgentInfo nai, NetworkCapabilities prevNc,
|
||||
NetworkCapabilities newNc) {
|
||||
// When the apps moved from/to a VPN, a proxy broadcast is needed to inform the apps that
|
||||
// the proxy might be changed since the default network satisfied by the apps might also
|
||||
// changed.
|
||||
// TODO: Try to track the default network that apps use and only send a proxy broadcast when
|
||||
// that happens to prevent false alarms.
|
||||
if (nai.isVPN() && nai.everConnected && !NetworkCapabilities.hasSameUids(prevNc, newNc)
|
||||
&& (nai.linkProperties.getHttpProxy() != null || isProxySetOnAnyDefaultNetwork())) {
|
||||
mProxyTracker.sendProxyBroadcast();
|
||||
}
|
||||
}
|
||||
|
||||
private void updateUids(NetworkAgentInfo nai, NetworkCapabilities prevNc,
|
||||
NetworkCapabilities newNc) {
|
||||
Set<UidRange> prevRanges = null == prevNc ? null : prevNc.getUidRanges();
|
||||
|
|
|
|||
Loading…
Reference in a new issue