Fixes fatal linter errors in android.net.metrics

am: 627b424

* commit '627b42494d82eca4fd51abfc0a5d7f330862b881':
  Fixes fatal linter errors in android.net.metrics

Change-Id: Iae6da861c9778747c81366ae0d3bca5dcf19efb2
This commit is contained in:
Hugo Benichi
2016-04-18 04:15:09 +00:00
committed by android-build-merger
11 changed files with 171 additions and 154 deletions

View File

@@ -22,25 +22,27 @@ import android.os.Parcelable;
/** /**
* {@hide} * {@hide}
*/ */
public class CaptivePortalCheckResultEvent extends IpConnectivityEvent implements Parcelable { public final class CaptivePortalCheckResultEvent extends IpConnectivityEvent implements Parcelable {
public static final String TAG = "CaptivePortalCheckResultEvent"; public final int netId;
public final int result;
private int mNetId; private CaptivePortalCheckResultEvent(int netId, int result) {
private int mResult; this.netId = netId;
this.result = result;
public CaptivePortalCheckResultEvent(int netId, int result) {
mNetId = netId;
mResult = result;
} }
public CaptivePortalCheckResultEvent(Parcel in) { private CaptivePortalCheckResultEvent(Parcel in) {
mNetId = in.readInt(); this.netId = in.readInt();
mResult = in.readInt(); this.result = in.readInt();
} }
public void writeToParcel(Parcel out, int flags) { public void writeToParcel(Parcel out, int flags) {
out.writeInt(mNetId); out.writeInt(netId);
out.writeInt(mResult); out.writeInt(result);
}
public int describeContents() {
return 0;
} }
public static final Parcelable.Creator<CaptivePortalCheckResultEvent> CREATOR public static final Parcelable.Creator<CaptivePortalCheckResultEvent> CREATOR
@@ -55,7 +57,6 @@ public class CaptivePortalCheckResultEvent extends IpConnectivityEvent implement
}; };
public static void logEvent(int netId, int result) { public static void logEvent(int netId, int result) {
IpConnectivityEvent.logEvent(IpConnectivityEvent.IPCE_NETMON_CHECK_RESULT, logEvent(IPCE_NETMON_CHECK_RESULT, new CaptivePortalCheckResultEvent(netId, result));
new CaptivePortalCheckResultEvent(netId, result));
} }
}; };

View File

@@ -22,24 +22,27 @@ import android.os.Parcelable;
/** /**
* {@hide} * {@hide}
*/ */
public class CaptivePortalStateChangeEvent extends IpConnectivityEvent implements Parcelable { public final class CaptivePortalStateChangeEvent extends IpConnectivityEvent implements Parcelable {
public static final String TAG = "CaptivePortalStateChangeEvent"; public static final int NETWORK_MONITOR_CONNECTED = 0;
public static final int NETWORK_MONITOR_CONNECTED = 0;
public static final int NETWORK_MONITOR_DISCONNECTED = 1; public static final int NETWORK_MONITOR_DISCONNECTED = 1;
public static final int NETWORK_MONITOR_VALIDATED = 2; public static final int NETWORK_MONITOR_VALIDATED = 2;
private int mState;
public final int state;
public CaptivePortalStateChangeEvent(int state) { public CaptivePortalStateChangeEvent(int state) {
mState = state; this.state = state;
} }
public CaptivePortalStateChangeEvent(Parcel in) { public CaptivePortalStateChangeEvent(Parcel in) {
mState = in.readInt(); state = in.readInt();
} }
public void writeToParcel(Parcel out, int flags) { public void writeToParcel(Parcel out, int flags) {
out.writeInt(mState); out.writeInt(state);
}
public int describeContents() {
return 0;
} }
public static final Parcelable.Creator<CaptivePortalStateChangeEvent> CREATOR public static final Parcelable.Creator<CaptivePortalStateChangeEvent> CREATOR
@@ -54,7 +57,6 @@ public class CaptivePortalStateChangeEvent extends IpConnectivityEvent implement
}; };
public static void logEvent(int state) { public static void logEvent(int state) {
IpConnectivityEvent.logEvent(IpConnectivityEvent.IPCE_NETMON_STATE_CHANGE, logEvent(IPCE_NETMON_STATE_CHANGE, new CaptivePortalStateChangeEvent(state));
new CaptivePortalStateChangeEvent(state));
} }
}; };

