summaryrefslogtreecommitdiffstats
path: root/gps/libloc_api_50001/loc_eng.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'gps/libloc_api_50001/loc_eng.cpp')
-rwxr-xr-x[-rw-r--r--]gps/libloc_api_50001/loc_eng.cpp102
1 files changed, 81 insertions, 21 deletions
diff --git a/gps/libloc_api_50001/loc_eng.cpp b/gps/libloc_api_50001/loc_eng.cpp
index 007f390..e092f0a 100644..100755
--- a/gps/libloc_api_50001/loc_eng.cpp
+++ b/gps/libloc_api_50001/loc_eng.cpp
@@ -1,4 +1,4 @@
-/* Copyright (c) 2009-2012 Code Aurora Forum. All rights reserved.
+/* Copyright (c) 2009-2012, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -9,7 +9,7 @@
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
- * * Neither the name of Code Aurora Forum, Inc. nor the names of its
+ * * Neither the name of The Linux Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
@@ -57,6 +57,7 @@
#include <loc_eng_dmn_conn_handler.h>
#include <loc_eng_msg.h>
#include <loc_eng_msg_id.h>
+#include <loc_eng_nmea.h>
#include <msg_q.h>
#include <loc.h>
@@ -83,6 +84,7 @@ static loc_param_s_type loc_parameter_table[] =
{"INTERMEDIATE_POS", &gps_conf.INTERMEDIATE_POS, NULL, 'n'},
{"ACCURACY_THRES", &gps_conf.ACCURACY_THRES, NULL, 'n'},
{"ENABLE_WIPER", &gps_conf.ENABLE_WIPER, NULL, 'n'},
+ {"NMEA_PROVIDER", &gps_conf.NMEA_PROVIDER, NULL, 'n'},
{"SUPL_VER", &gps_conf.SUPL_VER, NULL, 'n'},
{"CAPABILITIES", &gps_conf.CAPABILITIES, NULL, 'n'},
{"GYRO_BIAS_RANDOM_WALK", &gps_conf.GYRO_BIAS_RANDOM_WALK, &gps_conf.GYRO_BIAS_RANDOM_WALK_VALID, 'f'},
@@ -111,6 +113,7 @@ static void loc_default_parameters(void)
gps_conf.INTERMEDIATE_POS = 0;
gps_conf.ACCURACY_THRES = 0;
gps_conf.ENABLE_WIPER = 0;
+ gps_conf.NMEA_PROVIDER = 0;
gps_conf.SUPL_VER = 0x10000;
gps_conf.CAPABILITIES = 0x7;
@@ -271,11 +274,13 @@ int loc_eng_init(loc_eng_data_s_type &loc_eng_data, LocCallbacks* callbacks,
void (*loc_external_msg_sender) (void*, void*))
{
+ int ret_val =-1;
+
ENTRY_LOG_CALLFLOW();
if (NULL == callbacks || 0 == event) {
LOC_LOGE("loc_eng_init: bad parameters cb %p eMask %d", callbacks, event);
- EXIT_LOG(%d, 0);
- return NULL;
+ EXIT_LOG(%d, ret_val);
+ return ret_val;
}
if (NULL != loc_eng_data.context) {
@@ -303,7 +308,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
@@ -311,12 +316,21 @@ int loc_eng_init(loc_eng_data_s_type &loc_eng_data, LocCallbacks* callbacks,
// loc_eng_data.fix_session_status -- GPS_STATUS_NONE;
// loc_eng_data.mute_session_state -- LOC_MUTE_SESS_NONE;
+ if ((event & LOC_API_ADAPTER_BIT_NMEA_1HZ_REPORT) && (gps_conf.NMEA_PROVIDER == NMEA_PROVIDER_AP))
+ {
+ event = event ^ LOC_API_ADAPTER_BIT_NMEA_1HZ_REPORT; // unregister for modem NMEA report
+ loc_eng_data.generateNmea = true;
+ }
+ else
+ {
+ loc_eng_data.generateNmea = false;
+ }
+
LocEng locEngHandle(&loc_eng_data, event, loc_eng_data.acquire_wakelock_cb,
loc_eng_data.release_wakelock_cb, loc_eng_msg_sender, loc_external_msg_sender,
callbacks->location_ext_parser, callbacks->sv_ext_parser);
loc_eng_data.client_handle = LocApiAdapter::getLocApiAdapter(locEngHandle);
- int ret_val =-1;
if (NULL == loc_eng_data.client_handle) {
// drop the context and declare failure
((LocEngContext*)(loc_eng_data.context))->drop();
@@ -536,8 +550,8 @@ static int loc_eng_start_handler(loc_eng_data_s_type &loc_eng_data)
if (ret_val == LOC_API_ADAPTER_ERR_SUCCESS ||
ret_val == LOC_API_ADAPTER_ERR_ENGINE_DOWN)
{
- loc_inform_gps_status(loc_eng_data, GPS_STATUS_SESSION_BEGIN);
loc_eng_data.client_handle->setInSession(TRUE);
+ loc_inform_gps_status(loc_eng_data, GPS_STATUS_SESSION_BEGIN);
}
}
@@ -684,7 +698,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;
}
@@ -854,6 +867,11 @@ void loc_eng_agps_init(loc_eng_data_s_type &loc_eng_data, AGpsCallbacks* callbac
STATE_CHECK((NULL == loc_eng_data.agps_status_cb),
"agps instance already initialized",
return);
+ if(callbacks == NULL) {
+ LOC_LOGE("loc_eng_agps_init: bad parameters cb %p", callbacks);
+ EXIT_LOG(%s, VOID_RET);
+ return;
+ }
loc_eng_data.agps_status_cb = callbacks->status_cb;
loc_eng_data.agnss_nif = new AgpsStateMachine(loc_eng_data.agps_status_cb,
@@ -871,10 +889,14 @@ void loc_eng_agps_init(loc_eng_data_s_type &loc_eng_data, AGpsCallbacks* callbac
char baseband[PROPERTY_VALUE_MAX];
property_get("ro.baseband", baseband, "msm");
if ((strcmp(baseband,"svlte2a") == 0) ||
+ (strcmp(baseband,"sglte") == 0) ||
(strcmp(baseband,"msm") == 0))
{
loc_eng_dmn_conn_loc_api_server_launch(callbacks->create_thread_cb,
NULL, NULL, &loc_eng_data);
+ } else {
+ LOC_LOGD("%s:%d] loc_eng_dmn_conn_loc_api_server was not initialized.baseband = %s\n",
+ __func__, __LINE__, baseband);
}
}
#endif /* FEATURE_GNSS_BIT_API */
@@ -1490,13 +1512,21 @@ static void loc_eng_deferred_action_thread(void* arg)
}
// what's in the else if is... (line by line)
// 1. this is a good fix; or
+ // 1.1 there is source info; or
+ // 1.1.1 this is from hybrid provider;
+ // 1.2 it is a Satellite fix; or
+ // 1.2.1 it is a sensor fix
// 2. (must be intermediate fix... implicit)
// 2.1 we accepte intermediate; and
// 2.2 it is NOT the case that
// 2.2.1 there is inaccuracy; and
// 2.2.2 we care about inaccuracy; and
// 2.2.3 the inaccuracy exceeds our tolerance
- else if (LOC_SESS_SUCCESS == rpMsg->status ||
+ else if ((LOC_SESS_SUCCESS == rpMsg->status &&
+ (((LOCATION_HAS_SOURCE_INFO & rpMsg->location.flags) &&
+ ULP_LOCATION_IS_FROM_HYBRID == rpMsg->location.position_source) ||
+ ((LOC_POS_TECH_MASK_SATELLITE & rpMsg->technology_mask) ||
+ (LOC_POS_TECH_MASK_SENSORS & rpMsg->technology_mask)))) ||
(LOC_SESS_INTERMEDIATE == loc_eng_data_p->intermediateFix &&
!((rpMsg->location.flags & GPS_LOCATION_HAS_ACCURACY) &&
(gps_conf.ACCURACY_THRES != 0) &&
@@ -1521,6 +1551,11 @@ static void loc_eng_deferred_action_thread(void* arg)
loc_eng_data_p->client_handle->setInSession(false);
}
+ if (loc_eng_data_p->generateNmea && rpMsg->location.position_source == ULP_LOCATION_IS_FROM_GNSS)
+ {
+ loc_eng_nmea_generate_pos(loc_eng_data_p, rpMsg->location, rpMsg->locationExtended);
+ }
+
// Free the allocated memory for rawData
GpsLocation* gp = (GpsLocation*)&(rpMsg->location);
if (gp != NULL && gp->rawData != NULL)
@@ -1541,6 +1576,12 @@ static void loc_eng_deferred_action_thread(void* arg)
loc_eng_data_p->sv_status_cb((GpsSvStatus*)&(rsMsg->svStatus),
(void*)rsMsg->svExt);
}
+
+ if (loc_eng_data_p->generateNmea)
+ {
+ loc_eng_nmea_generate_sv(loc_eng_data_p, rsMsg->svStatus, rsMsg->locationExtended);
+ }
+
}
break;
@@ -1635,7 +1676,8 @@ static void loc_eng_deferred_action_thread(void* arg)
{
loc_eng_msg_request_wifi *wrqMsg = (loc_eng_msg_request_wifi *)msg;
if (wrqMsg->senderId == LOC_ENG_IF_REQUEST_SENDER_ID_QUIPC ||
- wrqMsg->senderId == LOC_ENG_IF_REQUEST_SENDER_ID_MSAPM) {
+ wrqMsg->senderId == LOC_ENG_IF_REQUEST_SENDER_ID_MSAPM ||
+ wrqMsg->senderId == LOC_ENG_IF_REQUEST_SENDER_ID_MSAPU) {
AgpsStateMachine* stateMachine = loc_eng_data_p->wifi_nif;
WIFISubscriber subscriber(stateMachine, wrqMsg->ssid, wrqMsg->password, wrqMsg->senderId);
stateMachine->subscribeRsrc((Subscriber*)&subscriber);
@@ -1663,6 +1705,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:
@@ -1856,15 +1906,15 @@ int loc_eng_ulp_init(loc_eng_data_s_type &loc_eng_data, const ulpInterface * loc
{
ENTRY_LOG();
int ret_val=-1;
-
- if(loc_eng_ulpInf != NULL)
+ if((loc_eng_ulpInf != NULL) && (((ulpInterface *)loc_eng_ulpInf)->init != NULL))
{
// Initialize the ULP interface
((ulpInterface *)loc_eng_ulpInf)->init(loc_eng_data);
loc_eng_data.ulp_initialized = TRUE;
+ ret_val = 0;
}
- ret_val = 0;
-exit:
+ else
+ LOC_LOGE("ulp not initialized. NULL parameter");
EXIT_LOG(%d, ret_val);
return ret_val;
}
@@ -2018,9 +2068,14 @@ SIDE EFFECTS
===========================================================================*/
int loc_eng_ulp_phone_context_init(loc_eng_data_s_type &loc_eng_data,UlpPhoneContextCallbacks *callback)
{
+ int ret_val = -1;
ENTRY_LOG();
- loc_eng_data.ulp_phone_context_req_cb = callback->ulp_request_phone_context_cb ;
- int ret_val =0;
+ if(callback != NULL) {
+ loc_eng_data.ulp_phone_context_req_cb = callback->ulp_request_phone_context_cb ;
+ ret_val = 0;
+ }
+ else
+ LOC_LOGE("loc_eng_ulp_phone_context_init: bad parameters cb %p", callback);
EXIT_LOG(%d, ret_val);
return ret_val;
}
@@ -2044,11 +2099,16 @@ SIDE EFFECTS
int loc_eng_ulp_network_init(loc_eng_data_s_type &loc_eng_data,
UlpNetworkLocationCallbacks *callbacks)
{
- ENTRY_LOG_CALLFLOW();
- loc_eng_data.ulp_network_callback = callbacks->ulp_network_location_request_cb;
- int ret_val =0;
- EXIT_LOG(%d, ret_val);
- return ret_val;
+ int ret_val = -1;
+ ENTRY_LOG_CALLFLOW();
+ if(callbacks != NULL) {
+ loc_eng_data.ulp_network_callback = callbacks->ulp_network_location_request_cb;
+ ret_val = 0;
+ }
+ else
+ LOC_LOGE("loc_eng_ulp_network_init: bad parameters cb %p", callbacks);
+ EXIT_LOG(%d, ret_val);
+ return ret_val;
}