Loading services/java/com/android/server/ThrottleService.java +19 −16 Original line number Diff line number Diff line Loading @@ -125,7 +125,7 @@ public class ThrottleService extends IThrottleManager.Stub { private boolean mNtpActive; public ThrottleService(Context context) { if (DBG) Slog.d(TAG, "Starting ThrottleService"); if (VDBG) Slog.v(TAG, "Starting ThrottleService"); mContext = context; mPolicyThreshold = new AtomicLong(); Loading Loading @@ -295,7 +295,7 @@ public class ThrottleService extends IThrottleManager.Stub { } void systemReady() { if (DBG) Slog.d(TAG, "systemReady"); if (VDBG) Slog.v(TAG, "systemReady"); mContext.registerReceiver( new BroadcastReceiver() { @Override Loading Loading @@ -378,7 +378,7 @@ public class ThrottleService extends IThrottleManager.Stub { } private void onRebootRecovery() { if (DBG) Slog.d(TAG, "onRebootRecovery"); if (VDBG) Slog.v(TAG, "onRebootRecovery"); // check for sim change TODO // reregister for notification of policy change Loading Loading @@ -443,10 +443,13 @@ public class ThrottleService extends IThrottleManager.Stub { mMaxNtpCacheAgeSec = Settings.Secure.getInt(mContext.getContentResolver(), Settings.Secure.THROTTLE_MAX_NTP_CACHE_AGE_SEC, MAX_NTP_CACHE_AGE_SEC); Slog.d(TAG, "onPolicyChanged testing=" + testing +", period=" + mPolicyPollPeriodSec + ", threshold=" + mPolicyThreshold.get() + ", value=" + mPolicyThrottleValue.get() + ", resetDay=" + mPolicyResetDay + ", noteType=" + mPolicyNotificationsAllowedMask + ", maxNtpCacheAge=" + mMaxNtpCacheAgeSec); if (VDBG || (mPolicyThreshold.get() != 0)) { Slog.d(TAG, "onPolicyChanged testing=" + testing +", period=" + mPolicyPollPeriodSec + ", threshold=" + mPolicyThreshold.get() + ", value=" + mPolicyThrottleValue.get() + ", resetDay=" + mPolicyResetDay + ", noteType=" + mPolicyNotificationsAllowedMask + ", maxNtpCacheAge=" + mMaxNtpCacheAgeSec); } // force updates mThrottleIndex.set(THROTTLE_INDEX_UNINITIALIZED); Loading Loading @@ -491,7 +494,7 @@ public class ThrottleService extends IThrottleManager.Stub { long periodRx = mRecorder.getPeriodRx(0); long periodTx = mRecorder.getPeriodTx(0); long total = periodRx + periodTx; if (DBG) { if (VDBG || (mPolicyThreshold.get() != 0)) { Slog.d(TAG, "onPollAlarm - roaming =" + roaming + ", read =" + incRead + ", written =" + incWrite + ", new total =" + total); } Loading @@ -508,7 +511,7 @@ public class ThrottleService extends IThrottleManager.Stub { mContext.sendStickyBroadcast(broadcast); mAlarmManager.cancel(mPendingPollIntent); mAlarmManager.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, next, mPendingPollIntent); mAlarmManager.set(AlarmManager.ELAPSED_REALTIME, next, mPendingPollIntent); } private void onIfaceUp() { Loading Loading @@ -689,7 +692,7 @@ public class ThrottleService extends IThrottleManager.Stub { } private void onResetAlarm() { if (DBG) { if (VDBG || (mPolicyThreshold.get() != 0)) { Slog.d(TAG, "onResetAlarm - last period had " + mRecorder.getPeriodRx(0) + " bytes read and " + mRecorder.getPeriodTx(0) + " written"); } Loading @@ -707,11 +710,11 @@ public class ThrottleService extends IThrottleManager.Stub { mAlarmManager.cancel(mPendingResetIntent); long offset = end.getTimeInMillis() - now; // use Elapsed realtime so clock changes don't fool us. mAlarmManager.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, mAlarmManager.set(AlarmManager.ELAPSED_REALTIME, SystemClock.elapsedRealtime() + offset, mPendingResetIntent); } else { if (DBG) Slog.d(TAG, "no authoritative time - not resetting period"); if (VDBG) Slog.d(TAG, "no authoritative time - not resetting period"); } } } Loading Loading @@ -748,7 +751,7 @@ public class ThrottleService extends IThrottleManager.Stub { cachedNtpTimestamp = SystemClock.elapsedRealtime(); if (!mNtpActive) { mNtpActive = true; if (DBG) Slog.d(TAG, "found Authoritative time - reseting alarm"); if (VDBG) Slog.d(TAG, "found Authoritative time - reseting alarm"); mHandler.obtainMessage(EVENT_RESET_ALARM).sendToTarget(); } if (VDBG) Slog.v(TAG, "using Authoritative time: " + cachedNtp); Loading Loading @@ -807,13 +810,13 @@ public class ThrottleService extends IThrottleManager.Stub { if (start.equals(mPeriodStart) && end.equals(mPeriodEnd)) { // same endpoints - keep collecting if (DBG) { if (VDBG) { Slog.d(TAG, "same period (" + start.getTimeInMillis() + "," + end.getTimeInMillis() +") - ammending data"); } startNewPeriod = false; } else { if (DBG) { if (VDBG) { if(start.equals(mPeriodEnd) || start.after(mPeriodEnd)) { Slog.d(TAG, "next period (" + start.getTimeInMillis() + "," + end.getTimeInMillis() + ") - old end was " + Loading Loading @@ -917,7 +920,7 @@ public class ThrottleService extends IThrottleManager.Stub { mImsi = mTelephonyManager.getSubscriberId(); if (mImsi == null) return; if (DBG) Slog.d(TAG, "finally have imsi - retreiving data"); if (VDBG) Slog.d(TAG, "finally have imsi - retreiving data"); retrieve(); } Loading Loading
services/java/com/android/server/ThrottleService.java +19 −16 Original line number Diff line number Diff line Loading @@ -125,7 +125,7 @@ public class ThrottleService extends IThrottleManager.Stub { private boolean mNtpActive; public ThrottleService(Context context) { if (DBG) Slog.d(TAG, "Starting ThrottleService"); if (VDBG) Slog.v(TAG, "Starting ThrottleService"); mContext = context; mPolicyThreshold = new AtomicLong(); Loading Loading @@ -295,7 +295,7 @@ public class ThrottleService extends IThrottleManager.Stub { } void systemReady() { if (DBG) Slog.d(TAG, "systemReady"); if (VDBG) Slog.v(TAG, "systemReady"); mContext.registerReceiver( new BroadcastReceiver() { @Override Loading Loading @@ -378,7 +378,7 @@ public class ThrottleService extends IThrottleManager.Stub { } private void onRebootRecovery() { if (DBG) Slog.d(TAG, "onRebootRecovery"); if (VDBG) Slog.v(TAG, "onRebootRecovery"); // check for sim change TODO // reregister for notification of policy change Loading Loading @@ -443,10 +443,13 @@ public class ThrottleService extends IThrottleManager.Stub { mMaxNtpCacheAgeSec = Settings.Secure.getInt(mContext.getContentResolver(), Settings.Secure.THROTTLE_MAX_NTP_CACHE_AGE_SEC, MAX_NTP_CACHE_AGE_SEC); Slog.d(TAG, "onPolicyChanged testing=" + testing +", period=" + mPolicyPollPeriodSec + ", threshold=" + mPolicyThreshold.get() + ", value=" + mPolicyThrottleValue.get() + ", resetDay=" + mPolicyResetDay + ", noteType=" + mPolicyNotificationsAllowedMask + ", maxNtpCacheAge=" + mMaxNtpCacheAgeSec); if (VDBG || (mPolicyThreshold.get() != 0)) { Slog.d(TAG, "onPolicyChanged testing=" + testing +", period=" + mPolicyPollPeriodSec + ", threshold=" + mPolicyThreshold.get() + ", value=" + mPolicyThrottleValue.get() + ", resetDay=" + mPolicyResetDay + ", noteType=" + mPolicyNotificationsAllowedMask + ", maxNtpCacheAge=" + mMaxNtpCacheAgeSec); } // force updates mThrottleIndex.set(THROTTLE_INDEX_UNINITIALIZED); Loading Loading @@ -491,7 +494,7 @@ public class ThrottleService extends IThrottleManager.Stub { long periodRx = mRecorder.getPeriodRx(0); long periodTx = mRecorder.getPeriodTx(0); long total = periodRx + periodTx; if (DBG) { if (VDBG || (mPolicyThreshold.get() != 0)) { Slog.d(TAG, "onPollAlarm - roaming =" + roaming + ", read =" + incRead + ", written =" + incWrite + ", new total =" + total); } Loading @@ -508,7 +511,7 @@ public class ThrottleService extends IThrottleManager.Stub { mContext.sendStickyBroadcast(broadcast); mAlarmManager.cancel(mPendingPollIntent); mAlarmManager.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, next, mPendingPollIntent); mAlarmManager.set(AlarmManager.ELAPSED_REALTIME, next, mPendingPollIntent); } private void onIfaceUp() { Loading Loading @@ -689,7 +692,7 @@ public class ThrottleService extends IThrottleManager.Stub { } private void onResetAlarm() { if (DBG) { if (VDBG || (mPolicyThreshold.get() != 0)) { Slog.d(TAG, "onResetAlarm - last period had " + mRecorder.getPeriodRx(0) + " bytes read and " + mRecorder.getPeriodTx(0) + " written"); } Loading @@ -707,11 +710,11 @@ public class ThrottleService extends IThrottleManager.Stub { mAlarmManager.cancel(mPendingResetIntent); long offset = end.getTimeInMillis() - now; // use Elapsed realtime so clock changes don't fool us. mAlarmManager.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, mAlarmManager.set(AlarmManager.ELAPSED_REALTIME, SystemClock.elapsedRealtime() + offset, mPendingResetIntent); } else { if (DBG) Slog.d(TAG, "no authoritative time - not resetting period"); if (VDBG) Slog.d(TAG, "no authoritative time - not resetting period"); } } } Loading Loading @@ -748,7 +751,7 @@ public class ThrottleService extends IThrottleManager.Stub { cachedNtpTimestamp = SystemClock.elapsedRealtime(); if (!mNtpActive) { mNtpActive = true; if (DBG) Slog.d(TAG, "found Authoritative time - reseting alarm"); if (VDBG) Slog.d(TAG, "found Authoritative time - reseting alarm"); mHandler.obtainMessage(EVENT_RESET_ALARM).sendToTarget(); } if (VDBG) Slog.v(TAG, "using Authoritative time: " + cachedNtp); Loading Loading @@ -807,13 +810,13 @@ public class ThrottleService extends IThrottleManager.Stub { if (start.equals(mPeriodStart) && end.equals(mPeriodEnd)) { // same endpoints - keep collecting if (DBG) { if (VDBG) { Slog.d(TAG, "same period (" + start.getTimeInMillis() + "," + end.getTimeInMillis() +") - ammending data"); } startNewPeriod = false; } else { if (DBG) { if (VDBG) { if(start.equals(mPeriodEnd) || start.after(mPeriodEnd)) { Slog.d(TAG, "next period (" + start.getTimeInMillis() + "," + end.getTimeInMillis() + ") - old end was " + Loading Loading @@ -917,7 +920,7 @@ public class ThrottleService extends IThrottleManager.Stub { mImsi = mTelephonyManager.getSubscriberId(); if (mImsi == null) return; if (DBG) Slog.d(TAG, "finally have imsi - retreiving data"); if (VDBG) Slog.d(TAG, "finally have imsi - retreiving data"); retrieve(); } Loading