Merge change 2111 into donut

* changes:
  GPS: Add support for forcing NTP time and XTRA data injection.
This commit is contained in:
Android (Google) Code Review
2009-05-20 14:00:24 -07:00

View File

@ -641,6 +641,16 @@ public class GpsLocationProvider extends ILocationProvider.Stub {
if ("delete_aiding_data".equals(command)) { if ("delete_aiding_data".equals(command)) {
return deleteAidingData(extras); 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); Log.w(TAG, "sendExtraCommand: unknown command " + command);
return false; return false;
@ -676,6 +686,15 @@ public class GpsLocationProvider extends ILocationProvider.Stub {
return false; return false;
} }
private boolean forceTimeInjection() {
if (Config.LOGD) Log.d(TAG, "forceTimeInjection");
if (mNetworkThread != null) {
mNetworkThread.timeInjectRequest();
return true;
}
return false;
}
public void startNavigating() { public void startNavigating() {
if (!mStarted) { if (!mStarted) {
if (DEBUG) Log.d(TAG, "startNavigating"); if (DEBUG) Log.d(TAG, "startNavigating");
@ -1004,6 +1023,7 @@ public class GpsLocationProvider extends ILocationProvider.Stub {
private long mNextNtpTime = 0; private long mNextNtpTime = 0;
private long mNextXtraTime = 0; private long mNextXtraTime = 0;
private boolean mTimeInjectRequested = false;
private boolean mXtraDownloadRequested = false; private boolean mXtraDownloadRequested = false;
private boolean mDone = false; private boolean mDone = false;
@ -1054,16 +1074,17 @@ public class GpsLocationProvider extends ILocationProvider.Stub {
} }
waitTime = getWaitTime(); waitTime = getWaitTime();
} while (!mDone && ((!mXtraDownloadRequested && } while (!mDone && ((!mXtraDownloadRequested &&
!mSetSuplServer && !mSetC2KServer && waitTime > 0) !mTimeInjectRequested && !mSetSuplServer && !mSetC2KServer && waitTime > 0)
|| !mNetworkAvailable)); || !mNetworkAvailable));
if (Config.LOGD) Log.d(TAG, "NetworkThread out of wake loop"); if (Config.LOGD) Log.d(TAG, "NetworkThread out of wake loop");
if (!mDone) { if (!mDone) {
if (mNtpServer != null && if (mNtpServer != null &&
mNextNtpTime <= System.currentTimeMillis()) { (mTimeInjectRequested || mNextNtpTime <= System.currentTimeMillis())) {
if (Config.LOGD) { if (Config.LOGD) {
Log.d(TAG, "Requesting time from NTP server " + mNtpServer); Log.d(TAG, "Requesting time from NTP server " + mNtpServer);
} }
mTimeInjectRequested = false;
if (client.requestTime(mNtpServer, 10000)) { if (client.requestTime(mNtpServer, 10000)) {
long time = client.getNtpTime(); long time = client.getNtpTime();
long timeReference = client.getNtpTimeReference(); long timeReference = client.getNtpTimeReference();
@ -1096,6 +1117,7 @@ public class GpsLocationProvider extends ILocationProvider.Stub {
if ((mXtraDownloadRequested || if ((mXtraDownloadRequested ||
(mNextXtraTime > 0 && mNextXtraTime <= System.currentTimeMillis())) (mNextXtraTime > 0 && mNextXtraTime <= System.currentTimeMillis()))
&& xtraDownloader != null) { && xtraDownloader != null) {
mXtraDownloadRequested = false;
byte[] data = xtraDownloader.downloadXtraData(); byte[] data = xtraDownloader.downloadXtraData();
if (data != null) { if (data != null) {
if (Config.LOGD) { if (Config.LOGD) {
@ -1103,7 +1125,6 @@ public class GpsLocationProvider extends ILocationProvider.Stub {
} }
native_inject_xtra_data(data, data.length); native_inject_xtra_data(data, data.length);
mNextXtraTime = 0; mNextXtraTime = 0;
mXtraDownloadRequested = false;
} else { } else {
mNextXtraTime = System.currentTimeMillis() + RETRY_INTERVAL; mNextXtraTime = System.currentTimeMillis() + RETRY_INTERVAL;
} }
@ -1118,6 +1139,11 @@ public class GpsLocationProvider extends ILocationProvider.Stub {
notify(); notify();
} }
synchronized void timeInjectRequest() {
mTimeInjectRequested = true;
notify();
}
synchronized void signal() { synchronized void signal() {
notify(); notify();
} }