DhcpClientEvent.java revision 2677b1957b444e2dae5737feee989109b811547c
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 17package android.net.metrics; 18 19import android.os.Parcel; 20import android.os.Parcelable; 21 22/** 23 * {@hide} 24 */ 25public class DhcpClientEvent extends IpConnectivityEvent implements Parcelable { 26 public static final String TAG = "DhcpClientEvent"; 27 28 private String mIfName; 29 private String mMsg; 30 31 public DhcpClientEvent(String ifName, String msg) { 32 mIfName = ifName; 33 mMsg = msg; 34 } 35 36 public DhcpClientEvent(Parcel in) { 37 mIfName = in.readString(); 38 mMsg = in.readString(); 39 } 40 41 public void writeToParcel(Parcel out, int flags) { 42 out.writeString(mIfName); 43 out.writeString(mMsg); 44 } 45 46 public static final Parcelable.Creator<DhcpClientEvent> CREATOR 47 = new Parcelable.Creator<DhcpClientEvent>() { 48 public DhcpClientEvent createFromParcel(Parcel in) { 49 return new DhcpClientEvent(in); 50 } 51 52 public DhcpClientEvent[] newArray(int size) { 53 return new DhcpClientEvent[size]; 54 } 55 }; 56 57 public static void logStateEvent(String ifName, String state) { 58 logEvent(IpConnectivityEvent.IPCE_DHCP_STATE_CHANGE, new DhcpClientEvent(ifName, state)); 59 } 60}; 61