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,