am 2d10ba33: Merge change 2111 into donut
Merge commit '2d10ba33190c2ff1b24d6c48dd621c55a25bf2cc'
* commit '2d10ba33190c2ff1b24d6c48dd621c55a25bf2cc':
GPS: Add support for forcing NTP time and XTRA data injection.
diff --git a/location/java/com/android/internal/location/GpsLocationProvider.java b/location/java/com/android/internal/location/GpsLocationProvider.java
index 565859c..9003848 100644
--- a/location/java/com/android/internal/location/GpsLocationProvider.java
+++ b/location/java/com/android/internal/location/GpsLocationProvider.java
@@ -641,6 +641,16 @@
if ("delete_aiding_data".equals(command)) {
return deleteAidingData(extras);
}
+ if ("force_time_injection".equals(command)) {
+ return forceTimeInjection();
+ }
+ if ("force_xtra_injection".equals(command)) {
+ if (native_supports_xtra() && mNetworkThread != null) {
+ xtraDownloadRequest();
+ return true;
+ }
+ return false;
+ }
Log.w(TAG, "sendExtraCommand: unknown command " + command);
return false;
@@ -676,6 +686,15 @@
return false;
}
+ private boolean forceTimeInjection() {
+ if (Config.LOGD) Log.d(TAG, "forceTimeInjection");
+ if (mNetworkThread != null) {
+ mNetworkThread.timeInjectRequest();
+ return true;
+ }
+ return false;
+ }
+
public void startNavigating() {
if (!mStarted) {
if (DEBUG) Log.d(TAG, "startNavigating");
@@ -1004,6 +1023,7 @@
private long mNextNtpTime = 0;
private long mNextXtraTime = 0;
+ private boolean mTimeInjectRequested = false;
private boolean mXtraDownloadRequested = false;
private boolean mDone = false;
@@ -1054,16 +1074,17 @@
}
waitTime = getWaitTime();
} while (!mDone && ((!mXtraDownloadRequested &&
- !mSetSuplServer && !mSetC2KServer && waitTime > 0)
+ !mTimeInjectRequested && !mSetSuplServer && !mSetC2KServer && waitTime > 0)
|| !mNetworkAvailable));
if (Config.LOGD) Log.d(TAG, "NetworkThread out of wake loop");
if (!mDone) {
if (mNtpServer != null &&
- mNextNtpTime <= System.currentTimeMillis()) {
+ (mTimeInjectRequested || mNextNtpTime <= System.currentTimeMillis())) {
if (Config.LOGD) {
Log.d(TAG, "Requesting time from NTP server " + mNtpServer);
}
+ mTimeInjectRequested = false;
if (client.requestTime(mNtpServer, 10000)) {
long time = client.getNtpTime();
long timeReference = client.getNtpTimeReference();
@@ -1096,6 +1117,7 @@
if ((mXtraDownloadRequested ||
(mNextXtraTime > 0 && mNextXtraTime <= System.currentTimeMillis()))
&& xtraDownloader != null) {
+ mXtraDownloadRequested = false;
byte[] data = xtraDownloader.downloadXtraData();
if (data != null) {
if (Config.LOGD) {
@@ -1103,7 +1125,6 @@
}
native_inject_xtra_data(data, data.length);
mNextXtraTime = 0;
- mXtraDownloadRequested = false;
} else {
mNextXtraTime = System.currentTimeMillis() + RETRY_INTERVAL;
}
@@ -1118,6 +1139,11 @@
notify();
}
+ synchronized void timeInjectRequest() {
+ mTimeInjectRequested = true;
+ notify();
+ }
+
synchronized void signal() {
notify();
}