IpConn metrics: add dhcp transition times
am: 176ed01a1f
Change-Id: I0375b97958614c4a1d1e9f904beef07d55c43462
This commit is contained in:
@@ -26063,6 +26063,7 @@ package android.net.metrics {
|
|||||||
method public static void logStateEvent(java.lang.String, java.lang.String);
|
method public static void logStateEvent(java.lang.String, java.lang.String);
|
||||||
method public void writeToParcel(android.os.Parcel, int);
|
method public void writeToParcel(android.os.Parcel, int);
|
||||||
field public static final android.os.Parcelable.Creator<android.net.metrics.DhcpClientEvent> CREATOR;
|
field public static final android.os.Parcelable.Creator<android.net.metrics.DhcpClientEvent> CREATOR;
|
||||||
|
field public final int durationMs;
|
||||||
field public final java.lang.String ifName;
|
field public final java.lang.String ifName;
|
||||||
field public final java.lang.String msg;
|
field public final java.lang.String msg;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,36 +21,43 @@ import android.os.Parcel;
|
|||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* An event recorded when a DhcpClient state machine transitions to a new state.
|
||||||
* {@hide}
|
* {@hide}
|
||||||
*/
|
*/
|
||||||
@SystemApi
|
@SystemApi
|
||||||
public final class DhcpClientEvent implements Parcelable {
|
public final class DhcpClientEvent implements Parcelable {
|
||||||
public final String ifName;
|
public final String ifName;
|
||||||
public final String msg;
|
public final String msg;
|
||||||
|
public final int durationMs;
|
||||||
|
|
||||||
/** {@hide} */
|
/** {@hide} */
|
||||||
public DhcpClientEvent(String ifName, String msg) {
|
public DhcpClientEvent(String ifName, String msg, int durationMs) {
|
||||||
this.ifName = ifName;
|
this.ifName = ifName;
|
||||||
this.msg = msg;
|
this.msg = msg;
|
||||||
|
this.durationMs = durationMs;
|
||||||
}
|
}
|
||||||
|
|
||||||
private DhcpClientEvent(Parcel in) {
|
private DhcpClientEvent(Parcel in) {
|
||||||
this.ifName = in.readString();
|
this.ifName = in.readString();
|
||||||
this.msg = in.readString();
|
this.msg = in.readString();
|
||||||
|
this.durationMs = in.readInt();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void writeToParcel(Parcel out, int flags) {
|
public void writeToParcel(Parcel out, int flags) {
|
||||||
out.writeString(ifName);
|
out.writeString(ifName);
|
||||||
out.writeString(msg);
|
out.writeString(msg);
|
||||||
|
out.writeInt(durationMs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int describeContents() {
|
public int describeContents() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return String.format("DhcpClientEvent(%s, %s)", ifName, msg);
|
return String.format("DhcpClientEvent(%s, %s, %dms)", ifName, msg, durationMs);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final Parcelable.Creator<DhcpClientEvent> CREATOR
|
public static final Parcelable.Creator<DhcpClientEvent> CREATOR
|
||||||
|
|||||||
@@ -492,10 +492,19 @@ public class DhcpClient extends StateMachine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
abstract class LoggingState extends State {
|
abstract class LoggingState extends State {
|
||||||
|
private long mEnterTimeMs;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void enter() {
|
public void enter() {
|
||||||
if (STATE_DBG) Log.d(TAG, "Entering state " + getName());
|
if (STATE_DBG) Log.d(TAG, "Entering state " + getName());
|
||||||
mMetricsLog.log(new DhcpClientEvent(mIfaceName, getName()));
|
mEnterTimeMs = SystemClock.elapsedRealtime();
|
||||||
|
// TODO: record time for Init -> Bound and Bound -> Renewing -> Bound
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void exit() {
|
||||||
|
long durationMs = SystemClock.elapsedRealtime() - mEnterTimeMs;
|
||||||
|
mMetricsLog.log(new DhcpClientEvent(mIfaceName, getName(), (int) durationMs));
|
||||||
}
|
}
|
||||||
|
|
||||||
private String messageName(int what) {
|
private String messageName(int what) {
|
||||||
@@ -520,6 +529,13 @@ public class DhcpClient extends StateMachine {
|
|||||||
}
|
}
|
||||||
return NOT_HANDLED;
|
return NOT_HANDLED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
// All DhcpClient's states are inner classes with a well defined name.
|
||||||
|
// Use getSimpleName() and avoid super's getName() creating new String instances.
|
||||||
|
return getClass().getSimpleName();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sends CMD_PRE_DHCP_ACTION to the controller, waits for the controller to respond with
|
// Sends CMD_PRE_DHCP_ACTION to the controller, waits for the controller to respond with
|
||||||
@@ -546,10 +562,9 @@ public class DhcpClient extends StateMachine {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class StoppedState extends LoggingState {
|
class StoppedState extends State {
|
||||||
@Override
|
@Override
|
||||||
public boolean processMessage(Message message) {
|
public boolean processMessage(Message message) {
|
||||||
super.processMessage(message);
|
|
||||||
switch (message.what) {
|
switch (message.what) {
|
||||||
case CMD_START_DHCP:
|
case CMD_START_DHCP:
|
||||||
if (mRegisteredForPreDhcpNotification) {
|
if (mRegisteredForPreDhcpNotification) {
|
||||||
@@ -578,10 +593,9 @@ public class DhcpClient extends StateMachine {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class DhcpState extends LoggingState {
|
class DhcpState extends State {
|
||||||
@Override
|
@Override
|
||||||
public void enter() {
|
public void enter() {
|
||||||
super.enter();
|
|
||||||
clearDhcpState();
|
clearDhcpState();
|
||||||
if (initInterface() && initSockets()) {
|
if (initInterface() && initSockets()) {
|
||||||
mReceiveThread = new ReceiveThread();
|
mReceiveThread = new ReceiveThread();
|
||||||
@@ -679,7 +693,9 @@ public class DhcpClient extends StateMachine {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void exit() {
|
public void exit() {
|
||||||
|
super.exit();
|
||||||
mKickAlarm.cancel();
|
mKickAlarm.cancel();
|
||||||
mTimeoutAlarm.cancel();
|
mTimeoutAlarm.cancel();
|
||||||
}
|
}
|
||||||
@@ -784,15 +800,9 @@ public class DhcpClient extends StateMachine {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class DhcpHaveLeaseState extends LoggingState {
|
class DhcpHaveLeaseState extends State {
|
||||||
@Override
|
|
||||||
public void enter() {
|
|
||||||
super.enter();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean processMessage(Message message) {
|
public boolean processMessage(Message message) {
|
||||||
super.processMessage(message);
|
|
||||||
switch (message.what) {
|
switch (message.what) {
|
||||||
case CMD_EXPIRE_DHCP:
|
case CMD_EXPIRE_DHCP:
|
||||||
Log.d(TAG, "Lease expired!");
|
Log.d(TAG, "Lease expired!");
|
||||||
|
|||||||
Reference in New Issue
Block a user