const GpsGeofencingInterface* get_geofence_interface(void) { ENTRY_LOG(); void *handle; const char *error; typedef const GpsGeofencingInterface* (*get_gps_geofence_interface_function) (void); get_gps_geofence_interface_function get_gps_geofence_interface; static const GpsGeofencingInterface* geofence_interface = NULL; dlerror(); /* Clear any existing error */ handle = dlopen ("libgeofence.so", RTLD_NOW); if (!handle) { if ((error = dlerror()) != NULL) { LOC_LOGE ("%s, dlopen for libgeofence.so failed, error = %s\n", __func__, error); } goto exit; } dlerror(); /* Clear any existing error */ get_gps_geofence_interface = (get_gps_geofence_interface_function)dlsym(handle, "gps_geofence_get_interface"); if ((error = dlerror()) != NULL) { LOC_LOGE ("%s, dlsym for ulpInterface failed, error = %s\n", __func__, error); goto exit; } geofence_interface = get_gps_geofence_interface(); exit: EXIT_LOG(%d, geofence_interface == NULL); return geofence_interface; }
int32 loc_close ( rpc_loc_client_handle_type handle ) { ENTRY_LOG(); LOC_GLUE_CHECK_INIT(int32); int32 ret_val; rpc_loc_close_args args; args.handle = handle; rpc_loc_close_rets rets; enum clnt_stat stat = RPC_SUCCESS; EXIT_LOG_CALLFLOW(%s, "loc client close"); stat = RPC_FUNC_VERSION(rpc_loc_close_, RPC_LOC_CLOSE_VERSION)(&args, &rets, loc_api_clnt); loc_clear(handle); LOC_GLUE_CHECK_RESULT(stat, int32); ret_val = (int32) rets.loc_close_result; return ret_val; }
/*=========================================================================== FUNCTION loc_init DESCRIPTION Initialize the location engine, this include setting up global datas and registers location engien with loc api service. DEPENDENCIES None RETURN VALUE 0: success SIDE EFFECTS N/Ax ===========================================================================*/ static int loc_init(GpsCallbacks* callbacks) { ENTRY_LOG(); LOC_API_ADAPTER_EVENT_MASK_T event = LOC_API_ADAPTER_BIT_PARSED_POSITION_REPORT | LOC_API_ADAPTER_BIT_SATELLITE_REPORT | LOC_API_ADAPTER_BIT_LOCATION_SERVER_REQUEST | LOC_API_ADAPTER_BIT_ASSISTANCE_DATA_REQUEST | LOC_API_ADAPTER_BIT_IOCTL_REPORT | LOC_API_ADAPTER_BIT_STATUS_REPORT | LOC_API_ADAPTER_BIT_NMEA_1HZ_REPORT | LOC_API_ADAPTER_BIT_NI_NOTIFY_VERIFY_REQUEST; LocCallbacks clientCallbacks = {loc_cb, /* location_cb */ callbacks->status_cb, /* status_cb */ sv_cb, /* sv_status_cb */ callbacks->nmea_cb, /* nmea_cb */ callbacks->set_capabilities_cb, /* set_capabilities_cb */ callbacks->acquire_wakelock_cb, /* acquire_wakelock_cb */ callbacks->release_wakelock_cb, /* release_wakelock_cb */ callbacks->create_thread_cb, /* create_thread_cb */ NULL, /* location_ext_parser */ NULL /* sv_ext_parser */}; gps_loc_cb = callbacks->location_cb; gps_sv_cb = callbacks->sv_status_cb; int ret_val = loc_eng_init(loc_afw_data, &clientCallbacks, event); EXIT_LOG(%d, ret_val); return ret_val; }
/*=========================================================================== FUNCTION loc_set_position_mode DESCRIPTION Sets the mode and fix frequency for the tracking session. DEPENDENCIES None RETURN VALUE 0: success SIDE EFFECTS N/A ===========================================================================*/ static int loc_set_position_mode(GpsPositionMode mode, GpsPositionRecurrence recurrence, uint32_t min_interval, uint32_t preferred_accuracy, uint32_t preferred_time) { ENTRY_LOG(); LocPositionMode locMode; switch (mode) { case GPS_POSITION_MODE_MS_BASED: locMode = LOC_POSITION_MODE_MS_BASED; break; case GPS_POSITION_MODE_MS_ASSISTED: locMode = LOC_POSITION_MODE_MS_ASSISTED; break; default: locMode = LOC_POSITION_MODE_STANDALONE; break; } LocPosMode params(locMode, recurrence, min_interval, preferred_accuracy, preferred_time, NULL, NULL); int ret_val = loc_eng_set_position_mode(loc_afw_data, params); EXIT_LOG(%d, ret_val); return ret_val; }
/*=========================================================================== FUNCTION loc_delete_aiding_data DESCRIPTION This is used by Java native function to delete the aiding data. The function updates the global variable for the aiding data to be deleted. If the GPS engine is off, the aiding data will be deleted. Otherwise, the actual action will happen when gps engine is turned off. DEPENDENCIES Assumes the aiding data type specified in GpsAidingData matches with LOC API specification. RETURN VALUE None SIDE EFFECTS N/A ===========================================================================*/ static void loc_delete_aiding_data(GpsAidingData f) { ENTRY_LOG(); loc_eng_delete_aiding_data(loc_afw_data, f); EXIT_LOG(%s, VOID_RET); }
/*=========================================================================== FUNCTION loc_inject_raw_command DESCRIPTION This is used to send special test modem commands from the applications down into the HAL DEPENDENCIES N/A RETURN VALUE 0: success SIDE EFFECTS N/A ===========================================================================*/ static bool loc_inject_raw_command(char* command, int length) { ENTRY_LOG(); int ret_val = loc_eng_inject_raw_command(loc_afw_data, command, length); EXIT_LOG(%s, loc_logger_boolStr[ret_val!=0]); return ret_val; }
static void loc_cb(GpsLocation* location, void* locExt) { ENTRY_LOG(); if (NULL != gps_loc_cb && NULL != location) { CALLBACK_LOG_CALLFLOW("location_cb - from", %d, location->position_source); gps_loc_cb(location); }
/*=========================================================================== FUNCTION loc_get_extension DESCRIPTION Get the gps extension to support XTRA. DEPENDENCIES N/A RETURN VALUE The GPS extension interface. SIDE EFFECTS N/A ===========================================================================*/ static const void* loc_get_extension(const char* name) { ENTRY_LOG(); const void* ret_val = NULL; if (strcmp(name, GPS_XTRA_INTERFACE) == 0) { ret_val = &sLocEngXTRAInterface; } else if (strcmp(name, AGPS_INTERFACE) == 0) { ret_val = &sLocEngAGpsInterface; } else if (strcmp(name, GPS_NI_INTERFACE) == 0) { ret_val = &sLocEngNiInterface; } else if (strcmp(name, AGPS_RIL_INTERFACE) == 0) { char baseband[PROPERTY_VALUE_MAX]; property_get("ro.baseband", baseband, "msm"); if (strcmp(baseband, "csfb") == 0) { ret_val = &sLocEngAGpsRilInterface; } } else if (strcmp(name, ULP_RAW_CMD_INTERFACE) == 0) { ret_val = &sLocEngInjectRawCmdInterface; } else if(strcmp(name, ULP_PHONE_CONTEXT_INTERFACE) == 0) { ret_val = &sLocEngUlpPhoneContextInterface; } else if(strcmp(name, ULP_NETWORK_INTERFACE) == 0) { //Return a valid value for ULP Network Interface only if ULP //turned on in gps.conf if(gps_conf.CAPABILITIES & ULP_CAPABILITY) ret_val = &sUlpNetworkInterface; } else if (strcmp(name, GPS_GEOFENCING_INTERFACE) == 0) { if ((gps_conf.CAPABILITIES | GPS_CAPABILITY_GEOFENCING) == gps_conf.CAPABILITIES) { ret_val = get_geofence_interface(); } } else { LOC_LOGE ("get_extension: Invalid interface passed in\n"); } EXIT_LOG(%p, ret_val); return ret_val; }
/*=========================================================================== FUNCTION loc_inject_time DESCRIPTION This is used by Java native function to do time injection. DEPENDENCIES None RETURN VALUE 0 SIDE EFFECTS N/A ===========================================================================*/ static int loc_inject_time(GpsUtcTime time, int64_t timeReference, int uncertainty) { ENTRY_LOG(); int ret_val = loc_eng_inject_time(loc_afw_data, time, timeReference, uncertainty); EXIT_LOG(%d, ret_val); return ret_val; }
/*=========================================================================== FUNCTION loc_stop DESCRIPTION Stops the tracking session DEPENDENCIES None RETURN VALUE 0: success SIDE EFFECTS N/A ===========================================================================*/ static int loc_stop() { ENTRY_LOG(); int ret_val = loc_eng_stop(loc_afw_data); EXIT_LOG(%d, ret_val); return ret_val; }
static int loc_agps_open(const char* apn) { ENTRY_LOG(); int ret_val = loc_eng_agps_open(loc_afw_data, apn); EXIT_LOG(%d, ret_val); return ret_val; }
/*=========================================================================== FUNCTION loc_inject_location DESCRIPTION This is used by Java native function to do location injection. DEPENDENCIES None RETURN VALUE 0 : Successful error code : Failure SIDE EFFECTS N/A ===========================================================================*/ static int loc_inject_location(double latitude, double longitude, float accuracy) { ENTRY_LOG(); int ret_val = loc_eng_inject_location(loc_afw_data, latitude, longitude, accuracy); EXIT_LOG(%d, ret_val); return ret_val; }
/*=========================================================================== FUNCTION loc_cleanup DESCRIPTION Cleans location engine. The location client handle will be released. DEPENDENCIES None RETURN VALUE None SIDE EFFECTS N/A ===========================================================================*/ static void loc_cleanup() { ENTRY_LOG(); loc_eng_cleanup(loc_afw_data); gps_loc_cb = NULL; gps_sv_cb = NULL; EXIT_LOG(%s, VOID_RET); }
/*=========================================================================== FUNCTION loc_xtra_inject_data DESCRIPTION Initialize XTRA module. DEPENDENCIES None RETURN VALUE 0: success SIDE EFFECTS N/A ===========================================================================*/ static int loc_xtra_inject_data(char* data, int length) { ENTRY_LOG(); int ret_val = loc_eng_xtra_inject_data(loc_afw_data, data, length); EXIT_LOG(%d, ret_val); return ret_val; }
/*=========================================================================== FUNCTION loc_agps_closed DESCRIPTION This function is called when on-demand data connection closing is done. It should inform ARM 9 about the data close result. DEPENDENCIES NONE RETURN VALUE 0 SIDE EFFECTS N/A ===========================================================================*/ static int loc_agps_closed(AGpsType agpsType) { ENTRY_LOG(); int ret_val = loc_eng_agps_closed(loc_afw_data, agpsType); EXIT_LOG(%d, ret_val); return ret_val; }
/*=========================================================================== FUNCTION loc_agps_open_failed DESCRIPTION This function is called when on-demand data connection opening has failed. It should inform ARM 9 about the data open result. DEPENDENCIES NONE RETURN VALUE 0 SIDE EFFECTS N/A ===========================================================================*/ int loc_agps_open_failed(AGpsType agpsType) { ENTRY_LOG(); int ret_val = loc_eng_agps_open_failed(loc_afw_data, agpsType); EXIT_LOG(%d, ret_val); return ret_val; }
/*=========================================================================== FUNCTION loc_update_criteria DESCRIPTION This is used to inform the ULP module of new unique criteria that are passed in by the applications DEPENDENCIES N/A RETURN VALUE 0: success SIDE EFFECTS N/A ===========================================================================*/ static int loc_update_criteria(UlpLocationCriteria criteria) { ENTRY_LOG(); int ret_val = loc_eng_update_criteria(loc_afw_data, criteria); EXIT_LOG(%d, ret_val); return ret_val; }
/*=========================================================================== FUNCTION loc_xtra_init DESCRIPTION Initialize XTRA module. DEPENDENCIES None RETURN VALUE 0: success SIDE EFFECTS N/A ===========================================================================*/ static int loc_xtra_init(GpsXtraCallbacks* callbacks) { ENTRY_LOG(); int ret_val = loc_eng_xtra_init(loc_afw_data, callbacks); EXIT_LOG(%d, ret_val); return ret_val; }
/*=========================================================================== FUNCTION loc_agps_open DESCRIPTION This function is called when on-demand data connection opening is successful. It should inform ARM 9 about the data open result. DEPENDENCIES NONE RETURN VALUE 0 SIDE EFFECTS N/A ===========================================================================*/ static int loc_agps_open(AGpsType agpsType, const char* apn, AGpsBearerType bearerType) { ENTRY_LOG(); int ret_val = loc_eng_agps_open(loc_afw_data, agpsType, apn, bearerType); EXIT_LOG(%d, ret_val); return ret_val; }
/*=========================================================================== FUNCTION loc_init DESCRIPTION Initialize the location engine, this include setting up global datas and registers location engien with loc api service. DEPENDENCIES None RETURN VALUE 0: success SIDE EFFECTS N/Ax ===========================================================================*/ static int loc_init(GpsCallbacks* callbacks) { int retVal = -1; ENTRY_LOG(); if(callbacks == NULL) { LOC_LOGE("loc_init failed. cb = NULL\n"); EXIT_LOG(%d, retVal); return retVal; }
static void loc_cb(GpsLocation* location, void* locExt) { ENTRY_LOG(); if (NULL != gps_loc_cb && NULL != location) { #ifdef QCOM_FEATURE_ULP CALLBACK_LOG_CALLFLOW("location_cb - from", %d, location->position_source); #else CALLBACK_LOG_CALLFLOW("location_cb - at", %llu, location->timestamp); #endif gps_loc_cb(location); }
/*=========================================================================== FUNCTION loc_eng_ni_request_handler DESCRIPTION Displays the NI request and awaits user input. If a previous request is in session, it is ignored. RETURN VALUE none ===========================================================================*/ void loc_eng_ni_request_handler(loc_eng_data_s_type &loc_eng_data, const GpsNiNotification *notif, const void* passThrough) { ENTRY_LOG(); char lcs_addr[32]; // Decoded LCS address for UMTS CP NI loc_eng_ni_data_s_type* loc_eng_ni_data_p = &loc_eng_data.loc_eng_ni_data; if (NULL == loc_eng_data.ni_notify_cb) { EXIT_LOG(%s, "loc_eng_ni_init hasn't happened yet."); return; }
/*=========================================================================== FUNCTION loc_init DESCRIPTION Initialize the location engine, this include setting up global datas and registers location engien with loc api service. DEPENDENCIES None RETURN VALUE 0: success SIDE EFFECTS N/Ax ===========================================================================*/ static int loc_init(GpsCallbacks* callbacks) { ENTRY_LOG(); LOC_API_ADAPTER_EVENT_MASK_T event = LOC_API_ADAPTER_BIT_PARSED_POSITION_REPORT | LOC_API_ADAPTER_BIT_SATELLITE_REPORT | LOC_API_ADAPTER_BIT_LOCATION_SERVER_REQUEST | LOC_API_ADAPTER_BIT_ASSISTANCE_DATA_REQUEST | LOC_API_ADAPTER_BIT_IOCTL_REPORT | LOC_API_ADAPTER_BIT_STATUS_REPORT | LOC_API_ADAPTER_BIT_NMEA_1HZ_REPORT | LOC_API_ADAPTER_BIT_NI_NOTIFY_VERIFY_REQUEST; LocCallbacks clientCallbacks = {loc_cb, /* location_cb */ callbacks->status_cb, /* status_cb */ sv_cb, /* sv_status_cb */ callbacks->nmea_cb, /* nmea_cb */ callbacks->set_capabilities_cb, /* set_capabilities_cb */ callbacks->acquire_wakelock_cb, /* acquire_wakelock_cb */ callbacks->release_wakelock_cb, /* release_wakelock_cb */ callbacks->create_thread_cb, /* create_thread_cb */ NULL, /* location_ext_parser */ NULL /* sv_ext_parser */}; gps_loc_cb = callbacks->location_cb; gps_sv_cb = callbacks->sv_status_cb; if (get_target_name() == TARGET_NAME_APQ8064_STANDALONE) { gps_conf.CAPABILITIES &= ~(GPS_CAPABILITY_MSA | GPS_CAPABILITY_MSB); gss_fd = open("/dev/gss", O_RDONLY); if (gss_fd < 0) { LOC_LOGE("GSS open failed: %s\n", strerror(errno)); return NULL; } LOC_LOGD("GSS open success! CAPABILITIES %0x\n", gps_conf.CAPABILITIES); } int retVal = -1; if (loc_eng_ulp_inf == NULL) retVal = loc_eng_init(loc_afw_data, &clientCallbacks, event, NULL); else retVal = loc_eng_init(loc_afw_data, &clientCallbacks, event, loc_ulp_msg_sender); int ret_val1 = loc_eng_ulp_init(loc_afw_data, loc_eng_ulp_inf); LOC_LOGD("loc_eng_ulp_init returned %d\n",ret_val1); EXIT_LOG(%d, retVal); return retVal; }
/*=========================================================================== FUNCTION loc_cleanup DESCRIPTION Cleans location engine. The location client handle will be released. DEPENDENCIES None RETURN VALUE None SIDE EFFECTS N/A ===========================================================================*/ static void loc_cleanup() { ENTRY_LOG(); loc_eng_cleanup(loc_afw_data); gps_loc_cb = NULL; gps_sv_cb = NULL; /* * if (get_target_name() == TARGET_NAME_APQ8064_STANDALONE) * { * close(gss_fd); * LOC_LOGD("GSS shutdown.\n"); * } */ EXIT_LOG(%s, VOID_RET); }
/*=========================================================================== FUNCTION loc_agps_set_server DESCRIPTION If loc_eng_set_server is called before loc_eng_init, it doesn't work. This proxy buffers server settings and calls loc_eng_set_server when the client is open. DEPENDENCIES NONE RETURN VALUE 0 SIDE EFFECTS N/A ===========================================================================*/ static int loc_agps_set_server(AGpsType type, const char* hostname, int port) { ENTRY_LOG(); LocServerType serverType; switch (type) { case AGPS_TYPE_SUPL: serverType = LOC_AGPS_SUPL_SERVER; break; case AGPS_TYPE_C2K: serverType = LOC_AGPS_CDMA_PDE_SERVER; break; } int ret_val = loc_eng_set_server_proxy(loc_afw_data, serverType, hostname, port); EXIT_LOG(%d, ret_val); return ret_val; }
static void* ulp_zpp_thread_proc(void *args) { ENTRY_LOG(); ulp_data_s_type* ulp_data_p = (ulp_data_s_type*)args; zpp_provider_info_s_type* zpp_provider_info_p = &ulp_data_p->zpp_provider_info; int rc = 0; /* return code from pthread calls */ struct timeval present_time; struct timespec expire_time; LOC_LOGD("Starting ulp_zpp thread...\n"); pthread_mutex_lock(&zpp_provider_info_p->tLock); while (zpp_provider_info_p->periodic_session_active) { /* Calculate absolute expire time */ gettimeofday(&present_time, NULL); expire_time.tv_sec = present_time.tv_sec + (zpp_provider_info_p->zpp_trigger_threshold/1000); expire_time.tv_nsec = present_time.tv_usec * 1000; LOC_LOGD("%s,ulp_zpp_thread_proc-Present time %ld, Time out set for abs time %ld with delay %d msec\n", __func__,(long) present_time.tv_sec, (long) expire_time.tv_sec, zpp_provider_info_p->zpp_trigger_threshold ); rc = pthread_cond_timedwait(&zpp_provider_info_p->tCond, &zpp_provider_info_p->tLock, &expire_time); if (rc == ETIMEDOUT) { LOC_LOGD("%s,ulp_zpp_thread_proc-Thread waking up. Ret Val %d\n",__func__, rc ); ulp_msg_system_update *msg(new ulp_msg_system_update(&ulp_data, ULP_LOC_ZPP_PERIODIC_WAKEUP)); msg_q_snd(ulp_data.loc_proxy->mQ, msg,ulp_msg_free); } } pthread_mutex_unlock(&zpp_provider_info_p->tLock); if (ETIMEDOUT != rc) { LOC_LOGD("ulp_zpp thread was signalled to exit. pthread_cond_timedwait = %d\n",rc ); } EXIT_LOG(%s, VOID_RET); return NULL; }
/** @brief Routes client register to the SLIM daemon task Function routes client register to the SLIM daemon task. @param request: Open request transaction data. */ void ClientListener::processClientRegister(slim_OpenTxnStructType &request) { ENTRY_LOG(); SlimDaemonMessage slimApMessage; memset(&slimApMessage, 0, sizeof(slimApMessage)); SlimDaemonMessage* pSlimDaemonMessage = &slimApMessage; pSlimDaemonMessage->msgHeader.msgSize = sizeof(*pSlimDaemonMessage); pSlimDaemonMessage->msgHeader.msgType = SLIM_DAEMON_CLIENT_OPEN_REQUEST; pSlimDaemonMessage->msgData.request.data.openRequest = request; bool rv = CLMsgQSnd(pSlimDaemonMessage, sizeof(*pSlimDaemonMessage)); if(!rv) { LOC_LOGE("%s: Failed sending sensor request", __FUNCTION__); } EXIT_LOG(%d, rv); }
/** @brief Routes time request to the SLIM daemon task Function routes time request to the SLIM daemon task. @param request: Time request transaction data. */ void ClientListener::processTimeRequest( slim_GetProviderTimeRequestTxnStructType &request) { ENTRY_LOG(); SlimDaemonMessage slimApMessage; memset(&slimApMessage, 0, sizeof(slimApMessage)); SlimDaemonMessage* pSlimDaemonMessage = &slimApMessage; pSlimDaemonMessage->msgHeader.msgSize = sizeof(*pSlimDaemonMessage); pSlimDaemonMessage->msgHeader.msgType = SLIM_DAEMON_TIME_SYNC_DATA_REQUEST; pSlimDaemonMessage->msgData.request.data.timeRequest = request; bool rv = CLMsgQSnd(pSlimDaemonMessage, sizeof(*pSlimDaemonMessage)); if(!rv) { LOC_LOGE("%s: Failed sending time request", __FUNCTION__); } EXIT_LOG(%d, rv); }
/** @brief Routes motion data request to the SLIM daemon task Function routes motion data request to the SLIM daemon task. @param request: Motion data request transaction data. */ void ClientListener::processMotionDataRequest( slim_EnableMotionDataTxnStructType &request) { ENTRY_LOG(); SlimDaemonMessage slimApMessage; memset(&slimApMessage, 0, sizeof(slimApMessage)); SlimDaemonMessage* pSlimDaemonMessage = &slimApMessage; pSlimDaemonMessage->msgHeader.msgSize = sizeof(*pSlimDaemonMessage); pSlimDaemonMessage->msgHeader.msgType = SLIM_DAEMON_MOTION_DATA_REQUEST; pSlimDaemonMessage->msgData.request.data.motionDataRequest = request; bool rv = CLMsgQSnd(pSlimDaemonMessage, sizeof(*pSlimDaemonMessage)); if(!rv) { LOC_LOGE("%s: Failed sending motion data request", __FUNCTION__); } EXIT_LOG(%d, rv); }
/*=========================================================================== FUNCTION loc_get_extension DESCRIPTION Get the gps extension to support XTRA. DEPENDENCIES N/A RETURN VALUE The GPS extension interface. SIDE EFFECTS N/A ===========================================================================*/ static const void* loc_get_extension(const char* name) { ENTRY_LOG(); const void* ret_val = NULL; if (strcmp(name, GPS_XTRA_INTERFACE) == 0) { ret_val = &sLocEngXTRAInterface; } else if (strcmp(name, AGPS_INTERFACE) == 0) { ret_val = &sLocEngAGpsInterface; } else if (strcmp(name, GPS_NI_INTERFACE) == 0) { ret_val = &sLocEngNiInterface; } else if (strcmp(name, AGPS_RIL_INTERFACE) == 0) { ret_val = &sLocEngAGpsRilInterface; } #ifdef QCOM_FEATURE_ULP else if (strcmp(name, ULP_RAW_CMD_INTERFACE) == 0) { ret_val = &sLocEngInjectRawCmdInterface; } #endif else { LOC_LOGE ("get_extension: Invalid interface passed in\n"); } EXIT_LOG(%p, ret_val); return ret_val; }