blob: 9b534d778302c9a93e00078f23682346e3a67d97 [file] [log] [blame]
Erik Kline5b25a0f2016-04-12 15:31:13 +09001/*
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 */
Hugo Benichi627b4242016-04-15 16:56:28 +090025public final class IpManagerEvent extends IpConnectivityEvent implements Parcelable {
26 public final String ifName;
27 public final long durationMs;
Erik Kline5b25a0f2016-04-12 15:31:13 +090028
Hugo Benichi627b4242016-04-15 16:56:28 +090029 private IpManagerEvent(String ifName, long duration) {
30 this.ifName = ifName;
31 this.durationMs = duration;
Erik Kline5b25a0f2016-04-12 15:31:13 +090032 }
33
Hugo Benichi627b4242016-04-15 16:56:28 +090034 private IpManagerEvent(Parcel in) {
35 this.ifName = in.readString();
36 this.durationMs = in.readLong();
Erik Kline5b25a0f2016-04-12 15:31:13 +090037 }
38
39 public void writeToParcel(Parcel out, int flags) {
Hugo Benichi627b4242016-04-15 16:56:28 +090040 out.writeString(ifName);
41 out.writeLong(durationMs);
42 }
43
44 public int describeContents() {
45 return 0;
Erik Kline5b25a0f2016-04-12 15:31:13 +090046 }
47
48 public static final Parcelable.Creator<IpManagerEvent> CREATOR
49 = new Parcelable.Creator<IpManagerEvent>() {
50 public IpManagerEvent createFromParcel(Parcel in) {
51 return new IpManagerEvent(in);
52 }
53
54 public IpManagerEvent[] newArray(int size) {
55 return new IpManagerEvent[size];
56 }
57 };
58
59 public static void logEvent(int eventType, String ifName, long durationMs) {
Hugo Benichi627b4242016-04-15 16:56:28 +090060 logEvent(eventType, new IpManagerEvent(ifName, durationMs));
Erik Kline5b25a0f2016-04-12 15:31:13 +090061 }
62};