Merge "Move connectivity events to frameworks/base." into nyc-dev

am: bc786b7

* commit 'bc786b74759470e52f3f5e80c3f4b5b1c0a52636':
  Move connectivity events to frameworks/base.

Change-Id: Ie6e22bf85a4c0330826f8200fc51c90717d93a33
This commit is contained in:
Pierre Imai
2016-03-30 01:23:27 +00:00
committed by android-build-merger
7 changed files with 21 additions and 0 deletions

View File

@@ -0,0 +1,61 @@
/*
* 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.os.Parcel;
import android.os.Parcelable;
/**
* {@hide}
*/
public class CaptivePortalCheckResultEvent extends IpConnectivityEvent implements Parcelable {
public static final String TAG = "CaptivePortalCheckResultEvent";
private int mNetId;
private int mResult;
public CaptivePortalCheckResultEvent(int netId, int result) {
mNetId = netId;
mResult = result;
}
public CaptivePortalCheckResultEvent(Parcel in) {
mNetId = in.readInt();
mResult = in.readInt();
}
public void writeToParcel(Parcel out, int flags) {
out.writeInt(mNetId);
out.writeInt(mResult);
}
public static final Parcelable.Creator<CaptivePortalCheckResultEvent> CREATOR
= new Parcelable.Creator<CaptivePortalCheckResultEvent>() {
public CaptivePortalCheckResultEvent createFromParcel(Parcel in) {
return new CaptivePortalCheckResultEvent(in);
}
public CaptivePortalCheckResultEvent[] newArray(int size) {
return new CaptivePortalCheckResultEvent[size];
}
};
public static void logEvent(int netId, int result) {
IpConnectivityEvent.logEvent(IpConnectivityEvent.IPCE_NETMON_CHECK_RESULT,
new CaptivePortalCheckResultEvent(netId, result));
}
};

View File

@@ -0,0 +1,60 @@
/*
* 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.os.Parcel;
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 static final int NETWORK_MONITOR_DISCONNECTED = 1;
public static final int NETWORK_MONITOR_VALIDATED = 2;
private int mState;
public CaptivePortalStateChangeEvent(int state) {
mState = state;
}
public CaptivePortalStateChangeEvent(Parcel in) {
mState = in.readInt();
}
public void writeToParcel(Parcel out, int flags) {
out.writeInt(mState);
}
public static final Parcelable.Creator<CaptivePortalStateChangeEvent> CREATOR
= new Parcelable.Creator<CaptivePortalStateChangeEvent>() {
public CaptivePortalStateChangeEvent createFromParcel(Parcel in) {
return new CaptivePortalStateChangeEvent(in);
}
public CaptivePortalStateChangeEvent[] newArray(int size) {
return new CaptivePortalStateChangeEvent[size];
}
};
public static void logEvent(int state) {
IpConnectivityEvent.logEvent(IpConnectivityEvent.IPCE_NETMON_STATE_CHANGE,
new CaptivePortalStateChangeEvent(state));
}
};

View File

@@ -0,0 +1,57 @@
/*
* 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.os.Parcel;
import android.os.Parcelable;
/**
* {@hide}
*/
public class ConnectivityServiceChangeEvent extends IpConnectivityEvent implements Parcelable {
public static final String TAG = "ConnectivityServiceChangeEvent";
private int mNetId;
public ConnectivityServiceChangeEvent(int netId) {
mNetId = netId;
}
public ConnectivityServiceChangeEvent(Parcel in) {
mNetId = in.readInt();
}
public void writeToParcel(Parcel out, int flags) {
out.writeInt(mNetId);
}
public static final Parcelable.Creator<ConnectivityServiceChangeEvent> CREATOR
= new Parcelable.Creator<ConnectivityServiceChangeEvent>() {
public ConnectivityServiceChangeEvent createFromParcel(Parcel in) {
return new ConnectivityServiceChangeEvent(in);
}
public ConnectivityServiceChangeEvent[] newArray(int size) {
return new ConnectivityServiceChangeEvent[size];
}
};
public static void logEvent(int netId) {
IpConnectivityEvent.logEvent(IpConnectivityEvent.IPCE_CONSRV_DEFAULT_NET_CHANGE,
new ConnectivityServiceChangeEvent(netId));
}
};

View File

@@ -0,0 +1,60 @@
/*
* 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.os.Parcel;
import android.os.Parcelable;
/**
* {@hide}
*/
public class DhcpClientEvent extends IpConnectivityEvent implements Parcelable {
public static final String TAG = "DhcpClientEvent";
private String mIfName;
private String mMsg;
public DhcpClientEvent(String ifName, String msg) {
mIfName = ifName;
mMsg = msg;
}
public DhcpClientEvent(Parcel in) {
mIfName = in.readString();
mMsg = in.readString();
}
public void writeToParcel(Parcel out, int flags) {
out.writeString(mIfName);
out.writeString(mMsg);
}
public static final Parcelable.Creator<DhcpClientEvent> CREATOR
= new Parcelable.Creator<DhcpClientEvent>() {
public DhcpClientEvent createFromParcel(Parcel in) {
return new DhcpClientEvent(in);
}
public DhcpClientEvent[] newArray(int size) {
return new DhcpClientEvent[size];
}
};
public static void logEvent(int eventType, String ifName, String msg) {
IpConnectivityEvent.logEvent(eventType, new DhcpClientEvent(ifName, msg));
}
};

View File

@@ -0,0 +1,61 @@
/*
* 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.net.ConnectivityMetricsLogger;
import android.os.Parcel;
import android.os.Parcelable;
/**
* {@hide}
*/
public class IpConnectivityEvent implements Parcelable {
// IPRM = IpReachabilityMonitor
// DHCP = DhcpClient
// NETMON = NetworkMonitorEvent
// CONSRV = ConnectivityServiceEvent
public static final String TAG = "IpConnectivityEvent";
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_IPRM_PROBE_RESULT = IPCE_IPRM_BASE + 0;
public static final int IPCE_IPRM_MESSAGE_RECEIVED = IPCE_IPRM_BASE + 1;
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_TIMEOUT = IPCE_DHCP_BASE + 2;
public static final int IPCE_DHCP_STATE_CHANGE = IPCE_DHCP_BASE + 3;
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_CONSRV_DEFAULT_NET_CHANGE = IPCE_CONSRV_BASE + 0;
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);
}
};

View File

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

View File

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