View File

@@ -22,43 +22,46 @@ import android.os.Parcelable;
/** /**
* {@hide} * {@hide}
*/ */
public class ConnectivityServiceChangeEvent extends IpConnectivityEvent implements Parcelable { public final class ConnectivityServiceChangeEvent extends IpConnectivityEvent
public static final String TAG = "ConnectivityServiceChangeEvent"; implements Parcelable {
// The ID of the network that has become the new default or NETID_UNSET if none. // The ID of the network that has become the new default or NETID_UNSET if none.
private final int mNetId; public final int netId;
// The list of transport types of the new default network, for example TRANSPORT_WIFI, as // The list of transport types of the new default network, for example TRANSPORT_WIFI, as
// defined in NetworkCapabilities.java. // defined in NetworkCapabilities.java.
private final int[] mTransportTypes; public final int[] transportTypes;
// The ID of the network that was the default before or NETID_UNSET if none. // The ID of the network that was the default before or NETID_UNSET if none.
private final int mPrevNetId; public final int prevNetId;
// Whether the previous network had IPv4/IPv6 connectivity. // Whether the previous network had IPv4/IPv6 connectivity.
private final boolean mPrevIPv4; public final boolean prevIPv4;
private final boolean mPrevIPv6; public final boolean prevIPv6;
public ConnectivityServiceChangeEvent(int netId, int[] transportTypes, private ConnectivityServiceChangeEvent(int netId, int[] transportTypes,
int prevNetId, boolean prevIPv4, boolean prevIPv6) { int prevNetId, boolean prevIPv4, boolean prevIPv6) {
mNetId = netId; this.netId = netId;
mTransportTypes = transportTypes; this.transportTypes = transportTypes;
mPrevNetId = prevNetId; this.prevNetId = prevNetId;
mPrevIPv4 = prevIPv4; this.prevIPv4 = prevIPv4;
mPrevIPv6 = prevIPv6; this.prevIPv6 = prevIPv6;
} }
public ConnectivityServiceChangeEvent(Parcel in) { private ConnectivityServiceChangeEvent(Parcel in) {
mNetId = in.readInt(); this.netId = in.readInt();
mTransportTypes = in.createIntArray(); this.transportTypes = in.createIntArray();
mPrevNetId = in.readInt(); this.prevNetId = in.readInt();
mPrevIPv4 = (in.readByte() > 0); this.prevIPv4 = (in.readByte() > 0);
mPrevIPv6 = (in.readByte() > 0); this.prevIPv6 = (in.readByte() > 0);
} }
public void writeToParcel(Parcel out, int flags) { public void writeToParcel(Parcel out, int flags) {
out.writeInt(mNetId); out.writeInt(netId);
out.writeIntArray(mTransportTypes); out.writeIntArray(transportTypes);
out.writeInt(mPrevNetId); out.writeInt(prevNetId);
out.writeByte(mPrevIPv4 ? (byte) 1 : (byte) 0); out.writeByte(prevIPv4 ? (byte) 1 : (byte) 0);
out.writeByte(mPrevIPv6 ? (byte) 1 : (byte) 0); out.writeByte(prevIPv6 ? (byte) 1 : (byte) 0);
}
public int describeContents() {
return 0;
} }
public static final Parcelable.Creator<ConnectivityServiceChangeEvent> CREATOR public static final Parcelable.Creator<ConnectivityServiceChangeEvent> CREATOR
@@ -74,7 +77,7 @@ public class ConnectivityServiceChangeEvent extends IpConnectivityEvent implemen
public static void logEvent(int netId, int[] transportTypes, public static void logEvent(int netId, int[] transportTypes,
int prevNetId, boolean prevIPv4, boolean prevIPv6) { int prevNetId, boolean prevIPv4, boolean prevIPv6) {
IpConnectivityEvent.logEvent(IpConnectivityEvent.IPCE_CONSRV_DEFAULT_NET_CHANGE, logEvent(IPCE_CONSRV_DEFAULT_NET_CHANGE,
new ConnectivityServiceChangeEvent( new ConnectivityServiceChangeEvent(
netId, transportTypes, prevNetId, prevIPv4, prevIPv6)); netId, transportTypes, prevNetId, prevIPv4, prevIPv6));
} }

View File

@@ -22,25 +22,27 @@ import android.os.Parcelable;
/** /**
* {@hide} * {@hide}
*/ */
public class DhcpClientEvent extends IpConnectivityEvent implements Parcelable { public final class DhcpClientEvent extends IpConnectivityEvent implements Parcelable {
public static final String TAG = "DhcpClientEvent"; public final String ifName;
public final String msg;
private String mIfName; private DhcpClientEvent(String ifName, String msg) {
private String mMsg; this.ifName = ifName;
this.msg = msg;
public DhcpClientEvent(String ifName, String msg) {
mIfName = ifName;
mMsg = msg;
} }
public DhcpClientEvent(Parcel in) { private DhcpClientEvent(Parcel in) {
mIfName = in.readString(); this.ifName = in.readString();
mMsg = in.readString(); this.msg = in.readString();
} }
public void writeToParcel(Parcel out, int flags) { public void writeToParcel(Parcel out, int flags) {
out.writeString(mIfName); out.writeString(ifName);
out.writeString(mMsg); out.writeString(msg);
}
public int describeContents() {
return 0;
} }
public static final Parcelable.Creator<DhcpClientEvent> CREATOR public static final Parcelable.Creator<DhcpClientEvent> CREATOR
@@ -55,6 +57,6 @@ public class DhcpClientEvent extends IpConnectivityEvent implements Parcelable {
}; };
public static void logStateEvent(String ifName, String state) { public static void logStateEvent(String ifName, String state) {
logEvent(IpConnectivityEvent.IPCE_DHCP_STATE_CHANGE, new DhcpClientEvent(ifName, state)); logEvent(IPCE_DHCP_STATE_CHANGE, new DhcpClientEvent(ifName, state));
} }
}; };

View File

@@ -22,9 +22,7 @@ import android.os.Parcelable;
/** /**
* {@hide} Event class used to record error events when parsing DHCP response packets. * {@hide} Event class used to record error events when parsing DHCP response packets.
*/ */
public class DhcpErrorEvent extends IpConnectivityEvent implements Parcelable { public final class DhcpErrorEvent extends IpConnectivityEvent implements Parcelable {
public static final String TAG = "DhcpErrorEvent";
public static final int L2_ERROR = 1; public static final int L2_ERROR = 1;
public static final int L3_ERROR = 2; public static final int L3_ERROR = 2;
public static final int L4_ERROR = 3; public static final int L4_ERROR = 3;
@@ -73,6 +71,10 @@ public class DhcpErrorEvent extends IpConnectivityEvent implements Parcelable {
out.writeInt(errorCode); out.writeInt(errorCode);
} }
public int describeContents() {
return 0;
}
public static final Parcelable.Creator<DhcpErrorEvent> CREATOR public static final Parcelable.Creator<DhcpErrorEvent> CREATOR
= new Parcelable.Creator<DhcpErrorEvent>() { = new Parcelable.Creator<DhcpErrorEvent>() {
public DhcpErrorEvent createFromParcel(Parcel in) { public DhcpErrorEvent createFromParcel(Parcel in) {
@@ -85,7 +87,7 @@ public class DhcpErrorEvent extends IpConnectivityEvent implements Parcelable {
}; };
public static void logParseError(String ifName, int errorCode) { public static void logParseError(String ifName, int errorCode) {
IpConnectivityEvent.logEvent(IPCE_DHCP_PARSE_ERROR, new DhcpErrorEvent(ifName, errorCode)); logEvent(IPCE_DHCP_PARSE_ERROR, new DhcpErrorEvent(ifName, errorCode));
} }
public static void logReceiveError(String ifName) { public static void logReceiveError(String ifName) {

View File

@@ -22,7 +22,7 @@ import android.os.Parcelable;
/** /**
* {@hide} * {@hide}
*/ */
public class DnsEvent extends IpConnectivityEvent implements Parcelable { final public class DnsEvent extends IpConnectivityEvent implements Parcelable {
public final int netId; public final int netId;
// The event type is currently only 1 or 2, so we store it as a byte. // The event type is currently only 1 or 2, so we store it as a byte.
@@ -43,10 +43,10 @@ public class DnsEvent extends IpConnectivityEvent implements Parcelable {
} }
private DnsEvent(Parcel in) { private DnsEvent(Parcel in) {
netId = in.readInt(); this.netId = in.readInt();
eventTypes = in.createByteArray(); this.eventTypes = in.createByteArray();
returnCodes = in.createByteArray(); this.returnCodes = in.createByteArray();
latenciesMs = in.createIntArray(); this.latenciesMs = in.createIntArray();
} }
@Override @Override
@@ -57,6 +57,10 @@ public class DnsEvent extends IpConnectivityEvent implements Parcelable {
out.writeIntArray(latenciesMs); out.writeIntArray(latenciesMs);
} }
public int describeContents() {
return 0;
}
public static final Parcelable.Creator<DnsEvent> CREATOR = new Parcelable.Creator<DnsEvent>() { public static final Parcelable.Creator<DnsEvent> CREATOR = new Parcelable.Creator<DnsEvent>() {
@Override @Override
public DnsEvent createFromParcel(Parcel in) { public DnsEvent createFromParcel(Parcel in) {
@@ -71,7 +75,6 @@ public class DnsEvent extends IpConnectivityEvent implements Parcelable {
public static void logEvent( public static void logEvent(
int netId, byte[] eventTypes, byte[] returnCodes, int[] latenciesMs) { int netId, byte[] eventTypes, byte[] returnCodes, int[] latenciesMs) {
IpConnectivityEvent.logEvent(IPCE_DNS_LOOKUPS, logEvent(IPCE_DNS_LOOKUPS, new DnsEvent(netId, eventTypes, returnCodes, latenciesMs));
new DnsEvent(netId, eventTypes, returnCodes, latenciesMs));
} }
} }

View File

@@ -23,14 +23,13 @@ import android.os.Parcelable;
/** /**
* {@hide} * {@hide}
*/ */
public class IpConnectivityEvent implements Parcelable { public abstract class IpConnectivityEvent {
public static final String TAG = "IpConnectivityEvent";
// IPRM = IpReachabilityMonitor // IPRM = IpReachabilityMonitor
// DHCP = DhcpClient // DHCP = DhcpClient
// NETMON = NetworkMonitorEvent // NETMON = NetworkMonitorEvent
// CONSRV = ConnectivityServiceEvent // CONSRV = ConnectivityServiceEvent
// IPMGR = IpManager // IPMGR = IpManager
// DNS = DnsEvent
public static final int IPCE_IPRM_BASE = 0 * 1024; public static final int IPCE_IPRM_BASE = 0 * 1024;
public static final int IPCE_DHCP_BASE = 1 * 1024; public static final int IPCE_DHCP_BASE = 1 * 1024;
public static final int IPCE_NETMON_BASE = 2 * 1024; public static final int IPCE_NETMON_BASE = 2 * 1024;
@@ -60,16 +59,10 @@ public class IpConnectivityEvent implements Parcelable {
private static ConnectivityMetricsLogger mMetricsLogger = new ConnectivityMetricsLogger(); private static ConnectivityMetricsLogger mMetricsLogger = new ConnectivityMetricsLogger();
public int describeContents() { public static <T extends IpConnectivityEvent & Parcelable> void logEvent(int tag, T event) {
return 0; final long timestamp = System.currentTimeMillis();
} final int componentTag = ConnectivityMetricsLogger.COMPONENT_TAG_CONNECTIVITY;
// TODO: consider using different component for DNS event.
public void writeToParcel(Parcel out, int flags) { mMetricsLogger.logEvent(timestamp, componentTag, tag, event);
}
public static void logEvent(int tag, IpConnectivityEvent event) {
long timestamp = System.currentTimeMillis();
mMetricsLogger.logEvent(timestamp, ConnectivityMetricsLogger.COMPONENT_TAG_CONNECTIVITY,
tag, event);
} }
}; };

View File

@@ -22,23 +22,27 @@ import android.os.Parcelable;
/** /**
* {@hide} * {@hide}
*/ */
public class IpManagerEvent extends IpConnectivityEvent implements Parcelable { public final class IpManagerEvent extends IpConnectivityEvent implements Parcelable {
private String mIfName; public final String ifName;
private long mDurationMs; public final long durationMs;
public IpManagerEvent(String ifName, long duration) { private IpManagerEvent(String ifName, long duration) {
mIfName = ifName; this.ifName = ifName;
mDurationMs = duration; this.durationMs = duration;
} }
public IpManagerEvent(Parcel in) { private IpManagerEvent(Parcel in) {
mIfName = in.readString(); this.ifName = in.readString();
mDurationMs = in.readLong(); this.durationMs = in.readLong();
} }
public void writeToParcel(Parcel out, int flags) { public void writeToParcel(Parcel out, int flags) {
out.writeString(mIfName); out.writeString(ifName);
out.writeLong(mDurationMs); out.writeLong(durationMs);
}
public int describeContents() {
return 0;
} }
public static final Parcelable.Creator<IpManagerEvent> CREATOR public static final Parcelable.Creator<IpManagerEvent> CREATOR
@@ -53,6 +57,6 @@ public class IpManagerEvent extends IpConnectivityEvent implements Parcelable {
}; };
public static void logEvent(int eventType, String ifName, long durationMs) { public static void logEvent(int eventType, String ifName, long durationMs) {
IpConnectivityEvent.logEvent(eventType, new IpManagerEvent(ifName, durationMs)); logEvent(eventType, new IpManagerEvent(ifName, durationMs));
} }
}; };

View File

@@ -22,20 +22,24 @@ import android.os.Parcelable;
/** /**
* {@hide} * {@hide}
*/ */
public class IpReachabilityMonitorLostEvent extends IpConnectivityEvent public final class IpReachabilityMonitorLostEvent extends IpConnectivityEvent
implements Parcelable { implements Parcelable {
private String mIfName; public final String ifName;
public IpReachabilityMonitorLostEvent(String ifName) { private IpReachabilityMonitorLostEvent(String ifName) {
mIfName = ifName; this.ifName = ifName;
} }
public IpReachabilityMonitorLostEvent(Parcel in) { private IpReachabilityMonitorLostEvent(Parcel in) {
mIfName = in.readString(); this.ifName = in.readString();
} }
public void writeToParcel(Parcel out, int flags) { public void writeToParcel(Parcel out, int flags) {
out.writeString(mIfName); out.writeString(ifName);
}
public int describeContents() {
return 0;
} }
public static final Parcelable.Creator<IpReachabilityMonitorLostEvent> CREATOR public static final Parcelable.Creator<IpReachabilityMonitorLostEvent> CREATOR
@@ -50,7 +54,6 @@ public class IpReachabilityMonitorLostEvent extends IpConnectivityEvent
}; };
public static void logEvent(String ifName) { public static void logEvent(String ifName) {
IpConnectivityEvent.logEvent(IpConnectivityEvent.IPCE_IPRM_REACHABILITY_LOST, logEvent(IPCE_IPRM_REACHABILITY_LOST, new IpReachabilityMonitorLostEvent(ifName));
new IpReachabilityMonitorLostEvent(ifName));
} }
}; };

View File

@@ -22,35 +22,37 @@ import android.os.Parcelable;
/** /**
* {@hide} * {@hide}
*/ */
public class IpReachabilityMonitorMessageEvent extends IpConnectivityEvent public final class IpReachabilityMonitorMessageEvent extends IpConnectivityEvent
implements Parcelable { implements Parcelable {
public static final String TAG = "IpReachabilityMonitorMessageEvent"; public final String ifName;
public final String destination;
public final int msgType;
public final int nudState;
private String mIfName; private IpReachabilityMonitorMessageEvent(String ifName, String destination, int msgType,
private String mDestination;
private int mMsgType;
private int mNudState;
public IpReachabilityMonitorMessageEvent(String ifName, String destination, int msgType,
int nudState) { int nudState) {
mIfName = ifName; this.ifName = ifName;
mDestination = destination; this.destination = destination;
mMsgType = msgType; this.msgType = msgType;
mNudState = nudState; this.nudState = nudState;
} }
public IpReachabilityMonitorMessageEvent(Parcel in) { private IpReachabilityMonitorMessageEvent(Parcel in) {
mIfName = in.readString(); this.ifName = in.readString();
mDestination = in.readString(); this.destination = in.readString();
mMsgType = in.readInt(); this.msgType = in.readInt();
mNudState = in.readInt(); this.nudState = in.readInt();
} }
public void writeToParcel(Parcel out, int flags) { public void writeToParcel(Parcel out, int flags) {
out.writeString(mIfName); out.writeString(ifName);
out.writeString(mDestination); out.writeString(destination);
out.writeInt(mMsgType); out.writeInt(msgType);
out.writeInt(mNudState); out.writeInt(nudState);
}
public int describeContents() {
return 0;
} }
public static final Parcelable.Creator<IpReachabilityMonitorMessageEvent> CREATOR public static final Parcelable.Creator<IpReachabilityMonitorMessageEvent> CREATOR
@@ -65,7 +67,7 @@ public class IpReachabilityMonitorMessageEvent extends IpConnectivityEvent
}; };
public static void logEvent(String ifName, String destination, int msgType, int nudState) { public static void logEvent(String ifName, String destination, int msgType, int nudState) {
IpConnectivityEvent.logEvent(IpConnectivityEvent.IPCE_IPRM_MESSAGE_RECEIVED, logEvent(IPCE_IPRM_MESSAGE_RECEIVED,
new IpReachabilityMonitorMessageEvent(ifName, destination, msgType, nudState)); new IpReachabilityMonitorMessageEvent(ifName, destination, msgType, nudState));
} }
}; };

View File

@@ -22,30 +22,32 @@ import android.os.Parcelable;
/** /**
* {@hide} * {@hide}
*/ */
public class IpReachabilityMonitorProbeEvent extends IpConnectivityEvent public final class IpReachabilityMonitorProbeEvent extends IpConnectivityEvent
implements Parcelable { implements Parcelable {
public static final String TAG = "IpReachabilityMonitorProbeEvent"; public final String ifName;
public final String destination;
public final boolean success;
private String mIfName; private IpReachabilityMonitorProbeEvent(String ifName, String destination, boolean success) {
private String mDestination; this.ifName = ifName;
private boolean mSuccess; this.destination = destination;
this.success = success;
public IpReachabilityMonitorProbeEvent(String ifName, String destination, boolean success) {
mIfName = ifName;
mDestination = destination;
mSuccess = success;
} }
public IpReachabilityMonitorProbeEvent(Parcel in) { private IpReachabilityMonitorProbeEvent(Parcel in) {
mIfName = in.readString(); this.ifName = in.readString();
mDestination = in.readString(); this.destination = in.readString();
mSuccess = in.readByte() > 0 ? true : false; this.success = in.readByte() > 0 ? true : false;
} }
public void writeToParcel(Parcel out, int flags) { public void writeToParcel(Parcel out, int flags) {
out.writeString(mIfName); out.writeString(ifName);
out.writeString(mDestination); out.writeString(destination);
out.writeByte((byte)(mSuccess ? 1 : 0)); out.writeByte((byte)(success ? 1 : 0));
}
public int describeContents() {
return 0;
} }
public static final Parcelable.Creator<IpReachabilityMonitorProbeEvent> CREATOR public static final Parcelable.Creator<IpReachabilityMonitorProbeEvent> CREATOR
@@ -60,7 +62,7 @@ public class IpReachabilityMonitorProbeEvent extends IpConnectivityEvent
}; };
public static void logEvent(String ifName, String destination, boolean success) { public static void logEvent(String ifName, String destination, boolean success) {
IpConnectivityEvent.logEvent(IpConnectivityEvent.IPCE_IPRM_PROBE_RESULT, logEvent(IPCE_IPRM_PROBE_RESULT,
new IpReachabilityMonitorProbeEvent(ifName, destination, success)); new IpReachabilityMonitorProbeEvent(ifName, destination, success));
} }
}; };