DhcpClientEvent.java revision 627b42494d82eca4fd51abfc0a5d7f330862b881
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 final class DhcpClientEvent extends IpConnectivityEvent implements Parcelable {
26    public final String ifName;
27    public final String msg;
28
29    private DhcpClientEvent(String ifName, String msg) {
30        this.ifName = ifName;
31        this.msg = msg;
32    }
33
34    private DhcpClientEvent(Parcel in) {
35        this.ifName = in.readString();
36        this.msg = in.readString();
37    }
38
39    public void writeToParcel(Parcel out, int flags) {
40        out.writeString(ifName);
41        out.writeString(msg);
42    }
43
44    public int describeContents() {
45        return 0;
46    }
47
48    public static final Parcelable.Creator<DhcpClientEvent> CREATOR
49        = new Parcelable.Creator<DhcpClientEvent>() {
50        public DhcpClientEvent createFromParcel(Parcel in) {
51            return new DhcpClientEvent(in);
52        }
53
54        public DhcpClientEvent[] newArray(int size) {
55            return new DhcpClientEvent[size];
56        }
57    };
58
59    public static void logStateEvent(String ifName, String state) {
60        logEvent(IPCE_DHCP_STATE_CHANGE, new DhcpClientEvent(ifName, state));
61    }
62};
63