Connectivity metrics: add transports to validation probes
This patch adds transports info to ValidationProbeEvent and migrates
netId logging for this event to the topt-level netId field in
ConnectivityMetricsEvent.
Test: modified unit tests. $ runtest frameworks-net passes
Bug: 3490169
Change-Id: Ibf51049ba8901ae5ca4ea86e2f500944a4738b5c
diff --git a/core/java/android/net/NetworkCapabilities.java b/core/java/android/net/NetworkCapabilities.java
index 0765c86..8665b9c 100644
--- a/core/java/android/net/NetworkCapabilities.java
+++ b/core/java/android/net/NetworkCapabilities.java
@@ -478,6 +478,17 @@
}
/**
+ * Gets all the transports set on this {@code NetworkCapability} instance.
+ *
+ * @return a bit field composed of up bits at indexes defined by
+ * {@code NetworkCapabilities.TRANSPORT_*} values for this instance.
+ * @hide
+ */
+ public long getTransports() {
+ return mTransportTypes;
+ }
+
+ /**
* Tests for the presence of a transport on this instance.
*
* @param transportType the {@code NetworkCapabilities.TRANSPORT_*} to be tested for.
diff --git a/tests/net/java/com/android/server/connectivity/IpConnectivityEventBuilderTest.java b/tests/net/java/com/android/server/connectivity/IpConnectivityEventBuilderTest.java
index dbc7861..d819b96 100644
--- a/tests/net/java/com/android/server/connectivity/IpConnectivityEventBuilderTest.java
+++ b/tests/net/java/com/android/server/connectivity/IpConnectivityEventBuilderTest.java
@@ -402,7 +402,6 @@
public void testValidationProbeEventSerialization() {
ConnectivityMetricsEvent ev = describeIpEvent(
aType(ValidationProbeEvent.class),
- anInt(120),
aLong(40730),
anInt(ValidationProbeEvent.PROBE_HTTP),
anInt(204));
@@ -417,9 +416,6 @@
" transports: 0",
" validation_probe_event <",
" latency_ms: 40730",
- " network_id <",
- " network_id: 120",
- " >",
" probe_result: 204",
" probe_type: 1",
" >",
diff --git a/tests/net/java/com/android/server/connectivity/IpConnectivityMetricsTest.java b/tests/net/java/com/android/server/connectivity/IpConnectivityMetricsTest.java
index 50c92b3..68786d0 100644
--- a/tests/net/java/com/android/server/connectivity/IpConnectivityMetricsTest.java
+++ b/tests/net/java/com/android/server/connectivity/IpConnectivityMetricsTest.java
@@ -153,12 +153,18 @@
apfStats.programUpdatesAll = 7;
apfStats.programUpdatesAllowingMulticast = 3;
apfStats.maxProgramSize = 2048;
+
+ ValidationProbeEvent validationEv = new ValidationProbeEvent();
+ validationEv.durationMs = 40730;
+ validationEv.probeType = ValidationProbeEvent.PROBE_HTTP;
+ validationEv.returnCode = 204;
+
Parcelable[] events = {
new IpReachabilityEvent(IpReachabilityEvent.NUD_FAILED),
new DhcpClientEvent("SomeState", 192),
new DefaultNetworkEvent(102, new int[]{1,2,3}, 101, true, false),
new IpManagerEvent(IpManagerEvent.PROVISIONING_OK, 5678),
- new ValidationProbeEvent(120, 40730, ValidationProbeEvent.PROBE_HTTP, 204),
+ validationEv,
apfStats,
new RaEvent(2000, 400, 300, -1, 1000, -1)
};
@@ -235,9 +241,6 @@
" transports: 0",
" validation_probe_event <",
" latency_ms: 40730",
- " network_id <",
- " network_id: 120",
- " >",
" probe_result: 204",
" probe_type: 1",
" >",