IpManagerEvent.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 IpManagerEvent extends IpConnectivityEvent implements Parcelable { 26 public final String ifName; 27 public final long durationMs; 28 29 private IpManagerEvent(String ifName, long duration) { 30 this.ifName = ifName; 31 this.durationMs = duration; 32 } 33 34 private IpManagerEvent(Parcel in) { 35 this.ifName = in.readString(); 36 this.durationMs = in.readLong(); 37 } 38 39 public void writeToParcel(Parcel out, int flags) { 40 out.writeString(ifName); 41 out.writeLong(durationMs); 42 } 43 44 public int describeContents() { 45 return 0; 46 } 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) { 60 logEvent(eventType, new IpManagerEvent(ifName, durationMs)); 61 } 62}; 63