diff --git a/services/core/java/com/android/server/ConnectivityService.java b/services/core/java/com/android/server/ConnectivityService.java index 753c1171ae..d96362c0f2 100644 --- a/services/core/java/com/android/server/ConnectivityService.java +++ b/services/core/java/com/android/server/ConnectivityService.java @@ -6470,17 +6470,12 @@ public class ConnectivityService extends IConnectivityManager.Stub // Second pass: process all listens. if (wasBackgroundNetwork != newNetwork.isBackgroundNetwork()) { - // TODO : most of the following is useless because the only thing that changed - // here is whether the network is a background network. Clean this up. - - NetworkCapabilities newNc = mixInCapabilities(newNetwork, + final NetworkCapabilities newNc = mixInCapabilities(newNetwork, newNetwork.networkCapabilities); - if (Objects.equals(newNetwork.networkCapabilities, newNc)) return; - final int oldPermission = getNetworkPermission(newNetwork.networkCapabilities); final int newPermission = getNetworkPermission(newNc); - if (oldPermission != newPermission && newNetwork.created && !newNetwork.isVPN()) { + if (oldPermission != newPermission) { try { mNMS.setNetworkPermission(newNetwork.network.netId, newPermission); } catch (RemoteException e) { @@ -6488,50 +6483,13 @@ public class ConnectivityService extends IConnectivityManager.Stub } } - final NetworkCapabilities prevNc; synchronized (newNetwork) { - prevNc = newNetwork.networkCapabilities; newNetwork.setNetworkCapabilities(newNc); } - updateUids(newNetwork, prevNc, newNc); - - if (newNetwork.getCurrentScore() == score - && newNc.equalRequestableCapabilities(prevNc)) { - // If the requestable capabilities haven't changed, and the score hasn't changed, - // then the change we're processing can't affect any requests, it can only affect - // the listens on this network. - processListenRequests(newNetwork, true); - } else { - rematchAllNetworksAndRequests(); - notifyNetworkCallbacks(newNetwork, ConnectivityManager.CALLBACK_CAP_CHANGED); - } - - if (prevNc != null) { - final boolean oldMetered = prevNc.isMetered(); - final boolean newMetered = newNc.isMetered(); - final boolean meteredChanged = oldMetered != newMetered; - - if (meteredChanged) { - maybeNotifyNetworkBlocked(newNetwork, oldMetered, newMetered, - mRestrictBackground, mRestrictBackground); - } - - final boolean roamingChanged = prevNc.hasCapability(NET_CAPABILITY_NOT_ROAMING) - != newNc.hasCapability(NET_CAPABILITY_NOT_ROAMING); - - // Report changes that are interesting for network statistics tracking. - if (meteredChanged || roamingChanged) { - notifyIfacesChangedForNetworkStats(); - } - } - - if (!newNc.hasTransport(TRANSPORT_VPN)) { - // Tell VPNs about updated capabilities, since they may need to - // bubble those changes through. - updateAllVpnsCapabilities(); - } - + // The requestable capabilities and the score can't have changed, therefore the change + // in background can't affect any requests. Only processing the listens is fine. + processListenRequests(newNetwork, true); } else { processListenRequests(newNetwork, false); }