Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 31cf55bd authored by Hugo Benichi's avatar Hugo Benichi
Browse files

DO NOT MERGE IpConnectivity metrics: add version number

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 d680d4c8)

Change-Id: I5f37633afd9ec82f5402c5b6670fe2febae82a14
parent e40bb555
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -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);
    }

+7 −0
Original line number Diff line number Diff line
@@ -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.
+12 −1
Original line number Diff line number Diff line
@@ -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;
};
+22 −11
Original line number Diff line number Diff line
@@ -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);
    }
+2 −1
Original line number Diff line number Diff line
@@ -204,7 +204,8 @@ public class IpConnectivityMetricsTest extends TestCase {
                "    router_lifetime: 2000",
                "  >",
                "  time_ms: 700",
                ">");
                ">",
                "version: 2");

        verifySerialization(want, getdump("flush"));
    }