ValidationProbeEvent.java revision cc92c6e87773df9d5a84922066716ae9bb09cd6d
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.annotation.SystemApi; 20import android.os.Parcel; 21import android.os.Parcelable; 22 23/** 24 * {@hide} 25 */ 26@SystemApi 27public final class ValidationProbeEvent extends IpConnectivityEvent implements Parcelable { 28 29 public static final int PROBE_HTTP = 0; 30 public static final int PROBE_HTTPS = 1; 31 32 public final int netId; 33 public final long durationMs; 34 public final int probeType; 35 public final int returnCode; 36 37 private ValidationProbeEvent(int netId, long durationMs, int probeType, int returnCode) { 38 this.netId = netId; 39 this.durationMs = durationMs; 40 this.probeType = probeType; 41 this.returnCode = returnCode; 42 } 43 44 private ValidationProbeEvent(Parcel in) { 45 netId = in.readInt(); 46 durationMs = in.readLong(); 47 probeType = in.readInt(); 48 returnCode = in.readInt(); 49 } 50 51 public void writeToParcel(Parcel out, int flags) { 52 out.writeInt(netId); 53 out.writeLong(durationMs); 54 out.writeInt(probeType); 55 out.writeInt(returnCode); 56 } 57 58 public int describeContents() { 59 return 0; 60 } 61 62 public static final Parcelable.Creator<ValidationProbeEvent> CREATOR 63 = new Parcelable.Creator<ValidationProbeEvent>() { 64 public ValidationProbeEvent createFromParcel(Parcel in) { 65 return new ValidationProbeEvent(in); 66 } 67 68 public ValidationProbeEvent[] newArray(int size) { 69 return new ValidationProbeEvent[size]; 70 } 71 }; 72 73 public static void logEvent(int netId, long durationMs, int probeType, int returnCode) { 74 logEvent(IPCE_NETMON_PORTAL_PROBE, 75 new ValidationProbeEvent(netId, durationMs, probeType, returnCode)); 76 } 77}; 78