Debian Codegraph @

core/java/android/net/ConnectivityMetricsEvent.java

raw symbols SCIP
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
19 import android.os.Parcel;
20 import android.os.Parcelable;
21
22 import java.util.BitSet;
23
24 /**
25 * Represents a core networking event defined in package android.net.metrics.
26 * Logged by IpConnectivityLog and managed by ConnectivityMetrics service.
27 * {@hide}
28 * */
29 public final class ConnectivityMetricsEvent implements Parcelable {
30
31 /** Time when this event was collected, as returned by System.currentTimeMillis(). */
32 public long timestamp;
33 /** Transports of the network associated with the event, as defined in NetworkCapabilities. */
34 public long transports;
35 /** Network id of the network associated with the event, or 0 if unspecified. */
36 public int netId;
37 /** Name of the network interface associated with the event, or null if unspecified. */
38 public String ifname;
39 /** Opaque event-specific data. */
40 public Parcelable data;
41
42 public ConnectivityMetricsEvent() {
43 }
44
45 private ConnectivityMetricsEvent(Parcel in) {
46 timestamp = in.readLong();
47 transports = in.readLong();
48 netId = in.readInt();
49 ifname = in.readString();
50 data = in.readParcelable(null);
51 }
52
53 /** Implement the Parcelable interface */
54 public static final @android.annotation.NonNull Parcelable.Creator<ConnectivityMetricsEvent> CREATOR
55 = new Parcelable.Creator<ConnectivityMetricsEvent> (){
56 public ConnectivityMetricsEvent createFromParcel(Parcel source) {
57 return new ConnectivityMetricsEvent(source);
58 }
59
60 public ConnectivityMetricsEvent[] newArray(int size) {
61 return new ConnectivityMetricsEvent[size];
62 }
63 };
64
65 @Override
66 public int describeContents() {
67 return 0;
68 }
69
70 @Override
71 public void writeToParcel(Parcel dest, int flags) {
72 dest.writeLong(timestamp);
73 dest.writeLong(transports);
74 dest.writeInt(netId);
75 dest.writeString(ifname);
76 dest.writeParcelable(data, 0);
77 }
78
79 @Override
80 public String toString() {
81 StringBuilder buffer = new StringBuilder("ConnectivityMetricsEvent(");
82 buffer.append(String.format("%tT.%tL", timestamp, timestamp));
83 if (netId != 0) {
84 buffer.append(", ").append("netId=").append(netId);
85 }
86 if (ifname != null) {
87 buffer.append(", ").append(ifname);
88 }
89 buffer.append(", transports=").append(BitSet.valueOf(new long[] { transports }));
90 buffer.append("): ").append(data.toString());
91 return buffer.toString();
92 }
93 }