IpManagerEvent.java revision 5b25a0f7960048cbf5929ba144e7a575eb4f7d32
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 IpManagerEvent extends IpConnectivityEvent implements Parcelable {
26    private String mIfName;
27    private long mDurationMs;
28
29    public IpManagerEvent(String ifName, long duration) {
30        mIfName = ifName;
31        mDurationMs = duration;
32    }
33
34    public IpManagerEvent(Parcel in) {
35        mIfName = in.readString();
36        mDurationMs = in.readLong();
37    }
38
39    public void writeToParcel(Parcel out, int flags) {
40        out.writeString(mIfName);
41        out.writeLong(mDurationMs);
42    }
43
44    public static final Parcelable.Creator<IpManagerEvent> CREATOR
45        = new Parcelable.Creator<IpManagerEvent>() {
46        public IpManagerEvent createFromParcel(Parcel in) {
47            return new IpManagerEvent(in);
48        }
49
50        public IpManagerEvent[] newArray(int size) {
51            return new IpManagerEvent[size];
52        }
53    };
54
55    public static void logEvent(int eventType, String ifName, long durationMs) {
56        IpConnectivityEvent.logEvent(eventType, new IpManagerEvent(ifName, durationMs));
57    }
58};
59