OSDN Git Service

IpConnectivity metrics: add version number
authorHugo Benichi <hugobenichi@google.com>
Thu, 13 Oct 2016 04:16:16 +0000 (13:16 +0900)
committerLorenzo Colitti <lorenzo@google.com>
Thu, 26 Jan 2017 09:51:18 +0000 (18:51 +0900)
This patch adds a version field to ipconnectivity.proto and populates it
to 2, which is the logical version number for NYC-MR2.

Test: IpConnectivity{EventBuilder,Metrics}Test pass
Bug: 32127906

(cherry picked from commit d680d4c856f54bea0c60dea74ba4204822391e49)

Change-Id: If8f167c0dc4c1abe0e235e2adfd131168a4ddc52

services/core/java/com/android/server/connectivity/IpConnectivityEventBuilder.java
services/core/java/com/android/server/connectivity/IpConnectivityMetrics.java
services/core/proto/ipconnectivity.proto
tests/net/java/com/android/server/connectivity/IpConnectivityEventBuilderTest.java
tests/net/java/com/android/server/connectivity/IpConnectivityMetricsTest.java

index f1ef947..f1d01e0 100644 (file)
@@ -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);
     }
 
index 28e724c..85c4303 100644 (file)
@@ -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.
index e0d7f09..29b318f 100644 (file)
@@ -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;
 };
index aed3635..84f0f90 100644 (file)
@@ -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);
     }
index 3fc89b9..8bdc829 100644 (file)
@@ -204,7 +204,8 @@ public class IpConnectivityMetricsTest extends TestCase {
                 "    router_lifetime: 2000",
                 "  >",
                 "  time_ms: 700",
-                ">");
+                ">",
+                "version: 2");
 
         verifySerialization(want, getdump("flush"));
     }