Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8acc08ed authored by Hugo Benichi's avatar Hugo Benichi Committed by android-build-merger
Browse files

IpConn metrics: add dhcp transition times am: 176ed01a

am: a2595b3b

Change-Id: Ie7394b77e2200fe80ec0dd62ce83cb476706d354
parents ed15390a a2595b3b
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -26082,6 +26082,7 @@ package android.net.metrics {
    method public static void logStateEvent(java.lang.String, java.lang.String);
    method public void writeToParcel(android.os.Parcel, int);
    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 msg;
  }
+9 −2
Original line number Diff line number Diff line
@@ -21,36 +21,43 @@ import android.os.Parcel;
import android.os.Parcelable;

/**
 *  An event recorded when a DhcpClient state machine transitions to a new state.
 * {@hide}
 */
@SystemApi
public final class DhcpClientEvent implements Parcelable {
    public final String ifName;
    public final String msg;
    public final int durationMs;

    /** {@hide} */
    public DhcpClientEvent(String ifName, String msg) {
    public DhcpClientEvent(String ifName, String msg, int durationMs) {
        this.ifName = ifName;
        this.msg = msg;
        this.durationMs = durationMs;
    }

    private DhcpClientEvent(Parcel in) {
        this.ifName = in.readString();
        this.msg = in.readString();
        this.durationMs = in.readInt();
    }

    @Override
    public void writeToParcel(Parcel out, int flags) {
        out.writeString(ifName);
        out.writeString(msg);
        out.writeInt(durationMs);
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    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
+22 −12
Original line number Diff line number Diff line
@@ -492,10 +492,19 @@ public class DhcpClient extends StateMachine {
    }

    abstract class LoggingState extends State {
        private long mEnterTimeMs;

        @Override
        public void enter() {
            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) {
@@ -520,6 +529,13 @@ public class DhcpClient extends StateMachine {
            }
            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
@@ -546,10 +562,9 @@ public class DhcpClient extends StateMachine {
        }
    }

    class StoppedState extends LoggingState {
    class StoppedState extends State {
        @Override
        public boolean processMessage(Message message) {
            super.processMessage(message);
            switch (message.what) {
                case CMD_START_DHCP:
                    if (mRegisteredForPreDhcpNotification) {
@@ -578,10 +593,9 @@ public class DhcpClient extends StateMachine {
        }
    }

    class DhcpState extends LoggingState {
    class DhcpState extends State {
        @Override
        public void enter() {
            super.enter();
            clearDhcpState();
            if (initInterface() && initSockets()) {
                mReceiveThread = new ReceiveThread();
@@ -679,7 +693,9 @@ public class DhcpClient extends StateMachine {
            }
        }

        @Override
        public void exit() {
            super.exit();
            mKickAlarm.cancel();
            mTimeoutAlarm.cancel();
        }
@@ -784,15 +800,9 @@ public class DhcpClient extends StateMachine {
        }
    }

    class DhcpHaveLeaseState extends LoggingState {
        @Override
        public void enter() {
            super.enter();
        }

    class DhcpHaveLeaseState extends State {
        @Override
        public boolean processMessage(Message message) {
            super.processMessage(message);
            switch (message.what) {
                case CMD_EXPIRE_DHCP:
                    Log.d(TAG, "Lease expired!");