Merge "IP connectivity metrics: NetworkEvents have transports" am: f8fdb06c27

am: f3ada43f6e

Change-Id: I8cd50ea805fe3e533c0fc21b220827155cb0d23b
This commit is contained in:
Hugo Benichi
2017-11-14 01:46:23 +00:00
committed by android-build-merger
4 changed files with 9 additions and 23 deletions

View File

@@ -60,29 +60,25 @@ public final class NetworkEvent implements Parcelable {
@Retention(RetentionPolicy.SOURCE) @Retention(RetentionPolicy.SOURCE)
public @interface EventType {} public @interface EventType {}
public final int netId;
public final @EventType int eventType; public final @EventType int eventType;
public final long durationMs; public final long durationMs;
public NetworkEvent(int netId, @EventType int eventType, long durationMs) { public NetworkEvent(@EventType int eventType, long durationMs) {
this.netId = netId;
this.eventType = eventType; this.eventType = eventType;
this.durationMs = durationMs; this.durationMs = durationMs;
} }
public NetworkEvent(int netId, @EventType int eventType) { public NetworkEvent(@EventType int eventType) {
this(netId, eventType, 0); this(eventType, 0);
} }
private NetworkEvent(Parcel in) { private NetworkEvent(Parcel in) {
netId = in.readInt();
eventType = in.readInt(); eventType = in.readInt();
durationMs = in.readLong(); durationMs = in.readLong();
} }
@Override @Override
public void writeToParcel(Parcel out, int flags) { public void writeToParcel(Parcel out, int flags) {
out.writeInt(netId);
out.writeInt(eventType); out.writeInt(eventType);
out.writeLong(durationMs); out.writeLong(durationMs);
} }
@@ -105,8 +101,8 @@ public final class NetworkEvent implements Parcelable {
@Override @Override
public String toString() { public String toString() {
return String.format("NetworkEvent(%d, %s, %dms)", return String.format("NetworkEvent(%s, %dms)",
netId, Decoder.constants.get(eventType), durationMs); Decoder.constants.get(eventType), durationMs);
} }
final static class Decoder { final static class Decoder {

View File

@@ -46,7 +46,6 @@ import android.util.SparseIntArray;
import com.android.server.connectivity.metrics.nano.IpConnectivityLogClass; import com.android.server.connectivity.metrics.nano.IpConnectivityLogClass;
import com.android.server.connectivity.metrics.nano.IpConnectivityLogClass.IpConnectivityEvent; import com.android.server.connectivity.metrics.nano.IpConnectivityLogClass.IpConnectivityEvent;
import com.android.server.connectivity.metrics.nano.IpConnectivityLogClass.IpConnectivityLog; import com.android.server.connectivity.metrics.nano.IpConnectivityLogClass.IpConnectivityLog;
import com.android.server.connectivity.metrics.nano.IpConnectivityLogClass.NetworkId;
import com.android.server.connectivity.metrics.nano.IpConnectivityLogClass.Pair; import com.android.server.connectivity.metrics.nano.IpConnectivityLogClass.Pair;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
@@ -247,7 +246,6 @@ final public class IpConnectivityEventBuilder {
private static void setNetworkEvent(IpConnectivityEvent out, NetworkEvent in) { private static void setNetworkEvent(IpConnectivityEvent out, NetworkEvent in) {
IpConnectivityLogClass.NetworkEvent networkEvent = IpConnectivityLogClass.NetworkEvent networkEvent =
new IpConnectivityLogClass.NetworkEvent(); new IpConnectivityLogClass.NetworkEvent();
networkEvent.networkId = netIdOf(in.netId);
networkEvent.eventType = in.eventType; networkEvent.eventType = in.eventType;
networkEvent.latencyMs = (int) in.durationMs; networkEvent.latencyMs = (int) in.durationMs;
out.setNetworkEvent(networkEvent); out.setNetworkEvent(networkEvent);
@@ -326,12 +324,6 @@ final public class IpConnectivityEventBuilder {
return pairs; return pairs;
} }
private static NetworkId netIdOf(int netid) {
final NetworkId ni = new NetworkId();
ni.networkId = netid;
return ni;
}
private static int ipSupportOf(DefaultNetworkEvent in) { private static int ipSupportOf(DefaultNetworkEvent in) {
if (in.ipv4 && in.ipv6) { if (in.ipv4 && in.ipv6) {
return IpConnectivityLogClass.DefaultNetworkEvent.DUAL; return IpConnectivityLogClass.DefaultNetworkEvent.DUAL;

View File

@@ -1129,7 +1129,8 @@ public class NetworkMonitor extends StateMachine {
} }
private void logNetworkEvent(int evtype) { private void logNetworkEvent(int evtype) {
mMetricsLog.log(new NetworkEvent(mNetId, evtype)); int[] transports = mNetworkAgentInfo.networkCapabilities.getTransportTypes();
mMetricsLog.log(mNetId, transports, new NetworkEvent(evtype));
} }
private int networkEventType(ValidationStage s, EvaluationResult r) { private int networkEventType(ValidationStage s, EvaluationResult r) {
@@ -1150,7 +1151,8 @@ public class NetworkMonitor extends StateMachine {
private void maybeLogEvaluationResult(int evtype) { private void maybeLogEvaluationResult(int evtype) {
if (mEvaluationTimer.isRunning()) { if (mEvaluationTimer.isRunning()) {
mMetricsLog.log(new NetworkEvent(mNetId, evtype, mEvaluationTimer.stop())); int[] transports = mNetworkAgentInfo.networkCapabilities.getTransportTypes();
mMetricsLog.log(mNetId, transports, new NetworkEvent(evtype, mEvaluationTimer.stop()));
mEvaluationTimer.reset(); mEvaluationTimer.reset();
} }
} }

View File

@@ -337,7 +337,6 @@ public class IpConnectivityEventBuilderTest {
public void testNetworkEventSerialization() { public void testNetworkEventSerialization() {
ConnectivityMetricsEvent ev = describeIpEvent( ConnectivityMetricsEvent ev = describeIpEvent(
aType(NetworkEvent.class), aType(NetworkEvent.class),
anInt(100),
anInt(5), anInt(5),
aLong(20410)); aLong(20410));
@@ -352,9 +351,6 @@ public class IpConnectivityEventBuilderTest {
" network_event <", " network_event <",
" event_type: 5", " event_type: 5",
" latency_ms: 20410", " latency_ms: 20410",
" network_id <",
" network_id: 100",
" >",
" >", " >",
">", ">",
"version: 2\n"); "version: 2\n");