1 /* 2 * Copyright (C) 2016 The Android Open Source Project 3 * 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 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 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. 15 */ 16 17 package android.net.metrics; 18 19 import android.annotation.SystemApi; 20 import android.os.Parcel; 21 import android.os.Parcelable; 22 23 /** 24 * {@hide} 25 */ 26 @SystemApi 27 public final class DhcpClientEvent extends IpConnectivityEvent implements Parcelable { 28 public final String ifName; 29 public final String msg; 30 DhcpClientEvent(String ifName, String msg)31 private DhcpClientEvent(String ifName, String msg) { 32 this.ifName = ifName; 33 this.msg = msg; 34 } 35 DhcpClientEvent(Parcel in)36 private DhcpClientEvent(Parcel in) { 37 this.ifName = in.readString(); 38 this.msg = in.readString(); 39 } 40 writeToParcel(Parcel out, int flags)41 public void writeToParcel(Parcel out, int flags) { 42 out.writeString(ifName); 43 out.writeString(msg); 44 } 45 describeContents()46 public int describeContents() { 47 return 0; 48 } 49 50 @Override toString()51 public String toString() { 52 return String.format("DhcpClientEvent(%s, %s)", ifName, msg); 53 } 54 55 public static final Parcelable.Creator<DhcpClientEvent> CREATOR 56 = new Parcelable.Creator<DhcpClientEvent>() { 57 public DhcpClientEvent createFromParcel(Parcel in) { 58 return new DhcpClientEvent(in); 59 } 60 61 public DhcpClientEvent[] newArray(int size) { 62 return new DhcpClientEvent[size]; 63 } 64 }; 65 logStateEvent(String ifName, String state)66 public static void logStateEvent(String ifName, String state) { 67 logEvent(new DhcpClientEvent(ifName, state)); 68 } 69 }; 70