Merge change I326c1f7e into eclair
* changes: Throttle nitz updates as the are too numerous on cdma.
This commit is contained in:
@@ -67,6 +67,15 @@ final class CdmaServiceStateTracker extends ServiceStateTracker {
|
|||||||
CdmaCellLocation cellLoc;
|
CdmaCellLocation cellLoc;
|
||||||
CdmaCellLocation newCellLoc;
|
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.
|
* Values correspond to ServiceStateTracker.DATA_ACCESS_ definitions.
|
||||||
*/
|
*/
|
||||||
@@ -1420,45 +1429,62 @@ final class CdmaServiceStateTracker extends ServiceStateTracker {
|
|||||||
try {
|
try {
|
||||||
mWakeLock.acquire();
|
mWakeLock.acquire();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Note: with range checks above, cast to int is safe
|
||||||
|
c.add(Calendar.MILLISECOND, (int)millisSinceNitzReceived);
|
||||||
|
|
||||||
if (getAutoTime()) {
|
if (getAutoTime()) {
|
||||||
long millisSinceNitzReceived
|
/**
|
||||||
= SystemClock.elapsedRealtime() - nitzReceiveTime;
|
* Update system time automatically
|
||||||
|
*/
|
||||||
|
long gained = c.getTimeInMillis() - System.currentTimeMillis();
|
||||||
|
long timeSinceLastUpdate = SystemClock.elapsedRealtime() - mSavedAtTime;
|
||||||
|
|
||||||
if (millisSinceNitzReceived < 0) {
|
if ((timeSinceLastUpdate > mNitzUpdateSpacing)
|
||||||
// Sanity check: something is wrong
|
|| (Math.abs(gained) > mNitzUpdateDiff)) {
|
||||||
Log.i(LOG_TAG, "NITZ: not setting time, clock has rolled "
|
Log.i(LOG_TAG, "NITZ: Auto updating time of day to " + c.getTime()
|
||||||
+ "backwards since NITZ time was received, "
|
+ " NITZ receive delay=" + millisSinceNitzReceived
|
||||||
+ nitz);
|
+ "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;
|
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Note: with range checks above, cast to int is safe
|
|
||||||
c.add(Calendar.MILLISECOND, (int)millisSinceNitzReceived);
|
|
||||||
|
|
||||||
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);
|
|
||||||
|
|
||||||
setAndBroadcastNetworkSetTime(c.getTimeInMillis());
|
|
||||||
Log.i(LOG_TAG, "NITZ: after Setting time of day");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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()));
|
SystemProperties.set("gsm.nitz.time", String.valueOf(c.getTimeInMillis()));
|
||||||
saveNitzTime(c.getTimeInMillis());
|
mSavedTime = c.getTimeInMillis();
|
||||||
if (Config.LOGV) {
|
mSavedAtTime = SystemClock.elapsedRealtime();
|
||||||
long end = SystemClock.elapsedRealtime();
|
|
||||||
Log.v(LOG_TAG, "NITZ: end=" + end + " dur=" + (end - start));
|
|
||||||
}
|
|
||||||
} finally {
|
} finally {
|
||||||
|
long end = SystemClock.elapsedRealtime();
|
||||||
|
Log.i(LOG_TAG, "NITZ: end=" + end + " dur=" + (end - start));
|
||||||
mWakeLock.release();
|
mWakeLock.release();
|
||||||
}
|
}
|
||||||
} catch (RuntimeException ex) {
|
} catch (RuntimeException ex) {
|
||||||
@@ -1479,11 +1505,6 @@ final class CdmaServiceStateTracker extends ServiceStateTracker {
|
|||||||
mSavedTimeZone = zoneId;
|
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
|
* Set the timezone and send out a sticky broadcast so the system can
|
||||||
* determine if the timezone was set by the carrier.
|
* determine if the timezone was set by the carrier.
|
||||||
|
|||||||
Reference in New Issue
Block a user