Skip to content

Commit d04ff11

Browse files
committed
Avoid NPE when missing network stats.
Bug: 5750339 Change-Id: I4b739dbd076b270a5a2b2e2a1e0f6e445d8c124e
1 parent 359bb3b commit d04ff11

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

services/java/com/android/server/net/NetworkStatsService.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1060,8 +1060,10 @@ private void removeUidLocked(int uid) {
10601060
}
10611061

10621062
// clear UID from current stats snapshot
1063-
mLastPollUidSnapshot = mLastPollUidSnapshot.withoutUid(uid);
1064-
mLastPollNetworkXtSnapshot = computeNetworkXtSnapshotFromUid(mLastPollUidSnapshot);
1063+
if (mLastPollUidSnapshot != null) {
1064+
mLastPollUidSnapshot = mLastPollUidSnapshot.withoutUid(uid);
1065+
mLastPollNetworkXtSnapshot = computeNetworkXtSnapshotFromUid(mLastPollUidSnapshot);
1066+
}
10651067

10661068
// clear kernel stats associated with UID
10671069
resetKernelUidStats(uid);

0 commit comments

Comments
 (0)