blob: d040a8563440a549eaa18a821ec76ae042014c22 [file] [log] [blame]
Pavel Zhamaitsiak02b3e6b2016-02-03 10:39:44 -08001/*
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;
18
19import android.annotation.SystemApi;
20import android.os.Parcel;
21import android.os.Parcelable;
22
23@SystemApi
24public class ConnectivityMetricsEvent implements Parcelable {
25
26 /** The time when this event was collected, as returned by System.currentTimeMillis(). */
27 final public long timestamp;
28
29 /** The subsystem that generated the event. One of the COMPONENT_TAG_xxx constants. */
30 final public int componentTag;
31
32 /** The subsystem-specific event ID. */
33 final public int eventTag;
34
35 /** Opaque event-specific data. */
36 final public Parcelable data;
37
38 public ConnectivityMetricsEvent(long timestamp, int componentTag,
39 int eventTag, Parcelable data) {
40 this.timestamp = timestamp;
41 this.componentTag = componentTag;
42 this.eventTag = eventTag;
43 this.data = data;
44 }
45
46 /** Implement the Parcelable interface */
47 public static final Parcelable.Creator<ConnectivityMetricsEvent> CREATOR
48 = new Parcelable.Creator<ConnectivityMetricsEvent> (){
49 public ConnectivityMetricsEvent createFromParcel(Parcel source) {
50 final long timestamp = source.readLong();
51 final int componentTag = source.readInt();
52 final int eventTag = source.readInt();
53 final Parcelable data = source.readParcelable(null);
54 return new ConnectivityMetricsEvent(timestamp, componentTag,
55 eventTag, data);
56 }
57
58 public ConnectivityMetricsEvent[] newArray(int size) {
59 return new ConnectivityMetricsEvent[size];
60 }
61 };
62
63 /** Implement the Parcelable interface */
64 @Override
65 public int describeContents() {
66 return 0;
67 }
68
69 /** Implement the Parcelable interface */
70 @Override
71 public void writeToParcel(Parcel dest, int flags) {
72 dest.writeLong(timestamp);
73 dest.writeInt(componentTag);
74 dest.writeInt(eventTag);
75 dest.writeParcelable(data, 0);
76 }
77
78 public String toString() {
79 return String.format("ConnectivityMetricsEvent(%d, %d, %d)", timestamp,
80 componentTag, eventTag);
81 }
82}