summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/java/android/net/SntpClient.java8
-rw-r--r--services/java/com/android/server/ThrottleService.java36
2 files changed, 25 insertions, 19 deletions
diff --git a/core/java/android/net/SntpClient.java b/core/java/android/net/SntpClient.java
index 550cc24..f607ee9 100644
--- a/core/java/android/net/SntpClient.java
+++ b/core/java/android/net/SntpClient.java
@@ -79,7 +79,7 @@ public class SntpClient
byte[] buffer = new byte[NTP_PACKET_SIZE];
DatagramPacket request = new DatagramPacket(buffer, buffer.length, address, NTP_PORT);
- // set mode = 3 (client) and version = 3
+ // set mode = 3 (client) and version = 3
// mode is in low 3 bits of first byte
// version is in bits 3-5 of first byte
buffer[0] = NTP_MODE_CLIENT | (NTP_VERSION << 3);
@@ -90,7 +90,7 @@ public class SntpClient
writeTimeStamp(buffer, TRANSMIT_TIME_OFFSET, requestTime);
socket.send(request);
-
+
// read the response
DatagramPacket response = new DatagramPacket(buffer, buffer.length);
socket.receive(response);
@@ -112,8 +112,8 @@ public class SntpClient
// = (transit + skew - transit + skew)/2
// = (2 * skew)/2 = skew
long clockOffset = ((receiveTime - originateTime) + (transmitTime - responseTime))/2;
- if (Config.LOGD) Log.d(TAG, "round trip: " + roundTripTime + " ms");
- if (Config.LOGD) Log.d(TAG, "clock offset: " + clockOffset + " ms");
+ // if (Config.LOGD) Log.d(TAG, "round trip: " + roundTripTime + " ms");
+ // if (Config.LOGD) Log.d(TAG, "clock offset: " + clockOffset + " ms");
// save our results - use the times on this side of the network latency
// (response rather than request time)
diff --git a/services/java/com/android/server/ThrottleService.java b/services/java/com/android/server/ThrottleService.java
index 4d2d2f9..4ff0fb9 100644
--- a/services/java/com/android/server/ThrottleService.java
+++ b/services/java/com/android/server/ThrottleService.java
@@ -68,7 +68,8 @@ public class ThrottleService extends IThrottleManager.Stub {
private static final String TESTING_ENABLED_PROPERTY = "persist.throttle.testing";
private static final String TAG = "ThrottleService";
- private static boolean DBG = true;
+ private static final boolean DBG = true;
+ private static final boolean VDBG = false;
private Handler mHandler;
private HandlerThread mThread;
@@ -424,7 +425,7 @@ public class ThrottleService extends IThrottleManager.Stub {
long periodTx = mRecorder.getPeriodTx(0);
long total = periodRx + periodTx;
if (DBG) {
- Slog.d(TAG, "onPollAlarm - now =" + now + ", roaming =" + roaming +
+ Slog.d(TAG, "onPollAlarm - roaming =" + roaming +
", read =" + incRead + ", written =" + incWrite + ", new total =" + total);
}
mLastRead += incRead;
@@ -653,6 +654,7 @@ public class ThrottleService extends IThrottleManager.Stub {
if (mNtpActive) {
long ntpAge = SystemClock.elapsedRealtime() - cachedNtpTimestamp;
if (ntpAge < MAX_NTP_CACHE_AGE) {
+ if (VDBG) Slog.v(TAG, "using cached time");
return cachedNtp + ntpAge;
}
}
@@ -665,12 +667,12 @@ public class ThrottleService extends IThrottleManager.Stub {
if (DBG) Slog.d(TAG, "found Authoritative time - reseting alarm");
mHandler.obtainMessage(EVENT_RESET_ALARM).sendToTarget();
}
- if (DBG) Slog.d(TAG, "using Authoritative time: " + cachedNtp);
+ if (VDBG) Slog.v(TAG, "using Authoritative time: " + cachedNtp);
return cachedNtp;
}
}
long time = System.currentTimeMillis();
- if (DBG) Slog.d(TAG, "using User time: " + time);
+ if (VDBG) Slog.v(TAG, "using User time: " + time);
mNtpActive = false;
return time;
}
@@ -718,15 +720,14 @@ public class ThrottleService extends IThrottleManager.Stub {
// TODO - how would we deal with a dual-IMSI device?
checkForSubscriberId();
boolean startNewPeriod = true;
- if (DBG) {
- Slog.d(TAG, "setting next period to " + start.getTimeInMillis() +
- " --until-- " + end.getTimeInMillis());
- }
+
// if we rolled back in time, toss out
// if we rolled foward, advance to the next
if (end.before(mPeriodStart)) {
if (DBG) {
- Slog.d(TAG, " old start was " + mPeriodStart.getTimeInMillis() + ", wiping");
+ Slog.d(TAG, "next period (" + start.getTimeInMillis() + "," +
+ end.getTimeInMillis() + ") - old start was " +
+ mPeriodStart.getTimeInMillis() + ", wiping");
}
synchronized (mParent) {
mPeriodRxData[mCurrentPeriod] = 0;
@@ -734,7 +735,9 @@ public class ThrottleService extends IThrottleManager.Stub {
}
} else if(start.after(mPeriodEnd)) {
if (DBG) {
- Slog.d(TAG, " old end was " + mPeriodEnd.getTimeInMillis() + ", following");
+ Slog.d(TAG, "next period (" + start.getTimeInMillis() + "," +
+ end.getTimeInMillis() + ") - old end was " +
+ mPeriodEnd.getTimeInMillis() + ", following");
}
synchronized (mParent) {
++mCurrentPeriod;
@@ -744,7 +747,10 @@ public class ThrottleService extends IThrottleManager.Stub {
}
} else {
startNewPeriod = false;
- if (DBG) Slog.d(TAG, " we fit - ammending to last period");
+ if (DBG) {
+ Slog.d(TAG, "next period (" + start.getTimeInMillis() + "," +
+ end.getTimeInMillis() + ") - we fit - ammending to last period");
+ }
}
setPeriodStart(start);
setPeriodEnd(end);
@@ -813,7 +819,7 @@ public class ThrottleService extends IThrottleManager.Stub {
File dataFile;
if (mImsi == null) {
dataFile = useMRUFile(throttleDir);
- Slog.d(TAG, "imsi not available yet, using " + dataFile);
+ if (VDBG) Slog.v(TAG, "imsi not available yet, using " + dataFile);
} else {
String imsiHash = Integer.toString(mImsi.hashCode());
dataFile = new File(throttleDir, imsiHash);
@@ -831,7 +837,7 @@ public class ThrottleService extends IThrottleManager.Stub {
mImsi = mTelephonyManager.getSubscriberId();
if (mImsi == null) return;
- Slog.d(TAG, "finally have imsi - retreiving data");
+ if (DBG) Slog.d(TAG, "finally have imsi - retreiving data");
retrieve();
}
@@ -841,7 +847,7 @@ public class ThrottleService extends IThrottleManager.Stub {
File[] files = dir.listFiles();
if (files.length <= MAX_SIMS_SUPPORTED) return;
- Slog.d(TAG, "Too many data files");
+ if (DBG) Slog.d(TAG, "Too many data files");
do {
File oldest = null;
for (File f : files) {
@@ -850,7 +856,7 @@ public class ThrottleService extends IThrottleManager.Stub {
}
}
if (oldest == null) return;
- Slog.d(TAG, " deleting " + oldest);
+ if (DBG) Slog.d(TAG, " deleting " + oldest);
oldest.delete();
files = dir.listFiles();
} while (files.length > MAX_SIMS_SUPPORTED);