From 2051ffae1f509a1b31e5a6bcf170cecf500376de Mon Sep 17 00:00:00 2001 From: Tushar Janefalkar Date: Mon, 8 Oct 2012 15:41:32 -0700 Subject: [PATCH] Service modem's request for NTP time Previously, modem's request for NTP time was not supported. This change enables that request to be serviced through the HAL and current NTP time is injected into the modem CRs-Fixed: 406357 Change-Id: I471f98cf57a276902d7991da48cf7244fe798318 --- loc_api/libloc_api_50001/LocApiAdapter.cpp | 6 +++--- loc_api/libloc_api_50001/loc.cpp | 4 ++-- loc_api/libloc_api_50001/loc.h | 1 + loc_api/libloc_api_50001/loc_eng.cpp | 11 +++++++++-- loc_api/libloc_api_50001/loc_eng.h | 1 + 5 files changed, 16 insertions(+), 7 deletions(-) diff --git a/loc_api/libloc_api_50001/LocApiAdapter.cpp b/loc_api/libloc_api_50001/LocApiAdapter.cpp index 950c6438..4bd2ec76 100755 --- a/loc_api/libloc_api_50001/LocApiAdapter.cpp +++ b/loc_api/libloc_api_50001/LocApiAdapter.cpp @@ -201,9 +201,9 @@ void LocApiAdapter::requestXtraData() void LocApiAdapter::requestTime() { - LOC_LOGD("loc_event_cb: XTRA time download request... not supported"); - // loc_eng_msg *msg(new loc_eng_msg(locEngHandle.owner, LOC_ENG_MSG_REQUEST_TIME)); - // locEngHandle.sendMsge(locEngHandle.owner, msg); + LOC_LOGD("loc_event_cb: XTRA time download request"); + loc_eng_msg *msg(new loc_eng_msg(locEngHandle.owner, LOC_ENG_MSG_REQUEST_TIME)); + locEngHandle.sendMsge(locEngHandle.owner, msg); } void LocApiAdapter::requestLocation() diff --git a/loc_api/libloc_api_50001/loc.cpp b/loc_api/libloc_api_50001/loc.cpp index cca44807..f78d8070 100644 --- a/loc_api/libloc_api_50001/loc.cpp +++ b/loc_api/libloc_api_50001/loc.cpp @@ -334,7 +334,8 @@ static int loc_init(GpsCallbacks* callbacks) callbacks->release_wakelock_cb, /* release_wakelock_cb */ callbacks->create_thread_cb, /* create_thread_cb */ NULL, /* location_ext_parser */ - NULL /* sv_ext_parser */}; + NULL, /* sv_ext_parser */ + callbacks->request_utc_time_cb /* request_utc_time_cb */}; gps_loc_cb = callbacks->location_cb; gps_sv_cb = callbacks->sv_status_cb; @@ -499,7 +500,6 @@ static int loc_inject_time(GpsUtcTime time, int64_t timeReference, int uncertain { ENTRY_LOG(); int ret_val = loc_eng_inject_time(loc_afw_data, time, timeReference, uncertainty); - EXIT_LOG(%d, ret_val); return ret_val; } diff --git a/loc_api/libloc_api_50001/loc.h b/loc_api/libloc_api_50001/loc.h index 17f6ab70..b823e476 100755 --- a/loc_api/libloc_api_50001/loc.h +++ b/loc_api/libloc_api_50001/loc.h @@ -72,6 +72,7 @@ typedef struct { gps_create_thread create_thread_cb; loc_ext_parser location_ext_parser; loc_ext_parser sv_ext_parser; + gps_request_utc_time request_utc_time_cb; } LocCallbacks; enum loc_sess_status { diff --git a/loc_api/libloc_api_50001/loc_eng.cpp b/loc_api/libloc_api_50001/loc_eng.cpp index 89a77292..a1fc6d57 100755 --- a/loc_api/libloc_api_50001/loc_eng.cpp +++ b/loc_api/libloc_api_50001/loc_eng.cpp @@ -298,7 +298,7 @@ int loc_eng_init(loc_eng_data_s_type &loc_eng_data, LocCallbacks* callbacks, loc_eng_data.nmea_cb = callbacks->nmea_cb; loc_eng_data.acquire_wakelock_cb = callbacks->acquire_wakelock_cb; loc_eng_data.release_wakelock_cb = callbacks->release_wakelock_cb; - + loc_eng_data.request_utc_time_cb = callbacks->request_utc_time_cb; loc_eng_data.intermediateFix = gps_conf.INTERMEDIATE_POS; // initial states taken care of by the memset above @@ -683,7 +683,6 @@ int loc_eng_inject_time(loc_eng_data_s_type &loc_eng_data, GpsUtcTime time, uncertainty)); msg_q_snd((void*)((LocEngContext*)(loc_eng_data.context))->deferred_q, msg, loc_eng_free_msg); - EXIT_LOG(%d, 0); return 0; } @@ -1682,6 +1681,14 @@ static void loc_eng_deferred_action_thread(void* arg) break; case LOC_ENG_MSG_REQUEST_TIME: + if (loc_eng_data_p->request_utc_time_cb != NULL) + { + loc_eng_data_p->request_utc_time_cb(); + } + else + { + LOC_LOGE("%s] ERROR: Callback function for request_time is NULL", __func__); + } break; case LOC_ENG_MSG_REQUEST_POSITION: diff --git a/loc_api/libloc_api_50001/loc_eng.h b/loc_api/libloc_api_50001/loc_eng.h index 1b9dcf58..646d1716 100644 --- a/loc_api/libloc_api_50001/loc_eng.h +++ b/loc_api/libloc_api_50001/loc_eng.h @@ -106,6 +106,7 @@ typedef struct gps_ni_notify_callback ni_notify_cb; gps_acquire_wakelock acquire_wakelock_cb; gps_release_wakelock release_wakelock_cb; + gps_request_utc_time request_utc_time_cb; ulp_network_location_request ulp_network_callback; ulp_request_phone_context ulp_phone_context_req_cb; boolean intermediateFix;