Merge "Merge up to MR1 tip"

This commit is contained in:
Linux Build Service Account 2013-07-21 15:29:22 -07:00 committed by Gohulan Balachandran
commit 2077be9e0a
59 changed files with 22101 additions and 460 deletions

10
Makefile.am Normal file
View file

@ -0,0 +1,10 @@
# Makefile.am - Automake script for gps loc_api
#
ACLOCAL_AMFLAGS = -I m4
SUBDIRS = utils loc_api/libloc_api_50001 loc_api/loc_api_v02
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = loc-api.pc
EXTRA_DIST = $(pkgconfig_DATA)

85
configure.ac Normal file
View file

@ -0,0 +1,85 @@
# configure.ac -- Autoconf script for gps loc_api
#
# Process this file with autoconf to produce a configure script
# Requires autoconf tool later than 2.61
AC_PREREQ(2.61)
# Initialize the gps loc_api package version 1.0.0
AC_INIT([loc-api],1.0.0)
# Does not strictly follow GNU Coding standards
AM_INIT_AUTOMAKE([foreign])
# Disables auto rebuilding of configure, Makefile.ins
AM_MAINTAINER_MODE
# Verifies the --srcdir is correct by checking for the path
AC_CONFIG_SRCDIR([utils/loc_cfg.cpp])
# defines some macros variable to be included by source
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_MACRO_DIR([m4])
# Checks for programs.
AC_PROG_LIBTOOL
AC_PROG_CXX
AC_PROG_CC
AM_PROG_CC_C_O
AC_PROG_AWK
AC_PROG_CPP
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_MAKE_SET
PKG_PROG_PKG_CONFIG
# Checks for libraries.
PKG_CHECK_MODULES([QMIF], [qmi-framework])
AC_SUBST([QMIF_CFLAGS])
AC_SUBST([QMIF_LIBS])
AC_ARG_WITH([libhardware_includes],
AC_HELP_STRING([--with-libhardware-includes=@<:@dir@:>@],
[Specify the location of the libhardware headers]),
[libhardware_incdir=$withval],
with_libhardware_includes=no)
if test "x$with_libhardware_includes" != "xno"; then
CPPFLAGS="${CPPFLAGS} -I${libhardware_incdir}"
fi
AC_ARG_WITH([core_includes],
AC_HELP_STRING([--with-core-includes=@<:@dir@:>@],
[Specify the location of the core headers]),
[core_incdir=$withval],
with_core_includes=no)
if test "x$with_core_includes" != "xno"; then
CPPFLAGS="${CPPFLAGS} -I${core_incdir}"
fi
AC_SUBST([CPPFLAGS])
AC_ARG_WITH([glib],
AC_HELP_STRING([--with-glib],
[enable glib, building HLOS systems which use glib]))
if (test "x${with_glib}" = "xyes"); then
AC_DEFINE(ENABLE_USEGLIB, 1, [Define if HLOS systems uses glib])
PKG_CHECK_MODULES(GTHREAD, gthread-2.0 >= 2.16, dummy=yes,
AC_MSG_ERROR(GThread >= 2.16 is required))
PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.16, dummy=yes,
AC_MSG_ERROR(GLib >= 2.16 is required))
GLIB_CFLAGS="$GLIB_CFLAGS $GTHREAD_CFLAGS"
GLIB_LIBS="$GLIB_LIBS $GTHREAD_LIBS"
AC_SUBST(GLIB_CFLAGS)
AC_SUBST(GLIB_LIBS)
fi
AM_CONDITIONAL(USE_GLIB, test "x${with_glib}" = "xyes")
AC_CONFIG_FILES([ \
Makefile \
utils/Makefile \
loc_api/libloc_api_50001/Makefile \
loc_api/loc_api_v02/Makefile \
loc-api.pc \
])
AC_OUTPUT

View file

@ -25,6 +25,7 @@ NTP_SERVER=time.gpsonextra.net
# DEBUG LEVELS: 0 - none, 1 - Error, 2 - Warning, 3 - Info
# 4 - Debug, 5 - Verbose
# If DEBUG_LEVEL is commented, Android's logging levels will be used
DEBUG_LEVEL = 3
# Intermediate position report, 1=enable, 0=disable

10
loc-api.pc.in Normal file
View file

@ -0,0 +1,10 @@
prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
includedir=@includedir@
Name: loc-api
Description: Qualcomm GPS Location API
Version: @VERSION@
Libs: -L${libdir} -lgps_utils_so -lloc_adapter_so -lloc_eng_so -lgps_default_so -lloc_api
Cflags: -I${includedir}/loc-api/libloc_api_50001 -I${includedir}/loc-api/utils -I${includedir}/ -I${includedir}/loc-api

49
loc_api/ds_api/Android.mk Normal file
View file

@ -0,0 +1,49 @@
ifneq ($(BUILD_TINY_ANDROID),true)
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := libds_api
LOCAL_MODULE_TAGS := optional
LOCAL_SHARED_LIBRARIES := \
libutils \
libcutils \
libqmi_cci \
libqmi_csi \
libqmi_common_so \
libgps.utils \
libdsi_netctrl \
libqmiservices
LOCAL_SRC_FILES += \
ds_client.c
LOCAL_CFLAGS += \
-fno-short-enums \
-D_ANDROID_
LOCAL_COPY_HEADERS_TO:= ds_api/
LOCAL_COPY_HEADERS:= \
ds_client.h
LOCAL_LDFLAGS += -Wl,--export-dynamic
## Includes
LOCAL_C_INCLUDES := \
$(TARGET_OUT_HEADERS)/libloc_eng \
$(TARGET_OUT_HEADERS)/qmi-framework/inc \
$(TARGET_OUT_HEADERS)/qmi/inc \
$(TARGET_OUT_HEADERS)/gps.utils \
$(TARGET_OUT_HEADERS)/data/inc
LOCAL_PRELINK_MODULE := false
include $(BUILD_SHARED_LIBRARY)
endif # not BUILD_TINY_ANDROID

704
loc_api/ds_api/ds_client.c Normal file
View file

@ -0,0 +1,704 @@
/* Copyright (c) 2013, 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
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* 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 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.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#define LOG_NDEBUG 0
#define LOG_TAG "LocSvc_ds_client"
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <stdbool.h>
#include <stddef.h>
#include <wireless_data_service_v01.h>
#include <utils/Log.h>
#include <log_util.h>
#include <loc_log.h>
#include <qmi_client.h>
#include <qmi_idl_lib.h>
#include <qmi_cci_target_ext.h>
#include <qmi_cci_target.h>
#include <qmi_cci_common.h>
#include <dsi_netctrl.h>
#include <ds_client.h>
#include<sys/time.h>
//Timeout to wait for wds service notification from qmi
#define DS_CLIENT_SERVICE_TIMEOUT (4000)
//Max timeout for the service to come up
#define DS_CLIENT_SERVICE_TIMEOUT_TOTAL (40000)
//Timeout for the service to respond to sync msg
#define DS_CLIENT_SYNC_MSG_TIMEOUT (5000)
/*Request messages the WDS client can send to the WDS service*/
typedef union
{
/*Requests the service for a list of all profiles present*/
wds_get_profile_list_req_msg_v01 *p_get_profile_list_req;
/*Requests the service for a profile's settings*/
wds_get_profile_settings_req_msg_v01 *p_get_profile_settings_req;
}ds_client_req_union_type;
/*Response indications that are sent by the WDS service*/
typedef union
{
wds_get_profile_list_resp_msg_v01 *p_get_profile_list_resp;
wds_get_profile_settings_resp_msg_v01 *p_get_profile_setting_resp;
}ds_client_resp_union_type;
struct event_strings_s
{
char * str;
dsi_net_evt_t evt;
};
struct event_strings_s event_string_tbl[DSI_EVT_MAX] =
{
NAME_VAL(DSI_EVT_INVALID),
NAME_VAL(DSI_EVT_NET_IS_CONN),
NAME_VAL(DSI_EVT_NET_NO_NET),
NAME_VAL(DSI_EVT_PHYSLINK_DOWN_STATE),
NAME_VAL(DSI_EVT_PHYSLINK_UP_STATE),
NAME_VAL(DSI_EVT_NET_RECONFIGURED),
};
typedef struct
{
ds_client_event_ind_cb_type event_cb;
void *caller_cookie;
}ds_caller_data;
typedef struct {
//Global dsi handle
dsi_hndl_t dsi_net_handle;
//Handle to caller's data
ds_caller_data caller_data;
} ds_client_session_data;
void net_ev_cb(dsi_hndl_t handle, void* user_data,
dsi_net_evt_t evt, dsi_evt_payload_t *payload_ptr)
{
int i;
(void)handle;
(void)user_data;
(void)payload_ptr;
ds_caller_data *callback_data = (ds_caller_data *)user_data;
LOC_LOGD("%s:%d]:Enter\n", __func__, __LINE__);
if(evt > DSI_EVT_INVALID && evt < DSI_EVT_MAX)
{
for(i=0;i<DSI_EVT_MAX;i++)
{
if(event_string_tbl[i].evt == evt)
LOC_LOGE("%s:%d]: Callback received: %s",
__func__, __LINE__, event_string_tbl[i].str);
}
switch(evt) {
case DSI_EVT_NET_IS_CONN:
{
LOC_LOGD("%s:%d]: Emergency call started\n", __func__, __LINE__);
callback_data->event_cb(E_DS_CLIENT_DATA_CALL_CONNECTED,
callback_data->caller_cookie);
break;
}
case DSI_EVT_NET_NO_NET:
{
LOC_LOGD("%s:%d]: Emergency call stopped\n", __func__, __LINE__);
callback_data->event_cb(E_DS_CLIENT_DATA_CALL_DISCONNECTED,
callback_data->caller_cookie);
break;
}
default:
LOC_LOGD("%s:%d]: uninteresting event\n", __func__, __LINE__);
}
}
LOC_LOGD("%s:%d]:Exit\n", __func__, __LINE__);
}
/*This function is called to obtain a handle to the QMI WDS service*/
static ds_client_status_enum_type
ds_client_qmi_ctrl_point_init(qmi_client_type *p_wds_qmi_client)
{
qmi_client_type wds_qmi_client, notifier = NULL;
ds_client_status_enum_type status = E_DS_CLIENT_SUCCESS;
qmi_service_info *p_service_info = NULL;
uint32_t num_services = 0, num_entries = 0;
qmi_client_error_type ret = QMI_NO_ERR;
unsigned char no_signal = 0;
qmi_client_os_params os_params;
int timeout = 0;
LOC_LOGD("%s:%d]:Enter\n", __func__, __LINE__);
//Get service object for QMI_WDS service
qmi_idl_service_object_type ds_client_service_object =
wds_get_service_object_v01();
if(ds_client_service_object == NULL) {
LOC_LOGE("%s:%d]: wds_get_service_object_v01 failed\n" ,
__func__, __LINE__);
status = E_DS_CLIENT_FAILURE_INTERNAL;
goto err;
}
//get service addressing information
ret = qmi_client_get_service_list(ds_client_service_object, NULL, NULL,
&num_services);
LOC_LOGD("%s:%d]: qmi_client_get_service_list() first try ret %d, "
"num_services %d]\n", __func__, __LINE__, ret, num_services);
if(ret != QMI_NO_ERR) {
//Register for service notification
ret = qmi_client_notifier_init(ds_client_service_object, &os_params, &notifier);
if (ret != QMI_NO_ERR) {
LOC_LOGE("%s:%d]: qmi_client_notifier_init failed %d\n",
__func__, __LINE__, ret);
status = E_DS_CLIENT_FAILURE_INTERNAL;
goto err;
}
do {
QMI_CCI_OS_SIGNAL_CLEAR(&os_params);
ret = qmi_client_get_service_list(ds_client_service_object, NULL,
NULL, &num_services);
if(ret != QMI_NO_ERR) {
QMI_CCI_OS_SIGNAL_WAIT(&os_params, DS_CLIENT_SERVICE_TIMEOUT);
no_signal = QMI_CCI_OS_SIGNAL_TIMED_OUT(&os_params);
if(!no_signal)
ret = qmi_client_get_service_list(ds_client_service_object, NULL,
NULL, &num_services);
}
timeout += DS_CLIENT_SERVICE_TIMEOUT;
LOC_LOGV("%s:%d]: qmi_client_get_service_list() returned ret: %d,"
"no_signal: %d, total timeout: %d\n", __func__, __LINE__,
ret, no_signal, timeout);
} while( (timeout < DS_CLIENT_SERVICE_TIMEOUT_TOTAL) &&
no_signal &&
(ret != QMI_NO_ERR) );
}
//Handle failure cases
if(num_services == 0 || ret != QMI_NO_ERR) {
if(!no_signal) {
LOC_LOGE("%s:%d]: qmi_client_get_service_list failed even though"
"service is up! Error: %d \n", __func__, __LINE__, ret);
status = E_DS_CLIENT_FAILURE_INTERNAL;
}
else {
LOC_LOGE("%s:%d]: qmi_client_get_service_list failed after retries"
"Error: %d \n", __func__, __LINE__, ret);
status = E_DS_CLIENT_FAILURE_TIMEOUT;
}
goto err;
}
LOC_LOGD("%s:%d]: qmi_client_get_service_list succeeded\n", __func__, __LINE__);
//Success
p_service_info = (qmi_service_info *)malloc(num_services * sizeof(qmi_service_info));
if(p_service_info == NULL) {
LOC_LOGE("%s:%d]: could not allocate memory for serviceInfo !!\n",
__func__, __LINE__);
status = E_DS_CLIENT_FAILURE_INTERNAL;
goto err;
}
num_entries = num_services;
//Populate service info
ret = qmi_client_get_service_list(ds_client_service_object, p_service_info,
&num_entries, &num_services);
if(ret != QMI_NO_ERR) {
LOC_LOGE("%s:%d]: qmi_client_get_service_list failed. ret: %d \n",
__func__, __LINE__, ret);
status = E_DS_CLIENT_FAILURE_INTERNAL;
goto err;
}
//Initialize wds_qmi_client
LOC_LOGD("%s:%d]: Initializing WDS client with qmi_client_init\n", __func__,
__LINE__);
ret = qmi_client_init(&p_service_info[0], ds_client_service_object,
NULL, NULL, NULL, &wds_qmi_client);
if(ret != QMI_NO_ERR) {
LOC_LOGE("%s:%d]: qmi_client_init Error. ret: %d\n", __func__, __LINE__, ret);
status = E_DS_CLIENT_FAILURE_INTERNAL;
goto err;
}
LOC_LOGD("%s:%d]: WDS client initialized with qmi_client_init\n", __func__,
__LINE__);
//Store WDS QMI client handle in the parameter passed in
*p_wds_qmi_client = wds_qmi_client;
status = E_DS_CLIENT_SUCCESS;
LOC_LOGD("%s:%d]: init success\n", __func__, __LINE__);
if(notifier)
qmi_client_release(notifier);
err:
if(p_service_info)
free(p_service_info);
LOC_LOGD("%s:%d]:Exit\n", __func__, __LINE__);
return status;
}
/*This function reads the error code from within the response struct*/
static ds_client_status_enum_type ds_client_convert_qmi_response(
uint32_t req_id,
ds_client_resp_union_type *resp_union)
{
ds_client_status_enum_type ret = E_DS_CLIENT_FAILURE_GENERAL;
LOC_LOGD("%s:%d]:Enter\n", __func__, __LINE__);
switch(req_id)
{
case QMI_WDS_GET_PROFILE_LIST_REQ_V01 :
{
if(resp_union->p_get_profile_list_resp->resp.error !=
QMI_ERR_NONE_V01) {
LOC_LOGE("%s:%d]: Response error: %d", __func__, __LINE__,
resp_union->p_get_profile_list_resp->resp.error);
}
else
ret = E_DS_CLIENT_SUCCESS;
}
break;
case QMI_WDS_GET_PROFILE_SETTINGS_REQ_V01 :
{
if(resp_union->p_get_profile_setting_resp->resp.error !=
QMI_ERR_NONE_V01) {
LOC_LOGE("%s:%d]: Response error: %d", __func__, __LINE__,
resp_union->p_get_profile_setting_resp->resp.error);
}
else
ret = E_DS_CLIENT_SUCCESS;
}
break;
default:
LOC_LOGE("%s:%d]: Unknown request ID\n", __func__, __LINE__);
}
LOC_LOGD("%s:%d]:Exit\n", __func__, __LINE__);
return ret;
}
static ds_client_status_enum_type ds_client_send_qmi_sync_req(
qmi_client_type *ds_client_handle,
uint32_t req_id,
ds_client_resp_union_type *resp_union,
ds_client_req_union_type *req_union)
{
uint32_t req_len = 0;
uint32_t resp_len = 0;
ds_client_status_enum_type ret = E_DS_CLIENT_SUCCESS;
qmi_client_error_type qmi_ret = QMI_NO_ERR;
LOC_LOGD("%s:%d]:Enter\n", __func__, __LINE__);
switch(req_id)
{
case QMI_WDS_GET_PROFILE_LIST_REQ_V01 :
{
req_len = sizeof(wds_get_profile_list_req_msg_v01);
resp_len = sizeof(wds_get_profile_list_resp_msg_v01);
LOC_LOGD("%s:%d]: req_id = GET_PROFILE_LIST_REQ\n",
__func__, __LINE__);
}
break;
case QMI_WDS_GET_PROFILE_SETTINGS_REQ_V01 :
{
req_len = sizeof(wds_get_profile_settings_req_msg_v01);
resp_len = sizeof(wds_get_profile_settings_resp_msg_v01);
LOC_LOGD("%s:%d]: req_id = GET_PROFILE_SETTINGS_REQ\n",
__func__, __LINE__);
}
break;
default:
LOC_LOGE("%s:%d]: Error unknown req_id=%d\n", __func__, __LINE__,
req_id);
ret = E_DS_CLIENT_FAILURE_INVALID_PARAMETER;
goto err;
}
LOC_LOGD("%s:%d]: req_id=%d, len = %d; resp_len= %d\n", __func__, __LINE__,
req_id, req_len, resp_len);
//Send msg through QCCI
qmi_ret = qmi_client_send_msg_sync(
*ds_client_handle,
req_id,
(void *)req_union->p_get_profile_list_req,
req_len,
(void *)resp_union->p_get_profile_list_resp,
resp_len,
DS_CLIENT_SYNC_MSG_TIMEOUT);
LOC_LOGD("%s:%d]: qmi_client_send_msg_sync returned: %d", __func__, __LINE__, qmi_ret);
if(qmi_ret != QMI_NO_ERR) {
ret = E_DS_CLIENT_FAILURE_INTERNAL;
goto err;
}
ret = ds_client_convert_qmi_response(req_id, resp_union);
err:
LOC_LOGD("%s:%d]:Exit\n", __func__, __LINE__);
return ret;
}
/*This function obtains the list of supported profiles*/
static ds_client_status_enum_type ds_client_get_profile_list(
qmi_client_type *ds_client_handle,
ds_client_resp_union_type *profile_list_resp_msg,
wds_profile_type_enum_v01 profile_type)
{
ds_client_status_enum_type ret = E_DS_CLIENT_SUCCESS;
ds_client_req_union_type req_union;
LOC_LOGD("%s:%d]:Enter\n", __func__, __LINE__);
req_union.p_get_profile_list_req = NULL;
req_union.p_get_profile_list_req = (wds_get_profile_list_req_msg_v01 *)
calloc(1, sizeof(wds_get_profile_list_req_msg_v01));
if(req_union.p_get_profile_list_req == NULL) {
LOC_LOGE("%s:%d]: Could not allocate memory for"
"wds_get_profile_list_req_msg_v01\n", __func__, __LINE__);
goto err;
}
//Populate required members of the request structure
req_union.p_get_profile_list_req->profile_type_valid = 1;
req_union.p_get_profile_list_req->profile_type = profile_type;
ret = ds_client_send_qmi_sync_req(ds_client_handle,
QMI_WDS_GET_PROFILE_LIST_REQ_V01,
profile_list_resp_msg, &req_union);
if(ret != E_DS_CLIENT_SUCCESS) {
LOC_LOGE("%s:%d]: ds_client_send_qmi_req failed. ret: %d\n",
__func__, __LINE__, ret);
goto err;
}
err:
LOC_LOGD("%s:%d]:Exit\n", __func__, __LINE__);
if(req_union.p_get_profile_list_req)
free(req_union.p_get_profile_list_req);
return ret;
}
/*This function obtains settings for the profile specified by
the profile_identifier*/
static ds_client_status_enum_type ds_client_get_profile_settings(
qmi_client_type *ds_client_handle,
ds_client_resp_union_type *profile_settings_resp_msg,
wds_profile_identifier_type_v01 *profile_identifier)
{
ds_client_status_enum_type ret = E_DS_CLIENT_SUCCESS;
ds_client_req_union_type req_union;
LOC_LOGD("%s:%d]:Enter\n", __func__, __LINE__);
//Since it's a union containing a pointer to a structure,
//following entities have the same address
//- req_union
//- req_union.p_get_profile_settings_req
//- req_union.p_get_profile_settings_req->profile
//so we can very well assign req_union = profile_identifier
req_union.p_get_profile_settings_req =
(wds_get_profile_settings_req_msg_v01 *)profile_identifier;
ret = ds_client_send_qmi_sync_req(ds_client_handle,
QMI_WDS_GET_PROFILE_SETTINGS_REQ_V01,
profile_settings_resp_msg, &req_union);
if(ret != E_DS_CLIENT_SUCCESS) {
LOC_LOGE("%s:%d]: ds_client_send_qmi_req failed. ret: %d\n",
__func__, __LINE__, ret);
goto err;
}
err:
LOC_LOGD("%s:%d]:Exit\n", __func__, __LINE__);
return ret;
}
/*
Starts data call using the handle and the profile index
*/
ds_client_status_enum_type
ds_client_start_call(dsClientHandleType client_handle, int profile_index)
{
ds_client_status_enum_type ret = E_DS_CLIENT_FAILURE_GENERAL;
dsi_call_param_value_t param_info;
dsi_hndl_t dsi_handle;
ds_client_session_data *ds_global_data = (ds_client_session_data *)client_handle;
LOC_LOGD("%s:%d]:Enter\n", __func__, __LINE__);
if(ds_global_data == NULL) {
LOC_LOGE("%s:%d]: Null callback parameter\n", __func__, __LINE__);
goto err;
}
dsi_handle = ds_global_data->dsi_net_handle;
//Set profile index as call parameter
param_info.buf_val = NULL;
param_info.num_val = profile_index;
dsi_set_data_call_param(dsi_handle,
DSI_CALL_INFO_UMTS_PROFILE_IDX,
&param_info);
LOC_LOGD("%s:%d]: Starting emergency call with profile index %d\n",
__func__, __LINE__, param_info.num_val);
if(dsi_start_data_call(dsi_handle) == DSI_SUCCESS) {
LOC_LOGD("%s:%d]: Sent request to start data call\n",
__func__, __LINE__);
ret = E_DS_CLIENT_SUCCESS;
}
else {
LOC_LOGE("%s:%d]: Could not send req to start data call \n", __func__, __LINE__);
ret = E_DS_CLIENT_FAILURE_GENERAL;
goto err;
}
err:
LOC_LOGD("%s:%d]:Exit\n", __func__, __LINE__);
return ret;
}
/*Function to open an emergency call. Does the following things:
- Obtains a handle to the WDS service
- Obtains a list of profiles configured in the modem
- Queries each profile and obtains settings to check if emergency calls
are supported
- Returns the profile index that supports emergency calls
- Returns handle to dsi_netctrl*/
ds_client_status_enum_type
ds_client_open_call(dsClientHandleType *client_handle,
ds_client_cb_data *callback,
void *caller_cookie,
int *profile_index)
{
ds_client_status_enum_type ret = E_DS_CLIENT_FAILURE_GENERAL;
ds_client_resp_union_type profile_list_resp_msg;
ds_client_resp_union_type profile_settings_resp_msg;
wds_profile_identifier_type_v01 profile_identifier;
uint32_t i=0;
dsi_hndl_t dsi_handle;
ds_client_session_data **ds_global_data = (ds_client_session_data **)client_handle;
unsigned char call_profile_index_found = 0;
uint32_t emergency_profile_index=0;
qmi_client_type wds_qmi_client;
profile_list_resp_msg.p_get_profile_list_resp = NULL;
profile_settings_resp_msg.p_get_profile_setting_resp = NULL;
LOC_LOGD("%s:%d]:Enter\n", __func__, __LINE__);
if(callback == NULL || ds_global_data == NULL) {
LOC_LOGE("%s:%d]: Null callback parameter\n", __func__, __LINE__);
goto err;
}
ret = ds_client_qmi_ctrl_point_init(&wds_qmi_client);
if(ret != E_DS_CLIENT_SUCCESS) {
LOC_LOGE("%s:%d]: ds_client_qmi_ctrl_point_init failed. ret: %d\n",
__func__, __LINE__, ret);
goto err;
}
//Allocate memory for the response msg to obtain a list of profiles
profile_list_resp_msg.p_get_profile_list_resp = (wds_get_profile_list_resp_msg_v01 *)
calloc(1, sizeof(wds_get_profile_list_resp_msg_v01));
if(profile_list_resp_msg.p_get_profile_list_resp == NULL) {
LOC_LOGE("%s:%d]: Could not allocate memory for"
"p_get_profile_list_resp\n", __func__, __LINE__);
ret = E_DS_CLIENT_FAILURE_NOT_ENOUGH_MEMORY;
goto err;
}
LOC_LOGD("%s:%d]: Getting profile list\n", __func__, __LINE__);
ret = ds_client_get_profile_list(&wds_qmi_client,
&profile_list_resp_msg,
WDS_PROFILE_TYPE_3GPP_V01);
if(ret != E_DS_CLIENT_SUCCESS) {
LOC_LOGE("%s:%d]: ds_client_get_profile_list failed. ret: %d\n",
__func__, __LINE__, ret);
goto err;
}
LOC_LOGD("%s:%d]: Got profile list; length = %d\n", __func__, __LINE__,
profile_list_resp_msg.p_get_profile_list_resp->profile_list_len);
//Allocate memory for the response msg to obtain profile settings
//We allocate memory for only one response msg and keep re-using it
profile_settings_resp_msg.p_get_profile_setting_resp =
(wds_get_profile_settings_resp_msg_v01 *)
calloc(1, sizeof(wds_get_profile_settings_resp_msg_v01));
if(profile_settings_resp_msg.p_get_profile_setting_resp == NULL) {
LOC_LOGE("%s:%d]: Could not allocate memory for"
"p_get_profile_setting_resp\n", __func__, __LINE__);
ret = E_DS_CLIENT_FAILURE_NOT_ENOUGH_MEMORY;
goto err;
}
//Loop over the list of profiles to find a profile that supports
//emergency calls
for(i=0; i < profile_list_resp_msg.p_get_profile_list_resp->profile_list_len; i++) {
/*QMI_WDS_GET_PROFILE_SETTINGS_REQ requires an input data
structure that is of type wds_profile_identifier_type_v01
We have to fill that structure for each profile from the
info obtained from the profile list*/
//copy profile type
profile_identifier.profile_type =
profile_list_resp_msg.p_get_profile_list_resp->profile_list[i].profile_type;
//copy profile index
profile_identifier.profile_index =
profile_list_resp_msg.p_get_profile_list_resp->profile_list[i].profile_index;
ret = ds_client_get_profile_settings(&wds_qmi_client,
&profile_settings_resp_msg,
&profile_identifier);
if(ret != E_DS_CLIENT_SUCCESS) {
LOC_LOGE("%s:%d]: ds_client_get_profile_settings failed. ret: %d\n",
__func__, __LINE__, ret);
goto err;
}
LOC_LOGD("%s:%d]: Got profile setting for profile %d\n", __func__, __LINE__, i);
LOC_LOGD("%s:%d]: Profile name: %s\n", __func__, __LINE__,
profile_settings_resp_msg.p_get_profile_setting_resp->profile_name);
if(profile_settings_resp_msg.p_get_profile_setting_resp->support_emergency_calls_valid) {
if(profile_settings_resp_msg.p_get_profile_setting_resp->support_emergency_calls) {
LOC_LOGD("%s:%d]: Found emergency profile in profile %d"
, __func__, __LINE__, i);
call_profile_index_found = 1;
emergency_profile_index = profile_identifier.profile_index;
break;
}
else
LOC_LOGE("%s:%d]: Emergency profile valid but not supported in profile: %d "
, __func__, __LINE__, i);
}
//Since this struct is loaded with settings for the next profile,
//it is important to clear out the memory to avoid values/flags
//from being carried over
memset((void *)profile_settings_resp_msg.p_get_profile_setting_resp,
0, sizeof(wds_get_profile_settings_resp_msg_v01));
}
//Release qmi client handle
if(qmi_client_release(wds_qmi_client) != QMI_NO_ERR) {
LOC_LOGE("%s:%d]: Could not release qmi client handle\n",
__func__, __LINE__);
ret = E_DS_CLIENT_FAILURE_GENERAL;
}
if(call_profile_index_found) {
*profile_index = emergency_profile_index;
*ds_global_data = (ds_client_session_data *)calloc(1, sizeof(ds_client_session_data));
if(*ds_global_data == NULL) {
LOC_LOGE("%s:%d]: Could not allocate memory for ds_global_data. Failing\n",
__func__, __LINE__);
ret = E_DS_CLIENT_FAILURE_NOT_ENOUGH_MEMORY;
goto err;
}
(*ds_global_data)->caller_data.event_cb = callback->event_cb;
(*ds_global_data)->caller_data.caller_cookie = caller_cookie;
dsi_handle = dsi_get_data_srvc_hndl(net_ev_cb, &(*ds_global_data)->caller_data);
if(dsi_handle == NULL) {
LOC_LOGE("%s:%d]: Could not get data handle. Retry Later\n",
__func__, __LINE__);
ret = E_DS_CLIENT_RETRY_LATER;
goto err;
}
else
(*ds_global_data)->dsi_net_handle = dsi_handle;
}
else {
LOC_LOGE("%s:%d]: Could not find a profile that supports emergency calls",
__func__, __LINE__);
ret = E_DS_CLIENT_FAILURE_GENERAL;
}
err:
if(profile_list_resp_msg.p_get_profile_list_resp)
free(profile_list_resp_msg.p_get_profile_list_resp);
if(profile_settings_resp_msg.p_get_profile_setting_resp)
free(profile_settings_resp_msg.p_get_profile_setting_resp);
LOC_LOGD("%s:%d]:Exit\n", __func__, __LINE__);
return ret;
}
ds_client_status_enum_type ds_client_stop_call(dsClientHandleType client_handle)
{
ds_client_status_enum_type ret = E_DS_CLIENT_SUCCESS;
ds_client_session_data *p_ds_global_data = (ds_client_session_data *)client_handle;
LOC_LOGD("%s:%d]:Enter\n", __func__, __LINE__);
if(client_handle == NULL) {
LOC_LOGE("%s:%d]: Null argument received. Failing\n", __func__, __LINE__);
ret = E_DS_CLIENT_FAILURE_GENERAL;
goto err;
}
if(dsi_stop_data_call(p_ds_global_data->dsi_net_handle) == DSI_SUCCESS) {
LOC_LOGD("%s:%d]: Sent request to stop data call\n", __func__, __LINE__);
}
else {
LOC_LOGE("%s:%d]: Could not send request to stop data call\n",
__func__, __LINE__);
ret = E_DS_CLIENT_FAILURE_GENERAL;
goto err;
}
err:
LOC_LOGD("%s:%d]:Exit\n", __func__, __LINE__);
return ret;
}
/*
Stops data call associated with the data handle
*/
void ds_client_close_call(dsClientHandleType *client_handle)
{
ds_client_session_data **ds_global_data = (ds_client_session_data **)client_handle;
LOC_LOGD("%s:%d]:Enter\n", __func__, __LINE__);
if(client_handle == NULL || *client_handle == NULL) {
LOC_LOGE("%s:%d]: Null argument received. Failing\n", __func__, __LINE__);
goto err;
}
dsi_rel_data_srvc_hndl((*ds_global_data)->dsi_net_handle);
(*ds_global_data)->dsi_net_handle = NULL;
free(*ds_global_data);
*ds_global_data = NULL;
LOC_LOGD("%s:%d]: Released Data handle\n", __func__, __LINE__);
err:
LOC_LOGD("%s:%d]:Exit\n", __func__, __LINE__);
return;
}
int ds_client_init()
{
int ret = 0;
LOC_LOGD("%s:%d]:Enter\n", __func__, __LINE__);
if(DSI_SUCCESS != dsi_init(DSI_MODE_GENERAL))
{
LOC_LOGE("%s:%d]:dsi_init failed\n", __func__, __LINE__);
ret = -1;
}
LOC_LOGD("%s:%d]:Exit\n", __func__, __LINE__);
return ret;
}

