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

Commit f927f0c5 authored by Hugo Benichi's avatar Hugo Benichi
Browse files

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
parent 948a8594
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -78,7 +78,10 @@ public final class ConnectivityMetricsEvent implements Parcelable {
    public String toString() {
        StringBuilder buffer = new StringBuilder("ConnectivityMetricsEvent(");
        buffer.append(String.format("%tT.%tL", timestamp, timestamp));
        // TODO: add transports, netId
        // TODO: add transports
        if (netId != 0) {
            buffer.append(", ").append(netId);
        }
        if (ifname != null) {
            buffer.append(", ").append(ifname);
        }
+11 −0
Original line number Diff line number Diff line
@@ -477,6 +477,17 @@ public final class NetworkCapabilities implements Parcelable {
        return enumerateBits(mTransportTypes);
    }

    /**
     * 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.
     *
+15 −0
Original line number Diff line number Diff line
@@ -109,6 +109,21 @@ public class IpConnectivityLog {
        return log(ev);
    }

    /**
     * Log an IpConnectivity event.
     * @param netid the id of the network associated with the event.
     * @param transports the current transports of the network associated with the event, as defined
     * in NetworkCapabilities.
     * @param data is a Parcelable instance representing the event.
     * @return true if the event was successfully logged.
     */
    public boolean log(int netid, long transports, Parcelable data) {
        ConnectivityMetricsEvent ev = makeEv(data);
        ev.netId = netid;
        ev.transports = transports;
        return log(ev);
    }

    /**
     * Log an IpConnectivity event.
     * @param data is a Parcelable instance representing the event.
+6 −14
Original line number Diff line number Diff line
@@ -48,26 +48,19 @@ public final class ValidationProbeEvent implements Parcelable {
    @Retention(RetentionPolicy.SOURCE)
    public @interface ReturnCode {}

    public final int netId;
    public final long durationMs;
    public long durationMs;
    // probeType byte format (MSB to LSB):
    // byte 0: unused
    // byte 1: unused
    // byte 2: 0 = UNKNOWN, 1 = FIRST_VALIDATION, 2 = REVALIDATION
    // byte 3: PROBE_* constant
    public final int probeType;
    public final @ReturnCode int returnCode;

    public ValidationProbeEvent(
            int netId, long durationMs, int probeType, @ReturnCode int returnCode) {
        this.netId = netId;
        this.durationMs = durationMs;
        this.probeType = probeType;
        this.returnCode = returnCode;
    public int probeType;
    public @ReturnCode int returnCode;

    public ValidationProbeEvent() {
    }

    private ValidationProbeEvent(Parcel in) {
        netId = in.readInt();
        durationMs = in.readLong();
        probeType = in.readInt();
        returnCode = in.readInt();
@@ -75,7 +68,6 @@ public final class ValidationProbeEvent implements Parcelable {

    @Override
    public void writeToParcel(Parcel out, int flags) {
        out.writeInt(netId);
        out.writeLong(durationMs);
        out.writeInt(probeType);
        out.writeInt(returnCode);
@@ -111,7 +103,7 @@ public final class ValidationProbeEvent implements Parcelable {

    @Override
    public String toString() {
        return String.format("ValidationProbeEvent(%d, %s:%d %s, %dms)", netId,
        return String.format("ValidationProbeEvent(%s:%d %s, %dms)",
                getProbeName(probeType), returnCode, getValidationStage(probeType), durationMs);
    }

+0 −1
Original line number Diff line number Diff line
@@ -210,7 +210,6 @@ final public class IpConnectivityEventBuilder {
    private static void setValidationProbeEvent(IpConnectivityEvent out, ValidationProbeEvent in) {
        IpConnectivityLogClass.ValidationProbeEvent validationProbeEvent =
                new IpConnectivityLogClass.ValidationProbeEvent();
        validationProbeEvent.networkId = netIdOf(in.netId);
        validationProbeEvent.latencyMs = (int) in.durationMs;
        validationProbeEvent.probeType = in.probeType;
        validationProbeEvent.probeResult = in.returnCode;
Loading