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}
*/
public class CaptivePortalCheckResultEvent extends IpConnectivityEvent implements Parcelable {
public static final String TAG = "CaptivePortalCheckResultEvent";
public final class CaptivePortalCheckResultEvent extends IpConnectivityEvent implements Parcelable {
public final int netId;
public final int result;
private int mNetId;
private int mResult;
public CaptivePortalCheckResultEvent(int netId, int result) {
mNetId = netId;
mResult = result;
private CaptivePortalCheckResultEvent(int netId, int result) {
this.netId = netId;
this.result = result;
}
public CaptivePortalCheckResultEvent(Parcel in) {
mNetId = in.readInt();
mResult = in.readInt();
private CaptivePortalCheckResultEvent(Parcel in) {
this.netId = in.readInt();
this.result = in.readInt();
}
public void writeToParcel(Parcel out, int flags) {
out.writeInt(mNetId);
out.writeInt(mResult);
out.writeInt(netId);
out.writeInt(result);
}
public int describeContents() {
return 0;
}
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) {
IpConnectivityEvent.logEvent(IpConnectivityEvent.IPCE_NETMON_CHECK_RESULT,
new CaptivePortalCheckResultEvent(netId, result));
logEvent(IPCE_NETMON_CHECK_RESULT, new CaptivePortalCheckResultEvent(netId, result));
}
};

View File

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

View File

@@ -22,43 +22,46 @@ import android.os.Parcelable;
/**
* {@hide}
*/
public class ConnectivityServiceChangeEvent extends IpConnectivityEvent implements Parcelable {
public static final String TAG = "ConnectivityServiceChangeEvent";
public final class ConnectivityServiceChangeEvent extends IpConnectivityEvent
implements Parcelable {
// 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
// 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.
private final int mPrevNetId;
public final int prevNetId;
// Whether the previous network had IPv4/IPv6 connectivity.
private final boolean mPrevIPv4;
private final boolean mPrevIPv6;
public final boolean prevIPv4;
public final boolean prevIPv6;
public ConnectivityServiceChangeEvent(int netId, int[] transportTypes,
private ConnectivityServiceChangeEvent(int netId, int[] transportTypes,
int prevNetId, boolean prevIPv4, boolean prevIPv6) {
mNetId = netId;
mTransportTypes = transportTypes;
mPrevNetId = prevNetId;
mPrevIPv4 = prevIPv4;
mPrevIPv6 = prevIPv6;
this.netId = netId;
this.transportTypes = transportTypes;
this.prevNetId = prevNetId;
this.prevIPv4 = prevIPv4;
this.prevIPv6 = prevIPv6;
}
public ConnectivityServiceChangeEvent(Parcel in) {
mNetId = in.readInt();
mTransportTypes = in.createIntArray();
mPrevNetId = in.readInt();
mPrevIPv4 = (in.readByte() > 0);
mPrevIPv6 = (in.readByte() > 0);
private ConnectivityServiceChangeEvent(Parcel in) {
this.netId = in.readInt();
this.transportTypes = in.createIntArray();
this.prevNetId = in.readInt();
this.prevIPv4 = (in.readByte() > 0);
this.prevIPv6 = (in.readByte() > 0);
}
public void writeToParcel(Parcel out, int flags) {
out.writeInt(mNetId);
out.writeIntArray(mTransportTypes);
out.writeInt(mPrevNetId);
out.writeByte(mPrevIPv4 ? (byte) 1 : (byte) 0);
out.writeByte(mPrevIPv6 ? (byte) 1 : (byte) 0);
out.writeInt(netId);
out.writeIntArray(transportTypes);
out.writeInt(prevNetId);
out.writeByte(prevIPv4 ? (byte) 1 : (byte) 0);
out.writeByte(prevIPv6 ? (byte) 1 : (byte) 0);
}
public int describeContents() {
return 0;
}
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,
int prevNetId, boolean prevIPv4, boolean prevIPv6) {
IpConnectivityEvent.logEvent(IpConnectivityEvent.IPCE_CONSRV_DEFAULT_NET_CHANGE,
logEvent(IPCE_CONSRV_DEFAULT_NET_CHANGE,
new ConnectivityServiceChangeEvent(
netId, transportTypes, prevNetId, prevIPv4, prevIPv6));
}

View File

@@ -22,25 +22,27 @@ import android.os.Parcelable;
/**
* {@hide}
*/
public class DhcpClientEvent extends IpConnectivityEvent implements Parcelable {
public static final String TAG = "DhcpClientEvent";
public final class DhcpClientEvent extends IpConnectivityEvent implements Parcelable {
public final String ifName;
public final String msg;
private String mIfName;
private String mMsg;
public DhcpClientEvent(String ifName, String msg) {
mIfName = ifName;
mMsg = msg;
private DhcpClientEvent(String ifName, String msg) {
this.ifName = ifName;
this.msg = msg;
}
public DhcpClientEvent(Parcel in) {
mIfName = in.readString();
mMsg = in.readString();
private DhcpClientEvent(Parcel in) {
this.ifName = in.readString();
this.msg = in.readString();
}
public void writeToParcel(Parcel out, int flags) {
out.writeString(mIfName);
out.writeString(mMsg);
out.writeString(ifName);
out.writeString(msg);
}
public int describeContents() {
return 0;
}
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) {
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.
*/
public class DhcpErrorEvent extends IpConnectivityEvent implements Parcelable {
public static final String TAG = "DhcpErrorEvent";
public final class DhcpErrorEvent extends IpConnectivityEvent implements Parcelable {
public static final int L2_ERROR = 1;
public static final int L3_ERROR = 2;
public static final int L4_ERROR = 3;
@@ -73,6 +71,10 @@ public class DhcpErrorEvent extends IpConnectivityEvent implements Parcelable {
out.writeInt(errorCode);
}
public int describeContents() {
return 0;
}
public static final Parcelable.Creator<DhcpErrorEvent> CREATOR
= new Parcelable.Creator<DhcpErrorEvent>() {
public DhcpErrorEvent createFromParcel(Parcel in) {
@@ -85,7 +87,7 @@ public class DhcpErrorEvent extends IpConnectivityEvent implements Parcelable {
};
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) {

View File

@@ -22,7 +22,7 @@ import android.os.Parcelable;
/**
* {@hide}
*/
public class DnsEvent extends IpConnectivityEvent implements Parcelable {
final public class DnsEvent extends IpConnectivityEvent implements Parcelable {
public final int netId;
// 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) {
netId = in.readInt();
eventTypes = in.createByteArray();
returnCodes = in.createByteArray();
latenciesMs = in.createIntArray();
this.netId = in.readInt();
this.eventTypes = in.createByteArray();
this.returnCodes = in.createByteArray();
this.latenciesMs = in.createIntArray();
}
@Override
@@ -57,6 +57,10 @@ public class DnsEvent extends IpConnectivityEvent implements Parcelable {
out.writeIntArray(latenciesMs);
}
public int describeContents() {
return 0;
}
public static final Parcelable.Creator<DnsEvent> CREATOR = new Parcelable.Creator<DnsEvent>() {
@Override
public DnsEvent createFromParcel(Parcel in) {
@@ -71,7 +75,6 @@ public class DnsEvent extends IpConnectivityEvent implements Parcelable {
public static void logEvent(
int netId, byte[] eventTypes, byte[] returnCodes, int[] latenciesMs) {
IpConnectivityEvent.logEvent(IPCE_DNS_LOOKUPS,
new DnsEvent(netId, eventTypes, returnCodes, latenciesMs));
logEvent(IPCE_DNS_LOOKUPS, new DnsEvent(netId, eventTypes, returnCodes, latenciesMs));
}
}

View File

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

View File

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

View File

@@ -22,20 +22,24 @@ import android.os.Parcelable;
/**
* {@hide}
*/
public class IpReachabilityMonitorLostEvent extends IpConnectivityEvent
public final class IpReachabilityMonitorLostEvent extends IpConnectivityEvent
implements Parcelable {
private String mIfName;
public final String ifName;
public IpReachabilityMonitorLostEvent(String ifName) {
mIfName = ifName;
private IpReachabilityMonitorLostEvent(String ifName) {
this.ifName = ifName;
}
public IpReachabilityMonitorLostEvent(Parcel in) {
mIfName = in.readString();
private IpReachabilityMonitorLostEvent(Parcel in) {
this.ifName = in.readString();
}
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
@@ -50,7 +54,6 @@ public class IpReachabilityMonitorLostEvent extends IpConnectivityEvent
};
public static void logEvent(String ifName) {
IpConnectivityEvent.logEvent(IpConnectivityEvent.IPCE_IPRM_REACHABILITY_LOST,
new IpReachabilityMonitorLostEvent(ifName));
logEvent(IPCE_IPRM_REACHABILITY_LOST, new IpReachabilityMonitorLostEvent(ifName));
}
};

View File

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

View File

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