142
loc_api/ds_api/ds_client.h Normal file
View file

@ -0,0 +1,142 @@
/* Copyright (c) 2013, 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
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* 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 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.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _DS_CLIENT_H_
#define _DS_CLIENT_H_
#ifdef __cplusplus
extern "C" {
#endif
typedef void* dsClientHandleType;
typedef enum
{
E_DS_CLIENT_SUCCESS = 0,
/**< Request was successful. */
E_DS_CLIENT_FAILURE_GENERAL = 1,
/**< Failed because of a general failure. */
E_DS_CLIENT_FAILURE_UNSUPPORTED = 2,
/**< Failed because the service does not support the command. */
E_DS_CLIENT_FAILURE_INVALID_PARAMETER = 3,
/**< Failed because the request contained invalid parameters. */
E_DS_CLIENT_FAILURE_ENGINE_BUSY = 4,
/**< Failed because the engine is busy. */
E_DS_CLIENT_FAILURE_PHONE_OFFLINE = 5,
/**< Failed because the phone is offline. */
E_DS_CLIENT_FAILURE_TIMEOUT = 6,
/**< Failed because of a timeout. */
E_DS_CLIENT_FAILURE_SERVICE_NOT_PRESENT = 7,
/**< Failed because the service is not present. */
E_DS_CLIENT_FAILURE_SERVICE_VERSION_UNSUPPORTED = 8,
/**< Failed because the service version is unsupported. */
E_DS_CLIENT_FAILURE_CLIENT_VERSION_UNSUPPORTED = 9,
/**< Failed because the service does not support client version. */
E_DS_CLIENT_FAILURE_INVALID_HANDLE = 10,
/**< Failed because an invalid handle was specified. */
E_DS_CLIENT_FAILURE_INTERNAL = 11,
/**< Failed because of an internal error in the service. */
E_DS_CLIENT_FAILURE_NOT_INITIALIZED = 12,
/**< Failed because the service has not been initialized. */
E_DS_CLIENT_FAILURE_NOT_ENOUGH_MEMORY = 13,
/**< Failed because not rnough memory to do the operation.*/
E_DS_CLIENT_SERVICE_ALREADY_STARTED = 14,
/*Service is already started*/
E_DS_CLIENT_DATA_CALL_CONNECTED = 15,
E_DS_CLIENT_DATA_CALL_DISCONNECTED = 16,
E_DS_CLIENT_RETRY_LATER = 17
}ds_client_status_enum_type;
typedef enum {
DATA_CALL_NONE = 0,
DATA_CALL_OPEN,
DATA_CALL_CLOSE
}data_call_request_enum_type;
typedef void (*ds_client_event_ind_cb_type)(ds_client_status_enum_type result,
void* loc_adapter_cookie);
typedef struct {
ds_client_event_ind_cb_type event_cb;
}ds_client_cb_data;
/*
This function is to be called as a first step by each process that
needs to use data services. This call internally calls dsi_init()
and prepares the module for making data calls.
Needs to be called once for every process
*/
int ds_client_init();
/*
Obtains a handle to the dsi_netctrl layer and looks up the profile
to make the call. As of now. It only searches for profiles that
support emergency calls
*/
ds_client_status_enum_type ds_client_open_call(dsClientHandleType *client_handle,
ds_client_cb_data *callback,
void *loc_adapter_cookie,
int *profile_index);
/*
Starts a data call using the profile number provided
*/
ds_client_status_enum_type ds_client_start_call(dsClientHandleType client_handle,
int profile_index);
/*
Stops a data call associated with the handle
*/
ds_client_status_enum_type ds_client_stop_call(dsClientHandleType client_handle);
/*
Releases the handle used for making data calls
*/
void ds_client_close_call(dsClientHandleType *client_handle);
#ifdef __cplusplus
}
#endif
#endif

View file

@ -0,0 +1,46 @@
AM_CFLAGS = \
-I../../../utils \
-I../../../platform_lib_abstractions \
-I./rpc_inc \
-I../libloc_api-rpc-stub/inc \
-I../../libloc_api_50001 \
$(MSM7K_CFLAGS) \
-DUSE_QCOM_AUTO_RPC
requiredlibs = \
../../../utils/libgps_utils_so.la \
$(MSM7K_LIBS)
h_sources = \
rpc_inc/loc_api_rpc_glue.h \
rpc_inc/loc_api_fixup.h \
rpc_inc/loc_api_sync_call.h \
rpc_inc/loc_apicb_appinit.h \
c_sources = \
src/loc_api_rpc_glue.c \
src/loc_api_sync_call.c \
src/loc_apicb_appinit.c \
src/loc_api_fixup.c \
src/loc_api_log.c \
src/LocApiRpcAdapter.cpp \
library_includedir = $(pkgincludedir)/libloc_api-rpc-50001/libloc_api-rpc-glue/rpc_inc
library_include_HEADERS = $(h_sources)
libloc_api_rpc_qc_la_SOURCES = $(c_sources) $(h_sources)
if USE_GLIB
libloc_api_rpc_qc_la_CFLAGS = -DUSE_GLIB $(AM_CFLAGS) @GLIB_CFLAGS@
libloc_api_rpc_qc_la_LDFLAGS = -lstdc++ -lpthread @GLIB_LIBS@ -shared -version-info 1:0:0
libloc_api_rpc_qc_la_CPPFLAGS = -DUSE_GLIB $(AM_CFLAGS) $(AM_CPPFLAGS) @GLIB_CFLAGS@
else
libloc_api_rpc_qc_la_CFLAGS = $(AM_CFLAGS)
libloc_api_rpc_qc_la_LDFLAGS = -lpthread -shared -version-info 1:0:0
libloc_api_rpc_qc_la_CPPFLAGS = $(AM_CFLAGS) $(AM_CPPFLAGS)
endif
libloc_api_rpc_qc_la_LIBADD = $(requiredlibs) -lstdc++
#Create and Install Libraries
lib_LTLIBRARIES = libloc_api_rpc_qc.la

View file

@ -48,8 +48,8 @@ typedef unsigned char boolean;
#define TRUE 1
#define FALSE 0
#include "rpc_inc/loc_api_fixup.h"
#include "rpc_inc/loc_api_sync_call.h"
#include "loc_api_fixup.h"
#include "loc_api_sync_call.h"
#include <rpc/clnt.h>
#ifdef __cplusplus

View file

