summaryrefslogtreecommitdiff
path: root/core/java/android
diff options
context:
space:
mode:
authorTreeHugger Robot <treehugger-gerrit@google.com>2016-04-21 05:24:38 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2016-04-21 05:24:40 +0000
commitb99d6af3ab406db14d161cdc0000ed521957d7ca (patch)
treeb6a41bba6f5db5feb17a394051d857ebdf8c1f1c /core/java/android
parent7261fb27de16bb6d3ebd81bd3b73062bd212ea7e (diff)
parenta488c23dd5c9e024fb8ec702cee722916cdeaf0e (diff)
Merge "Expand NetworkMonitor metrics" into nyc-dev
Diffstat (limited to 'core/java/android')
-rw-r--r--core/java/android/net/metrics/CaptivePortalStateChangeEvent.java10
-rw-r--r--core/java/android/net/metrics/IpConnectivityEvent.java3
-rw-r--r--core/java/android/net/metrics/NetworkMonitorEvent.java80
3 files changed, 90 insertions, 3 deletions
diff --git a/core/java/android/net/metrics/CaptivePortalStateChangeEvent.java b/core/java/android/net/metrics/CaptivePortalStateChangeEvent.java
index aabd09b1ec07..a67589af2563 100644
--- a/core/java/android/net/metrics/CaptivePortalStateChangeEvent.java
+++ b/core/java/android/net/metrics/CaptivePortalStateChangeEvent.java
@@ -29,17 +29,21 @@ public final class CaptivePortalStateChangeEvent extends IpConnectivityEvent imp
public static final int NETWORK_MONITOR_DISCONNECTED = 1;
public static final int NETWORK_MONITOR_VALIDATED = 2;
+ public final int netId;
public final int state;
- public CaptivePortalStateChangeEvent(int state) {
+ public CaptivePortalStateChangeEvent(int netId, int state) {
+ this.netId = netId;
this.state = state;
}
public CaptivePortalStateChangeEvent(Parcel in) {
+ netId = in.readInt();
state = in.readInt();
}
public void writeToParcel(Parcel out, int flags) {
+ out.writeInt(netId);
out.writeInt(state);
}
@@ -58,7 +62,7 @@ public final class CaptivePortalStateChangeEvent extends IpConnectivityEvent imp
}
};
- public static void logEvent(int state) {
- logEvent(IPCE_NETMON_STATE_CHANGE, new CaptivePortalStateChangeEvent(state));
+ public static void logEvent(int netId, int state) {
+ logEvent(IPCE_NETMON_STATE_CHANGE, new CaptivePortalStateChangeEvent(netId, state));
}
};
diff --git a/core/java/android/net/metrics/IpConnectivityEvent.java b/core/java/android/net/metrics/IpConnectivityEvent.java
index d455a0fcdaa5..0b5e3544fe8c 100644
--- a/core/java/android/net/metrics/IpConnectivityEvent.java
+++ b/core/java/android/net/metrics/IpConnectivityEvent.java
@@ -50,6 +50,9 @@ public abstract class IpConnectivityEvent {
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;
diff --git a/core/java/android/net/metrics/NetworkMonitorEvent.java b/core/java/android/net/metrics/NetworkMonitorEvent.java
new file mode 100644
index 000000000000..23712661b9d5
--- /dev/null
+++ b/core/java/android/net/metrics/NetworkMonitorEvent.java
@@ -0,0 +1,80 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.net.metrics;
+
+import android.annotation.SystemApi;
+import android.os.Parcel;
+import android.os.Parcelable;
+
+/**
+ * {@hide}
+ */
+@SystemApi
+public final class NetworkMonitorEvent extends IpConnectivityEvent implements Parcelable {
+ public final int netId;
+ public final long durationMs;
+ public final int returnCode;
+
+ private NetworkMonitorEvent(int netId, long durationMs, int returnCode) {
+ this.netId = netId;
+ this.durationMs = durationMs;
+ this.returnCode = returnCode;
+ }
+
+ public NetworkMonitorEvent(Parcel in) {
+ netId = in.readInt();
+ durationMs = in.readLong();
+ returnCode = in.readInt();
+ }
+
+ public void writeToParcel(Parcel out, int flags) {
+ out.writeInt(netId);
+ out.writeLong(durationMs);
+ out.writeInt(returnCode);
+ }
+
+ public int describeContents() {
+ return 0;
+ }
+
+ public static final Parcelable.Creator<NetworkMonitorEvent> CREATOR
+ = new Parcelable.Creator<NetworkMonitorEvent>() {
+ public NetworkMonitorEvent createFromParcel(Parcel in) {
+ return new NetworkMonitorEvent(in);
+ }
+
+ public NetworkMonitorEvent[] newArray(int size) {
+ return new NetworkMonitorEvent[size];
+ }
+ };
+
+ private static void logEvent(int eventType, int netId, long durationMs, int returnCode) {
+ logEvent(eventType, new NetworkMonitorEvent(netId, durationMs, returnCode));
+ }
+
+ public static void logValidated(int netId, long durationMs) {
+ logEvent(IPCE_NETMON_VALIDATED, netId, durationMs, 0);
+ }
+
+ public static void logPortalProbeEvent(int netId, long durationMs, int returnCode) {
+ logEvent(IPCE_NETMON_PORTAL_PROBE, netId, durationMs, returnCode);
+ }
+
+ public static void logCaptivePortalFound(int netId, long durationMs) {
+ logEvent(IPCE_NETMON_CAPPORT_FOUND, netId, durationMs, 0);
+ }
+};