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
This commit is contained in:
Jeff Sharkey
2012-09-19 14:10:39 -07:00
parent 77127d1c93
commit 8c8309a6fe
4 changed files with 85 additions and 23 deletions

View File

@@ -21,6 +21,7 @@ import android.os.Parcelable;
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 @@ public class NetworkStats implements Parcelable {
* 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);
}
}