From 84a92fd256311b4a3ca9985fa87d0efa1c360ac3 Mon Sep 17 00:00:00 2001 From: Antonio Cansado Date: Fri, 22 Apr 2016 11:23:27 -0700 Subject: [PATCH] Fixing network tags. - History was not populating the tag, so all of them appeared as tag 0x0. Bug: 28345240 Change-Id: I9c898695bbe8d18531f7ea432ebb8f02d72e5d27 --- core/java/android/app/usage/NetworkStats.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/core/java/android/app/usage/NetworkStats.java b/core/java/android/app/usage/NetworkStats.java index 6d5c81b142..9963eab9b9 100644 --- a/core/java/android/app/usage/NetworkStats.java +++ b/core/java/android/app/usage/NetworkStats.java @@ -63,6 +63,11 @@ public final class NetworkStats implements AutoCloseable { */ private int mUidOrUidIndex; + /** + * Tag id in case if was specified in the query. + */ + private int mTag = android.net.NetworkStats.TAG_NONE; + /** * The session while the query requires it, null if all the stats have been collected or close() * has been called. @@ -434,7 +439,7 @@ public final class NetworkStats implements AutoCloseable { mHistory = mSession.getHistoryIntervalForUid(mTemplate, uid, android.net.NetworkStats.SET_ALL, tag, NetworkStatsHistory.FIELD_ALL, mStartTimeStamp, mEndTimeStamp); - setSingleUid(uid); + setSingleUidTag(uid, tag); } catch (RemoteException e) { Log.w(TAG, e); // Leaving mHistory null @@ -538,6 +543,7 @@ public final class NetworkStats implements AutoCloseable { mRecycledHistoryEntry = mHistory.getValues(mEnumerationIndex++, mRecycledHistoryEntry); bucketOut.mUid = Bucket.convertUid(getUid()); + bucketOut.mTag = Bucket.convertTag(mTag); bucketOut.mState = Bucket.STATE_ALL; bucketOut.mRoaming = Bucket.ROAMING_ALL; bucketOut.mBeginTimeStamp = mRecycledHistoryEntry.bucketStart; @@ -579,8 +585,9 @@ public final class NetworkStats implements AutoCloseable { return mUidOrUidIndex; } - private void setSingleUid(int uid) { + private void setSingleUidTag(int uid, int tag) { mUidOrUidIndex = uid; + mTag = tag; } private void stepUid() {