Loading core/java/android/net/metrics/DhcpClientEvent.java +8 −1 Original line number Diff line number Diff line Loading @@ -26,6 +26,13 @@ import android.os.Parcelable; */ @SystemApi public final class DhcpClientEvent implements Parcelable { // Names for recording DhcpClient pseudo-state transitions. /** {@hide} Represents transitions from DhcpInitState to DhcpBoundState */ public static final String INITIAL_BOUND = "InitialBoundState"; /** {@hide} Represents transitions from and to DhcpBoundState via DhcpRenewingState */ public static final String RENEWING_BOUND = "RenewingBoundState"; public final String ifName; public final String msg; public final int durationMs; Loading services/net/java/android/net/dhcp/DhcpClient.java +26 −2 Original line number Diff line number Diff line Loading @@ -194,6 +194,10 @@ public class DhcpClient extends StateMachine { private long mDhcpLeaseExpiry; private DhcpResults mOffer; // Milliseconds SystemClock timestamps used to record transition times to DhcpBoundState. private long mLastInitEnterTime; private long mLastBoundExitTime; // States. private State mStoppedState = new StoppedState(); private State mDhcpState = new DhcpState(); Loading Loading @@ -498,13 +502,12 @@ public class DhcpClient extends StateMachine { public void enter() { if (STATE_DBG) Log.d(TAG, "Entering state " + 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)); logState(getName(), (int) durationMs); } private String messageName(int what) { Loading Loading @@ -742,6 +745,7 @@ public class DhcpClient extends StateMachine { public void enter() { super.enter(); startNewTransaction(); mLastInitEnterTime = SystemClock.elapsedRealtime(); } protected boolean sendPacket() { Loading Loading @@ -866,6 +870,13 @@ public class DhcpClient extends StateMachine { } scheduleLeaseTimers(); logTimeToBoundState(); } @Override public void exit() { super.exit(); mLastBoundExitTime = SystemClock.elapsedRealtime(); } @Override Loading @@ -883,6 +894,15 @@ public class DhcpClient extends StateMachine { return NOT_HANDLED; } } private void logTimeToBoundState() { long now = SystemClock.elapsedRealtime(); if (mLastBoundExitTime > mLastInitEnterTime) { logState(DhcpClientEvent.RENEWING_BOUND, (int)(now - mLastBoundExitTime)); } else { logState(DhcpClientEvent.INITIAL_BOUND, (int)(now - mLastInitEnterTime)); } } } abstract class DhcpReacquiringState extends PacketRetransmittingState { Loading Loading @@ -993,4 +1013,8 @@ public class DhcpClient extends StateMachine { private void logError(int errorCode) { mMetricsLog.log(new DhcpErrorEvent(mIfaceName, errorCode)); } private void logState(String name, int durationMs) { mMetricsLog.log(new DhcpClientEvent(mIfaceName, name, durationMs)); } } Loading
core/java/android/net/metrics/DhcpClientEvent.java +8 −1 Original line number Diff line number Diff line Loading @@ -26,6 +26,13 @@ import android.os.Parcelable; */ @SystemApi public final class DhcpClientEvent implements Parcelable { // Names for recording DhcpClient pseudo-state transitions. /** {@hide} Represents transitions from DhcpInitState to DhcpBoundState */ public static final String INITIAL_BOUND = "InitialBoundState"; /** {@hide} Represents transitions from and to DhcpBoundState via DhcpRenewingState */ public static final String RENEWING_BOUND = "RenewingBoundState"; public final String ifName; public final String msg; public final int durationMs; Loading
services/net/java/android/net/dhcp/DhcpClient.java +26 −2 Original line number Diff line number Diff line Loading @@ -194,6 +194,10 @@ public class DhcpClient extends StateMachine { private long mDhcpLeaseExpiry; private DhcpResults mOffer; // Milliseconds SystemClock timestamps used to record transition times to DhcpBoundState. private long mLastInitEnterTime; private long mLastBoundExitTime; // States. private State mStoppedState = new StoppedState(); private State mDhcpState = new DhcpState(); Loading Loading @@ -498,13 +502,12 @@ public class DhcpClient extends StateMachine { public void enter() { if (STATE_DBG) Log.d(TAG, "Entering state " + 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)); logState(getName(), (int) durationMs); } private String messageName(int what) { Loading Loading @@ -742,6 +745,7 @@ public class DhcpClient extends StateMachine { public void enter() { super.enter(); startNewTransaction(); mLastInitEnterTime = SystemClock.elapsedRealtime(); } protected boolean sendPacket() { Loading Loading @@ -866,6 +870,13 @@ public class DhcpClient extends StateMachine { } scheduleLeaseTimers(); logTimeToBoundState(); } @Override public void exit() { super.exit(); mLastBoundExitTime = SystemClock.elapsedRealtime(); } @Override Loading @@ -883,6 +894,15 @@ public class DhcpClient extends StateMachine { return NOT_HANDLED; } } private void logTimeToBoundState() { long now = SystemClock.elapsedRealtime(); if (mLastBoundExitTime > mLastInitEnterTime) { logState(DhcpClientEvent.RENEWING_BOUND, (int)(now - mLastBoundExitTime)); } else { logState(DhcpClientEvent.INITIAL_BOUND, (int)(now - mLastInitEnterTime)); } } } abstract class DhcpReacquiringState extends PacketRetransmittingState { Loading Loading @@ -993,4 +1013,8 @@ public class DhcpClient extends StateMachine { private void logError(int errorCode) { mMetricsLog.log(new DhcpErrorEvent(mIfaceName, errorCode)); } private void logState(String name, int durationMs) { mMetricsLog.log(new DhcpClientEvent(mIfaceName, name, durationMs)); } }