Merge "Notify NetworkStats only when interfaces changed in updateLinkProperties"

This commit is contained in:
Junyu Lai
2022-10-27 06:49:33 +00:00
committed by Gerrit Code Review
3 changed files with 23 additions and 4 deletions

View File

@@ -7500,7 +7500,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
}
private void updateLinkProperties(NetworkAgentInfo networkAgent, @NonNull LinkProperties newLp,
@NonNull LinkProperties oldLp) {
@Nullable LinkProperties oldLp) {
int netId = networkAgent.network.getNetId();
// The NetworkAgent does not know whether clatd is running on its network or not, or whether
@@ -7552,7 +7552,13 @@ public class ConnectivityService extends IConnectivityManager.Stub
}
// Start or stop DNS64 detection and 464xlat according to network state.
networkAgent.clatd.update();
notifyIfacesChangedForNetworkStats();
// Notify NSS when relevant events happened. Currently, NSS only cares about
// interface changed to update clat interfaces accounting.
final boolean interfacesChanged = oldLp == null
|| !Objects.equals(newLp.getAllInterfaceNames(), oldLp.getAllInterfaceNames());
if (interfacesChanged) {
notifyIfacesChangedForNetworkStats();
}
networkAgent.networkMonitor().notifyLinkPropertiesChanged(
new LinkProperties(newLp, true /* parcelSensitiveFields */));
notifyNetworkCallbacks(networkAgent, ConnectivityManager.CALLBACK_IP_CHANGED);
@@ -8315,7 +8321,8 @@ public class ConnectivityService extends IConnectivityManager.Stub
}
}
public void handleUpdateLinkProperties(NetworkAgentInfo nai, LinkProperties newLp) {
public void handleUpdateLinkProperties(@NonNull NetworkAgentInfo nai,
@NonNull LinkProperties newLp) {
ensureRunningOnConnectivityServiceThread();
if (!mNetworkAgentInfos.contains(nai)) {