DhcpClientEvent.java revision bc9cc50947c129d11a282198ac458ffb82fef5bd
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 logEvent(int eventType, String ifName, String msg) {
58        IpConnectivityEvent.logEvent(eventType, new DhcpClientEvent(ifName, msg));
59    }
60};
61