diff options
| author | 2016-10-21 04:35:48 +0000 | |
|---|---|---|
| committer | 2016-10-21 04:35:52 +0000 | |
| commit | 1ca2ee78377589440adf18bc43a4cf7c62202948 (patch) | |
| tree | 4e6942c703670b611137d95e1dce50ff42dfa851 | |
| parent | 577e66cc432a348c5fe811b006472d2026c7d12a (diff) | |
| parent | d680d4c856f54bea0c60dea74ba4204822391e49 (diff) | |
Merge "IpConnectivity metrics: add version number"
5 files changed, 47 insertions, 13 deletions
diff --git a/services/core/java/com/android/server/connectivity/IpConnectivityEventBuilder.java b/services/core/java/com/android/server/connectivity/IpConnectivityEventBuilder.java index f1ef947f3472..f1d01e06911a 100644 --- a/services/core/java/com/android/server/connectivity/IpConnectivityEventBuilder.java +++ b/services/core/java/com/android/server/connectivity/IpConnectivityEventBuilder.java @@ -48,6 +48,10 @@ final public class IpConnectivityEventBuilder { final IpConnectivityLog log = new IpConnectivityLog(); log.events = toProto(events); log.droppedEvents = dropped; + if ((log.events.length > 0) || (dropped > 0)) { + // Only write version number if log has some information at all. + log.version = IpConnectivityMetrics.VERSION; + } return IpConnectivityLog.toByteArray(log); } diff --git a/services/core/java/com/android/server/connectivity/IpConnectivityMetrics.java b/services/core/java/com/android/server/connectivity/IpConnectivityMetrics.java index 2e3359f0f525..e176fe1575c1 100644 --- a/services/core/java/com/android/server/connectivity/IpConnectivityMetrics.java +++ b/services/core/java/com/android/server/connectivity/IpConnectivityMetrics.java @@ -40,6 +40,13 @@ final public class IpConnectivityMetrics extends SystemService { private static final String TAG = IpConnectivityMetrics.class.getSimpleName(); private static final boolean DBG = false; + // The logical version numbers of ipconnectivity.proto, corresponding to the + // "version" field of IpConnectivityLog. + private static final int NYC = 0; + private static final int NYC_MR1 = 1; + private static final int NYC_MR2 = 2; + public static final int VERSION = NYC_MR2; + private static final String SERVICE_NAME = IpConnectivityLog.SERVICE_NAME; // Default size of the event buffer. Once the buffer is full, incoming events are dropped. diff --git a/services/core/proto/ipconnectivity.proto b/services/core/proto/ipconnectivity.proto index e0d7f0984eb0..29b318f5ca89 100644 --- a/services/core/proto/ipconnectivity.proto +++ b/services/core/proto/ipconnectivity.proto @@ -53,6 +53,7 @@ message IpReachabilityEvent { // The event type code of the probe, represented by constants defined in // android.net.metrics.IpReachabilityEvent. + // NUD_FAILED_ORGANIC and PROVISIONING_LOST_ORGANIC recorded since version 1. optional int32 event_type = 2; }; @@ -126,11 +127,12 @@ message DHCPEvent { // Lifetime duration in milliseconds of a DhcpClient state, or transition // time in milliseconds between specific pairs of DhcpClient's states. - // Only populated when state_transition is populated. + // Only populated since version 1, when state_transition is populated. optional int32 duration_ms = 4; } // Represents the generation of an Android Packet Filter program. +// Since version 1. message ApfProgramEvent { // Lifetime of the program in seconds. optional int64 lifetime = 1; @@ -154,6 +156,7 @@ message ApfProgramEvent { // Represents Router Advertisement listening statistics for an interface with // Android Packet Filter enabled. +// Since version 1. message ApfStatistics { // The time interval in milliseconds these stastistics cover. optional int64 duration_ms = 1; @@ -183,6 +186,7 @@ message ApfStatistics { // Represents the reception of a Router Advertisement packet for an interface // with Android Packet Filter enabled. +// Since version 1. message RaEvent { // All lifetime values are expressed in seconds. The default value for an // option lifetime that was not present in the RA option list is -1. @@ -271,4 +275,11 @@ message IpConnectivityLog { // The number of events that had to be dropped due to a full buffer. optional int32 dropped_events = 2; + + // The version number of the metrics events being collected. + // nyc-dev: not populated, implicitly 0 + // nyc-dr1: not populated, implicitly 1 (sailfish and marlin only) + // nyc-mr1: not populated, implicitly 1 + // nyc-mr2: 2 + optional int32 version = 3; }; diff --git a/services/tests/servicestests/src/com/android/server/connectivity/IpConnectivityEventBuilderTest.java b/services/tests/servicestests/src/com/android/server/connectivity/IpConnectivityEventBuilderTest.java index aed363524560..84f0f9040b0c 100644 --- a/services/tests/servicestests/src/com/android/server/connectivity/IpConnectivityEventBuilderTest.java +++ b/services/tests/servicestests/src/com/android/server/connectivity/IpConnectivityEventBuilderTest.java @@ -71,7 +71,8 @@ public class IpConnectivityEventBuilderTest extends TestCase { " transport_types: 3", " >", " time_ms: 1", - ">"); + ">", + "version: 2"); verifySerialization(want, ev); } @@ -93,7 +94,8 @@ public class IpConnectivityEventBuilderTest extends TestCase { " state_transition: \"SomeState\"", " >", " time_ms: 1", - ">"); + ">", + "version: 2"); verifySerialization(want, ev); } @@ -114,7 +116,8 @@ public class IpConnectivityEventBuilderTest extends TestCase { " state_transition: \"\"", " >", " time_ms: 1", - ">"); + ">", + "version: 2"); verifySerialization(want, ev); } @@ -160,7 +163,8 @@ public class IpConnectivityEventBuilderTest extends TestCase { " return_codes: 178", " >", " time_ms: 1", - ">"); + ">", + "version: 2"); verifySerialization(want, ev); } @@ -181,7 +185,8 @@ public class IpConnectivityEventBuilderTest extends TestCase { " latency_ms: 5678", " >", " time_ms: 1", - ">"); + ">", + "version: 2"); verifySerialization(want, ev); } @@ -200,7 +205,8 @@ public class IpConnectivityEventBuilderTest extends TestCase { " if_name: \"wlan0\"", " >", " time_ms: 1", - ">"); + ">", + "version: 2"); verifySerialization(want, ev); } @@ -223,7 +229,8 @@ public class IpConnectivityEventBuilderTest extends TestCase { " >", " >", " time_ms: 1", - ">"); + ">", + "version: 2"); verifySerialization(want, ev); } @@ -248,7 +255,8 @@ public class IpConnectivityEventBuilderTest extends TestCase { " probe_result: 204", " probe_type: 1", " >", - ">"); + ">", + "version: 2"); verifySerialization(want, ev); } @@ -274,7 +282,8 @@ public class IpConnectivityEventBuilderTest extends TestCase { " program_length: 2048", " >", " time_ms: 1", - ">"); + ">", + "version: 2"); verifySerialization(want, ev); } @@ -305,7 +314,8 @@ public class IpConnectivityEventBuilderTest extends TestCase { " zero_lifetime_ras: 1", " >", " time_ms: 1", - ">"); + ">", + "version: 2"); verifySerialization(want, ev); } @@ -332,7 +342,8 @@ public class IpConnectivityEventBuilderTest extends TestCase { " router_lifetime: 2000", " >", " time_ms: 1", - ">"); + ">", + "version: 2"); verifySerialization(want, ev); } diff --git a/services/tests/servicestests/src/com/android/server/connectivity/IpConnectivityMetricsTest.java b/services/tests/servicestests/src/com/android/server/connectivity/IpConnectivityMetricsTest.java index 3fc89b9ff12d..8bdc829f7bfa 100644 --- a/services/tests/servicestests/src/com/android/server/connectivity/IpConnectivityMetricsTest.java +++ b/services/tests/servicestests/src/com/android/server/connectivity/IpConnectivityMetricsTest.java @@ -204,7 +204,8 @@ public class IpConnectivityMetricsTest extends TestCase { " router_lifetime: 2000", " >", " time_ms: 700", - ">"); + ">", + "version: 2"); verifySerialization(want, getdump("flush")); } |