From b9439a4c2aa58d42336ede9b98f1bb16f5afc00c Mon Sep 17 00:00:00 2001 From: Jeff Sharkey Date: Wed, 9 May 2012 19:59:07 -0700 Subject: [PATCH] Avoid updating thresholds during shutdown. Bug: 6472388 Change-Id: I70e1ed5dc75056840f2f0b130ce0dfecb06f385e --- .../java/com/android/server/net/NetworkStatsService.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/services/java/com/android/server/net/NetworkStatsService.java b/services/java/com/android/server/net/NetworkStatsService.java index e710b3389e..0e93b0affc 100644 --- a/services/java/com/android/server/net/NetworkStatsService.java +++ b/services/java/com/android/server/net/NetworkStatsService.java @@ -608,17 +608,19 @@ public class NetworkStatsService extends INetworkStatsService.Stub { // clamp threshold into safe range mPersistThreshold = MathUtils.constrain(thresholdBytes, 128 * KB_IN_BYTES, 2 * MB_IN_BYTES); - updatePersistThresholds(); - if (LOGV) { Slog.v(TAG, "advisePersistThreshold() given " + thresholdBytes + ", clamped to " + mPersistThreshold); } - // persist if beyond new thresholds + // update and persist if beyond new thresholds final long currentTime = mTime.hasCache() ? mTime.currentTimeMillis() : System.currentTimeMillis(); synchronized (mStatsLock) { + if (!mSystemReady) return; + + updatePersistThresholds(); + mDevRecorder.maybePersistLocked(currentTime); mXtRecorder.maybePersistLocked(currentTime); mUidRecorder.maybePersistLocked(currentTime);