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