2 * Copyright (C) 2016 The Android Open Source Project
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package android.net.metrics;
19 import android.annotation.SystemApi;
20 import android.os.Parcel;
21 import android.os.Parcelable;
24 * An event recorded when a DhcpClient state machine transitions to a new state.
28 public final class DhcpClientEvent implements Parcelable {
30 // Names for recording DhcpClient pseudo-state transitions.
31 /** {@hide} Represents transitions from DhcpInitState to DhcpBoundState */
32 public static final String INITIAL_BOUND = "InitialBoundState";
33 /** {@hide} Represents transitions from and to DhcpBoundState via DhcpRenewingState */
34 public static final String RENEWING_BOUND = "RenewingBoundState";
36 public final String ifName;
37 public final String msg;
38 public final int durationMs;
41 public DhcpClientEvent(String ifName, String msg, int durationMs) {
44 this.durationMs = durationMs;
47 private DhcpClientEvent(Parcel in) {
48 this.ifName = in.readString();
49 this.msg = in.readString();
50 this.durationMs = in.readInt();
54 public void writeToParcel(Parcel out, int flags) {
55 out.writeString(ifName);
57 out.writeInt(durationMs);
61 public int describeContents() {
66 public String toString() {
67 return String.format("DhcpClientEvent(%s, %s, %dms)", ifName, msg, durationMs);
70 public static final Parcelable.Creator<DhcpClientEvent> CREATOR
71 = new Parcelable.Creator<DhcpClientEvent>() {
72 public DhcpClientEvent createFromParcel(Parcel in) {
73 return new DhcpClientEvent(in);
76 public DhcpClientEvent[] newArray(int size) {
77 return new DhcpClientEvent[size];
81 public static void logStateEvent(String ifName, String state) {