@ -31,12 +31,20 @@
#include <unistd.h>
#include <math.h>
#ifndef USE_GLIB
#include <utils/SystemClock.h>
#endif /* USE_GLIB */
#include "LocApiRpcAdapter.h"
#include "loc_api_rpcgen_common_rpc.h"
#include "log_util.h"
#include "loc_log.h"
#include "loc_api_log.h"
#ifdef USE_GLIB
#include <glib.h>
#endif
#include "librpc.h"
#include "platform_lib_includes.h"
#define LOC_XTRA_INJECT_DEFAULT_TIMEOUT (3100)
#define XTRA_BLOCK_SIZE (3072)
@ -390,7 +398,7 @@ LocApiRpcAdapter::setTime(GpsUtcTime time, int64_t timeReference, int uncertaint
time_info_ptr = &ioctl_data.rpc_loc_ioctl_data_u_type_u.assistance_data_time;
time_info_ptr->time_utc = time;
time_info_ptr->time_utc += (int64_t)(android::elapsedRealtime() - timeReference);
time_info_ptr->time_utc += (int64_t)(ELAPSED_MILLIS_SINCE_BOOT_PLATFORM_LIB_ABSTRACTION - timeReference);
time_info_ptr->uncertainty = uncertainty; // Uncertainty in ms
ioctl_data.disc = ioctl_type;

View file

@ -33,6 +33,7 @@
#include "loc_api_log.h"
#include "loc_log.h"
#include "log_util.h"
#include "platform_lib_includes.h"
#include "rpc/rpc.h"
#include "loc_api_fixup.h"

View file

@ -57,10 +57,15 @@
/* Logging */
#define LOG_TAG "LocSvc_api_rpc_glue"
#define LOG_NDDEBUG 0
#ifndef USE_GLIB
#include <utils/Log.h>
#endif /* USE_GLIB */
/* Logging Improvement */
#include "log_util.h"
#include "platform_lib_includes.h"
/*Maximum number of Modem init*/
#define RPC_TRY_NUM 10
/*Maximum number of Modem init*/
#define RPC_TRY_NUM 10

View file

@ -40,7 +40,9 @@
/* Logging */
#define LOG_TAG "LocSvc_api_rpc_glue"
// #define LOG_NDDEBUG 0
#ifndef USE_GLIB
#include <utils/Log.h>
#endif /* USE_GLIB */
/***************************************************************************
* DATA FOR ASYNCHRONOUS RPC PROCESSING

View file

@ -0,0 +1,42 @@
AM_CFLAGS = \
-I../../../utils \
-I./inc \
$(MSM7K_CFLAGS)
requiredlibs = \
../../../utils/libgps_utils_so.la \
$(MSM7K_LIBS)
h_sources = \
inc/loc_api_rpcgen_rpc.h \
inc/loc_api_rpcgen_common_rpc.h \
inc/loc_api_rpcgen_cb_rpc.h \
inc/loc_apicb_appinit.h
c_sources = \
src/loc_api_rpcgen_cb_xdr.c \
src/loc_api_rpcgen_common_xdr.c \
src/loc_api_rpcgen_cb_svc.c \
src/loc_api_rpcgen_clnt.c \
src/loc_api_rpcgen_xdr.c
library_includedir = $(pkgincludedir)/libloc_api-rpc-50001/libloc_api-rpc-stub/inc
library_include_HEADERS = $(h_sources)
libloc_api_rpcgen_la_SOURCES = $(c_sources) $(h_sources)
if USE_GLIB
libloc_api_rpcgen_la_CFLAGS = -DUSE_GLIB $(AM_CFLAGS) @GLIB_CFLAGS@
libloc_api_rpcgen_la_LDFLAGS = -lstdc++ -lpthread @GLIB_LIBS@ -shared -version-info 1:0:0
libloc_api_rpcgen_la_CPPFLAGS = -DUSE_GLIB $(AM_CFLAGS) $(AM_CPPFLAGS) @GLIB_CFLAGS@
else
libloc_api_rpcgen_la_CFLAGS = $(AM_CFLAGS)
libloc_api_rpcgen_la_LDFLAGS = -lpthread -shared -version-info 1:0:0
libloc_api_rpcgen_la_CPPFLAGS = $(AM_CFLAGS) $(AM_CPPFLAGS)
endif
libloc_api_rpcgen_la_LIBADD = $(requiredlibs) -lstdc++
#Create and Install Libraries
lib_LTLIBRARIES = libloc_api_rpcgen.la

View file

@ -192,6 +192,18 @@ void LocApiAdapter::requestATL(int connHandle, AGpsType agps_type)
locEngHandle.sendMsge(locEngHandle.owner, msg);
}
void LocApiAdapter::requestSuplES(int connHandle)
{
loc_eng_msg_request_supl_es *msg(new loc_eng_msg_request_supl_es(locEngHandle.owner, connHandle));
locEngHandle.sendMsge(locEngHandle.owner, msg);
}
void LocApiAdapter::releaseDataHandle(void)
{
loc_eng_msg_close_data_call *msg(new loc_eng_msg_close_data_call(locEngHandle.owner));
locEngHandle.sendMsge(locEngHandle.owner, msg);
}
void LocApiAdapter::releaseATL(int connHandle)
{
loc_eng_msg_release_atl *msg(new loc_eng_msg_release_atl(locEngHandle.owner, connHandle));
@ -240,3 +252,18 @@ void LocApiAdapter::handleEngineUpEvent()
loc_eng_msg *msg(new loc_eng_msg(locEngHandle.owner, LOC_ENG_MSG_ENGINE_UP));
locEngHandle.sendMsge(locEngHandle.owner, msg);
}
void LocApiAdapter::reportDataCallOpened()
{
loc_eng_msg_atl_open_success *msg(new loc_eng_msg_atl_open_success(locEngHandle.owner,
AGPS_TYPE_INVALID,
NULL, 0, 0));
locEngHandle.sendMsge(locEngHandle.owner, msg);
}
void LocApiAdapter::reportDataCallClosed()
{
loc_eng_msg_atl_closed *msg(new loc_eng_msg_atl_closed(locEngHandle.owner,
AGPS_TYPE_INVALID));
locEngHandle.sendMsge(locEngHandle.owner, msg);
}

View file

@ -35,6 +35,7 @@
#include <loc_eng_log.h>
#include <log_util.h>
#include <loc_eng_msg.h>
#include "platform_lib_includes.h"
#define MAX_APN_LEN 100
#define MAX_URL_LEN 256
@ -142,7 +143,10 @@ public:
void requestNiNotify(GpsNiNotification &notify, const void* data);
void handleEngineDownEvent();
void handleEngineUpEvent();
void requestSuplES(int connHandle);
void releaseDataHandle(void);
void reportDataCallOpened(void);
void reportDataCallClosed(void);
// All below functions are to be defined by adapter specific modules:
// RPC, QMI, etc. The default implementation is empty.
inline virtual enum loc_api_adapter_err
@ -228,6 +232,15 @@ public:
inline bool isInSession() { return navigating; }
inline virtual void setInSession(bool inSession) { navigating = inSession; }
inline virtual int openAndStartDataCall()
{LOC_LOGW("%s: default implementation invoked", __func__); return -1;}
inline virtual void stopDataCall()
{LOC_LOGW("%s: default implementation invoked", __func__);}
inline virtual void closeDataCall()
{LOC_LOGW("%s: default implementation invoked", __func__);}
inline virtual int initDataServiceClient()
{LOC_LOGW("%s: default implementation invoked", __func__); return -1;}
};
extern "C" LocApiAdapter* getLocApiAdapter(LocEng &locEng);

View file

@ -0,0 +1,79 @@
AM_CFLAGS = \
-I../../utils \
-I../../platform_lib_abstractions \
-I../ulp/inc \
-fno-short-enums \
-DFEATURE_GNSS_BIT_API
libloc_adapter_so_la_SOURCES = loc_eng_log.cpp LocApiAdapter.cpp
if USE_GLIB
libloc_adapter_so_la_CFLAGS = -DUSE_GLIB $(AM_CFLAGS) @GLIB_CFLAGS@
libloc_adapter_so_la_LDFLAGS = -lstdc++ -lpthread @GLIB_LIBS@ -shared -version-info 1:0:0
libloc_adapter_so_la_CPPFLAGS = -DUSE_GLIB $(AM_CFLAGS) $(AM_CPPFLAGS) @GLIB_CFLAGS@
else
libloc_adapter_so_la_CFLAGS = $(AM_CFLAGS)
libloc_adapter_so_la_LDFLAGS = -lpthread -shared -version-info 1:0:0
libloc_adapter_so_la_CPPFLAGS = $(AM_CFLAGS) $(AM_CPPFLAGS)
endif
libloc_adapter_so_la_LIBADD = -lstdc++ -lcutils ../../utils/libgps_utils_so.la
libloc_eng_so_la_SOURCES = \
loc_eng.cpp \
loc_eng_agps.cpp \
loc_eng_xtra.cpp \
loc_eng_ni.cpp \
loc_eng_log.cpp \
loc_eng_dmn_conn.cpp \
loc_eng_dmn_conn_handler.cpp \
loc_eng_dmn_conn_thread_helper.c \
loc_eng_dmn_conn_glue_msg.c \
loc_eng_dmn_conn_glue_pipe.c
if USE_GLIB
libloc_eng_so_la_CFLAGS = -DUSE_GLIB $(AM_CFLAGS) @GLIB_CFLAGS@
libloc_eng_so_la_LDFLAGS = -lstdc++ -lpthread @GLIB_LIBS@ -shared -version-info 1:0:0
libloc_eng_so_la_CPPFLAGS = -DUSE_GLIB $(AM_CFLAGS) $(AM_CPPFLAGS) @GLIB_CFLAGS@
else
libloc_eng_so_la_CFLAGS = $(AM_CFLAGS)
libloc_eng_so_la_LDFLAGS = -lpthread -shared -version-info 1:0:0
libloc_eng_so_la_CPPFLAGS = $(AM_CFLAGS) $(AM_CPPFLAGS)
endif
libloc_eng_so_la_LIBADD = -lstdc++ -lcutils -ldl ../../utils/libgps_utils_so.la libloc_adapter_so.la
libgps_default_so_la_SOURCES = \
loc.cpp \
gps.c
if USE_GLIB
libgps_default_so_la_CFLAGS = -DUSE_GLIB $(AM_CFLAGS) @GLIB_CFLAGS@
libgps_default_so_la_LDFLAGS = -lstdc++ -lpthread @GLIB_LIBS@ -shared -version-info 1:0:0
libgps_default_so_la_CPPFLAGS = -DUSE_GLIB $(AM_CFLAGS) $(AM_CPPFLAGS) @GLIB_CFLAGS@
else
libgps_default_so_la_CFLAGS = $(AM_CFLAGS)
libgps_default_so_la_LDFLAGS = -lpthread -shared -version-info 1:0:0
libgps_default_so_la_CPPFLAGS = $(AM_CFLAGS) $(AM_CPPFLAGS)
endif
libgps_default_so_la_LIBADD = -lstdc++ -lcutils ../../utils/libgps_utils_so.la -ldl libloc_eng_so.la
library_include_HEADERS = \
LocApiAdapter.h \
loc.h \
loc_eng.h \
loc_eng_xtra.h \
loc_eng_ni.h \
loc_eng_agps.h \
loc_eng_msg.h \
loc_eng_msg_id.h \
loc_eng_log.h \
../ulp/inc/ulp.h
library_includedir = $(pkgincludedir)/libloc_api_50001
#Create and Install libraries
lib_LTLIBRARIES = libloc_adapter_so.la libloc_eng_so.la libgps_default_so.la

View file

@ -174,6 +174,8 @@ const GpsInterface* gps_get_hardware_interface ()
char propBuf[PROPERTY_VALUE_MAX];
loc_eng_read_config();
// check to see if GPS should be disabled
property_get("gps.disable", propBuf, "");
if (propBuf[0] == '1')
@ -216,8 +218,9 @@ extern "C" const GpsInterface* get_gps_interface()
if((target == TARGET_APQ8064_STANDALONE) || (target == TARGET_APQ8030_STANDALONE)) {
gps_conf.CAPABILITIES &= ~(GPS_CAPABILITY_MSA | GPS_CAPABILITY_MSB);
gss_fd = open("/dev/gss", O_RDONLY);
if (gss_fd < 0)
if (gss_fd < 0) {
LOC_LOGE("GSS open failed: %s\n", strerror(errno));
}
else {
LOC_LOGD("GSS open success! CAPABILITIES %0lx\n", gps_conf.CAPABILITIES);
}

View file

@ -92,7 +92,8 @@ typedef uint32_t LocPosTechMask;
#define LOC_POS_TECH_MASK_SENSORS ((LocPosTechMask)0x00000008)
#define LOC_POS_TECH_MASK_REFERENCE_LOCATION ((LocPosTechMask)0x00000010)
#define LOC_POS_TECH_MASK_INJECTED_COARSE_POSITION ((LocPosTechMask)0x00000020)
#define LOC_POS_TECH_MASK_AFLT ((LocPosTechMask)0x00000040)
#define LOC_POS_TECH_MASK_HYBRID ((LocPosTechMask)0x00000080)
void loc_ulp_msg_sender(void* loc_eng_data_p, void* msg);
#ifdef __cplusplus

View file

@ -47,8 +47,16 @@
#include "LocApiAdapter.h"
#include <cutils/sched_policy.h>
#ifndef USE_GLIB
#include <utils/SystemClock.h>
#include <utils/Log.h>
#endif /* USE_GLIB */
#ifdef USE_GLIB
#include <glib.h>
#include <sys/syscall.h>
#endif /* USE_GLIB */
#include <string.h>
#include <loc_eng.h>
@ -60,8 +68,8 @@
#include <loc_eng_nmea.h>
#include <msg_q.h>
#include <loc.h>
#include "log_util.h"
#include "platform_lib_includes.h"
#include "loc_eng_log.h"
#define SUCCESS TRUE
@ -171,7 +179,7 @@ LocEngContext::LocEngContext(gps_create_thread threadCreator) :
counter(0)
{
LOC_LOGV("LocEngContext %d : %d pthread_id %ld\n",
getpid(), gettid(),
getpid(), GETTID_PLATFORM_LIB_ABSTRACTION,
deferred_action_thread);
}
@ -523,8 +531,8 @@ int loc_eng_start(loc_eng_data_s_type &loc_eng_data)
ENTRY_LOG_CALLFLOW();
INIT_CHECK(loc_eng_data.context, return -1);
void* target_q = loc_eng_data.ulp_initialized?
(void*)((LocEngContext*)(loc_eng_data.context))->ulp_q:
void* target_q = loc_eng_data.ulp_initialized ?
(void*)((LocEngContext*)(loc_eng_data.context))->ulp_q :
(void*)((LocEngContext*)(loc_eng_data.context))->deferred_q;
//Pass the start messgage to ULP if present & activated
@ -575,8 +583,8 @@ int loc_eng_stop(loc_eng_data_s_type &loc_eng_data)
ENTRY_LOG_CALLFLOW();
INIT_CHECK(loc_eng_data.context, return -1);
void* target_q = loc_eng_data.ulp_initialized?
(void*)((LocEngContext*)(loc_eng_data.context))->ulp_q:
void* target_q = loc_eng_data.ulp_initialized ?
(void*)((LocEngContext*)(loc_eng_data.context))->ulp_q :
(void*)((LocEngContext*)(loc_eng_data.context))->deferred_q;
//Pass the start messgage to ULP if present & activated
@ -802,6 +810,38 @@ static void loc_inform_gps_status(loc_eng_data_s_type &loc_eng_data, GpsStatusVa
EXIT_LOG(%s, VOID_RET);
}
/*
Callback function passed to Data Services State Machine
This becomes part of the state machine's servicer and
is used to send requests to the data services client
*/
static int dataCallCb(void *cb_data)
{
LOC_LOGD("Enter dataCallCb\n");
int ret=0;
if(cb_data != NULL) {
dsCbData *cbData = (dsCbData *)cb_data;
LocApiAdapter *locAdapter = (LocApiAdapter *)cbData->mAdapter;
if(cbData->action == GPS_REQUEST_AGPS_DATA_CONN) {
LOC_LOGD("dataCallCb GPS_REQUEST_AGPS_DATA_CONN\n");
ret = locAdapter->openAndStartDataCall();
}
else if(cbData->action == GPS_RELEASE_AGPS_DATA_CONN) {
LOC_LOGD("dataCallCb GPS_RELEASE_AGPS_DATA_CONN\n");
locAdapter->stopDataCall();
}
}
else {
LOC_LOGE("NULL argument received. Failing.\n");
ret = -1;
goto err;
}
err:
LOC_LOGD("Exit dataCallCb ret = %d\n", ret);
return ret;
}
/*===========================================================================
FUNCTION loc_eng_agps_reinit
@ -868,15 +908,25 @@ void loc_eng_agps_init(loc_eng_data_s_type &loc_eng_data, AGpsExtCallbacks* call
}
loc_eng_data.agps_status_cb = callbacks->status_cb;
loc_eng_data.agnss_nif = new AgpsStateMachine(loc_eng_data.agps_status_cb,
loc_eng_data.agnss_nif = new AgpsStateMachine(servicerTypeAgps,
(void *)loc_eng_data.agps_status_cb,
AGPS_TYPE_SUPL,
false);
loc_eng_data.internet_nif = new AgpsStateMachine(loc_eng_data.agps_status_cb,
loc_eng_data.internet_nif = new AgpsStateMachine(servicerTypeAgps,
(void *)loc_eng_data.agps_status_cb,
AGPS_TYPE_WWAN_ANY,
false);
loc_eng_data.wifi_nif = new AgpsStateMachine(loc_eng_data.agps_status_cb,
loc_eng_data.wifi_nif = new AgpsStateMachine(servicerTypeAgps,
(void *)loc_eng_data.agps_status_cb,
AGPS_TYPE_WIFI,
true);
if(!loc_eng_data.client_handle->initDataServiceClient()) {
LOC_LOGD("%s:%d]: Creating new ds state machine\n", __func__, __LINE__);
loc_eng_data.ds_nif = new DSStateMachine(servicerTypeExt,
(void *)dataCallCb,
loc_eng_data.client_handle);
LOC_LOGD("%s:%d]: Created new ds state machine\n", __func__, __LINE__);
}
loc_eng_dmn_conn_loc_api_server_launch(callbacks->create_thread_cb,
NULL, NULL, &loc_eng_data);
@ -1305,6 +1355,29 @@ void loc_eng_handle_engine_up(loc_eng_data_s_type &loc_eng_data)
EXIT_LOG(%s, VOID_RET);
}
#ifdef USE_GLIB
/*===========================================================================
FUNCTION set_sched_policy
DESCRIPTION
Local copy of this function which bypasses android set_sched_policy
DEPENDENCIES
None
RETURN VALUE
0
SIDE EFFECTS
N/A
===========================================================================*/
static int set_sched_policy(int tid, SchedPolicy policy)
{
return 0;
}
#endif /* USE_GLIB */
/*===========================================================================
FUNCTION loc_eng_deferred_action_thread
@ -1329,7 +1402,7 @@ static void loc_eng_deferred_action_thread(void* arg)
LocEngContext* context = (LocEngContext*)arg;
// make sure we do not run in background scheduling group
set_sched_policy(gettid(), SP_FOREGROUND);
set_sched_policy(GETTID_PLATFORM_LIB_ABSTRACTION, SP_FOREGROUND);
while (1)
{
@ -1544,7 +1617,10 @@ static void loc_eng_deferred_action_thread(void* arg)
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);
unsigned char generate_nmea = reported && (rpMsg->status != LOC_SESS_FAILURE);
loc_eng_nmea_generate_pos(loc_eng_data_p, rpMsg->location,
rpMsg->locationExtended,
generate_nmea);
}
// Free the allocated memory for rawData
@ -1660,13 +1736,32 @@ static void loc_eng_deferred_action_thread(void* arg)
loc_eng_data_p->client_handle,
false);
// attempt to unsubscribe from agnss_nif first
if (! loc_eng_data_p->agnss_nif->unsubscribeRsrc((Subscriber*)&s1)) {
if (loc_eng_data_p->agnss_nif->unsubscribeRsrc((Subscriber*)&s1)) {
LOC_LOGD("%s:%d]: Unsubscribed from agnss_nif", __func__, __LINE__);
}
else {
ATLSubscriber s2(arlMsg->handle,
loc_eng_data_p->internet_nif,
loc_eng_data_p->client_handle,
false);
// if unsuccessful, try internet_nif
loc_eng_data_p->internet_nif->unsubscribeRsrc((Subscriber*)&s2);
if(loc_eng_data_p->internet_nif->unsubscribeRsrc((Subscriber*)&s2)) {
LOC_LOGD("%s:%d]: Unsubscribed from internet_nif", __func__, __LINE__);
}
else {
DSSubscriber s3(loc_eng_data_p->ds_nif,
arlMsg->handle);
LOC_LOGD("%s:%d]: Request to stop Emergency call. Handle: %d\n",
__func__, __LINE__, arlMsg->handle);
if(loc_eng_data_p->ds_nif->unsubscribeRsrc((Subscriber*)&s3)) {
LOC_LOGD("%s:%d]: Unsubscribed from ds_nif", __func__, __LINE__);
}
else {
LOC_LOGE("%s:%d]: Could not release ATL. No subscribers found\n",
__func__, __LINE__);
loc_eng_data_p->client_handle->atlCloseStatus(arlMsg->handle, 0);
}
}
}
}
break;
@ -1747,17 +1842,25 @@ static void loc_eng_deferred_action_thread(void* arg)
{
loc_eng_msg_atl_open_success *aosMsg = (loc_eng_msg_atl_open_success*)msg;
AgpsStateMachine* stateMachine;
LOC_LOGD("%s:%d]: AGPS_TYPE: %d\n", __func__, __LINE__, (int)aosMsg->agpsType);
switch (aosMsg->agpsType) {
case AGPS_TYPE_WIFI: {
LOC_LOGD("%s:%d]: AGPS Type wifi\n", __func__, __LINE__);
stateMachine = loc_eng_data_p->wifi_nif;
break;
}
case AGPS_TYPE_SUPL: {
LOC_LOGD("%s:%d]: AGPS Type supl\n", __func__, __LINE__);
stateMachine = loc_eng_data_p->agnss_nif;
break;
}
case AGPS_TYPE_INVALID: {
stateMachine = loc_eng_data_p->ds_nif;
LOC_LOGD("%s:%d]: AGPS Type invalid\n", __func__, __LINE__);
}
break;
default: {
LOC_LOGD("%s:%d]: AGPS Type default internet\n", __func__, __LINE__);
stateMachine = loc_eng_data_p->internet_nif;
}
}
@ -1782,6 +1885,10 @@ static void loc_eng_deferred_action_thread(void* arg)
stateMachine = loc_eng_data_p->agnss_nif;
break;
}
case AGPS_TYPE_INVALID: {
stateMachine = loc_eng_data_p->ds_nif;
break;
}
default: {
stateMachine = loc_eng_data_p->internet_nif;
}
@ -1826,6 +1933,25 @@ static void loc_eng_deferred_action_thread(void* arg)
}
break;
case LOC_ENG_MSG_REQUEST_SUPL_ES:
{
loc_eng_msg_request_supl_es *reqMsg =
(loc_eng_msg_request_supl_es *)msg;
AgpsStateMachine *stateMachine = loc_eng_data_p->ds_nif;
DSSubscriber subscriber(stateMachine, reqMsg->handle);
LOC_LOGD("%s:%d]: Starting data call\n", __func__, __LINE__);
stateMachine->subscribeRsrc((Subscriber *)&subscriber);
}
break;
case LOC_ENG_MSG_CLOSE_DATA_CALL:
{
loc_eng_data_p->client_handle->closeDataCall();
LOC_LOGD("%s:%d]: Request to close data call\n",
__func__, __LINE__);
}
break;
default:
LOC_LOGE("unsupported msgid = %d\n", msg->msgid);
break;
@ -1926,4 +2052,3 @@ int loc_eng_read_config(void)
EXIT_LOG(%d, 0);
return 0;
}

View file

@ -119,6 +119,8 @@ typedef struct loc_eng_data_s
AgpsStateMachine* agnss_nif;
AgpsStateMachine* internet_nif;
AgpsStateMachine* wifi_nif;
//State machine for Data Services
AgpsStateMachine* ds_nif;
// GPS engine status
GpsStatusValue engine_status;

View file

@ -33,8 +33,10 @@
#include <loc_eng_agps.h>
#include <loc_eng_log.h>
#include <log_util.h>
#include "platform_lib_includes.h"
#include <loc_eng_dmn_conn_handler.h>
#include <loc_eng_dmn_conn.h>
#include<sys/time.h>
//======================================================================
// C callbacks
@ -84,8 +86,8 @@ static bool notifySubscriber(void* fromCaller, void* fromList)
const int Notification::BROADCAST_ALL = 0x80000000;
const int Notification::BROADCAST_ACTIVE = 0x80000001;
const int Notification::BROADCAST_INACTIVE = 0x80000002;
const unsigned char DSStateMachine::MAX_START_DATA_CALL_RETRIES = 4;
const unsigned int DSStateMachine::DATA_CALL_RETRY_DELAY_MSEC = 500;
//======================================================================
// Subscriber: BITSubscriber / ATLSubscriber / WIFISubscriber
//======================================================================
@ -211,7 +213,29 @@ bool WIFISubscriber::notifyRsrcStatus(Notification &notification)
return notify;
}
bool DSSubscriber::notifyRsrcStatus(Notification &notification)
{
bool notify = forMe(notification);
LOC_LOGD("DSSubscriber::notifyRsrcStatus. notify:%d \n",(int)(notify));
if(notify) {
switch(notification.rsrcStatus) {
case RSRC_UNSUBSCRIBE:
case RSRC_RELEASED:
case RSRC_DENIED:
case RSRC_GRANTED:
((DSStateMachine *)mStateMachine)->informStatus(notification.rsrcStatus, ID);
break;
default:
notify = false;
}
}
return notify;
}
void DSSubscriber :: setInactive()
{
mIsInactive = true;
((DSStateMachine *)mStateMachine)->informStatus(RSRC_UNSUBSCRIBE, ID);
}
//======================================================================
// AgpsState: AgpsReleasedState / AgpsPendingState / AgpsAcquiredState
//======================================================================
@ -233,13 +257,14 @@ public:
AgpsState* AgpsReleasedState::onRsrcEvent(AgpsRsrcStatus event, void* data)
{
LOC_LOGD("AgpsReleasedState::onRsrcEvent; event:%d\n", (int)event);
if (mStateMachine->hasSubscribers()) {
LOC_LOGE("Error: %s subscriber list not empty!!!", whoami());
// I don't know how to recover from it. I am adding this rather
// for debugging purpose.
}
AgpsState* nextState = this;;
AgpsState* nextState = this;
switch (event)
{
case RSRC_SUBSCRIBE:
@ -247,11 +272,14 @@ AgpsState* AgpsReleasedState::onRsrcEvent(AgpsRsrcStatus event, void* data)
// no notification until we get RSRC_GRANTED
// but we need to add subscriber to the list
mStateMachine->addSubscriber((Subscriber*)data);
// request from connecivity service for NIF
//The if condition is added so that if the data call setup fails
//for DS State Machine, we want to retry in released state.
//for AGps State Machine, sendRsrcRequest() will always return success
if(!mStateMachine->sendRsrcRequest(GPS_REQUEST_AGPS_DATA_CONN)) {
// move the state to PENDING
nextState = mPendingState;
// request from connecivity service for NIF
mStateMachine->sendRsrcRequest(GPS_REQUEST_AGPS_DATA_CONN);
}
}
break;
@ -297,6 +325,7 @@ public:
AgpsState* AgpsPendingState::onRsrcEvent(AgpsRsrcStatus event, void* data)
{
AgpsState* nextState = this;;
LOC_LOGD("AgpsPendingState::onRsrcEvent; event:%d\n", (int)event);
switch (event)
{
case RSRC_SUBSCRIBE:
@ -392,6 +421,7 @@ public:
AgpsState* AgpsAcquiredState::onRsrcEvent(AgpsRsrcStatus event, void* data)
{
AgpsState* nextState = this;
LOC_LOGD("AgpsAcquiredState::onRsrcEvent; event:%d\n", (int)event);
switch (event)
{
case RSRC_SUBSCRIBE:
@ -484,6 +514,8 @@ public:
AgpsState* AgpsReleasingState::onRsrcEvent(AgpsRsrcStatus event, void* data)
{
AgpsState* nextState = this;;
LOC_LOGD("AgpsReleasingState::onRsrcEvent; event:%d\n", (int)event);
switch (event)
{
case RSRC_SUBSCRIBE:
@ -525,7 +557,7 @@ AgpsState* AgpsReleasingState::onRsrcEvent(AgpsRsrcStatus event, void* data)
// by setting false, we keep subscribers on the linked list
mStateMachine->notifySubscribers(notification);
if (mStateMachine->hasSubscribers()) {
if (mStateMachine->hasActiveSubscribers()) {
nextState = mPendingState;
// request from connecivity service for NIF
mStateMachine->sendRsrcRequest(GPS_REQUEST_AGPS_DATA_CONN);
@ -545,20 +577,58 @@ AgpsState* AgpsReleasingState::onRsrcEvent(AgpsRsrcStatus event, void* data)
whoami(), nextState->whoami(), event);
return nextState;
}
//======================================================================
//Servicer
//======================================================================
Servicer* Servicer :: getServicer(servicerType type, void *cb_func)
{
LOC_LOGD(" Enter getServicer type:%d\n", (int)type);
switch(type) {
case servicerTypeNoCbParam:
return (new Servicer(cb_func));
case servicerTypeExt:
return (new ExtServicer(cb_func));
case servicerTypeAgps:
return (new AGpsServicer(cb_func));
default:
return NULL;
}
}
int Servicer :: requestRsrc(void *cb_data)
{
callback();
return 0;
}
int ExtServicer :: requestRsrc(void *cb_data)
{
int ret=-1;
LOC_LOGD("Enter ExtServicer :: requestRsrc\n");
ret = callbackExt(cb_data);
LOC_LOGD("Exit ExtServicer :: requestRsrc\n");
return(ret);
}
int AGpsServicer :: requestRsrc(void *cb_data)
{
callbackAGps((AGpsStatus *)cb_data);
return 0;
}
//======================================================================
// AgpsStateMachine
//======================================================================
AgpsStateMachine::AgpsStateMachine(void (*servicer)(AGpsExtStatus* status),
AgpsStateMachine::AgpsStateMachine(servicerType servType,
void *cb_func,
AGpsExtType type,
bool enforceSingleSubscriber) :
mServicer(servicer), mType(type),
mStatePtr(new AgpsReleasedState(this)),
mStatePtr(new AgpsReleasedState(this)),mType(type),
mAPN(NULL),
mAPNLen(0),
mEnforceSingleSubscriber(enforceSingleSubscriber)
mEnforceSingleSubscriber(enforceSingleSubscriber),
mServicer(Servicer :: getServicer(servType, (void *)cb_func))
{
linked_list_init(&mSubscribers);
@ -599,6 +669,7 @@ AgpsStateMachine::~AgpsStateMachine()
delete releasedState;
delete pendindState;
delete releasingState;
delete mServicer;
linked_list_destroy(&mSubscribers);
if (NULL != mAPN) {
@ -653,6 +724,7 @@ void AgpsStateMachine::notifySubscribers(Notification& notification) const
// rest of the list unprocessed. So we need a loop.
linked_list_search(mSubscribers, (void**)&s, notifySubscriber,
(void*)&notification, true);
delete s;
}
} else {
// no loop needed if it the last param sets to false, which
@ -674,7 +746,7 @@ void AgpsStateMachine::addSubscriber(Subscriber* subscriber) const
}
}
void AgpsStateMachine::sendRsrcRequest(AGpsStatusValue action) const
int AgpsStateMachine::sendRsrcRequest(AGpsStatusValue action) const
{
Subscriber* s = NULL;
Notification notification(Notification::BROADCAST_ACTIVE);
@ -698,8 +770,9 @@ void AgpsStateMachine::sendRsrcRequest(AGpsStatusValue action) const
}
CALLBACK_LOG_CALLFLOW("agps_cb", %s, loc_get_agps_status_name(action));
(*mServicer)(&nifRequest);
mServicer->requestRsrc((void *)&nifRequest);
}
return 0;
}
void AgpsStateMachine::subscribeRsrc(Subscriber *subscriber)
@ -734,3 +807,163 @@ bool AgpsStateMachine::hasActiveSubscribers() const
hasSubscriber, (void*)&notification, false);
return NULL != s;
}
//======================================================================
// DSStateMachine
//======================================================================
void delay_callback(void *callbackData, int result)
{
if(callbackData) {
DSStateMachine *DSSMInstance = (DSStateMachine *)callbackData;
DSSMInstance->retryCallback();
}
else {
LOC_LOGE(" NULL argument received. Failing.\n");
goto err;
}
err:
return;
}
DSStateMachine :: DSStateMachine(servicerType type, void *cb_func,
LocApiAdapter* adapterHandle):
AgpsStateMachine(type, cb_func, AGPS_TYPE_INVALID,false),
mLocAdapter(adapterHandle)
{
LOC_LOGD("%s:%d]: New DSStateMachine\n", __func__, __LINE__);
mRetries = 0;
}
void DSStateMachine :: retryCallback(void)
{
DSSubscriber *subscriber = NULL;
Notification notification(Notification::BROADCAST_ACTIVE);
linked_list_search(mSubscribers, (void**)&subscriber, hasSubscriber,
(void*)&notification, false);
if(subscriber)
mLocAdapter->requestSuplES(subscriber->ID);
else
LOC_LOGE("DSStateMachine :: retryCallback: No subscriber found." \
"Cannot retry data call\n");
return;
}
int DSStateMachine :: sendRsrcRequest(AGpsStatusValue action) const
{
DSSubscriber* s = NULL;
dsCbData cbData;
int ret=-1;
int connHandle=-1;
LOC_LOGD("Enter DSStateMachine :: sendRsrcRequest\n");
Notification notification(Notification::BROADCAST_ACTIVE);
linked_list_search(mSubscribers, (void**)&s, hasSubscriber,
(void*)&notification, false);
if(s) {
connHandle = s->ID;
LOC_LOGD("DSStateMachine :: sendRsrcRequest - subscriber found\n");
}
else
LOC_LOGD("DSStateMachine :: sendRsrcRequest - No subscriber found\n");
cbData.action = action;
cbData.mAdapter = mLocAdapter;
ret = mServicer->requestRsrc((void *)&cbData);
//Only the request to start data call returns a success/failure
//The request to stop data call will always succeed
//Hence, the below block will only be executed when the
//request to start the data call fails
switch(ret) {
case LOC_API_ADAPTER_ERR_ENGINE_BUSY:
LOC_LOGD("DSStateMachine :: sendRsrcRequest - Failure returned: %d\n",ret);
((DSStateMachine *)this)->incRetries();
if(mRetries > MAX_START_DATA_CALL_RETRIES) {
LOC_LOGE(" Failed to start Data call. Fallback to normal ATL SUPL\n");
informStatus(RSRC_DENIED, connHandle);
}
else {
if(loc_timer_start(DATA_CALL_RETRY_DELAY_MSEC, delay_callback, (void *)this)) {
LOC_LOGE("Error: Could not start delay thread\n");
ret = -1;
goto err;
}
}
break;
case LOC_API_ADAPTER_ERR_UNSUPPORTED:
LOC_LOGE("No profile found for emergency call. Fallback to normal SUPL ATL\n");
informStatus(RSRC_DENIED, connHandle);
break;
case LOC_API_ADAPTER_ERR_SUCCESS:
LOC_LOGD("%s:%d]: Request to start data call sent\n", __func__, __LINE__);
break;
case -1:
//One of the ways this case can be encountered is if the callback function
//receives a null argument, it just exits with -1 error
LOC_LOGE("Error: Something went wrong somewhere. Falling back to normal SUPL ATL\n");
informStatus(RSRC_DENIED, connHandle);
break;
default:
LOC_LOGE("%s:%d]: Unrecognized return value\n", __func__, __LINE__);
}
err:
LOC_LOGD("EXIT DSStateMachine :: sendRsrcRequest; ret = %d\n", ret);
return ret;
}
void DSStateMachine :: onRsrcEvent(AgpsRsrcStatus event)
{
void* currState = (void *)mStatePtr;
LOC_LOGD("Enter DSStateMachine :: onRsrcEvent. event = %d\n", (int)event);
switch (event)
{
case RSRC_GRANTED:
LOC_LOGD("DSStateMachine :: onRsrcEvent RSRC_GRANTED\n");
mStatePtr = mStatePtr->onRsrcEvent(event, NULL);
break;
case RSRC_RELEASED:
LOC_LOGD("DSStateMachine :: onRsrcEvent RSRC_RELEASED\n");
mStatePtr = mStatePtr->onRsrcEvent(event, NULL);
//To handle the case where we get a RSRC_RELEASED in
//pending state, we translate that to a RSRC_DENIED state
//since the callback from DSI is either RSRC_GRANTED or RSRC_RELEASED
//for when the call is connected or disconnected respectively.
if((void *)mStatePtr != currState)
break;
else {
event = RSRC_DENIED;
LOC_LOGE(" Switching event to RSRC_DENIED\n");
}
case RSRC_DENIED:
mStatePtr = mStatePtr->onRsrcEvent(event, NULL);
break;
default:
LOC_LOGW("AgpsStateMachine: unrecognized event %d", event);
break;
}
LOC_LOGD("Exit DSStateMachine :: onRsrcEvent. event = %d\n", (int)event);
}
void DSStateMachine :: informStatus(AgpsRsrcStatus status, int ID) const
{
LOC_LOGD("DSStateMachine :: informStatus. Status=%d\n",(int)status);
switch(status) {
case RSRC_UNSUBSCRIBE:
((LocApiAdapter*)mLocAdapter)->atlCloseStatus(ID, 1);
break;
case RSRC_RELEASED:
((LocApiAdapter*)mLocAdapter)->releaseDataHandle();
break;
case RSRC_DENIED:
((DSStateMachine *)this)->mRetries = 0;
mLocAdapter->requestATL(ID, AGPS_TYPE_SUPL);
break;
case RSRC_GRANTED:
((LocApiAdapter*)mLocAdapter)->atlOpenStatus(ID, 1,
NULL,
AGPS_APN_BEARER_INVALID,
AGPS_TYPE_INVALID);
break;
default:
LOC_LOGW("DSStateMachine :: informStatus - unknown status");
}
return;
}

View file

@ -38,6 +38,7 @@
#include <linked_list.h>
#include <LocApiAdapter.h>
#include "loc_eng_msg.h"
#include <loc_timer.h>
// forward declaration
class AgpsStateMachine;
@ -53,6 +54,18 @@ typedef enum {
RSRC_STATUS_MAX
} AgpsRsrcStatus;
typedef enum {
servicerTypeNoCbParam,
servicerTypeAgps,
servicerTypeExt
}servicerType;
//DS Callback struct
typedef struct {
LocApiAdapter *mAdapter;
AGpsStatusValue action;
}dsCbData;
// information bundle for subscribers
struct Notification {
// goes to every subscriber
@ -101,7 +114,7 @@ class AgpsState {
// no class members are public. We don't want
// anyone but state machine to use state.
friend class AgpsStateMachine;
friend class DSStateMachine;
// state transitions are done here.
// Each state implements its own transitions (of course).
inline virtual AgpsState* onRsrcEvent(AgpsRsrcStatus event, void* data) = 0;
@ -129,21 +142,56 @@ public:
inline virtual char* whoami() = 0;
};
class Servicer {
void (*callback)(void);
public:
static Servicer* getServicer(servicerType type, void *cb_func);
virtual int requestRsrc(void *cb_data);
Servicer() {}
Servicer(void *cb_func)
{ callback = (void(*)(void))(cb_func); }
virtual ~Servicer(){}
inline virtual char *whoami() {return (char*)"Servicer";}
};
class ExtServicer : public Servicer {
int (*callbackExt)(void *cb_data);
public:
int requestRsrc(void *cb_data);
ExtServicer() {}
ExtServicer(void *cb_func)
{ callbackExt = (int(*)(void *))(cb_func); }
virtual ~ExtServicer(){}
inline virtual char *whoami() {return (char*)"ExtServicer";}
};
class AGpsServicer : public Servicer {
void (*callbackAGps)(AGpsStatus* status);
public:
int requestRsrc(void *cb_data);
AGpsServicer() {}
AGpsServicer(void *cb_func)
{ callbackAGps = (void(*)(AGpsStatus *))(cb_func); }
virtual ~AGpsServicer(){}
inline virtual char *whoami() {return (char*)"AGpsServicer";}
};
class AgpsStateMachine {
protected:
// a linked list of subscribers.
void* mSubscribers;
//handle to whoever provides the service
Servicer *mServicer;
// allows AgpsState to access private data
// each state is really internal data to the
// state machine, so it should be able to
// access anything within the state machine.
friend class AgpsState;
// handle to whoever provides the service
void (* const mServicer)(AGpsExtStatus* status);
// NIF type: AGNSS or INTERNET.
const AGpsExtType mType;
// pointer to the current state.
AgpsState* mStatePtr;
// a linked list of subscribers.
void* mSubscribers;
private:
// NIF type: AGNSS or INTERNET.
const AGpsExtType mType;
// apn to the NIF. Each state machine tracks
// resource state of a particular NIF. For each
// NIF, there is also an active APN.
@ -156,7 +204,8 @@ class AgpsStateMachine {
bool mEnforceSingleSubscriber;
public:
AgpsStateMachine(void (*servicer)(AGpsExtStatus* status), AGpsExtType type, bool enforceSingleSubscriber);
AgpsStateMachine(servicerType servType, void *cb_func,
AGpsExtType type, bool enforceSingleSubscriber);
virtual ~AgpsStateMachine();
// self explanatory methods below
@ -175,11 +224,15 @@ public:
// add a subscriber in the linked list, if not already there.
void addSubscriber(Subscriber* subscriber) const;
void onRsrcEvent(AgpsRsrcStatus event);
virtual void onRsrcEvent(AgpsRsrcStatus event);
// put the data together and send the FW
void sendRsrcRequest(AGpsStatusValue action) const;
virtual int sendRsrcRequest(AGpsStatusValue action) const;
//if list is empty, linked_list_empty returns 1
//else if list is not empty, returns 0
//so hasSubscribers() returns 1 if list is not empty
//and returns 0 if list is empty
inline bool hasSubscribers() const
{ return !linked_list_empty(mSubscribers); }
@ -190,6 +243,24 @@ public:
// private. Only a state gets to call this.
void notifySubscribers(Notification& notification) const;
};
class DSStateMachine : public AgpsStateMachine {
static const unsigned char MAX_START_DATA_CALL_RETRIES;
static const unsigned int DATA_CALL_RETRY_DELAY_MSEC;
LocApiAdapter* mLocAdapter;
unsigned char mRetries;
public:
DSStateMachine(servicerType type,
void *cb_func,
LocApiAdapter* adapterHandle);
int sendRsrcRequest(AGpsStatusValue action) const;
void onRsrcEvent(AgpsRsrcStatus event);
void retryCallback();
void informStatus(AgpsRsrcStatus status, int ID) const;
inline void incRetries() {mRetries++;}
inline virtual char *whoami() {return (char*)"DSStateMachine";}
};
// each subscriber is a AGPS client. In the case of ATL, there could be
@ -248,7 +319,7 @@ struct BITSubscriber : public Subscriber {
}
virtual bool equals(const Subscriber *s) const;
inline virtual ~BITSubscriber(){}
private:
char ipv6Addr[16];
};
@ -273,6 +344,7 @@ struct ATLSubscriber : public Subscriber {
return new ATLSubscriber(ID, mStateMachine, mLocAdapter,
mBackwardCompatibleMode);
}
inline virtual ~ATLSubscriber(){}
};
// WIFISubscriber, created with requests from MSAPM or QuIPC
@ -320,6 +392,27 @@ struct WIFISubscriber : public Subscriber {
{
return new WIFISubscriber(mStateMachine, mSSID, mPassword, senderId);
}
inline virtual ~WIFISubscriber(){}
};
struct DSSubscriber : public Subscriber {
bool mIsInactive;
inline DSSubscriber(const AgpsStateMachine *stateMachine,
const int id) :
Subscriber(id, stateMachine)
{
mIsInactive = false;
}
inline virtual void setIPAddresses(uint32_t &v4, char* v6) {}
virtual Subscriber* clone()
{return new DSSubscriber(mStateMachine, ID);}
virtual bool notifyRsrcStatus(Notification &notification);
inline virtual bool waitForCloseComplete() { return true; }
virtual void setInactive();
inline virtual bool isInactive()
{ return mIsInactive; }
inline virtual ~DSSubscriber(){}
inline virtual char *whoami() {return (char*)"DSSubscriber";}
};
#endif //__LOC_ENG_AGPS_H__

View file

@ -38,7 +38,7 @@
#include <sys/stat.h>
#include "log_util.h"
#include "platform_lib_includes.h"
#include "loc_eng_dmn_conn_glue_msg.h"
#include "loc_eng_dmn_conn_handler.h"
#include "loc_eng_dmn_conn.h"

View file

@ -32,7 +32,7 @@
#include <linux/types.h>
#include "log_util.h"
#include "platform_lib_includes.h"
#include "loc_eng_dmn_conn_glue_msg.h"
#include "loc_eng_dmn_conn_handler.h"

View file

@ -38,7 +38,7 @@
#include "loc_eng_dmn_conn_glue_pipe.h"
#include "log_util.h"
#include "platform_lib_includes.h"
/*===========================================================================
FUNCTION loc_eng_dmn_conn_glue_pipeget

View file

@ -32,6 +32,7 @@
#include <unistd.h>
#include "log_util.h"
#include "platform_lib_includes.h"
#include "loc_eng_msg.h"
#include "loc_eng_dmn_conn.h"
#include "loc_eng_dmn_conn_handler.h"

View file

@ -29,6 +29,7 @@
#include <stdio.h>
#include "log_util.h"
#include "platform_lib_includes.h"
#include "loc_eng_dmn_conn_thread_helper.h"
/*===========================================================================

View file

@ -97,7 +97,9 @@ static loc_name_val_s_type loc_eng_msgs[] =
NAME_VAL( LOC_ENG_MSG_REQUEST_POSITION ),
NAME_VAL( LOC_ENG_MSG_LPP_CONFIG ),
NAME_VAL( LOC_ENG_MSG_A_GLONASS_PROTOCOL ),
NAME_VAL( LOC_ENG_MSG_LOC_INIT )
NAME_VAL( LOC_ENG_MSG_LOC_INIT ),
NAME_VAL( LOC_ENG_MSG_REQUEST_SUPL_ES ),
NAME_VAL( LOC_ENG_MSG_CLOSE_DATA_CALL)
};
static int loc_eng_msgs_num = sizeof(loc_eng_msgs) / sizeof(loc_name_val_s_type);

View file

@ -35,9 +35,20 @@
#include <stdlib.h>
#include <string.h>
#include "log_util.h"
#include "loc.h"
#include <loc_eng_log.h>
#include "loc_eng_msg_id.h"
#ifndef SSID_BUF_SIZE
#define SSID_BUF_SIZE (32+1)
#endif
#ifdef USE_GLIB
#include <glib.h>
#endif /* USE_GLIB */
#include "platform_lib_includes.h"
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
@ -619,6 +630,23 @@ struct loc_eng_msg_request_atl : public loc_eng_msg {
}
};
struct loc_eng_msg_request_supl_es : public loc_eng_msg {
const int handle;
inline loc_eng_msg_request_supl_es(void* instance, int hndl) :
loc_eng_msg(instance, LOC_ENG_MSG_REQUEST_SUPL_ES),
handle(hndl)
{
LOC_LOGV("handle: %d\n", handle);
}
};
struct loc_eng_msg_close_data_call: public loc_eng_msg {
inline loc_eng_msg_close_data_call(void *instance) :
loc_eng_msg(instance, LOC_ENG_MSG_CLOSE_DATA_CALL)
{
LOC_LOGV("%s:%d]Close data call: ", __func__, __LINE__);
}
};
struct loc_eng_msg_release_atl : public loc_eng_msg {
const int handle;
inline loc_eng_msg_release_atl(void* instance, int hndl) :
@ -751,12 +779,12 @@ struct loc_eng_msg_request_xtra_server : public loc_eng_msg {
};
struct loc_eng_msg_atl_open_success : public loc_eng_msg {
const AGpsStatusValue agpsType;
const AGpsType agpsType;
const int length;
char* const apn;
const AGpsBearerType bearerType;
inline loc_eng_msg_atl_open_success(void* instance,
AGpsStatusValue atype,
AGpsType atype,
const char* name,
int len,
AGpsBearerType btype) :
@ -777,7 +805,6 @@ struct loc_eng_msg_atl_open_success : public loc_eng_msg {
}
};
struct loc_eng_msg_atl_open_failed : public loc_eng_msg {
const AGpsStatusValue agpsType;
inline loc_eng_msg_atl_open_failed(void* instance,
@ -790,11 +817,10 @@ struct loc_eng_msg_atl_open_failed : public loc_eng_msg {
}
};
struct loc_eng_msg_atl_closed : public loc_eng_msg {
const AGpsStatusValue agpsType;
const AGpsType agpsType;
inline loc_eng_msg_atl_closed(void* instance,
AGpsStatusValue atype) :
AGpsType atype) :
loc_eng_msg(instance, LOC_ENG_MSG_ATL_CLOSED),
agpsType(atype)
{

View file

@ -99,6 +99,12 @@ enum loc_eng_msg_ids_t {
//Message is sent by LOC to do LOC INIT
LOC_ENG_MSG_LOC_INIT,
/*Message is sent by modem to request emergency call setup*/
LOC_ENG_MSG_REQUEST_SUPL_ES,
/*Ask the DS client to close the data call by releasing the handle*/
LOC_ENG_MSG_CLOSE_DATA_CALL,
};
#ifdef __cplusplus

View file

@ -43,7 +43,7 @@
#include <loc_eng.h>
#include "log_util.h"
#include "platform_lib_includes.h"
/*=============================================================================
*
* DATA DECLARATION

View file

@ -110,7 +110,9 @@ SIDE EFFECTS
===========================================================================*/
void loc_eng_nmea_generate_pos(loc_eng_data_s_type *loc_eng_data_p,
const UlpLocation &location, const GpsLocationExtended &locationExtended)
const UlpLocation &location,
const GpsLocationExtended &locationExtended,
unsigned char generate_nmea)
{
ENTRY_LOG();
@ -128,6 +130,7 @@ void loc_eng_nmea_generate_pos(loc_eng_data_s_type *loc_eng_data_p,
int utcMinutes = pTm->tm_min;
int utcSeconds = pTm->tm_sec;
if (generate_nmea) {
// ------------------
// ------$GPGSA------
// ------------------
@ -548,6 +551,25 @@ void loc_eng_nmea_generate_pos(loc_eng_data_s_type *loc_eng_data_p,
length = loc_eng_nmea_put_checksum(sentence, sizeof(sentence));
loc_eng_nmea_send(sentence, length, loc_eng_data_p);
}
//Send blank NMEA reports for non-final fixes
else {
strlcpy(sentence, "$GPGSA,A,1,,,,,,,,,,,,,,,", sizeof(sentence));
length = loc_eng_nmea_put_checksum(sentence, sizeof(sentence));
loc_eng_nmea_send(sentence, length, loc_eng_data_p);
strlcpy(sentence, "$GPVTG,,T,,M,,N,,K,N", sizeof(sentence));
length = loc_eng_nmea_put_checksum(sentence, sizeof(sentence));
loc_eng_nmea_send(sentence, length, loc_eng_data_p);
strlcpy(sentence, "$GPRMC,,V,,,,,,,,,,N", sizeof(sentence));
length = loc_eng_nmea_put_checksum(sentence, sizeof(sentence));
loc_eng_nmea_send(sentence, length, loc_eng_data_p);
strlcpy(sentence, "$GPGGA,,,,,,0,,,,,,,,", sizeof(sentence));
length = loc_eng_nmea_put_checksum(sentence, sizeof(sentence));
loc_eng_nmea_send(sentence, length, loc_eng_data_p);
}
// clear the dop cache so they can't be used again
loc_eng_data_p->pdop = 0;
loc_eng_data_p->hdop = 0;

View file

@ -37,6 +37,6 @@
void loc_eng_nmea_send(char *pNmea, int length, loc_eng_data_s_type *loc_eng_data_p);
int loc_eng_nmea_put_checksum(char *pNmea, int maxSize);
void loc_eng_nmea_generate_sv(loc_eng_data_s_type *loc_eng_data_p, const GpsSvStatus &svStatus, const GpsLocationExtended &locationExtended);
void loc_eng_nmea_generate_pos(loc_eng_data_s_type *loc_eng_data_p, const UlpLocation &location, const GpsLocationExtended &locationExtended);
void loc_eng_nmea_generate_pos(loc_eng_data_s_type *loc_eng_data_p, const UlpLocation &location, const GpsLocationExtended &locationExtended, unsigned char generate_nmea);
#endif // LOC_ENG_NMEA_H

View file

@ -33,7 +33,7 @@
#include <loc_eng.h>
#include <loc_eng_msg.h>
#include "log_util.h"
#include "platform_lib_includes.h"
/*===========================================================================
FUNCTION loc_eng_xtra_init
@ -57,9 +57,9 @@ int loc_eng_xtra_init (loc_eng_data_s_type &loc_eng_data,
int ret_val = -1;
loc_eng_xtra_data_s_type *xtra_module_data_ptr;
if(callbacks == NULL)
if(callbacks == NULL) {
LOC_LOGE("loc_eng_xtra_init: failed, cb is NULL");
else {
} else {
xtra_module_data_ptr = &loc_eng_data.xtra_module_data;
xtra_module_data_ptr->download_request_cb = callbacks->download_request_cb;
xtra_module_data_ptr->report_xtra_server_cb = callbacks->report_xtra_server_cb;

View file

@ -0,0 +1,52 @@
ifneq ($(BUILD_TINY_ANDROID),true)
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := libloc_api_v02
LOCAL_MODULE_TAGS := optional
LOCAL_SHARED_LIBRARIES := \
libutils \
libcutils \
libqmi_cci \
libqmi_csi \
libqmi_common_so \
libloc_adapter \
libgps.utils \
libds_api
LOCAL_SRC_FILES += \
LocApiV02Adapter.cpp \
loc_api_v02_log.c \
loc_api_v02_client.c \
loc_api_sync_req.c \
location_service_v02.c
LOCAL_CFLAGS += \
-fno-short-enums \
-D_ANDROID_
ifeq ($(FEATURE_IPV6), true)
LOCAL_CFLAGS += -DFEATURE_IPV6
endif #FEATURE_IPV6
ifeq ($(FEATURE_DELEXT), true)
LOCAL_CFLAGS += -DFEATURE_DELEXT
endif #FEATURE_DELEXT
## Includes
LOCAL_C_INCLUDES := \
$(TARGET_OUT_HEADERS)/libloc_eng \
$(TARGET_OUT_HEADERS)/qmi-framework/inc \
$(TARGET_OUT_HEADERS)/qmi/inc \
$(TARGET_OUT_HEADERS)/gps.utils \
$(TARGET_OUT_HEADERS)/ds_api
LOCAL_PRELINK_MODULE := false
include $(BUILD_SHARED_LIBRARY)
endif # not BUILD_TINY_ANDROID

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,182 @@
/* Copyright (c) 2011-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
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* 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 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.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef LOC_API_V_0_2_ADAPTER_H
#define LOC_API_V_0_2_ADAPTER_H
#include <LocApiAdapter.h>
#include "loc_api_v02_client.h"
#include <stdint.h>
#include <stdbool.h>
#include "ds_client.h"
/* This class derives from the LocApiAdapter class.
The members of this class are responsible for converting
the Loc API V02 data structures into Loc Engine data structures.
This class also implements some of the virtual functions that
handle the requests from loc engine. */
class LocApiV02Adapter : public LocApiAdapter {
/*ds client handle*/
dsClientHandleType dsClientHandle;
/* loc api v02 handle*/
locClientHandleType clientHandle;
/* events the client is registered for */
locClientEventMaskType eventMask;
/* Convert event mask from loc eng to loc_api_v02 format */
locClientEventMaskType convertMask(LOC_API_ADAPTER_EVENT_MASK_T mask);
/* Convert error from loc_api_v02 to loc eng format*/
enum loc_api_adapter_err convertErr(locClientStatusEnumType status);
/* convert Ni Encoding type from QMI_LOC to loc eng format */
GpsNiEncodingType convertNiEncoding(
qmiLocNiDataCodingSchemeEnumT_v02 loc_encoding);
/*convert NI notify verify type from QMI LOC to loc eng format*/
bool convertNiNotifyVerifyType (GpsNiNotification *notif,
qmiLocNiNotifyVerifyEnumT_v02 notif_priv);
/* close Loc API V02 client */
int deInitLocClient();
/* convert position report to loc eng format and send the converted
position to loc eng */
void reportPosition
(const qmiLocEventPositionReportIndMsgT_v02 *location_report_ptr);
/* convert satellite report to loc eng format and send the converted
report to loc eng */
void reportSv (const qmiLocEventGnssSvInfoIndMsgT_v02 *gnss_report_ptr);
/* convert engine state report to loc eng format and send the converted
report to loc eng */
void reportEngineState (
const qmiLocEventEngineStateIndMsgT_v02 *engine_state_ptr);
/* convert fix session report to loc eng format and send the converted
report to loc eng */
void reportFixSessionState (
const qmiLocEventFixSessionStateIndMsgT_v02 *fix_session_state_ptr);
/* convert NMEA report to loc eng format and send the converted
report to loc eng */
void reportNmea (const qmiLocEventNmeaIndMsgT_v02 *nmea_report_ptr);
/* convert and report an ATL request to loc engine */
void reportAtlRequest(
const qmiLocEventLocationServerConnectionReqIndMsgT_v02
*server_request_ptr);
/* convert and report NI request to loc eng */
void reportNiRequest(
const qmiLocEventNiNotifyVerifyReqIndMsgT_v02 *ni_req_ptr);
public:
LocApiV02Adapter(LocEng &locEng);
~LocApiV02Adapter();
/* event callback registered with the loc_api v02 interface */
void eventCb(locClientHandleType client_handle,
uint32_t loc_event_id,
locClientEventIndUnionType loc_event_payload);
/* error callback, this function handles the service unavailable
error */
void errorCb(locClientHandleType handle,
locClientErrorEnumType errorId);
void ds_client_event_cb(ds_client_status_enum_type result);
int openAndStartDataCall();
void stopDataCall();
void closeDataCall();
int initDataServiceClient();
virtual enum loc_api_adapter_err reinit();
virtual enum loc_api_adapter_err startFix();
virtual enum loc_api_adapter_err stopFix();
virtual enum loc_api_adapter_err
setPositionMode(const LocPosMode *mode);
virtual enum loc_api_adapter_err
setTime(GpsUtcTime time, int64_t timeReference, int uncertainty);
virtual enum loc_api_adapter_err
injectPosition(double latitude, double longitude, float accuracy);
virtual enum loc_api_adapter_err
deleteAidingData(GpsAidingData f);
virtual enum loc_api_adapter_err
informNiResponse(GpsUserResponseType userResponse,
const void* passThroughData);
virtual enum loc_api_adapter_err
setServer(const char* url, int len);
virtual enum loc_api_adapter_err
setServer(unsigned int ip, int port, LocServerType type);
virtual enum loc_api_adapter_err
setXtraData(char* data, int length);
#ifdef FEATURE_IPV6
virtual enum loc_api_adapter_err
atlOpenStatus(int handle, int is_succ, char* apn, AGpsBearerType bear,
AGpsType agpsType);
#else
virtual enum loc_api_adapter_err
atlOpenStatus(int handle, int is_succ, char* apn,
AGpsType agpsType);
#endif
virtual enum loc_api_adapter_err atlCloseStatus(int handle, int is_succ);
virtual enum loc_api_adapter_err setSUPLVersion(uint32_t version);
virtual enum loc_api_adapter_err setLPPConfig(uint32_t profile);
virtual enum loc_api_adapter_err
setSensorControlConfig(int sensorUsage);
virtual enum loc_api_adapter_err
setSensorProperties(bool gyroBiasVarianceRandomWalk_valid, float gyroBiasVarianceRandomWalk,
bool accelBiasVarianceRandomWalk_valid, float accelBiasVarianceRandomWalk,
bool angleBiasVarianceRandomWalk_valid, float angleBiasVarianceRandomWalk,
bool rateBiasVarianceRandomWalk_valid, float rateBiasVarianceRandomWalk,
bool velocityBiasVarianceRandomWalk_valid, float velocityBiasVarianceRandomWalk);
virtual enum loc_api_adapter_err
setSensorPerfControlConfig(int controlMode, int accelSamplesPerBatch, int accelBatchesPerSec,
int gyroSamplesPerBatch, int gyroBatchesPerSec,
int accelSamplesPerBatchHigh, int accelBatchesPerSecHigh,
int gyroSamplesPerBatchHigh, int gyroBatchesPerSecHigh, int algorithmConfig);
virtual enum loc_api_adapter_err setExtPowerConfig(int isBatteryCharging);
virtual enum loc_api_adapter_err setAGLONASSProtocol(unsigned long aGlonassProtocol);
};
#endif //LOC_API_V_0_2_ADAPTER_H

View file

@ -0,0 +1,42 @@
AM_CFLAGS = \
${QMIF_CFLAGS} \
-I../../utils \
-I../../platform_lib_abstractions \
-I../libloc_api_50001
requiredlibs = \
${QMIF_LIBS} \
../libloc_api_50001/libloc_adapter_so.la \
../../utils/libgps_utils_so.la
h_sources = LocApiV02Adapter.h \
loc_util_log.h \
location_service_v02.h \
loc_api_sync_req.h \
loc_api_v02_client.h \
loc_api_v02_log.h
c_sources = LocApiV02Adapter.cpp \
loc_api_v02_log.c \
loc_api_v02_client.c \
loc_api_sync_req.c \
location_service_v02.c
library_includedir = $(pkgincludedir)
library_include_HEADERS = $(h_sources)
libloc_api_la_SOURCES = $(c_sources) $(h_sources)
if USE_GLIB
libloc_api_la_CFLAGS = -DUSE_GLIB $(AM_CFLAGS) @GLIB_CFLAGS@
libloc_api_la_LDFLAGS = -lstdc++ -lpthread @GLIB_LIBS@ -shared -version-info 1:0:0
libloc_api_la_CPPFLAGS = -DUSE_GLIB $(AM_CFLAGS) $(AM_CPPFLAGS) @GLIB_CFLAGS@
else
libloc_api_la_CFLAGS = $(AM_CFLAGS)
libloc_api_la_LDFLAGS = -shared -version-info 1:0:0
libloc_api_la_CPPFLAGS = $(AM_CFLAGS) $(AM_CPPFLAGS)
endif
libloc_api_la_LIBADD = $(requiredlibs) -lstdc++
lib_LTLIBRARIES = libloc_api.la

View file

@ -0,0 +1,547 @@
/* Copyright (c) 2011-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
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* 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 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.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <stdio.h>
#include <assert.h>
#include <errno.h>
#include <sys/time.h>
#include <string.h>
#include <pthread.h>
#include <stdbool.h>
#include <stdint.h>
#include <loc_cfg.h>
#include "loc_api_v02_client.h"
#include "loc_api_sync_req.h"
/* Logging */
// Uncomment to log verbose logs
#define LOG_NDEBUG 1
// log debug logs
#define LOG_NDDEBUG 1
#define LOG_TAG "LocSvc_api_v02"
#include "loc_util_log.h"
#define LOC_SYNC_REQ_BUFFER_SIZE 8
#define GPS_CONF_FILE "/etc/gps.conf"
pthread_mutex_t loc_sync_call_mutex = PTHREAD_MUTEX_INITIALIZER;
static bool loc_sync_call_initialized = false;
typedef struct {
pthread_mutex_t sync_req_lock;
/* Client ID */
locClientHandleType client_handle;
/* waiting conditional variable */
pthread_cond_t ind_arrived_cond;
/* Callback waiting data block, protected by loc_cb_data_mutex */
bool ind_is_selected; /* is cb selected? */
bool ind_is_waiting; /* is waiting? */
bool ind_has_arrived; /* callback has arrived */
uint32_t req_id; /* sync request */
void *recv_ind_payload_ptr; /* received payload */
uint32_t recv_ind_id; /* received ind */
} loc_sync_req_data_s_type;
typedef struct {
bool in_use; /* at least one sync call is active */
bool slot_in_use[LOC_SYNC_REQ_BUFFER_SIZE];
loc_sync_req_data_s_type slots[LOC_SYNC_REQ_BUFFER_SIZE];
} loc_sync_req_array_s_type;
/***************************************************************************
* DATA FOR ASYNCHRONOUS RPC PROCESSING
**************************************************************************/
loc_sync_req_array_s_type loc_sync_array;
/*===========================================================================
FUNCTION loc_sync_req_init
DESCRIPTION
Initialize this module
DEPENDENCIES
N/A
RETURN VALUE
none
SIDE EFFECTS
N/A
===========================================================================*/
void loc_sync_req_init()
{
LOC_LOGV(" %s:%d]:\n", __func__, __LINE__);
UTIL_READ_CONF_DEFAULT(GPS_CONF_FILE);
pthread_mutex_lock(&loc_sync_call_mutex);
if(true == loc_sync_call_initialized)
{
LOC_LOGD("%s:%d]:already initialized\n", __func__, __LINE__);
pthread_mutex_unlock(&loc_sync_call_mutex);
return;
}
loc_sync_array.in_use = false;
memset(loc_sync_array.slot_in_use, 0, sizeof(loc_sync_array.slot_in_use));
int i;
for (i = 0; i < LOC_SYNC_REQ_BUFFER_SIZE; i++)
{
loc_sync_req_data_s_type *slot = &loc_sync_array.slots[i];
pthread_mutex_init(&slot->sync_req_lock, NULL);
pthread_cond_init(&slot->ind_arrived_cond, NULL);
slot->client_handle = LOC_CLIENT_INVALID_HANDLE_VALUE;
slot->ind_is_selected = false; /* is ind selected? */
slot->ind_is_waiting = false; /* is waiting? */
slot->ind_has_arrived = false; /* callback has arrived */
slot->recv_ind_id = 0; /* ind to wait for */
slot->recv_ind_payload_ptr = NULL;
slot->req_id = 0; /* req id */
}
loc_sync_call_initialized = true;
pthread_mutex_unlock(&loc_sync_call_mutex);
}
/*===========================================================================
FUNCTION loc_sync_process_ind
DESCRIPTION
Wakes up blocked API calls to check if the needed callback has arrived
DEPENDENCIES
N/A
RETURN VALUE
none
SIDE EFFECTS
N/A
===========================================================================*/
void loc_sync_process_ind(
locClientHandleType client_handle, /* handle of the client */
uint32_t ind_id , /* ind id */
void *ind_payload_ptr /* payload */
)
{
LOC_LOGV("%s:%d]: received indication, handle = %p ind_id = %u \n",
__func__,__LINE__, client_handle, ind_id);
pthread_mutex_lock(&loc_sync_call_mutex);
if (!loc_sync_array.in_use)
{
LOC_LOGD("%s:%d]: loc_sync_array not in use \n",
__func__, __LINE__);
pthread_mutex_unlock(&loc_sync_call_mutex);
return;
}
bool in_use = false, consumed = false;
int i;
for (i = 0; i < LOC_SYNC_REQ_BUFFER_SIZE && !consumed; i++)
{
loc_sync_req_data_s_type *slot = &loc_sync_array.slots[i];
in_use |= loc_sync_array.slot_in_use[i];
pthread_mutex_lock(&slot->sync_req_lock);
if ( (loc_sync_array.slot_in_use[i]) && (slot->client_handle == client_handle)
&& (ind_id == slot->recv_ind_id) && (!slot->ind_has_arrived))
{
// copy the payload to the slot waiting for this ind
size_t payload_size = 0;
LOC_LOGV("%s:%d]: found slot %d selected for ind %u \n",
__func__, __LINE__, i, ind_id);
if(true == locClientGetSizeByRespIndId(ind_id, &payload_size) &&
NULL != slot->recv_ind_payload_ptr && NULL != ind_payload_ptr)
{
LOC_LOGV("%s:%d]: copying ind payload size = %u \n",
__func__, __LINE__, payload_size);
memcpy(slot->recv_ind_payload_ptr, ind_payload_ptr, payload_size);
consumed = true;
}
/* Received a callback while waiting, wake up thread to check it */
if (slot->ind_is_waiting)
{
slot->recv_ind_id = ind_id;
pthread_cond_signal(&slot->ind_arrived_cond);
}
else
{
/* If callback arrives before wait, remember it */
LOC_LOGV("%s:%d]: ind %u arrived before wait was called \n",
__func__, __LINE__, ind_id);
slot->ind_has_arrived = true;
}
}
pthread_mutex_unlock(&slot->sync_req_lock);
}
if (!in_use) {
loc_sync_array.in_use = false;
}
pthread_mutex_unlock(&loc_sync_call_mutex);
}
/*===========================================================================
FUNCTION loc_alloc_slot
DESCRIPTION
Allocates a buffer slot for the synchronous API call
DEPENDENCIES
N/A
RETURN VALUE
Select ID (>=0) : successful
-1 : buffer full
SIDE EFFECTS
N/A
===========================================================================*/
static int loc_alloc_slot()
{
int i, select_id = -1; /* no free buffer */
pthread_mutex_lock(&loc_sync_call_mutex);
for (i = 0; i < LOC_SYNC_REQ_BUFFER_SIZE; i++)
{
if (!loc_sync_array.slot_in_use[i])
{
select_id = i;
loc_sync_array.slot_in_use[i] = 1;
loc_sync_array.in_use = true;
break;
}
}
pthread_mutex_unlock(&loc_sync_call_mutex);
LOC_LOGV("%s:%d]: returning slot %d\n",
__func__, __LINE__, select_id);
return select_id;
}
/*===========================================================================
FUNCTION loc_free_slot
DESCRIPTION
Frees a buffer slot after the synchronous API call
DEPENDENCIES
N/A
RETURN VALUE
None
SIDE EFFECTS
N/A
===========================================================================*/
static void loc_free_slot(int select_id)
{
int i;
loc_sync_req_data_s_type *slot;
pthread_mutex_lock(&loc_sync_call_mutex);
LOC_LOGD("%s:%d]: freeing slot %d\n", __func__, __LINE__, select_id);
loc_sync_array.slot_in_use[select_id] = 0;
slot = &loc_sync_array.slots[select_id];
slot->client_handle = LOC_CLIENT_INVALID_HANDLE_VALUE;
slot->ind_is_selected = false; /* is ind selected? */
slot->ind_is_waiting = false; /* is waiting? */
slot->ind_has_arrived = false; /* callback has arrived */
slot->recv_ind_id = 0; /* ind to wait for */
slot->recv_ind_payload_ptr = NULL;
slot->req_id = 0;
// check if all slots are now free
for (i = 0; i < LOC_SYNC_REQ_BUFFER_SIZE; i++)
{
if (loc_sync_array.slot_in_use[i]) break;
}
if (i >= LOC_SYNC_REQ_BUFFER_SIZE)
{
loc_sync_array.in_use = false;
}
pthread_mutex_unlock(&loc_sync_call_mutex);
}
/*===========================================================================
FUNCTION loc_sync_select_ind
DESCRIPTION
Selects which indication to wait for.
DEPENDENCIES
N/A
RETURN VALUE
Select ID (>=0) : successful
-ENOMEM : out of buffer
SIDE EFFECTS
N/A
===========================================================================*/
static int loc_sync_select_ind(
locClientHandleType client_handle, /* Client handle */
uint32_t ind_id, /* ind Id wait for */
uint32_t req_id, /* req id */
void * ind_payload_ptr /* ptr where payload should be copied to*/
)
{
int select_id = loc_alloc_slot();
LOC_LOGV("%s:%d]: client handle %p, ind_id %u, req_id %u \n",
__func__, __LINE__, client_handle, ind_id, req_id);
if (select_id < 0)
{
LOC_LOGE("%s:%d]: buffer full for this synchronous req %s \n",
__func__, __LINE__, loc_get_v02_event_name(req_id));
return -ENOMEM;
}
loc_sync_req_data_s_type *slot = &loc_sync_array.slots[select_id];
pthread_mutex_lock(&slot->sync_req_lock);
slot->client_handle = client_handle;
slot->ind_is_selected = true;
slot->ind_is_waiting = false;
slot->ind_has_arrived = false;
slot->recv_ind_id = ind_id;
slot->req_id = req_id;
slot->recv_ind_payload_ptr = ind_payload_ptr; //store the payload ptr
pthread_mutex_unlock(&slot->sync_req_lock);
return select_id;
}
/*===========================================================================
FUNCTION loc_sync_wait_for_ind
DESCRIPTION
Waits for a selected indication. The wait expires in timeout_seconds seconds.
If the function is called before an existing wait has finished, it will
immediately return error.
DEPENDENCIES
N/A
RETURN VALUE
0 on SUCCESS, -ve value on failure
SIDE EFFECTS
N/A
===========================================================================*/
static int loc_sync_wait_for_ind(
int select_id, /* ID from loc_sync_select_ind() */
int timeout_seconds, /* Timeout in this number of seconds */
uint32_t ind_id
)
{
if (select_id < 0 || select_id >= LOC_SYNC_REQ_BUFFER_SIZE || !loc_sync_array.slot_in_use[select_id])
{
LOC_LOGE("%s:%d]: invalid select_id: %d \n",
__func__, __LINE__, select_id);
return (-EINVAL);
}
loc_sync_req_data_s_type *slot = &loc_sync_array.slots[select_id];
int ret_val = 0; /* the return value of this function: 0 = no error */
int rc; /* return code from pthread calls */
struct timeval present_time;
struct timespec expire_time;
pthread_mutex_lock(&slot->sync_req_lock);
do
{
if (slot->ind_has_arrived)
{
ret_val = 0; /* success */
break;
}
if (slot->ind_is_waiting)
{
LOC_LOGW("%s:%d]: already waiting in this slot %d\n", __func__,
__LINE__, select_id);
ret_val = -EBUSY; // busy
break;
}
/* Calculate absolute expire time */
gettimeofday(&present_time, NULL);
expire_time.tv_sec = present_time.tv_sec;
expire_time.tv_nsec = present_time.tv_usec * 1000;
expire_time.tv_sec += timeout_seconds;
/* Take new wait request */
slot->ind_is_waiting = true;
/* Waiting */
rc = pthread_cond_timedwait(&slot->ind_arrived_cond,
&slot->sync_req_lock, &expire_time);
slot->ind_is_waiting = false;
if(rc == ETIMEDOUT)
{
LOC_LOGE("%s:%d]: slot %d, timed out for ind_id %s\n",
__func__, __LINE__, select_id, loc_get_v02_event_name(ind_id));
ret_val = -ETIMEDOUT; //time out
}
} while (0);
pthread_mutex_unlock(&slot->sync_req_lock);
loc_free_slot(select_id);
return ret_val;
}
/*===========================================================================
FUNCTION loc_sync_send_req
DESCRIPTION
Synchronous req call (thread safe)
DEPENDENCIES
N/A
RETURN VALUE
Loc API 2.0 status
SIDE EFFECTS
N/A
===========================================================================*/
locClientStatusEnumType loc_sync_send_req
(
locClientHandleType client_handle,
uint32_t req_id, /* req id */
locClientReqUnionType req_payload,
uint32_t timeout_msec,
uint32_t ind_id, //ind ID to block for, usually the same as req_id */
void *ind_payload_ptr /* can be NULL*/
)
{
locClientStatusEnumType status = eLOC_CLIENT_SUCCESS ;
int select_id;
int rc = 0;
// Select the callback we are waiting for
select_id = loc_sync_select_ind(client_handle, ind_id, req_id,
ind_payload_ptr);
if (select_id >= 0)
{
status = locClientSendReq (client_handle, req_id, req_payload);
LOC_LOGV("%s:%d]: select_id = %d,locClientSendReq returned %d\n",
__func__, __LINE__, select_id, status);
if (status != eLOC_CLIENT_SUCCESS )
{
loc_free_slot(select_id);
}
else
{
// Wait for the indication callback
if (( rc = loc_sync_wait_for_ind( select_id,
timeout_msec / 1000,
ind_id) ) < 0)
{
if ( rc == -ETIMEDOUT)
status = eLOC_CLIENT_FAILURE_TIMEOUT;
else
status = eLOC_CLIENT_FAILURE_INTERNAL;
// Callback waiting failed
LOC_LOGE("%s:%d]: loc_api_wait_for_ind failed, err %d, "
"select id %d, status %s", __func__, __LINE__, rc ,
select_id, loc_get_v02_client_status_name(status));
}
else
{
status = eLOC_CLIENT_SUCCESS;
LOC_LOGV("%s:%d]: success (select id %d)\n",
__func__, __LINE__, select_id);
}
}
} /* select id */
return status;
}

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,295 @@
/* Copyright (c) 2011-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
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* 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 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.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#include <loc_api_v02_log.h>
#include <location_service_v02.h>
static loc_name_val_s_type loc_v02_event_name[] =
{
NAME_VAL(QMI_LOC_INFORM_CLIENT_REVISION_REQ_V02),
NAME_VAL(QMI_LOC_INFORM_CLIENT_REVISION_RESP_V02),
NAME_VAL(QMI_LOC_REG_EVENTS_REQ_V02),
NAME_VAL(QMI_LOC_REG_EVENTS_RESP_V02),
NAME_VAL(QMI_LOC_START_REQ_V02),
NAME_VAL(QMI_LOC_START_RESP_V02),
NAME_VAL(QMI_LOC_STOP_REQ_V02),
NAME_VAL(QMI_LOC_STOP_RESP_V02),
NAME_VAL(QMI_LOC_EVENT_POSITION_REPORT_IND_V02),
NAME_VAL(QMI_LOC_EVENT_GNSS_SV_INFO_IND_V02),
NAME_VAL(QMI_LOC_EVENT_NMEA_IND_V02),
NAME_VAL(QMI_LOC_EVENT_NI_NOTIFY_VERIFY_REQ_IND_V02),
NAME_VAL(QMI_LOC_EVENT_INJECT_TIME_REQ_IND_V02),
NAME_VAL(QMI_LOC_EVENT_INJECT_PREDICTED_ORBITS_REQ_IND_V02),
NAME_VAL(QMI_LOC_EVENT_INJECT_POSITION_REQ_IND_V02),
NAME_VAL(QMI_LOC_EVENT_ENGINE_STATE_IND_V02),
NAME_VAL(QMI_LOC_EVENT_FIX_SESSION_STATE_IND_V02),
NAME_VAL(QMI_LOC_EVENT_WIFI_REQ_IND_V02),
NAME_VAL(QMI_LOC_EVENT_SENSOR_STREAMING_READY_STATUS_IND_V02),
NAME_VAL(QMI_LOC_EVENT_TIME_SYNC_REQ_IND_V02),
NAME_VAL(QMI_LOC_EVENT_SET_SPI_STREAMING_REPORT_IND_V02),
NAME_VAL(QMI_LOC_EVENT_LOCATION_SERVER_CONNECTION_REQ_IND_V02),
NAME_VAL(QMI_LOC_GET_SERVICE_REVISION_REQ_V02),
NAME_VAL(QMI_LOC_GET_SERVICE_REVISION_RESP_V02),
NAME_VAL(QMI_LOC_GET_SERVICE_REVISION_IND_V02),
NAME_VAL(QMI_LOC_GET_FIX_CRITERIA_REQ_V02),
NAME_VAL(QMI_LOC_GET_FIX_CRITERIA_RESP_V02),
NAME_VAL(QMI_LOC_GET_FIX_CRITERIA_IND_V02),
NAME_VAL(QMI_LOC_NI_USER_RESPONSE_REQ_V02),
NAME_VAL(QMI_LOC_NI_USER_RESPONSE_RESP_V02),
NAME_VAL(QMI_LOC_NI_USER_RESPONSE_IND_V02),
NAME_VAL(QMI_LOC_INJECT_PREDICTED_ORBITS_DATA_REQ_V02),
NAME_VAL(QMI_LOC_INJECT_PREDICTED_ORBITS_DATA_RESP_V02),
NAME_VAL(QMI_LOC_INJECT_PREDICTED_ORBITS_DATA_IND_V02),
NAME_VAL(QMI_LOC_GET_PREDICTED_ORBITS_DATA_SOURCE_REQ_V02),
NAME_VAL(QMI_LOC_GET_PREDICTED_ORBITS_DATA_SOURCE_RESP_V02),
NAME_VAL(QMI_LOC_GET_PREDICTED_ORBITS_DATA_SOURCE_IND_V02),
NAME_VAL(QMI_LOC_GET_PREDICTED_ORBITS_DATA_VALIDITY_REQ_V02),
NAME_VAL(QMI_LOC_GET_PREDICTED_ORBITS_DATA_VALIDITY_RESP_V02),
NAME_VAL(QMI_LOC_GET_PREDICTED_ORBITS_DATA_VALIDITY_IND_V02),
NAME_VAL(QMI_LOC_INJECT_UTC_TIME_REQ_V02),
NAME_VAL(QMI_LOC_INJECT_UTC_TIME_RESP_V02),
NAME_VAL(QMI_LOC_INJECT_UTC_TIME_IND_V02),
NAME_VAL(QMI_LOC_INJECT_POSITION_REQ_V02),
NAME_VAL(QMI_LOC_INJECT_POSITION_RESP_V02),
NAME_VAL(QMI_LOC_INJECT_POSITION_IND_V02),
NAME_VAL(QMI_LOC_SET_ENGINE_LOCK_REQ_V02),
NAME_VAL(QMI_LOC_SET_ENGINE_LOCK_RESP_V02),
NAME_VAL(QMI_LOC_SET_ENGINE_LOCK_IND_V02),
NAME_VAL(QMI_LOC_GET_ENGINE_LOCK_REQ_V02),
NAME_VAL(QMI_LOC_GET_ENGINE_LOCK_RESP_V02),
NAME_VAL(QMI_LOC_GET_ENGINE_LOCK_IND_V02),
NAME_VAL(QMI_LOC_SET_SBAS_CONFIG_REQ_V02),
NAME_VAL(QMI_LOC_SET_SBAS_CONFIG_RESP_V02),
NAME_VAL(QMI_LOC_SET_SBAS_CONFIG_IND_V02),
NAME_VAL(QMI_LOC_GET_SBAS_CONFIG_REQ_V02),
NAME_VAL(QMI_LOC_GET_SBAS_CONFIG_RESP_V02),
NAME_VAL(QMI_LOC_GET_SBAS_CONFIG_IND_V02),
NAME_VAL(QMI_LOC_SET_NMEA_TYPES_REQ_V02),
NAME_VAL(QMI_LOC_SET_NMEA_TYPES_RESP_V02),
NAME_VAL(QMI_LOC_SET_NMEA_TYPES_IND_V02),
NAME_VAL(QMI_LOC_GET_NMEA_TYPES_REQ_V02),
NAME_VAL(QMI_LOC_GET_NMEA_TYPES_RESP_V02),
NAME_VAL(QMI_LOC_GET_NMEA_TYPES_IND_V02),
NAME_VAL(QMI_LOC_SET_LOW_POWER_MODE_REQ_V02),
NAME_VAL(QMI_LOC_SET_LOW_POWER_MODE_RESP_V02),
NAME_VAL(QMI_LOC_SET_LOW_POWER_MODE_IND_V02),
NAME_VAL(QMI_LOC_GET_LOW_POWER_MODE_REQ_V02),
NAME_VAL(QMI_LOC_GET_LOW_POWER_MODE_RESP_V02),
NAME_VAL(QMI_LOC_GET_LOW_POWER_MODE_IND_V02),
NAME_VAL(QMI_LOC_SET_SERVER_REQ_V02),
NAME_VAL(QMI_LOC_SET_SERVER_RESP_V02),
NAME_VAL(QMI_LOC_SET_SERVER_IND_V02),
NAME_VAL(QMI_LOC_GET_SERVER_REQ_V02),
NAME_VAL(QMI_LOC_GET_SERVER_RESP_V02),
NAME_VAL(QMI_LOC_GET_SERVER_IND_V02),
NAME_VAL(QMI_LOC_DELETE_ASSIST_DATA_REQ_V02),
NAME_VAL(QMI_LOC_DELETE_ASSIST_DATA_RESP_V02),
NAME_VAL(QMI_LOC_DELETE_ASSIST_DATA_IND_V02),
NAME_VAL(QMI_LOC_SET_XTRA_T_SESSION_CONTROL_REQ_V02),
NAME_VAL(QMI_LOC_SET_XTRA_T_SESSION_CONTROL_RESP_V02),
NAME_VAL(QMI_LOC_SET_XTRA_T_SESSION_CONTROL_IND_V02),
NAME_VAL(QMI_LOC_GET_XTRA_T_SESSION_CONTROL_REQ_V02),
NAME_VAL(QMI_LOC_GET_XTRA_T_SESSION_CONTROL_RESP_V02),
NAME_VAL(QMI_LOC_GET_XTRA_T_SESSION_CONTROL_IND_V02),
NAME_VAL(QMI_LOC_INJECT_WIFI_POSITION_REQ_V02),
NAME_VAL(QMI_LOC_INJECT_WIFI_POSITION_RESP_V02),
NAME_VAL(QMI_LOC_INJECT_WIFI_POSITION_IND_V02),
NAME_VAL(QMI_LOC_NOTIFY_WIFI_STATUS_REQ_V02),
NAME_VAL(QMI_LOC_NOTIFY_WIFI_STATUS_RESP_V02),
NAME_VAL(QMI_LOC_NOTIFY_WIFI_STATUS_IND_V02),
NAME_VAL(QMI_LOC_GET_REGISTERED_EVENTS_REQ_V02),
NAME_VAL(QMI_LOC_GET_REGISTERED_EVENTS_RESP_V02),
NAME_VAL(QMI_LOC_GET_REGISTERED_EVENTS_IND_V02),
NAME_VAL(QMI_LOC_SET_OPERATION_MODE_REQ_V02),
NAME_VAL(QMI_LOC_SET_OPERATION_MODE_RESP_V02),
NAME_VAL(QMI_LOC_SET_OPERATION_MODE_IND_V02),
NAME_VAL(QMI_LOC_GET_OPERATION_MODE_REQ_V02),
NAME_VAL(QMI_LOC_GET_OPERATION_MODE_RESP_V02),
NAME_VAL(QMI_LOC_GET_OPERATION_MODE_IND_V02),
NAME_VAL(QMI_LOC_SET_SPI_STATUS_REQ_V02),
NAME_VAL(QMI_LOC_SET_SPI_STATUS_RESP_V02),
NAME_VAL(QMI_LOC_SET_SPI_STATUS_IND_V02),
NAME_VAL(QMI_LOC_INJECT_SENSOR_DATA_REQ_V02),
NAME_VAL(QMI_LOC_INJECT_SENSOR_DATA_RESP_V02),
NAME_VAL(QMI_LOC_INJECT_SENSOR_DATA_IND_V02),
NAME_VAL(QMI_LOC_INJECT_TIME_SYNC_DATA_REQ_V02),
NAME_VAL(QMI_LOC_INJECT_TIME_SYNC_DATA_RESP_V02),
NAME_VAL(QMI_LOC_INJECT_TIME_SYNC_DATA_IND_V02),
NAME_VAL(QMI_LOC_SET_CRADLE_MOUNT_CONFIG_REQ_V02),
NAME_VAL(QMI_LOC_SET_CRADLE_MOUNT_CONFIG_RESP_V02),
NAME_VAL(QMI_LOC_SET_CRADLE_MOUNT_CONFIG_IND_V02),
NAME_VAL(QMI_LOC_GET_CRADLE_MOUNT_CONFIG_REQ_V02),
NAME_VAL(QMI_LOC_GET_CRADLE_MOUNT_CONFIG_RESP_V02),
NAME_VAL(QMI_LOC_GET_CRADLE_MOUNT_CONFIG_IND_V02),
NAME_VAL(QMI_LOC_SET_EXTERNAL_POWER_CONFIG_REQ_V02),
NAME_VAL(QMI_LOC_SET_EXTERNAL_POWER_CONFIG_RESP_V02),
NAME_VAL(QMI_LOC_SET_EXTERNAL_POWER_CONFIG_IND_V02),
NAME_VAL(QMI_LOC_GET_EXTERNAL_POWER_CONFIG_REQ_V02),
NAME_VAL(QMI_LOC_GET_EXTERNAL_POWER_CONFIG_RESP_V02),
NAME_VAL(QMI_LOC_GET_EXTERNAL_POWER_CONFIG_IND_V02),
NAME_VAL(QMI_LOC_INFORM_LOCATION_SERVER_CONN_STATUS_REQ_V02),
NAME_VAL(QMI_LOC_INFORM_LOCATION_SERVER_CONN_STATUS_RESP_V02),
NAME_VAL(QMI_LOC_INFORM_LOCATION_SERVER_CONN_STATUS_IND_V02),
NAME_VAL(QMI_LOC_SET_PROTOCOL_CONFIG_PARAMETERS_REQ_V02),
NAME_VAL(QMI_LOC_SET_PROTOCOL_CONFIG_PARAMETERS_RESP_V02),
NAME_VAL(QMI_LOC_SET_PROTOCOL_CONFIG_PARAMETERS_IND_V02),
NAME_VAL(QMI_LOC_GET_PROTOCOL_CONFIG_PARAMETERS_REQ_V02),
NAME_VAL(QMI_LOC_GET_PROTOCOL_CONFIG_PARAMETERS_RESP_V02),
NAME_VAL(QMI_LOC_GET_PROTOCOL_CONFIG_PARAMETERS_IND_V02),
NAME_VAL(QMI_LOC_SET_SENSOR_CONTROL_CONFIG_REQ_V02),
NAME_VAL(QMI_LOC_SET_SENSOR_CONTROL_CONFIG_RESP_V02),
NAME_VAL(QMI_LOC_SET_SENSOR_CONTROL_CONFIG_IND_V02),
NAME_VAL(QMI_LOC_GET_SENSOR_CONTROL_CONFIG_REQ_V02),
NAME_VAL(QMI_LOC_GET_SENSOR_CONTROL_CONFIG_RESP_V02),
NAME_VAL(QMI_LOC_GET_SENSOR_CONTROL_CONFIG_IND_V02),
NAME_VAL(QMI_LOC_SET_SENSOR_PROPERTIES_REQ_V02),
NAME_VAL(QMI_LOC_SET_SENSOR_PROPERTIES_RESP_V02),
NAME_VAL(QMI_LOC_SET_SENSOR_PROPERTIES_IND_V02),
NAME_VAL(QMI_LOC_GET_SENSOR_PROPERTIES_REQ_V02),
NAME_VAL(QMI_LOC_GET_SENSOR_PROPERTIES_RESP_V02),
NAME_VAL(QMI_LOC_GET_SENSOR_PROPERTIES_IND_V02),
NAME_VAL(QMI_LOC_SET_SENSOR_PERFORMANCE_CONTROL_CONFIGURATION_REQ_V02),
NAME_VAL(QMI_LOC_SET_SENSOR_PERFORMANCE_CONTROL_CONFIGURATION_RESP_V02),
NAME_VAL(QMI_LOC_SET_SENSOR_PERFORMANCE_CONTROL_CONFIGURATION_IND_V02),
NAME_VAL(QMI_LOC_GET_SENSOR_PERFORMANCE_CONTROL_CONFIGURATION_REQ_V02),
NAME_VAL(QMI_LOC_GET_SENSOR_PERFORMANCE_CONTROL_CONFIGURATION_RESP_V02),
NAME_VAL(QMI_LOC_GET_SENSOR_PERFORMANCE_CONTROL_CONFIGURATION_IND_V02),
NAME_VAL(QMI_LOC_INJECT_SUPL_CERTIFICATE_REQ_V02),
NAME_VAL(QMI_LOC_INJECT_SUPL_CERTIFICATE_RESP_V02),
NAME_VAL(QMI_LOC_INJECT_SUPL_CERTIFICATE_IND_V02),
NAME_VAL(QMI_LOC_DELETE_SUPL_CERTIFICATE_REQ_V02),
NAME_VAL(QMI_LOC_DELETE_SUPL_CERTIFICATE_RESP_V02),
NAME_VAL(QMI_LOC_DELETE_SUPL_CERTIFICATE_IND_V02),
NAME_VAL(QMI_LOC_SET_POSITION_ENGINE_CONFIG_PARAMETERS_REQ_V02),
NAME_VAL(QMI_LOC_SET_POSITION_ENGINE_CONFIG_PARAMETERS_RESP_V02),
NAME_VAL(QMI_LOC_SET_POSITION_ENGINE_CONFIG_PARAMETERS_IND_V02),
NAME_VAL(QMI_LOC_GET_POSITION_ENGINE_CONFIG_PARAMETERS_REQ_V02),
NAME_VAL(QMI_LOC_GET_POSITION_ENGINE_CONFIG_PARAMETERS_RESP_V02),
NAME_VAL(QMI_LOC_GET_POSITION_ENGINE_CONFIG_PARAMETERS_IND_V02),
NAME_VAL(QMI_LOC_EVENT_NI_GEOFENCE_NOTIFICATION_IND_V02),
NAME_VAL(QMI_LOC_EVENT_GEOFENCE_GEN_ALERT_IND_V02),
NAME_VAL(QMI_LOC_EVENT_GEOFENCE_BREACH_NOTIFICATION_IND_V02),
NAME_VAL(QMI_LOC_ADD_CIRCULAR_GEOFENCE_REQ_V02),
NAME_VAL(QMI_LOC_ADD_CIRCULAR_GEOFENCE_RESP_V02),
NAME_VAL(QMI_LOC_ADD_CIRCULAR_GEOFENCE_IND_V02),
NAME_VAL(QMI_LOC_DELETE_GEOFENCE_REQ_V02),
NAME_VAL(QMI_LOC_DELETE_GEOFENCE_RESP_V02),
NAME_VAL(QMI_LOC_DELETE_GEOFENCE_IND_V02),
NAME_VAL(QMI_LOC_QUERY_GEOFENCE_REQ_V02),
NAME_VAL(QMI_LOC_QUERY_GEOFENCE_RESP_V02),
NAME_VAL(QMI_LOC_QUERY_GEOFENCE_IND_V02),
NAME_VAL(QMI_LOC_EDIT_GEOFENCE_REQ_V02),
NAME_VAL(QMI_LOC_EDIT_GEOFENCE_RESP_V02),
NAME_VAL(QMI_LOC_EDIT_GEOFENCE_IND_V02),
NAME_VAL(QMI_LOC_GET_BEST_AVAILABLE_POSITION_REQ_V02),
NAME_VAL(QMI_LOC_GET_BEST_AVAILABLE_POSITION_RESP_V02),
NAME_VAL(QMI_LOC_GET_BEST_AVAILABLE_POSITION_IND_V02),
NAME_VAL(QMI_LOC_INJECT_MOTION_DATA_REQ_V02),
NAME_VAL(QMI_LOC_INJECT_MOTION_DATA_RESP_V02),
NAME_VAL(QMI_LOC_INJECT_MOTION_DATA_IND_V02),
NAME_VAL(QMI_LOC_GET_NI_GEOFENCE_ID_LIST_REQ_V02),
NAME_VAL(QMI_LOC_GET_NI_GEOFENCE_ID_LIST_RESP_V02),
NAME_VAL(QMI_LOC_GET_NI_GEOFENCE_ID_LIST_IND_V02),
NAME_VAL(QMI_LOC_INJECT_GSM_CELL_INFO_REQ_V02),
NAME_VAL(QMI_LOC_INJECT_GSM_CELL_INFO_RESP_V02),
NAME_VAL(QMI_LOC_INJECT_GSM_CELL_INFO_IND_V02),
NAME_VAL(QMI_LOC_INJECT_NETWORK_INITIATED_MESSAGE_REQ_V02),
NAME_VAL(QMI_LOC_INJECT_NETWORK_INITIATED_MESSAGE_RESP_V02),
NAME_VAL(QMI_LOC_INJECT_NETWORK_INITIATED_MESSAGE_IND_V02),
NAME_VAL(QMI_LOC_WWAN_OUT_OF_SERVICE_NOTIFICATION_REQ_V02),
NAME_VAL(QMI_LOC_WWAN_OUT_OF_SERVICE_NOTIFICATION_RESP_V02),
NAME_VAL(QMI_LOC_WWAN_OUT_OF_SERVICE_NOTIFICATION_IND_V02),
NAME_VAL(QMI_LOC_EVENT_PEDOMETER_CONTROL_IND_V02),
NAME_VAL(QMI_LOC_EVENT_MOTION_DATA_CONTROL_IND_V02),
NAME_VAL(QMI_LOC_PEDOMETER_REPORT_REQ_V02),
NAME_VAL(QMI_LOC_PEDOMETER_REPORT_RESP_V02),
NAME_VAL(QMI_LOC_PEDOMETER_REPORT_IND_V02),
NAME_VAL(QMI_LOC_INJECT_WCDMA_CELL_INFO_REQ_V02),
NAME_VAL(QMI_LOC_INJECT_WCDMA_CELL_INFO_RESP_V02),
NAME_VAL(QMI_LOC_INJECT_WCDMA_CELL_INFO_IND_V02),
NAME_VAL(QMI_LOC_INJECT_TDSCDMA_CELL_INFO_REQ_V02),
NAME_VAL(QMI_LOC_INJECT_TDSCDMA_CELL_INFO_RESP_V02),
NAME_VAL(QMI_LOC_INJECT_TDSCDMA_CELL_INFO_IND_V02),
NAME_VAL(QMI_LOC_INJECT_SUBSCRIBER_ID_REQ_V02),
NAME_VAL(QMI_LOC_INJECT_SUBSCRIBER_ID_RESP_V02),
NAME_VAL(QMI_LOC_INJECT_SUBSCRIBER_ID_IND_V02),
NAME_VAL(QMI_LOC_GET_SUPPORTED_MSGS_REQ_V02),
NAME_VAL(QMI_LOC_GET_SUPPORTED_MSGS_RESP_V02),
NAME_VAL(QMI_LOC_GET_SUPPORTED_FIELDS_REQ_V02),
NAME_VAL(QMI_LOC_GET_SUPPORTED_FIELDS_RESP_V02),
};
static int loc_v02_event_num = sizeof(loc_v02_event_name) / sizeof(loc_name_val_s_type);
const char* loc_get_v02_event_name(uint32_t event)
{
return loc_get_name_from_val(loc_v02_event_name, loc_v02_event_num, (long) event);
}
static loc_name_val_s_type loc_v02_client_status_name[] =
{
NAME_VAL(eLOC_CLIENT_SUCCESS),
NAME_VAL(eLOC_CLIENT_FAILURE_GENERAL),
NAME_VAL(eLOC_CLIENT_FAILURE_UNSUPPORTED),
NAME_VAL(eLOC_CLIENT_FAILURE_INVALID_PARAMETER),
NAME_VAL(eLOC_CLIENT_FAILURE_ENGINE_BUSY),
NAME_VAL(eLOC_CLIENT_FAILURE_PHONE_OFFLINE),
NAME_VAL(eLOC_CLIENT_FAILURE_TIMEOUT),
NAME_VAL(eLOC_CLIENT_FAILURE_SERVICE_NOT_PRESENT),
NAME_VAL(eLOC_CLIENT_FAILURE_SERVICE_VERSION_UNSUPPORTED),
NAME_VAL(eLOC_CLIENT_FAILURE_CLIENT_VERSION_UNSUPPORTED),
NAME_VAL(eLOC_CLIENT_FAILURE_INVALID_HANDLE),
NAME_VAL(eLOC_CLIENT_FAILURE_INTERNAL),
NAME_VAL(eLOC_CLIENT_FAILURE_NOT_INITIALIZED),
NAME_VAL(eLOC_CLIENT_FAILURE_NOT_ENOUGH_MEMORY),
};
static int loc_v02_client_status_num = sizeof(loc_v02_client_status_name) / sizeof(loc_name_val_s_type);
const char* loc_get_v02_client_status_name(locClientStatusEnumType status)
{
return loc_get_name_from_val(loc_v02_client_status_name, loc_v02_client_status_num, (long) status);
}
static loc_name_val_s_type loc_v02_qmi_status_name[] =
{
NAME_VAL(eQMI_LOC_SUCCESS_V02),
NAME_VAL(eQMI_LOC_GENERAL_FAILURE_V02),
NAME_VAL(eQMI_LOC_UNSUPPORTED_V02),
NAME_VAL(eQMI_LOC_INVALID_PARAMETER_V02),
NAME_VAL(eQMI_LOC_ENGINE_BUSY_V02),
NAME_VAL(eQMI_LOC_PHONE_OFFLINE_V02),
NAME_VAL(eQMI_LOC_TIMEOUT_V02),
NAME_VAL(eQMI_LOC_CONFIG_NOT_SUPPORTED_V02),
NAME_VAL(eQMI_LOC_INSUFFICIENT_MEMORY_V02),
};
static int loc_v02_qmi_status_num = sizeof(loc_v02_qmi_status_name) / sizeof(loc_name_val_s_type);
const char* loc_get_v02_qmi_status_name(qmiLocStatusEnumT_v02 status)
{
return loc_get_name_from_val(loc_v02_qmi_status_name, loc_v02_qmi_status_num, (long) status);
}

View file

@ -0,0 +1,75 @@
/* Copyright (c) 2011-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
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* 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 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.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef LOC_UTIL_LOG_H
#define LOC_UTIL_LOG_H
#if defined(_ANDROID_)
#include "loc_api_v02_log.h"
#include <log_util.h>
#else // no _ANDROID_
// common for QNX and Griffon
//error logs
#define LOC_LOGE(...) printf(__VA_ARGS__)
//warning logs
#define LOC_LOGW(...) printf(__VA_ARGS__)
// debug logs
#define LOC_LOGD(...) printf(__VA_ARGS__)
//info logs
#define LOC_LOGI(...) printf(__VA_ARGS__)
//verbose logs
#define LOC_LOGV(...) printf(__VA_ARGS__)
#define MODEM_LOG_CALLFLOW(SPEC, VAL)
#define EXIT_LOG_CALLFLOW(SPEC, VAL)
#define loc_get_v02_event_name(X) #X
#define loc_get_v02_client_status_name(X) #X
#define loc_get_v02_qmi_status_name(X) #X
//specific to OFF TARGET
#ifdef LOC_UTIL_TARGET_OFF_TARGET
#include <stdio.h>
# include <asm/errno.h>
# include <sys/time.h>
// get around strl*: not found in glibc
// TBD:look for presence of eglibc other libraries
// with strlcpy supported.
#define strlcpy(X,Y,Z) strcpy(X,Y)
#define strlcat(X,Y,Z) strcat(X,Y)
#endif //LOC_UTIL_TARGET_OFF_TARGET
#endif //_ANDROID_
#endif //LOC_UTIL_LOG_H

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,46 @@
/* Copyright (c) 2013, 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
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* 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 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.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <stdlib.h>
#include <sys/time.h>
#include "platform_lib_time.h"
int64_t systemTime(int clock)
{
struct timeval t;
t.tv_sec = t.tv_usec = 0;
gettimeofday(&t, NULL);
return t.tv_sec*1000000LL + t.tv_usec;
}
int64_t elapsedMillisSinceBoot()
{
int64_t t_us = systemTime(0);
return (int64_t) t_us / 1000LL;
}

View file

@ -0,0 +1,35 @@
/* Copyright (c) 2013, 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
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* 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 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.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _PLATFORM_LIB_INCLUDES_H_
#define _PLATFORM_LIB_INCLUDES_H_
#include "platform_lib_time.h"
#include "platform_lib_macros.h"
#endif

View file

@ -0,0 +1,81 @@
/* Copyright (c) 2013, 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
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* 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 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.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef __PLATFORM_LIB_MACROS_H__
#define __PLATFORM_LIB_MACROS_H__
#include <sys/time.h>
#define TS_PRINTF(format, x...) \
{ \
struct timeval tv; \
struct timezone tz; \
int hh, mm, ss; \
gettimeofday(&tv, &tz); \
hh = tv.tv_sec/3600%24; \
mm = (tv.tv_sec%3600)/60; \
ss = tv.tv_sec%60; \
fprintf(stdout,"%02d:%02d:%02d.%06ld]" format "\n", hh, mm, ss, tv.tv_usec,##x); \
}
#ifdef USE_GLIB
#define strlcat g_strlcat
#define strlcpy g_strlcpy
#define ALOGE(format, x...) TS_PRINTF("E/%s (%d): " format , LOG_TAG, getpid(), ##x)
#define ALOGW(format, x...) TS_PRINTF("W/%s (%d): " format , LOG_TAG, getpid(), ##x)
#define ALOGI(format, x...) TS_PRINTF("I/%s (%d): " format , LOG_TAG, getpid(), ##x)
#define ALOGD(format, x...) TS_PRINTF("D/%s (%d): " format , LOG_TAG, getpid(), ##x)
#define ALOGV(format, x...) TS_PRINTF("V/%s (%d): " format , LOG_TAG, getpid(), ##x)
#define GETTID_PLATFORM_LIB_ABSTRACTION (syscall(SYS_gettid))
#define LOC_EXT_CREATE_THREAD_CB_PLATFORM_LIB_ABSTRACTION createPthread
#define ELAPSED_MILLIS_SINCE_BOOT_PLATFORM_LIB_ABSTRACTION (elapsedMillisSinceBoot())
#else
#ifdef __cplusplus
extern "C" {
#endif
pid_t gettid(void);
#ifdef __cplusplus
}
#endif
#define GETTID_PLATFORM_LIB_ABSTRACTION (gettid())
#define LOC_EXT_CREATE_THREAD_CB_PLATFORM_LIB_ABSTRACTION android::AndroidRuntime::createJavaThread
#define ELAPSED_MILLIS_SINCE_BOOT_PLATFORM_LIB_ABSTRACTION (android::elapsedRealtime())
#endif
#endif

View file

@ -0,0 +1,35 @@
/* Copyright (c) 2013, 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
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* 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 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.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _PLATFORM_LIB_TIME_H_
#define _PLATFORM_LIB_TIME_H_
int64_t systemTime(int clock);
int64_t elapsedMillisSinceBoot();
#endif

View file

@ -17,7 +17,10 @@ LOCAL_SRC_FILES += \
loc_cfg.cpp \
msg_q.c \
linked_list.c \
loc_target.cpp
loc_target.cpp \
loc_timer.c \
../platform_lib_abstractions/elapsed_millis_since_boot.cpp
LOCAL_CFLAGS += \
-fno-short-enums \
@ -26,7 +29,8 @@ LOCAL_CFLAGS += \
LOCAL_LDFLAGS += -Wl,--export-dynamic
## Includes
LOCAL_C_INCLUDES:=
LOCAL_C_INCLUDES:= \
$(LOCAL_PATH)/../platform_lib_abstractions
LOCAL_COPY_HEADERS_TO:= gps.utils/
LOCAL_COPY_HEADERS:= \
@ -35,7 +39,12 @@ LOCAL_COPY_HEADERS:= \
log_util.h \
linked_list.h \
msg_q.h \
loc_target.h
loc_target.h \
loc_timer.h \
../platform_lib_abstractions/platform_lib_includes.h \
../platform_lib_abstractions/platform_lib_time.h \
../platform_lib_abstractions/platform_lib_macros.h
LOCAL_MODULE := libgps.utils

44
utils/Makefile.am Normal file
View file

@ -0,0 +1,44 @@
AM_CFLAGS = -Wundef \
-MD \
-Wno-trigraphs \
-g -O0 \
-fno-inline \
-fno-short-enums \
-fpic \
-I../platform_lib_abstractions
libgps_utils_so_la_h_sources = log_util.h \
msg_q.h \
linked_list.h \
loc_cfg.h \
loc_log.h \
../platform_lib_abstractions/platform_lib_includes.h \
../platform_lib_abstractions/platform_lib_time.h \
../platform_lib_abstractions/platform_lib_macros.h
libgps_utils_so_la_c_sources = linked_list.c \
msg_q.c \
loc_cfg.cpp \
loc_log.cpp \
../platform_lib_abstractions/elapsed_millis_since_boot.cpp
library_includedir = $(pkgincludedir)/utils
library_include_HEADERS = $(libgps_utils_so_la_h_sources)
libgps_utils_so_la_SOURCES = $(libgps_utils_so_la_c_sources)
if USE_GLIB
libgps_utils_so_la_CFLAGS = -DUSE_GLIB $(AM_CFLAGS) @GLIB_CFLAGS@
libgps_utils_so_la_LDFLAGS = -lstdc++ -lpthread @GLIB_LIBS@ -shared -version-info 1:0:0
libgps_utils_so_la_CPPFLAGS = -DUSE_GLIB $(AM_CFLAGS) $(AM_CPPFLAGS) @GLIB_CFLAGS@
else
libgps_utils_so_la_CFLAGS = $(AM_CFLAGS)
libgps_utils_so_la_LDFLAGS = -lpthread -shared -version-info 1:0:0
libgps_utils_so_la_CPPFLAGS = $(AM_CFLAGS) $(AM_CPPFLAGS)
endif
libgps_utils_so_la_LIBADD = -lstdc++ -lcutils
#Create and Install libraries
lib_LTLIBRARIES = libgps_utils_so.la

View file

@ -32,7 +32,7 @@
#define LOG_TAG "LocSvc_utils_ll"
#include "log_util.h"
#include "platform_lib_includes.h"
#include <stdlib.h>
#include <stdint.h>

View file

@ -39,6 +39,10 @@
#include <time.h>
#include <loc_cfg.h>
#include <log_util.h>
#ifdef USE_GLIB
#include <glib.h>
#endif
#include "platform_lib_includes.h"
/*=============================================================================
*
@ -47,7 +51,7 @@
*============================================================================*/
/* Parameter data */
static uint8_t DEBUG_LEVEL = 3;
static uint8_t DEBUG_LEVEL = 0xff;
static uint8_t TIMESTAMP = 0;
/* Parameter spec table */

View file

@ -34,8 +34,11 @@
#include <sys/time.h>
#include "loc_log.h"
#include "msg_q.h"
#ifdef USE_GLIB
#include <time.h>
#endif /* USE_GLIB */
#include "log_util.h"
#include "platform_lib_includes.h"
// Logging Improvements
const char *loc_logger_boolStr[]={"False","True"};
const char VOID_RET[] = "None";

157
utils/loc_timer.c Normal file
View file

@ -0,0 +1,157 @@
/* Copyright (c) 2013, 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
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* 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 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.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#include<stdio.h>
#include<stdlib.h>
#include<sys/time.h>
#include "loc_timer.h"
#include<time.h>
#include<errno.h>
#define MAX_DELAY_RETRIES 3
typedef struct {
loc_timer_callback callback_func;
void *user_data;
unsigned int time_msec;
}timer_data;
static void *timer_thread(void *thread_data)
{
int ret;
unsigned char retries=0;
struct timespec ts;
struct timeval tv;
timer_data t;
t.callback_func = ((timer_data *)thread_data)->callback_func;
t.user_data = ((timer_data *)thread_data)->user_data;
t.time_msec = ((timer_data *)thread_data)->time_msec;
pthread_cond_t timer_cond;
pthread_mutex_t timer_mutex;
LOC_LOGD("%s:%d]: Enter. Delay = %d\n", __func__, __LINE__, t.time_msec);
//Copied over all info into local variable. Do not need allocated struct
free(thread_data);
if(pthread_cond_init(&timer_cond, NULL)) {
LOC_LOGE("%s:%d]: Pthread cond init failed\n", __func__, __LINE__);
ret = -1;
goto err;
}
if(pthread_mutex_init(&timer_mutex, NULL)) {
LOC_LOGE("%s:%d]: Pthread mutex init failed\n", __func__, __LINE__);
ret = -1;
goto mutex_err;
}
while(retries < MAX_DELAY_RETRIES) {
gettimeofday(&tv, NULL);
clock_gettime(CLOCK_REALTIME, &ts);
if(t.time_msec >= 1000) {
ts.tv_sec += t.time_msec/1000;
t.time_msec = t.time_msec % 1000;
}
if(t.time_msec)
ts.tv_nsec += t.time_msec * 1000000;
if(ts.tv_nsec > 999999999) {
LOC_LOGD("%s:%d]: Large nanosecs\n", __func__, __LINE__);
ts.tv_sec += 1;
ts.tv_nsec -= 1000000000;
}
LOC_LOGD("%s:%d]: ts.tv_sec:%d; ts.tv_nsec:%d\n",
__func__, __LINE__, (int)ts.tv_sec, (int)ts.tv_nsec);
LOC_LOGD("%s:%d]: Current time: %d sec; %d nsec\n",
__func__, __LINE__, (int)tv.tv_sec, (int)tv.tv_usec*1000);
pthread_mutex_lock(&(timer_mutex));
ret = pthread_cond_timedwait(&timer_cond, &timer_mutex, &ts);
pthread_mutex_unlock(&(timer_mutex));
if(ret != ETIMEDOUT) {
LOC_LOGE("%s:%d]: Call to pthread timedwait failed; ret=%d\n",
__func__, __LINE__,ret);
ret = -1;
retries++;
}
else {
ret = 0;
break;
}
}
pthread_mutex_destroy(&timer_mutex);
mutex_err:
pthread_cond_destroy(&timer_cond);
err:
if(!ret)
t.callback_func(t.user_data, ret);
LOC_LOGD("%s:%d]: Exit\n", __func__, __LINE__);
return NULL;
}
int loc_timer_start(unsigned int msec, loc_timer_callback cb_func,
void* caller_data)
{
int ret=0;
timer_data *t=NULL;
pthread_attr_t tattr;
pthread_t id;
LOC_LOGD("%s:%d]: Enter\n", __func__, __LINE__);
if(cb_func == NULL || msec == 0) {
LOC_LOGE("%s:%d]: Error: Wrong parameters\n", __func__, __LINE__);
ret = -1;
goto err;
}
t = (timer_data *)calloc(1, sizeof(timer_data));
if(t == NULL) {
LOC_LOGE("%s:%d]: Could not allocate memory. Failing.\n",
__func__, __LINE__);
ret = -1;
goto err;
}
t->callback_func = cb_func;
t->user_data = caller_data;
t->time_msec = msec;
pthread_attr_init(&tattr);
pthread_attr_setdetachstate(&tattr, PTHREAD_CREATE_DETACHED);
if(pthread_create(&(id), &tattr, timer_thread, (void *)t)) {
LOC_LOGE("%s:%d]: Could not create thread\n", __func__, __LINE__);
ret = -1;
goto attr_err;
}
else {
LOC_LOGD("%s:%d]: Created thread with id: %d\n",
__func__, __LINE__, (int)id);
}
attr_err:
pthread_attr_destroy(&tattr);
err:
LOC_LOGD("%s:%d]: Exit\n", __func__, __LINE__);
return ret;
}

54
utils/loc_timer.h Normal file
View file

@ -0,0 +1,54 @@
/* Copyright (c) 2013, 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
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* 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 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.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef __LOC_DELAY_H__
#define __LOC_DELAY_H__
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#include<pthread.h>
#include "log_util.h"
/*
Return values:
Success = 0
Failure = Non zero
*/
typedef void(*loc_timer_callback)(void *user_data, int result);
//int loc_timer_start(loc_timer_client_data *p_thread);
int loc_timer_start(unsigned int delay_msec,
loc_timer_callback,
void* user_data);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif //__LOC_DELAY_H__

View file

@ -30,6 +30,23 @@
#ifndef __LOG_UTIL_H__
#define __LOG_UTIL_H__
#ifndef USE_GLIB
#include <utils/Log.h>
#endif /* USE_GLIB */
#ifdef USE_GLIB
#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
#ifndef LOG_TAG
#define LOG_TAG "GPS_UTILS"
#endif // LOG_TAG
#endif /* USE_GLIB */
#ifdef __cplusplus
extern "C"
{
@ -72,29 +89,32 @@ extern const char ENTRY_TAG[];
extern void loc_logger_init(unsigned long debug, unsigned long timestamp);
extern char* get_timestamp(char* str, unsigned long buf_size);
#include <utils/Log.h>
#ifndef DEBUG_DMN_LOC_API
/* LOGGING MACROS */
#define LOC_LOGE(...) ALOGE("E/"__VA_ARGS__)
/*loc_logger.DEBUG_LEVEL is initialized to 0xff in loc_cfg.cpp
if that value remains unchanged, it means gps.conf did not
provide a value and we default to the initial value to use
Android's logging levels*/
#define LOC_LOGE(...) \
if ((loc_logger.DEBUG_LEVEL >= 1) && (loc_logger.DEBUG_LEVEL <= 5)) { ALOGE("W/"__VA_ARGS__); } \
else if (loc_logger.DEBUG_LEVEL == 0xff) { ALOGE("W/"__VA_ARGS__); }
#define LOC_LOGW(...) \
if (loc_logger.DEBUG_LEVEL >= 2) { ALOGE("W/"__VA_ARGS__); } \
else if (loc_logger.DEBUG_LEVEL <= 0) { ALOGW("W/"__VA_ARGS__); }
if ((loc_logger.DEBUG_LEVEL >= 2) && (loc_logger.DEBUG_LEVEL <= 5)) { ALOGE("W/"__VA_ARGS__); } \
else if (loc_logger.DEBUG_LEVEL == 0xff) { ALOGW("W/"__VA_ARGS__); }
#define LOC_LOGI(...) \
if (loc_logger.DEBUG_LEVEL >= 3) { ALOGE("I/"__VA_ARGS__); } \
else if (loc_logger.DEBUG_LEVEL <= 0) { ALOGI("I/"__VA_ARGS__); }
if ((loc_logger.DEBUG_LEVEL >= 3) && (loc_logger.DEBUG_LEVEL <= 5)) { ALOGE("I/"__VA_ARGS__); } \
else if (loc_logger.DEBUG_LEVEL == 0xff) { ALOGI("I/"__VA_ARGS__); }
#define LOC_LOGD(...) \
if (loc_logger.DEBUG_LEVEL >= 4) { ALOGE("D/"__VA_ARGS__); } \
else if (loc_logger.DEBUG_LEVEL <= 0) { ALOGD("D/"__VA_ARGS__); }
if ((loc_logger.DEBUG_LEVEL >= 4) && (loc_logger.DEBUG_LEVEL <= 5)) { ALOGE("D/"__VA_ARGS__); } \
else if (loc_logger.DEBUG_LEVEL == 0xff) { ALOGD("D/"__VA_ARGS__); }
#define LOC_LOGV(...) \
if (loc_logger.DEBUG_LEVEL >= 5) { ALOGE("V/"__VA_ARGS__); } \
else if (loc_logger.DEBUG_LEVEL <= 0) { ALOGV("V/"__VA_ARGS__); }
if ((loc_logger.DEBUG_LEVEL >= 5) && (loc_logger.DEBUG_LEVEL <= 5)) { ALOGE("V/"__VA_ARGS__); } \
else if (loc_logger.DEBUG_LEVEL == 0xff) { ALOGV("V/"__VA_ARGS__); }
#else /* DEBUG_DMN_LOC_API */

View file

@ -30,7 +30,7 @@
#define LOG_TAG "LocSvc_utils_q"
#include "log_util.h"
#include "platform_lib_includes.h"
#include "linked_list.h"
#include <stdio.h>
#include <stdlib.h>