From 782431aff037174b5d6bf533975a05aafff98ed2 Mon Sep 17 00:00:00 2001 From: Tushar Janefalkar Date: Wed, 7 Aug 2013 18:48:22 -0700 Subject: [PATCH] Return NULL AGPS interface on APQ target. The AGPS interface will be returned as null if MSA and MSB capabilities are not set in gps config Change-Id: I388654c9f527bfed128f431ccb8956e19be0f7f2 (cherry picked from commit 50891ecfe09b19a130b675ddc818ecf4ae31a3da) --- loc_api/libloc_api_50001/loc.cpp | 14 +++++++++++++- loc_api/libloc_api_50001/loc_eng.cpp | 18 ++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/loc_api/libloc_api_50001/loc.cpp b/loc_api/libloc_api_50001/loc.cpp index 6cca8544..90b3b86e 100644 --- a/loc_api/libloc_api_50001/loc.cpp +++ b/loc_api/libloc_api_50001/loc.cpp @@ -571,7 +571,19 @@ const void* loc_get_extension(const char* name) } else if (strcmp(name, AGPS_INTERFACE) == 0) { - ret_val = &sLocEngAGpsInterface; + //Return an interface to AGPS only if MSA or MSB capabilities + //are present. If the target is an APQ, these masks are + //cleared in get_gps_interface() and the below logic will + //return NULL as the interface for AGPS + if((gps_conf.CAPABILITIES & GPS_CAPABILITY_MSA) || + (gps_conf.CAPABILITIES & GPS_CAPABILITY_MSB) ) { + LOC_LOGD("%s:%d]: AGPS capabilities found\n", __func__, __LINE__); + ret_val = &sLocEngAGpsInterface; + } + else { + LOC_LOGD("%s:%d]: Returning NULL AgpsInterface\n", __func__, __LINE__); + ret_val = NULL; + } } else if (strcmp(name, GPS_NI_INTERFACE) == 0) { diff --git a/loc_api/libloc_api_50001/loc_eng.cpp b/loc_api/libloc_api_50001/loc_eng.cpp index 7befc740..d23516ef 100644 --- a/loc_api/libloc_api_50001/loc_eng.cpp +++ b/loc_api/libloc_api_50001/loc_eng.cpp @@ -1454,6 +1454,13 @@ int loc_eng_init(loc_eng_data_s_type &loc_eng_data, LocCallbacks* callbacks, loc_eng_data.generateNmea = false; } + //Disable AGPS if capabilities are not present + if(!(gps_conf.CAPABILITIES & GPS_CAPABILITY_MSA) && + !(gps_conf.CAPABILITIES & GPS_CAPABILITY_MSA)) { + event &= ~(LOC_API_ADAPTER_BIT_LOCATION_SERVER_REQUEST | + LOC_API_ADAPTER_BIT_NI_NOTIFY_VERIFY_REQUEST); + } + loc_eng_data.adapter = new LocEngAdapter(event, &loc_eng_data, (MsgTask::tCreate)callbacks->create_thread_cb); @@ -1950,6 +1957,17 @@ void loc_eng_agps_init(loc_eng_data_s_type &loc_eng_data, AGpsExtCallbacks* call EXIT_LOG(%s, VOID_RET); return; } + + //Proceed to create AGPS framework only if MSA or MSB capabilities + //are present. If the target is an APQ, these masks are + //cleared in get_gps_interface() + if(!(gps_conf.CAPABILITIES & GPS_CAPABILITY_MSA) && + !(gps_conf.CAPABILITIES & GPS_CAPABILITY_MSB) ) { + LOC_LOGD("%s:%d]: No AGPS capabilities found. Returning\n", + __func__, __LINE__); + return; + } + loc_eng_data.agps_status_cb = callbacks->status_cb; loc_eng_data.agnss_nif = new AgpsStateMachine(servicerTypeAgps,