Migrate network stats from removed users.
When a user is removed, migrate all network stats belonging to that
user into special UID_REMOVED bucket. Also removes those stats from
kernel to avoid double-counting if another user is created.
Bug: 7194784
Change-Id: I03f1d660fe3754566326b7749cae8068fc224ea9
diff --git a/core/java/android/net/NetworkStats.java b/core/java/android/net/NetworkStats.java
index fb7a4f8..446bbf0 100644
--- a/core/java/android/net/NetworkStats.java
+++ b/core/java/android/net/NetworkStats.java
@@ -21,6 +21,7 @@
import android.os.SystemClock;
import android.util.SparseBooleanArray;
+import com.android.internal.util.ArrayUtils;
import com.android.internal.util.Objects;
import java.io.CharArrayWriter;
@@ -608,13 +609,13 @@
* Return all rows except those attributed to the requested UID; doesn't
* mutate the original structure.
*/
- public NetworkStats withoutUid(int uid) {
+ public NetworkStats withoutUids(int[] uids) {
final NetworkStats stats = new NetworkStats(elapsedRealtime, 10);
Entry entry = new Entry();
for (int i = 0; i < size; i++) {
entry = getValues(i, entry);
- if (entry.uid != uid) {
+ if (!ArrayUtils.contains(uids, entry.uid)) {
stats.addValues(entry);
}
}