summaryrefslogtreecommitdiffstats
path: root/telephony
diff options
context:
space:
mode:
authorWink Saville <wink@google.com>2009-11-11 11:55:38 -0800
committerWink Saville <wink@google.com>2009-11-11 11:55:38 -0800
commitaeff5fd8eb17bc0f611918d6482139c1921e7b60 (patch)
treec5a3934c65d87abacfd02787cbd3417d428d3bf2 /telephony
parentb9c40a65c7fb2121d3076a522248574162bf5f8c (diff)
downloadframeworks_base-aeff5fd8eb17bc0f611918d6482139c1921e7b60.zip
frameworks_base-aeff5fd8eb17bc0f611918d6482139c1921e7b60.tar.gz
frameworks_base-aeff5fd8eb17bc0f611918d6482139c1921e7b60.tar.bz2
Throttle nitz updates as the are too numerous on cdma.
bug: 2251845 Change-Id: I326c1f7e28d19b678ea748e36f8286dd1378cecf
Diffstat (limited to 'telephony')
-rw-r--r--telephony/java/com/android/internal/telephony/cdma/CdmaServiceStateTracker.java97
1 files changed, 59 insertions, 38 deletions
diff --git a/telephony/java/com/android/internal/telephony/cdma/CdmaServiceStateTracker.java b/telephony/java/com/android/internal/telephony/cdma/CdmaServiceStateTracker.java
index 3051e2f..bb3f2a7 100644
--- a/telephony/java/com/android/internal/telephony/cdma/CdmaServiceStateTracker.java
+++ b/telephony/java/com/android/internal/telephony/cdma/CdmaServiceStateTracker.java
@@ -67,6 +67,15 @@ final class CdmaServiceStateTracker extends ServiceStateTracker {
CdmaCellLocation cellLoc;
CdmaCellLocation newCellLoc;
+ /** if time between NTIZ updates is less than mNitzUpdateSpacing the update may be ignored. */
+ private static final int NITZ_UPDATE_SPACING_DEFAULT = 1000 * 60 * 10;
+ private int mNitzUpdateSpacing = SystemProperties.getInt("ro.nitz_update_spacing",
+ NITZ_UPDATE_SPACING_DEFAULT);
+
+ /** If mNitzUpdateSpacing hasn't been exceeded but update is > mNitzUpdate do the update */
+ private static final int NITZ_UPDATE_DIFF_DEFAULT = 2000;
+ private int mNitzUpdateDiff = SystemProperties.getInt("ro.nitz_update_diff",
+ NITZ_UPDATE_DIFF_DEFAULT);
/**
* Values correspond to ServiceStateTracker.DATA_ACCESS_ definitions.
*/
@@ -1420,45 +1429,62 @@ final class CdmaServiceStateTracker extends ServiceStateTracker {
try {
mWakeLock.acquire();
- if (getAutoTime()) {
- long millisSinceNitzReceived
- = SystemClock.elapsedRealtime() - nitzReceiveTime;
-
- if (millisSinceNitzReceived < 0) {
- // Sanity check: something is wrong
- Log.i(LOG_TAG, "NITZ: not setting time, clock has rolled "
- + "backwards since NITZ time was received, "
- + nitz);
- return;
- }
-
- if (millisSinceNitzReceived > Integer.MAX_VALUE) {
- // If the time is this far off, something is wrong > 24 days!
- Log.i(LOG_TAG, "NITZ: not setting time, processing has taken "
- + (millisSinceNitzReceived / (1000 * 60 * 60 * 24))
- + " days");
- return;
- }
+ /**
+ * Correct the NITZ time by how long its taken to get here.
+ */
+ long millisSinceNitzReceived
+ = SystemClock.elapsedRealtime() - nitzReceiveTime;
+
+ if (millisSinceNitzReceived < 0) {
+ // Sanity check: something is wrong
+ Log.i(LOG_TAG, "NITZ: not setting time, clock has rolled "
+ + "backwards since NITZ time was received, "
+ + nitz);
+ return;
+ }
- // Note: with range checks above, cast to int is safe
- c.add(Calendar.MILLISECOND, (int)millisSinceNitzReceived);
+ if (millisSinceNitzReceived > Integer.MAX_VALUE) {
+ // If the time is this far off, something is wrong > 24 days!
+ Log.i(LOG_TAG, "NITZ: not setting time, processing has taken "
+ + (millisSinceNitzReceived / (1000 * 60 * 60 * 24))
+ + " days");
+ return;
+ }
- Log.i(LOG_TAG, "NITZ: Setting time of day to " + c.getTime()
- + " NITZ receive delay(ms): " + millisSinceNitzReceived
- + " gained(ms): "
- + (c.getTimeInMillis() - System.currentTimeMillis())
- + " from " + nitz);
+ // Note: with range checks above, cast to int is safe
+ c.add(Calendar.MILLISECOND, (int)millisSinceNitzReceived);
- setAndBroadcastNetworkSetTime(c.getTimeInMillis());
- Log.i(LOG_TAG, "NITZ: after Setting time of day");
+ if (getAutoTime()) {
+ /**
+ * Update system time automatically
+ */
+ long gained = c.getTimeInMillis() - System.currentTimeMillis();
+ long timeSinceLastUpdate = SystemClock.elapsedRealtime() - mSavedAtTime;
+
+ if ((timeSinceLastUpdate > mNitzUpdateSpacing)
+ || (Math.abs(gained) > mNitzUpdateDiff)) {
+ Log.i(LOG_TAG, "NITZ: Auto updating time of day to " + c.getTime()
+ + " NITZ receive delay=" + millisSinceNitzReceived
+ + "ms gained=" + gained + "ms from " + nitz);
+
+ setAndBroadcastNetworkSetTime(c.getTimeInMillis());
+ } else {
+ Log.i(LOG_TAG, "NITZ: ignore, a previous update was "
+ + timeSinceLastUpdate + "ms ago and gained=" + gained + "ms");
+ return;
+ }
}
+
+ /**
+ * Update properties and save the time we did the update
+ */
+ Log.i(LOG_TAG, "NITZ: update nitz time property");
SystemProperties.set("gsm.nitz.time", String.valueOf(c.getTimeInMillis()));
- saveNitzTime(c.getTimeInMillis());
- if (Config.LOGV) {
- long end = SystemClock.elapsedRealtime();
- Log.v(LOG_TAG, "NITZ: end=" + end + " dur=" + (end - start));
- }
+ mSavedTime = c.getTimeInMillis();
+ mSavedAtTime = SystemClock.elapsedRealtime();
} finally {
+ long end = SystemClock.elapsedRealtime();
+ Log.i(LOG_TAG, "NITZ: end=" + end + " dur=" + (end - start));
mWakeLock.release();
}
} catch (RuntimeException ex) {
@@ -1479,11 +1505,6 @@ final class CdmaServiceStateTracker extends ServiceStateTracker {
mSavedTimeZone = zoneId;
}
- private void saveNitzTime(long time) {
- mSavedTime = time;
- mSavedAtTime = SystemClock.elapsedRealtime();
- }
-
/**
* Set the timezone and send out a sticky broadcast so the system can
* determine if the timezone was set by the carrier.