Stop calling Vpn#updateCapabilities in CS.
Instead, make Vpn#onUserAdded and Vpn#onUserRemoved notify CS of UID range changes through the VPN's NetworkAgent. After this change, ConnectivityService no longer touches the VPN's NetworkCapabilities directly, which is a much cleaner design. Bug: 173331190 Test: passes existing tests in ConnectivityServiceTest Change-Id: If2201f392cdb5f00c89a97683ad4ce6bda7b89e5
This commit is contained in:
@@ -4821,15 +4821,6 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
||||
}
|
||||
}
|
||||
|
||||
private void updateVpnCapabilities(Vpn vpn, @Nullable NetworkCapabilities nc) {
|
||||
ensureRunningOnConnectivityServiceThread();
|
||||
NetworkAgentInfo vpnNai = getNetworkAgentInfoForNetId(vpn.getNetId());
|
||||
if (vpnNai == null || nc == null) {
|
||||
return;
|
||||
}
|
||||
updateCapabilities(vpnNai.getCurrentScore(), vpnNai, nc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateLockdownVpn() {
|
||||
if (Binder.getCallingUid() != Process.SYSTEM_UID) {
|
||||
@@ -5169,28 +5160,22 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
||||
|
||||
private void onUserAdded(int userId) {
|
||||
mPermissionMonitor.onUserAdded(userId);
|
||||
Network defaultNetwork = getNetwork(getDefaultNetwork());
|
||||
synchronized (mVpns) {
|
||||
final int vpnsSize = mVpns.size();
|
||||
for (int i = 0; i < vpnsSize; i++) {
|
||||
Vpn vpn = mVpns.valueAt(i);
|
||||
vpn.onUserAdded(userId);
|
||||
NetworkCapabilities nc = vpn.updateCapabilities(defaultNetwork);
|
||||
updateVpnCapabilities(vpn, nc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void onUserRemoved(int userId) {
|
||||
mPermissionMonitor.onUserRemoved(userId);
|
||||
Network defaultNetwork = getNetwork(getDefaultNetwork());
|
||||
synchronized (mVpns) {
|
||||
final int vpnsSize = mVpns.size();
|
||||
for (int i = 0; i < vpnsSize; i++) {
|
||||
Vpn vpn = mVpns.valueAt(i);
|
||||
vpn.onUserRemoved(userId);
|
||||
NetworkCapabilities nc = vpn.updateCapabilities(defaultNetwork);
|
||||
updateVpnCapabilities(vpn, nc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user