Merge changes I8de95add,Ia6f4ccfd into nyc-dev
* changes: Remove unused event tags of IpConnectivityEvent Better ConnectivityMetricsEvent printing
This commit is contained in:
committed by
Android (Google) Code Review
commit
24b6e2bcc8
@@ -26057,7 +26057,7 @@ package android.net.http {
|
||||
|
||||
package android.net.metrics {
|
||||
|
||||
public final class DefaultNetworkEvent extends android.net.metrics.IpConnectivityEvent implements android.os.Parcelable {
|
||||
public final class DefaultNetworkEvent implements android.os.Parcelable {
|
||||
method public int describeContents();
|
||||
method public static void logEvent(int, int[], int, boolean, boolean);
|
||||
method public void writeToParcel(android.os.Parcel, int);
|
||||
@@ -26069,7 +26069,7 @@ package android.net.metrics {
|
||||
field public final int[] transportTypes;
|
||||
}
|
||||
|
||||
public final class DhcpClientEvent extends android.net.metrics.IpConnectivityEvent implements android.os.Parcelable {
|
||||
public final class DhcpClientEvent implements android.os.Parcelable {
|
||||
method public int describeContents();
|
||||
method public static void logStateEvent(java.lang.String, java.lang.String);
|
||||
method public void writeToParcel(android.os.Parcel, int);
|
||||
@@ -26078,7 +26078,7 @@ package android.net.metrics {
|
||||
field public final java.lang.String msg;
|
||||
}
|
||||
|
||||
public final class DhcpErrorEvent extends android.net.metrics.IpConnectivityEvent implements android.os.Parcelable {
|
||||
public final class DhcpErrorEvent implements android.os.Parcelable {
|
||||
method public int describeContents();
|
||||
method public static int errorCodeWithOption(int, int);
|
||||
method public static void logParseError(java.lang.String, int);
|
||||
@@ -26108,7 +26108,7 @@ package android.net.metrics {
|
||||
field public final java.lang.String ifName;
|
||||
}
|
||||
|
||||
public final class DnsEvent extends android.net.metrics.IpConnectivityEvent implements android.os.Parcelable {
|
||||
public final class DnsEvent implements android.os.Parcelable {
|
||||
method public int describeContents();
|
||||
method public static void logEvent(int, byte[], byte[], int[]);
|
||||
method public void writeToParcel(android.os.Parcel, int);
|
||||
@@ -26119,44 +26119,20 @@ package android.net.metrics {
|
||||
field public final byte[] returnCodes;
|
||||
}
|
||||
|
||||
public abstract class IpConnectivityEvent {
|
||||
ctor public IpConnectivityEvent();
|
||||
method public static void logEvent(int, T);
|
||||
field public static final int IPCE_CONSRV_BASE = 3072; // 0xc00
|
||||
field public static final int IPCE_CONSRV_DEFAULT_NET_CHANGE = 3072; // 0xc00
|
||||
field public static final int IPCE_DHCP_BASE = 1024; // 0x400
|
||||
field public static final int IPCE_DHCP_PARSE_ERROR = 1025; // 0x401
|
||||
field public static final int IPCE_DHCP_RECV_ERROR = 1024; // 0x400
|
||||
field public static final int IPCE_DHCP_STATE_CHANGE = 1026; // 0x402
|
||||
field public static final int IPCE_DNS_BASE = 5120; // 0x1400
|
||||
field public static final int IPCE_DNS_LOOKUPS = 5120; // 0x1400
|
||||
field public static final int IPCE_IPMGR_BASE = 4096; // 0x1000
|
||||
field public static final int IPCE_IPMGR_COMPLETE_LIFECYCLE = 4098; // 0x1002
|
||||
field public static final int IPCE_IPMGR_PROVISIONING_FAIL = 4097; // 0x1001
|
||||
field public static final int IPCE_IPMGR_PROVISIONING_OK = 4096; // 0x1000
|
||||
field public static final int IPCE_IPRM_BASE = 0; // 0x0
|
||||
field public static final int IPCE_IPRM_NUD_FAILED = 2; // 0x2
|
||||
field public static final int IPCE_IPRM_PROBE_FAILURE = 1; // 0x1
|
||||
field public static final int IPCE_IPRM_PROBE_STARTED = 0; // 0x0
|
||||
field public static final int IPCE_IPRM_PROVISIONING_LOST = 3; // 0x3
|
||||
field public static final int IPCE_NETMON_BASE = 2048; // 0x800
|
||||
field public static final int IPCE_NETMON_CAPPORT_FOUND = 2052; // 0x804
|
||||
field public static final int IPCE_NETMON_CHECK_RESULT = 2049; // 0x801
|
||||
field public static final int IPCE_NETMON_PORTAL_PROBE = 2051; // 0x803
|
||||
field public static final int IPCE_NETMON_STATE_CHANGE = 2048; // 0x800
|
||||
field public static final int IPCE_NETMON_VALIDATED = 2050; // 0x802
|
||||
}
|
||||
|
||||
public final class IpManagerEvent extends android.net.metrics.IpConnectivityEvent implements android.os.Parcelable {
|
||||
public final class IpManagerEvent implements android.os.Parcelable {
|
||||
method public int describeContents();
|
||||
method public static void logEvent(int, java.lang.String, long);
|
||||
method public void writeToParcel(android.os.Parcel, int);
|
||||
field public static final int COMPLETE_LIFECYCLE = 3; // 0x3
|
||||
field public static final android.os.Parcelable.Creator<android.net.metrics.IpManagerEvent> CREATOR;
|
||||
field public static final int PROVISIONING_FAIL = 2; // 0x2
|
||||
field public static final int PROVISIONING_OK = 1; // 0x1
|
||||
field public final long durationMs;
|
||||
field public final int eventType;
|
||||
field public final java.lang.String ifName;
|
||||
}
|
||||
|
||||
public final class IpReachabilityEvent extends android.net.metrics.IpConnectivityEvent implements android.os.Parcelable {
|
||||
public final class IpReachabilityEvent implements android.os.Parcelable {
|
||||
method public int describeContents();
|
||||
method public static void logNudFailed(java.lang.String);
|
||||
method public static void logProbeEvent(java.lang.String, int);
|
||||
@@ -26170,7 +26146,7 @@ package android.net.metrics {
|
||||
field public final java.lang.String ifName;
|
||||
}
|
||||
|
||||
public final class NetworkEvent extends android.net.metrics.IpConnectivityEvent implements android.os.Parcelable {
|
||||
public final class NetworkEvent implements android.os.Parcelable {
|
||||
method public int describeContents();
|
||||
method public static void logCaptivePortalFound(int, long);
|
||||
method public static void logEvent(int, int);
|
||||
@@ -26189,7 +26165,7 @@ package android.net.metrics {
|
||||
field public final int netId;
|
||||
}
|
||||
|
||||
public final class ValidationProbeEvent extends android.net.metrics.IpConnectivityEvent implements android.os.Parcelable {
|
||||
public final class ValidationProbeEvent implements android.os.Parcelable {
|
||||
method public int describeContents();
|
||||
method public static void logEvent(int, long, int, int);
|
||||
method public void writeToParcel(android.os.Parcel, int);
|
||||
|
||||
@@ -77,8 +77,8 @@ public final class ConnectivityMetricsEvent implements Parcelable {
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return String.format("ConnectivityMetricsEvent(%d, %d, %d): %s", timestamp,
|
||||
componentTag, eventTag, data);
|
||||
return String.format("ConnectivityMetricsEvent(%tT.%tL, %d, %d): %s",
|
||||
timestamp, timestamp, componentTag, eventTag, data);
|
||||
}
|
||||
|
||||
/** {@hide} */
|
||||
|
||||
@@ -809,17 +809,7 @@ public final class NetworkCapabilities implements Parcelable {
|
||||
@Override
|
||||
public String toString() {
|
||||
int[] types = getTransportTypes();
|
||||
String transports = (types.length > 0 ? " Transports: " : "");
|
||||
for (int i = 0; i < types.length;) {
|
||||
switch (types[i]) {
|
||||
case TRANSPORT_CELLULAR: transports += "CELLULAR"; break;
|
||||
case TRANSPORT_WIFI: transports += "WIFI"; break;
|
||||
case TRANSPORT_BLUETOOTH: transports += "BLUETOOTH"; break;
|
||||
case TRANSPORT_ETHERNET: transports += "ETHERNET"; break;
|
||||
case TRANSPORT_VPN: transports += "VPN"; break;
|
||||
}
|
||||
if (++i < types.length) transports += "|";
|
||||
}
|
||||
String transports = (types.length > 0) ? " Transports: " + transportNamesOf(types) : "";
|
||||
|
||||
types = getCapabilities();
|
||||
String capabilities = (types.length > 0 ? " Capabilities: " : "");
|
||||
@@ -859,4 +849,22 @@ public final class NetworkCapabilities implements Parcelable {
|
||||
|
||||
return "[" + transports + capabilities + upBand + dnBand + specifier + signalStrength + "]";
|
||||
}
|
||||
|
||||
/**
|
||||
* @hide
|
||||
*/
|
||||
public static String transportNamesOf(int[] types) {
|
||||
String transports = "";
|
||||
for (int i = 0; i < types.length;) {
|
||||
switch (types[i]) {
|
||||
case TRANSPORT_CELLULAR: transports += "CELLULAR"; break;
|
||||
case TRANSPORT_WIFI: transports += "WIFI"; break;
|
||||
case TRANSPORT_BLUETOOTH: transports += "BLUETOOTH"; break;
|
||||
case TRANSPORT_ETHERNET: transports += "ETHERNET"; break;
|
||||
case TRANSPORT_VPN: transports += "VPN"; break;
|
||||
}
|
||||
if (++i < types.length) transports += "|";
|
||||
}
|
||||
return transports;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package android.net.metrics;
|
||||
|
||||
import android.annotation.SystemApi;
|
||||
import android.net.NetworkCapabilities;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
@@ -65,6 +66,12 @@ public final class DefaultNetworkEvent extends IpConnectivityEvent implements Pa
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("DefaultNetworkEvent(%d -> %d, %s, IPv4: %b, IPv6: %b)", prevNetId,
|
||||
netId, NetworkCapabilities.transportNamesOf(transportTypes), prevIPv4, prevIPv6);
|
||||
}
|
||||
|
||||
public static final Parcelable.Creator<DefaultNetworkEvent> CREATOR
|
||||
= new Parcelable.Creator<DefaultNetworkEvent>() {
|
||||
public DefaultNetworkEvent createFromParcel(Parcel in) {
|
||||
@@ -78,8 +85,6 @@ public final class DefaultNetworkEvent extends IpConnectivityEvent implements Pa
|
||||
|
||||
public static void logEvent(
|
||||
int netId, int[] transports, int prevNetId, boolean hadIPv4, boolean hadIPv6) {
|
||||
final DefaultNetworkEvent ev =
|
||||
new DefaultNetworkEvent(netId, transports, prevNetId, hadIPv4, hadIPv6);
|
||||
logEvent(IPCE_CONSRV_DEFAULT_NET_CHANGE, ev);
|
||||
logEvent(new DefaultNetworkEvent(netId, transports, prevNetId, hadIPv4, hadIPv6));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -47,6 +47,11 @@ public final class DhcpClientEvent extends IpConnectivityEvent implements Parcel
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("DhcpClientEvent(%s, %s)", ifName, msg);
|
||||
}
|
||||
|
||||
public static final Parcelable.Creator<DhcpClientEvent> CREATOR
|
||||
= new Parcelable.Creator<DhcpClientEvent>() {
|
||||
public DhcpClientEvent createFromParcel(Parcel in) {
|
||||
@@ -59,6 +64,6 @@ public final class DhcpClientEvent extends IpConnectivityEvent implements Parcel
|
||||
};
|
||||
|
||||
public static void logStateEvent(String ifName, String state) {
|
||||
logEvent(IPCE_DHCP_STATE_CHANGE, new DhcpClientEvent(ifName, state));
|
||||
logEvent(new DhcpClientEvent(ifName, state));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -19,6 +19,9 @@ package android.net.metrics;
|
||||
import android.annotation.SystemApi;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import android.util.SparseArray;
|
||||
|
||||
import com.android.internal.util.MessageUtils;
|
||||
|
||||
/**
|
||||
* {@hide} Event class used to record error events when parsing DHCP response packets.
|
||||
@@ -89,11 +92,11 @@ public final class DhcpErrorEvent extends IpConnectivityEvent implements Parcela
|
||||
};
|
||||
|
||||
public static void logParseError(String ifName, int errorCode) {
|
||||
logEvent(IPCE_DHCP_PARSE_ERROR, new DhcpErrorEvent(ifName, errorCode));
|
||||
logEvent(new DhcpErrorEvent(ifName, errorCode));
|
||||
}
|
||||
|
||||
public static void logReceiveError(String ifName) {
|
||||
logEvent(IPCE_DHCP_RECV_ERROR, new DhcpErrorEvent(ifName, RECEIVE_ERROR));
|
||||
logEvent(new DhcpErrorEvent(ifName, RECEIVE_ERROR));
|
||||
}
|
||||
|
||||
public static int errorCodeWithOption(int errorCode, int option) {
|
||||
@@ -103,4 +106,15 @@ public final class DhcpErrorEvent extends IpConnectivityEvent implements Parcela
|
||||
private static int makeErrorCode(int type, int subtype) {
|
||||
return (type << 24) | ((0xFF & subtype) << 16);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("DhcpErrorEvent(%s, %s)", ifName, Decoder.constants.get(errorCode));
|
||||
}
|
||||
|
||||
final static class Decoder {
|
||||
static final SparseArray<String> constants =
|
||||
MessageUtils.findMessageNames(new Class[]{DhcpErrorEvent.class},
|
||||
new String[]{"L2_", "L3_", "L4_", "BOOTP_", "DHCP_", "BUFFER_", "RECEIVE_"});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,6 +63,11 @@ final public class DnsEvent extends IpConnectivityEvent implements Parcelable {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("DnsEvent(%d, %d events)", netId, eventTypes.length);
|
||||
}
|
||||
|
||||
public static final Parcelable.Creator<DnsEvent> CREATOR = new Parcelable.Creator<DnsEvent>() {
|
||||
@Override
|
||||
public DnsEvent createFromParcel(Parcel in) {
|
||||
@@ -77,6 +82,6 @@ final public class DnsEvent extends IpConnectivityEvent implements Parcelable {
|
||||
|
||||
public static void logEvent(
|
||||
int netId, byte[] eventTypes, byte[] returnCodes, int[] latenciesMs) {
|
||||
logEvent(IPCE_DNS_LOOKUPS, new DnsEvent(netId, eventTypes, returnCodes, latenciesMs));
|
||||
logEvent(new DnsEvent(netId, eventTypes, returnCodes, latenciesMs));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package android.net.metrics;
|
||||
|
||||
import android.annotation.SystemApi;
|
||||
import android.net.ConnectivityMetricsLogger;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
@@ -24,50 +23,13 @@ import android.os.Parcelable;
|
||||
/**
|
||||
* {@hide}
|
||||
*/
|
||||
@SystemApi
|
||||
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;
|
||||
public static final int IPCE_CONSRV_BASE = 3 * 1024;
|
||||
public static final int IPCE_IPMGR_BASE = 4 * 1024;
|
||||
public static final int IPCE_DNS_BASE = 5 * 1024;
|
||||
private static final int COMPONENT_TAG = ConnectivityMetricsLogger.COMPONENT_TAG_CONNECTIVITY;
|
||||
|
||||
public static final int IPCE_IPRM_PROBE_STARTED = IPCE_IPRM_BASE + 0;
|
||||
public static final int IPCE_IPRM_PROBE_FAILURE = IPCE_IPRM_BASE + 1;
|
||||
public static final int IPCE_IPRM_NUD_FAILED = IPCE_IPRM_BASE + 2;
|
||||
public static final int IPCE_IPRM_PROVISIONING_LOST = IPCE_IPRM_BASE + 3;
|
||||
private static final ConnectivityMetricsLogger sMetricsLogger = new ConnectivityMetricsLogger();
|
||||
|
||||
public static final int IPCE_DHCP_RECV_ERROR = IPCE_DHCP_BASE + 0;
|
||||
public static final int IPCE_DHCP_PARSE_ERROR = IPCE_DHCP_BASE + 1;
|
||||
public static final int IPCE_DHCP_STATE_CHANGE = IPCE_DHCP_BASE + 2;
|
||||
|
||||
public static final int IPCE_NETMON_STATE_CHANGE = IPCE_NETMON_BASE + 0;
|
||||
public static final int IPCE_NETMON_CHECK_RESULT = IPCE_NETMON_BASE + 1;
|
||||
public static final int IPCE_NETMON_VALIDATED = IPCE_NETMON_BASE + 2;
|
||||
public static final int IPCE_NETMON_PORTAL_PROBE = IPCE_NETMON_BASE + 3;
|
||||
public static final int IPCE_NETMON_CAPPORT_FOUND = IPCE_NETMON_BASE + 4;
|
||||
|
||||
public static final int IPCE_CONSRV_DEFAULT_NET_CHANGE = IPCE_CONSRV_BASE + 0;
|
||||
|
||||
public static final int IPCE_IPMGR_PROVISIONING_OK = IPCE_IPMGR_BASE + 0;
|
||||
public static final int IPCE_IPMGR_PROVISIONING_FAIL = IPCE_IPMGR_BASE + 1;
|
||||
public static final int IPCE_IPMGR_COMPLETE_LIFECYCLE = IPCE_IPMGR_BASE + 2;
|
||||
|
||||
public static final int IPCE_DNS_LOOKUPS = IPCE_DNS_BASE + 0;
|
||||
|
||||
private static ConnectivityMetricsLogger mMetricsLogger = new ConnectivityMetricsLogger();
|
||||
|
||||
public static <T extends IpConnectivityEvent & Parcelable> void logEvent(int tag, T event) {
|
||||
final long timestamp = System.currentTimeMillis();
|
||||
final int componentTag = ConnectivityMetricsLogger.COMPONENT_TAG_CONNECTIVITY;
|
||||
public static <T extends IpConnectivityEvent & Parcelable> void logEvent(T event) {
|
||||
// TODO: consider using different component for DNS event.
|
||||
mMetricsLogger.logEvent(timestamp, componentTag, tag, event);
|
||||
sMetricsLogger.logEvent(System.currentTimeMillis(), COMPONENT_TAG, 0, event);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -19,27 +19,39 @@ package android.net.metrics;
|
||||
import android.annotation.SystemApi;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import android.util.SparseArray;
|
||||
|
||||
import com.android.internal.util.MessageUtils;
|
||||
|
||||
/**
|
||||
* {@hide}
|
||||
*/
|
||||
@SystemApi
|
||||
public final class IpManagerEvent extends IpConnectivityEvent implements Parcelable {
|
||||
|
||||
public static final int PROVISIONING_OK = 1;
|
||||
public static final int PROVISIONING_FAIL = 2;
|
||||
public static final int COMPLETE_LIFECYCLE = 3;
|
||||
|
||||
public final String ifName;
|
||||
public final int eventType;
|
||||
public final long durationMs;
|
||||
|
||||
private IpManagerEvent(String ifName, long duration) {
|
||||
private IpManagerEvent(String ifName, int eventType, long duration) {
|
||||
this.ifName = ifName;
|
||||
this.eventType = eventType;
|
||||
this.durationMs = duration;
|
||||
}
|
||||
|
||||
private IpManagerEvent(Parcel in) {
|
||||
this.ifName = in.readString();
|
||||
this.eventType = in.readInt();
|
||||
this.durationMs = in.readLong();
|
||||
}
|
||||
|
||||
public void writeToParcel(Parcel out, int flags) {
|
||||
out.writeString(ifName);
|
||||
out.writeInt(eventType);
|
||||
out.writeLong(durationMs);
|
||||
}
|
||||
|
||||
@@ -59,6 +71,17 @@ public final class IpManagerEvent extends IpConnectivityEvent implements Parcela
|
||||
};
|
||||
|
||||
public static void logEvent(int eventType, String ifName, long durationMs) {
|
||||
logEvent(eventType, new IpManagerEvent(ifName, durationMs));
|
||||
logEvent(new IpManagerEvent(ifName, eventType, durationMs));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("IpManagerEvent(%s, %s, %dms)",
|
||||
ifName, Decoder.constants.get(eventType), durationMs);
|
||||
}
|
||||
|
||||
final static class Decoder {
|
||||
static final SparseArray<String> constants = MessageUtils.findMessageNames(
|
||||
new Class[]{IpManagerEvent.class}, new String[]{"PROVISIONING_", "COMPLETE_"});
|
||||
}
|
||||
};
|
||||
|
||||
@@ -19,6 +19,9 @@ package android.net.metrics;
|
||||
import android.annotation.SystemApi;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import android.util.SparseArray;
|
||||
|
||||
import com.android.internal.util.MessageUtils;
|
||||
|
||||
/**
|
||||
* {@hide}
|
||||
@@ -69,16 +72,26 @@ public final class IpReachabilityEvent extends IpConnectivityEvent implements Pa
|
||||
};
|
||||
|
||||
public static void logProbeEvent(String ifName, int nlErrorCode) {
|
||||
final int tag = (nlErrorCode == 0) ? IPCE_IPRM_PROBE_STARTED : IPCE_IPRM_PROBE_FAILURE;
|
||||
final int eventType = PROBE | (nlErrorCode & 0xFF);
|
||||
logEvent(tag, new IpReachabilityEvent(ifName, eventType));
|
||||
logEvent(new IpReachabilityEvent(ifName, PROBE | (nlErrorCode & 0xFF)));
|
||||
}
|
||||
|
||||
public static void logNudFailed(String ifName) {
|
||||
logEvent(IPCE_IPRM_NUD_FAILED, new IpReachabilityEvent(ifName, NUD_FAILED));
|
||||
logEvent(new IpReachabilityEvent(ifName, NUD_FAILED));
|
||||
}
|
||||
|
||||
public static void logProvisioningLost(String ifName) {
|
||||
logEvent(IPCE_IPRM_PROVISIONING_LOST, new IpReachabilityEvent(ifName, PROVISIONING_LOST));
|
||||
logEvent(new IpReachabilityEvent(ifName, PROVISIONING_LOST));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("IpReachabilityEvent(%s, %s)", ifName,
|
||||
Decoder.constants.get(eventType));
|
||||
}
|
||||
|
||||
final static class Decoder {
|
||||
static final SparseArray<String> constants =
|
||||
MessageUtils.findMessageNames(new Class[]{IpReachabilityEvent.class},
|
||||
new String[]{"PROBE", "PROVISIONING_", "NUD_"});
|
||||
}
|
||||
};
|
||||
|
||||
@@ -19,6 +19,9 @@ package android.net.metrics;
|
||||
import android.annotation.SystemApi;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import android.util.SparseArray;
|
||||
|
||||
import com.android.internal.util.MessageUtils;
|
||||
|
||||
/**
|
||||
* {@hide}
|
||||
@@ -72,15 +75,25 @@ public final class NetworkEvent extends IpConnectivityEvent implements Parcelabl
|
||||
};
|
||||
|
||||
public static void logEvent(int netId, int eventType) {
|
||||
logEvent(IPCE_NETMON_STATE_CHANGE, new NetworkEvent(netId, eventType, 0));
|
||||
logEvent(new NetworkEvent(netId, eventType, 0));
|
||||
}
|
||||
|
||||
public static void logValidated(int netId, long durationMs) {
|
||||
logEvent(IPCE_NETMON_VALIDATED, new NetworkEvent(netId, NETWORK_VALIDATED, durationMs));
|
||||
logEvent(new NetworkEvent(netId, NETWORK_VALIDATED, durationMs));
|
||||
}
|
||||
|
||||
public static void logCaptivePortalFound(int netId, long durationMs) {
|
||||
final NetworkEvent ev = new NetworkEvent(netId, NETWORK_CAPTIVE_PORTAL_FOUND, durationMs);
|
||||
logEvent(IPCE_NETMON_CAPPORT_FOUND, ev);
|
||||
logEvent(new NetworkEvent(netId, NETWORK_CAPTIVE_PORTAL_FOUND, durationMs));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("NetworkEvent(%d, %s, %dms)",
|
||||
netId, Decoder.constants.get(eventType), durationMs);
|
||||
}
|
||||
|
||||
final static class Decoder {
|
||||
static final SparseArray<String> constants = MessageUtils.findMessageNames(
|
||||
new Class[]{NetworkEvent.class}, new String[]{"NETWORK_"});
|
||||
}
|
||||
};
|
||||
|
||||
@@ -19,6 +19,9 @@ package android.net.metrics;
|
||||
import android.annotation.SystemApi;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import android.util.SparseArray;
|
||||
|
||||
import com.android.internal.util.MessageUtils;
|
||||
|
||||
/**
|
||||
* {@hide}
|
||||
@@ -71,7 +74,17 @@ public final class ValidationProbeEvent extends IpConnectivityEvent implements P
|
||||
};
|
||||
|
||||
public static void logEvent(int netId, long durationMs, int probeType, int returnCode) {
|
||||
logEvent(IPCE_NETMON_PORTAL_PROBE,
|
||||
new ValidationProbeEvent(netId, durationMs, probeType, returnCode));
|
||||
logEvent(new ValidationProbeEvent(netId, durationMs, probeType, returnCode));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("ValidationProbeEvent(%d, %s:%d, %dms)",
|
||||
netId, Decoder.constants.get(probeType), returnCode, durationMs);
|
||||
}
|
||||
|
||||
final static class Decoder {
|
||||
static final SparseArray<String> constants = MessageUtils.findMessageNames(
|
||||
new Class[]{ValidationProbeEvent.class}, new String[]{"PROBE_"});
|
||||
}
|
||||
};
|
||||
|
||||
@@ -348,8 +348,8 @@ public class DhcpClient extends StateMachine {
|
||||
} catch (IOException|ErrnoException e) {
|
||||
if (!mStopped) {
|
||||
Log.e(TAG, "Read error", e);
|
||||
DhcpErrorEvent.logReceiveError(mIfaceName);
|
||||
}
|
||||
DhcpErrorEvent.logReceiveError(mIfaceName);
|
||||
} catch (DhcpPacket.ParseException e) {
|
||||
Log.e(TAG, "Can't parse packet: " + e.getMessage());
|
||||
if (PACKET_DBG) {
|
||||
|
||||
@@ -54,10 +54,6 @@ import java.net.NetworkInterface;
|
||||
import java.net.SocketException;
|
||||
import java.util.Objects;
|
||||
|
||||
import static android.net.metrics.IpConnectivityEvent.IPCE_IPMGR_PROVISIONING_OK;
|
||||
import static android.net.metrics.IpConnectivityEvent.IPCE_IPMGR_PROVISIONING_FAIL;
|
||||
import static android.net.metrics.IpConnectivityEvent.IPCE_IPMGR_COMPLETE_LIFECYCLE;
|
||||
|
||||
|
||||
/**
|
||||
* IpManager
|
||||
@@ -657,13 +653,13 @@ public class IpManager extends StateMachine {
|
||||
switch (delta) {
|
||||
case GAINED_PROVISIONING:
|
||||
if (VDBG) { Log.d(mTag, "onProvisioningSuccess()"); }
|
||||
recordMetric(IPCE_IPMGR_PROVISIONING_OK);
|
||||
recordMetric(IpManagerEvent.PROVISIONING_OK);
|
||||
mCallback.onProvisioningSuccess(newLp);
|
||||
break;
|
||||
|
||||
case LOST_PROVISIONING:
|
||||
if (VDBG) { Log.d(mTag, "onProvisioningFailure()"); }
|
||||
recordMetric(IPCE_IPMGR_PROVISIONING_FAIL);
|
||||
recordMetric(IpManagerEvent.PROVISIONING_FAIL);
|
||||
mCallback.onProvisioningFailure(newLp);
|
||||
break;
|
||||
|
||||
@@ -847,7 +843,7 @@ public class IpManager extends StateMachine {
|
||||
|
||||
resetLinkProperties();
|
||||
if (mStartTimeMillis > 0) {
|
||||
recordMetric(IPCE_IPMGR_COMPLETE_LIFECYCLE);
|
||||
recordMetric(IpManagerEvent.COMPLETE_LIFECYCLE);
|
||||
mStartTimeMillis = 0;
|
||||
}
|
||||
}
|
||||
@@ -960,7 +956,7 @@ public class IpManager extends StateMachine {
|
||||
handleIPv4Success(new DhcpResults(mConfiguration.mStaticIpConfig));
|
||||
} else {
|
||||
if (VDBG) { Log.d(mTag, "onProvisioningFailure()"); }
|
||||
recordMetric(IPCE_IPMGR_PROVISIONING_FAIL);
|
||||
recordMetric(IpManagerEvent.PROVISIONING_FAIL);
|
||||
mCallback.onProvisioningFailure(new LinkProperties(mLinkProperties));
|
||||
transitionTo(mStoppingState);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user