Skip to content

Commit 5a671d0

Browse files
author
Robert Greenwalt
committed
Cut logging, boost efficiency of ThrottleService
Changed the Alarms to be non-waking. bug:2748959 bug:2747862 Change-Id: I9e4294162a4fc2f90aed36393b858edcf82aa307
1 parent df2e2ef commit 5a671d0

File tree

1 file changed

+20
-17
lines changed

1 file changed

+20
-17
lines changed

services/java/com/android/server/ThrottleService.java

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ public class ThrottleService extends IThrottleManager.Stub {
123123
private boolean mNtpActive;
124124

125125
public ThrottleService(Context context) {
126-
if (DBG) Slog.d(TAG, "Starting ThrottleService");
126+
if (VDBG) Slog.v(TAG, "Starting ThrottleService");
127127
mContext = context;
128128

129129
mNtpActive = false;
@@ -288,7 +288,7 @@ public synchronized int getThrottle(String iface) {
288288
}
289289

290290
void systemReady() {
291-
if (DBG) Slog.d(TAG, "systemReady");
291+
if (VDBG) Slog.v(TAG, "systemReady");
292292
mContext.registerReceiver(
293293
new BroadcastReceiver() {
294294
@Override
@@ -371,7 +371,7 @@ public void handleMessage(Message msg) {
371371
}
372372

373373
private void onRebootRecovery() {
374-
if (DBG) Slog.d(TAG, "onRebootRecovery");
374+
if (VDBG) Slog.v(TAG, "onRebootRecovery");
375375
// check for sim change TODO
376376
// reregister for notification of policy change
377377

@@ -437,10 +437,12 @@ private void onPolicyChanged() {
437437
mMaxNtpCacheAgeSec = Settings.Secure.getInt(mContext.getContentResolver(),
438438
Settings.Secure.THROTTLE_MAX_NTP_CACHE_AGE_SEC, MAX_NTP_CACHE_AGE_SEC);
439439

440-
Slog.d(TAG, "onPolicyChanged testing=" + testing +", period=" + mPolicyPollPeriodSec +
441-
", threshold=" + mPolicyThreshold + ", value=" + mPolicyThrottleValue +
442-
", resetDay=" + mPolicyResetDay + ", noteType=" +
443-
mPolicyNotificationsAllowedMask + ", maxNtpCacheAge=" + mMaxNtpCacheAgeSec);
440+
if (VDBG || (mPolicyThreshold != 0)) {
441+
Slog.d(TAG, "onPolicyChanged testing=" + testing +", period=" +
442+
mPolicyPollPeriodSec + ", threshold=" + mPolicyThreshold + ", value=" +
443+
mPolicyThrottleValue + ", resetDay=" + mPolicyResetDay + ", noteType=" +
444+
mPolicyNotificationsAllowedMask + ", maxNtpCacheAge=" + mMaxNtpCacheAgeSec);
445+
}
444446

445447
// force updates
446448
mThrottleIndex = THROTTLE_INDEX_UNINITIALIZED;
@@ -485,7 +487,7 @@ private void onPollAlarm() {
485487
long periodRx = mRecorder.getPeriodRx(0);
486488
long periodTx = mRecorder.getPeriodTx(0);
487489
long total = periodRx + periodTx;
488-
if (DBG) {
490+
if (VDBG || (mPolicyThreshold != 0)) {
489491
Slog.d(TAG, "onPollAlarm - roaming =" + roaming +
490492
", read =" + incRead + ", written =" + incWrite + ", new total =" + total);
491493
}
@@ -502,7 +504,7 @@ private void onPollAlarm() {
502504
mContext.sendStickyBroadcast(broadcast);
503505

504506
mAlarmManager.cancel(mPendingPollIntent);
505-
mAlarmManager.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, next, mPendingPollIntent);
507+
mAlarmManager.set(AlarmManager.ELAPSED_REALTIME, next, mPendingPollIntent);
506508
}
507509

508510
private void onIfaceUp() {
@@ -685,7 +687,7 @@ private Calendar calculatePeriodStart(Calendar end) {
685687
}
686688

687689
private void onResetAlarm() {
688-
if (DBG) {
690+
if (VDBG || (mPolicyThreshold != 0)) {
689691
Slog.d(TAG, "onResetAlarm - last period had " + mRecorder.getPeriodRx(0) +
690692
" bytes read and " + mRecorder.getPeriodTx(0) + " written");
691693
}
@@ -703,11 +705,11 @@ private void onResetAlarm() {
703705
mAlarmManager.cancel(mPendingResetIntent);
704706
long offset = end.getTimeInMillis() - now;
705707
// use Elapsed realtime so clock changes don't fool us.
706-
mAlarmManager.set(AlarmManager.ELAPSED_REALTIME_WAKEUP,
708+
mAlarmManager.set(AlarmManager.ELAPSED_REALTIME,
707709
SystemClock.elapsedRealtime() + offset,
708710
mPendingResetIntent);
709711
} else {
710-
if (DBG) Slog.d(TAG, "no authoritative time - not resetting period");
712+
if (VDBG) Slog.d(TAG, "no authoritative time - not resetting period");
711713
}
712714
}
713715
}
@@ -741,7 +743,7 @@ private long getBestTime() {
741743
cachedNtpTimestamp = SystemClock.elapsedRealtime();
742744
if (!mNtpActive) {
743745
mNtpActive = true;
744-
if (DBG) Slog.d(TAG, "found Authoritative time - reseting alarm");
746+
if (VDBG) Slog.d(TAG, "found Authoritative time - reseting alarm");
745747
mHandler.obtainMessage(EVENT_RESET_ALARM).sendToTarget();
746748
}
747749
if (VDBG) Slog.v(TAG, "using Authoritative time: " + cachedNtp);
@@ -800,13 +802,13 @@ boolean setNextPeriod(Calendar start, Calendar end) {
800802

801803
if (start.equals(mPeriodStart) && end.equals(mPeriodEnd)) {
802804
// same endpoints - keep collecting
803-
if (DBG) {
805+
if (VDBG) {
804806
Slog.d(TAG, "same period (" + start.getTimeInMillis() + "," +
805807
end.getTimeInMillis() +") - ammending data");
806808
}
807809
startNewPeriod = false;
808810
} else {
809-
if (DBG) {
811+
if (VDBG) {
810812
if(start.equals(mPeriodEnd) || start.after(mPeriodEnd)) {
811813
Slog.d(TAG, "next period (" + start.getTimeInMillis() + "," +
812814
end.getTimeInMillis() + ") - old end was " +
@@ -910,7 +912,7 @@ private void checkForSubscriberId() {
910912
mImsi = mTelephonyManager.getSubscriberId();
911913
if (mImsi == null) return;
912914

913-
if (DBG) Slog.d(TAG, "finally have imsi - retreiving data");
915+
if (VDBG) Slog.d(TAG, "finally have imsi - retreiving data");
914916
retrieve();
915917
}
916918

@@ -1038,7 +1040,8 @@ private void retrieve() {
10381040

10391041
mPeriodCount = Integer.parseInt(parsed[parsedUsed++]);
10401042
if (parsed.length != 5 + (2 * mPeriodCount)) {
1041-
Slog.e(TAG, "reading data file with bad length ("+parsed.length+" != "+(5 + (2*mPeriodCount))+") - ignoring");
1043+
Slog.e(TAG, "reading data file with bad length (" + parsed.length +
1044+
" != " + (5+(2*mPeriodCount)) + ") - ignoring");
10421045
return;
10431046
}
10441047

0 commit comments

Comments
 (0)