Merge "Only write network stats when already loaded." into ics-mr1
This commit is contained in:
@ -203,6 +203,8 @@ public class NetworkStatsService extends INetworkStatsService.Stub {
|
||||
/** Set of historical {@code xtables} stats for known UIDs. */
|
||||
private HashMap<UidStatsKey, NetworkStatsHistory> mUidStats = Maps.newHashMap();
|
||||
|
||||
/** Flag if {@link #mNetworkDevStats} have been loaded from disk. */
|
||||
private boolean mNetworkStatsLoaded = false;
|
||||
/** Flag if {@link #mUidStats} have been loaded from disk. */
|
||||
private boolean mUidStatsLoaded = false;
|
||||
|
||||
@ -272,6 +274,7 @@ public class NetworkStatsService extends INetworkStatsService.Stub {
|
||||
// until actually needed.
|
||||
readNetworkDevStatsLocked();
|
||||
readNetworkXtStatsLocked();
|
||||
mNetworkStatsLoaded = true;
|
||||
}
|
||||
|
||||
// bootstrap initial stats to prevent double-counting later
|
||||
@ -322,14 +325,17 @@ public class NetworkStatsService extends INetworkStatsService.Stub {
|
||||
|
||||
mTeleManager.listen(mPhoneListener, LISTEN_NONE);
|
||||
|
||||
writeNetworkDevStatsLocked();
|
||||
writeNetworkXtStatsLocked();
|
||||
if (mNetworkStatsLoaded) {
|
||||
writeNetworkDevStatsLocked();
|
||||
writeNetworkXtStatsLocked();
|
||||
}
|
||||
if (mUidStatsLoaded) {
|
||||
writeUidStatsLocked();
|
||||
}
|
||||
mNetworkDevStats.clear();
|
||||
mNetworkXtStats.clear();
|
||||
mUidStats.clear();
|
||||
mNetworkStatsLoaded = false;
|
||||
mUidStatsLoaded = false;
|
||||
}
|
||||
|
||||
|
@ -693,12 +693,13 @@ public class NetworkPolicyManagerServiceTest extends AndroidTestCase {
|
||||
expectSetInterfaceQuota(TEST_IFACE, Long.MAX_VALUE);
|
||||
expectMeteredIfacesChanged(TEST_IFACE);
|
||||
|
||||
expectClearNotifications();
|
||||
future = expectClearNotifications();
|
||||
tagFuture = expectEnqueueNotification();
|
||||
|
||||
replay();
|
||||
mService.snoozePolicy(sTemplateWifi);
|
||||
assertNotificationType(TYPE_LIMIT_SNOOZED, tagFuture.get());
|
||||
future.get();
|
||||
verifyAndReset();
|
||||
}
|
||||
}
|
||||
@ -734,9 +735,11 @@ public class NetworkPolicyManagerServiceTest extends AndroidTestCase {
|
||||
expectLastCall().atLeastOnce();
|
||||
}
|
||||
|
||||
private void expectClearNotifications() throws Exception {
|
||||
private Future<Void> expectClearNotifications() throws Exception {
|
||||
final FutureAnswer future = new FutureAnswer();
|
||||
mNotifManager.cancelNotificationWithTag(isA(String.class), isA(String.class), anyInt());
|
||||
expectLastCall().anyTimes();
|
||||
expectLastCall().andAnswer(future).anyTimes();
|
||||
return future;
|
||||
}
|
||||
|
||||
private Future<String> expectEnqueueNotification() throws Exception {
|
||||
|
Reference in New Issue
Block a user