summaryrefslogtreecommitdiff
path: root/framework/java/android/bluetooth/UidTraffic.java
diff options
context:
space:
mode:
authorAdam Lesinski <adamlesinski@google.com>2015-12-04 17:04:54 -0800
committerAdam Lesinski <adamlesinski@google.com>2016-01-18 18:22:55 -0800
commit3b3264d54efc8e9040b7f786e8f359f490b42283 (patch)
tree33bc10cdfdbc76695952c7f615c4099b41dc9685 /framework/java/android/bluetooth/UidTraffic.java
parent031d983a4d68e80b06898b5ac9daed27c8a61f33 (diff)
Record bytes transferred for bluetooth
Bug:26039657 Change-Id: Iec42459d12f4106d5733f55313e8544d58930285
Diffstat (limited to 'framework/java/android/bluetooth/UidTraffic.java')
-rw-r--r--framework/java/android/bluetooth/UidTraffic.java111
1 files changed, 111 insertions, 0 deletions
diff --git a/framework/java/android/bluetooth/UidTraffic.java b/framework/java/android/bluetooth/UidTraffic.java
new file mode 100644
index 0000000000..78013cc0cb
--- /dev/null
+++ b/framework/java/android/bluetooth/UidTraffic.java
@@ -0,0 +1,111 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package android.bluetooth;
+
+import android.os.Parcel;
+import android.os.Parcelable;
+
+/**
+ * Record of data traffic (in bytes) by an application identified by its UID.
+ * @hide
+ */
+public class UidTraffic implements Cloneable, Parcelable {
+ private final int mAppUid;
+ private long mRxBytes;
+ private long mTxBytes;
+
+ public UidTraffic(int appUid) {
+ mAppUid = appUid;
+ }
+
+ public UidTraffic(int appUid, long rx, long tx) {
+ mAppUid = appUid;
+ mRxBytes = rx;
+ mTxBytes = tx;
+ }
+
+ UidTraffic(Parcel in) {
+ mAppUid = in.readInt();
+ mRxBytes = in.readLong();
+ mTxBytes = in.readLong();
+ }
+
+ @Override
+ public void writeToParcel(Parcel dest, int flags) {
+ dest.writeInt(mAppUid);
+ dest.writeLong(mRxBytes);
+ dest.writeLong(mTxBytes);
+ }
+
+ public void setRxBytes(long bytes) {
+ mRxBytes = bytes;
+ }
+
+ public void setTxBytes(long bytes) {
+ mTxBytes = bytes;
+ }
+
+ public void addRxBytes(long bytes) {
+ mRxBytes += bytes;
+ }
+
+ public void addTxBytes(long bytes) {
+ mTxBytes += bytes;
+ }
+
+ public int getUid() {
+ return mAppUid;
+ }
+
+ public long getRxBytes() {
+ return mRxBytes;
+ }
+
+ public long getTxBytes() {
+ return mTxBytes;
+ }
+
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ @Override
+ public UidTraffic clone() {
+ return new UidTraffic(mAppUid, mRxBytes, mTxBytes);
+ }
+
+ @Override
+ public String toString() {
+ return "UidTraffic{" +
+ "mAppUid=" + mAppUid +
+ ", mRxBytes=" + mRxBytes +
+ ", mTxBytes=" + mTxBytes +
+ '}';
+ }
+
+ public static final Creator<UidTraffic> CREATOR = new Creator<UidTraffic>() {
+ @Override
+ public UidTraffic createFromParcel(Parcel source) {
+ return new UidTraffic(source);
+ }
+
+ @Override
+ public UidTraffic[] newArray(int size) {
+ return new UidTraffic[size];
+ }
+ };
+}