Merge changes Ieb8645ac,I6466ec14,I87deb82b,I995b108e,Ib6521459
* changes: Remove VPN info arrays from NetworkStats(Observer|Recorder) NetworkStatsFactory: Take VPNs into account for network/battery stats Remove duplicate line in clat_simple test file Remove unused lastStats parameter Revert "Revert "Take all VPN underlying networks into account when migrating traffic for""
This commit is contained in:
@@ -192,6 +192,7 @@ import com.android.server.net.BaseNetdEventCallback;
|
||||
import com.android.server.net.BaseNetworkObserver;
|
||||
import com.android.server.net.LockdownVpnTracker;
|
||||
import com.android.server.net.NetworkPolicyManagerInternal;
|
||||
import com.android.server.net.NetworkStatsFactory;
|
||||
import com.android.server.utils.PriorityDump;
|
||||
|
||||
import com.google.android.collect.Lists;
|
||||
@@ -4374,7 +4375,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
||||
|
||||
/**
|
||||
* @return VPN information for accounting, or null if we can't retrieve all required
|
||||
* information, e.g primary underlying iface.
|
||||
* information, e.g underlying ifaces.
|
||||
*/
|
||||
@Nullable
|
||||
private VpnInfo createVpnInfo(Vpn vpn) {
|
||||
@@ -4386,17 +4387,28 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
||||
// see VpnService.setUnderlyingNetworks()'s javadoc about how to interpret
|
||||
// the underlyingNetworks list.
|
||||
if (underlyingNetworks == null) {
|
||||
NetworkAgentInfo defaultNetwork = getDefaultNetwork();
|
||||
if (defaultNetwork != null && defaultNetwork.linkProperties != null) {
|
||||
info.primaryUnderlyingIface = getDefaultNetwork().linkProperties.getInterfaceName();
|
||||
}
|
||||
} else if (underlyingNetworks.length > 0) {
|
||||
LinkProperties linkProperties = getLinkProperties(underlyingNetworks[0]);
|
||||
if (linkProperties != null) {
|
||||
info.primaryUnderlyingIface = linkProperties.getInterfaceName();
|
||||
NetworkAgentInfo defaultNai = getDefaultNetwork();
|
||||
if (defaultNai != null) {
|
||||
underlyingNetworks = new Network[] { defaultNai.network };
|
||||
}
|
||||
}
|
||||
return info.primaryUnderlyingIface == null ? null : info;
|
||||
if (underlyingNetworks != null && underlyingNetworks.length > 0) {
|
||||
List<String> interfaces = new ArrayList<>();
|
||||
for (Network network : underlyingNetworks) {
|
||||
LinkProperties lp = getLinkProperties(network);
|
||||
if (lp != null) {
|
||||
for (String iface : lp.getAllInterfaceNames()) {
|
||||
if (!TextUtils.isEmpty(iface)) {
|
||||
interfaces.add(iface);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!interfaces.isEmpty()) {
|
||||
info.underlyingIfaces = interfaces.toArray(new String[interfaces.size()]);
|
||||
}
|
||||
}
|
||||
return info.underlyingIfaces == null ? null : info;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -6776,8 +6788,8 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
||||
}
|
||||
|
||||
/**
|
||||
* Notify NetworkStatsService that the set of active ifaces has changed, or that one of the
|
||||
* properties tracked by NetworkStatsService on an active iface has changed.
|
||||
* Notify NetworkStatsService and NetworkStatsFactory that the set of active ifaces has changed,
|
||||
* or that one of the active iface's trackedproperties has changed.
|
||||
*/
|
||||
private void notifyIfacesChangedForNetworkStats() {
|
||||
ensureRunningOnConnectivityServiceThread();
|
||||
@@ -6786,11 +6798,17 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
||||
if (activeLinkProperties != null) {
|
||||
activeIface = activeLinkProperties.getInterfaceName();
|
||||
}
|
||||
|
||||
// CAUTION: Ordering matters between updateVpnInfos() and forceUpdateIfaces(), which
|
||||
// triggers a new poll. Trigger the poll first to ensure a snapshot is taken before
|
||||
// switching to the new state. This ensures that traffic does not get mis-attributed to
|
||||
// incorrect apps (including VPN app).
|
||||
try {
|
||||
mStatsService.forceUpdateIfaces(
|
||||
getDefaultNetworks(), getAllVpnInfo(), getAllNetworkState(), activeIface);
|
||||
getDefaultNetworks(), getAllNetworkState(), activeIface);
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
NetworkStatsFactory.updateVpnInfos(getAllVpnInfo());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user