Merge "Merge branch jb_mr1 into jb_2.6"

This commit is contained in:
Linux Build Service Account 2013-06-13 12:11:32 -07:00 committed by Gerrit - the friendly Code Review server
commit a01c9c6b63
110 changed files with 24981 additions and 2393 deletions

0
CleanSpec.mk Executable file → Normal file
View file

0
etc/Android.mk Executable file → Normal file
View file

82
etc/gps.conf Normal file → Executable file
View file

@ -1,3 +1,12 @@
XTRA_SERVER_1=http://xtra1.gpsonextra.net/xtra.bin
XTRA_SERVER_2=http://xtra2.gpsonextra.net/xtra.bin
XTRA_SERVER_3=http://xtra3.gpsonextra.net/xtra.bin
# Error Estimate
# _SET = 1
# _CLEAR = 0
ERR_ESTIMATE=0
#Test
NTP_SERVER=time.gpsonextra.net
#Asia
@ -7,13 +16,9 @@ NTP_SERVER=time.gpsonextra.net
#North America
# NTP_SERVER=north-america.pool.ntp.org
XTRA_SERVER_1=http://xtra1.gpsonextra.net/xtra.bin
XTRA_SERVER_2=http://xtra2.gpsonextra.net/xtra.bin
XTRA_SERVER_3=http://xtra3.gpsonextra.net/xtra.bin
# DEBUG LEVELS: 0 - none, 1 - Error, 2 - Warning, 3 - Info
# 4 - Debug, 5 - Verbose
DEBUG_LEVEL = 2
DEBUG_LEVEL = 3
# Intermediate position report, 1=enable, 0=disable
INTERMEDIATE_POS=0
@ -21,18 +26,14 @@ INTERMEDIATE_POS=0
# supl version 1.0
SUPL_VER=0x10000
# Error Estimate
# _SET = 1
# _CLEAR = 0
ERR_ESTIMATE=0
# GPS Capabilities bit mask
# SCHEDULING = 1
# MSB = 2
# MSA = 4
# SCHEDULING = 0x01
# MSB = 0x02
# MSA = 0x04
# ON_DEMAND_TIME = 0x10
# GEOFENCE = 0x20
# default = MSA | MSB | SCHEDULING | GEOFENCE
CAPABILITIES=0x27
# default = ON_DEMAND_TIME | MSA | MSB | SCHEDULING | GEOFENCE
CAPABILITIES=0x37
# Accuracy threshold for intermediate positions
# less accurate positions are ignored, 0 for passing all positions
@ -50,42 +51,25 @@ CAPABILITIES=0x27
# C2K_HOST=c2k.pde.com or IP
# C2K_PORT=1234
################################
# Sensor Settings
################################
# Needs to be set explicitly based on sensor
# There is no default value.
#GYRO_BIAS_RANDOM_WALK=
SENSOR_ACCEL_BATCHES_PER_SEC=2
SENSOR_ACCEL_SAMPLES_PER_BATCH=5
SENSOR_GYRO_BATCHES_PER_SEC=2
SENSOR_GYRO_SAMPLES_PER_BATCH=5
# Sensor Control Mode (0=AUTO, 1=FORCE_ON)
SENSOR_CONTROL_MODE=0
# Enable or Disable Sensors for GPS use (0=Enable, 1=Disable)
SENSOR_USAGE=1
# Choose GSIFF sensor provider (1=DSPS, 2=Android NDK)
SENSOR_PROVIDER=1
################################
# Indoor Positioning Settings
################################
# 0: QUIPC disabled, 1: QUIPC enabled, 2: forced QUIPC only
QUIPC_ENABLED = 0
####################################
# LTE Positioning Profile Settings
####################################
# 0: Enable RRLP on LTE(Default)
# 1: Enable LPP_User_Plane on LTE
# 2: Enable LPP_Control_Plane
# 3: Enable both LPP_User_Plane and LPP_Control_Plane
LPP_PROFILE = 0
################################
# EXTRA SETTINGS
################################
# Enable or Disable Wiper (1=Enable, 0=Disable)
ENABLE_WIPER=0
# NMEA provider (1=Modem Processor, 0=Application Processor)
NMEA_PROVIDER=0
####################################
# LTE Positioning Profile Settings
####################################
# 0: Enable RRLP on LTE(Default) 1: Enable LPP_User_Plane on LTE
LPP_PROFILE = 0
##################################################
# Select Positioning Protocol on A-GLONASS system
##################################################
# 0x1: RRC CPlane
# 0x2: RRLP UPlane
# 0x4: LLP Uplane
A_GLONASS_POS_PROTOCOL_SELECT = 0

22
loc_api/Android.mk Executable file → Normal file
View file

@ -1,18 +1,12 @@
# Copyright (c) 2009, QUALCOMM USA, INC.
# 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 QUALCOMM USA, INC. 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 BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER 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.
ifneq ($(BOARD_VENDOR_QCOM_GPS_LOC_API_HARDWARE),)
LOCAL_PATH := $(call my-dir)
GPS_DIR_LIST :=
ifeq (exists, $(shell test -d $(TOP)/vendor/qcom/proprietary/qmi-framework && echo exists))
FEATURE_IPV6 := true
FEATURE_DELEXT := true
FEATURE_ULP := true
# add RPC dirs if RPC is available
ifneq ($(TARGET_NO_RPC),true)
@ -23,8 +17,18 @@ GPS_DIR_LIST += $(LOCAL_PATH)/libloc_api/
endif #TARGET_NO_RPC
ifeq ($(BOARD_USES_QCOM_HARDWARE), true)
#add QMI libraries for QMI targets
QMI_BOARD_PLATFORM_LIST := msm8960
QMI_BOARD_PLATFORM_LIST += msm8974
QMI_BOARD_PLATFORM_LIST += msm8226
QMI_BOARD_PLATFORM_LIST += msm8610
endif
ifeq ($(call is-board-platform-in-list,$(QMI_BOARD_PLATFORM_LIST)),true)
GPS_DIR_LIST += $(LOCAL_PATH)/loc_api_v02/
endif #is-board-platform-in-list
GPS_DIR_LIST += $(LOCAL_PATH)/libloc_api_50001/
#call the subfolders

0
loc_api/NOTICE Executable file → Normal file
View file

0
loc_api/libloc_api-rpc-50001/Android.mk Executable file → Normal file
View file

View file

@ -20,6 +20,10 @@ LOCAL_CFLAGS+=$(GPS_FEATURES)
# for loc_api_fixup.c
LOCAL_CFLAGS+=-DADD_XDR_FLOAT -DADD_XDR_BOOL
ifeq ($(FEATURE_IPV6), true)
LOCAL_CFLAGS += -DFEATURE_IPV6
endif #FEATURE_IPV6
LOCAL_SHARED_LIBRARIES:= \
librpc \
libutils \

View file

@ -1,4 +1,4 @@
/* Copyright (c) 2011, Code Aurora Forum. All rights reserved.
/* Copyright (c) 2011, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@ -9,7 +9,7 @@
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of Code Aurora Forum, Inc. nor the names of its
* * Neither the name of The Linux Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
@ -38,6 +38,8 @@ class LocApiRpcAdapter : public LocApiAdapter {
// RPC communication establishment
rpc_loc_client_handle_type client_handle;
rpc_loc_event_mask_type eMask;
int dataEnableLastSet;
char apnLastSet[MAX_APN_LEN];
static const rpc_loc_event_mask_type locBits[];
static rpc_loc_event_mask_type convertMask(LOC_API_ADAPTER_EVENT_MASK_T mask);
@ -71,10 +73,11 @@ public:
virtual enum loc_api_adapter_err
stopFix();
virtual enum loc_api_adapter_err
setPositionMode(LocPositionMode mode, GpsPositionRecurrence recurrence,
uint32_t min_interval, uint32_t preferred_accuracy, uint32_t preferred_time);
setPositionMode(const LocPosMode *mode);
inline virtual enum loc_api_adapter_err
enableData(int enable) { return enableData(enable, false); }
virtual enum loc_api_adapter_err
enableData(int enable);
enableData(int enable, boolean force);
virtual enum loc_api_adapter_err
setTime(GpsUtcTime time, int64_t timeReference, int uncertainty);
virtual enum loc_api_adapter_err
@ -83,20 +86,30 @@ public:
deleteAidingData(GpsAidingData f);
virtual enum loc_api_adapter_err
informNiResponse(GpsUserResponseType userResponse, const void* passThroughData);
inline virtual enum loc_api_adapter_err
setAPN(char* apn, int len) { return setAPN(apn, len, false); }
virtual enum loc_api_adapter_err
setAPN(char* apn, int len);
setAPN(char* apn, int len, boolean force);
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 void setInSession(bool inSession);
};
#endif //LOC_API_RPC_ADAPTER_H

View file

@ -1,4 +1,4 @@
/* Copyright (c) 2011, Code Aurora Forum. All rights reserved.
/* Copyright (c) 2011, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@ -9,7 +9,7 @@
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of Code Aurora Forum, Inc. nor the names of its
* * Neither the name of The Linux Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
@ -37,7 +37,7 @@
#define PRINT(x...) do { \
fprintf(stdout, "%s(%d) ", __FUNCTION__, __LINE__); \
fprintf(stdout, ##x); \
LOGD(x); \
ALOGD(x); \
} while(0)
#ifdef DEBUG
@ -55,14 +55,14 @@
#define E(x...) do { \
fprintf(stderr, "%s(%d) ", __FUNCTION__, __LINE__); \
fprintf(stderr, ##x); \
LOGE(x); \
ALOGE(x); \
} while(0)
#define FAILIF(cond, msg...) do { \
if (__builtin_expect (cond, 0)) { \
fprintf(stderr, "%s:%s:(%d): ", __FILE__, __FUNCTION__, __LINE__); \
fprintf(stderr, ##msg); \
LOGE(##msg); \
ALOGE(##msg); \
} \
} while(0)

View file

@ -1,4 +1,4 @@
/* Copyright (c) 2011, Code Aurora Forum. All rights reserved.
/* Copyright (c) 2011, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@ -9,7 +9,7 @@
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of Code Aurora Forum, Inc. nor the names of its
* * Neither the name of The Linux Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*

View file

@ -1,4 +1,4 @@
/* Copyright (c) 2011 Code Aurora Forum. All rights reserved.
/* Copyright (c) 2011 The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@ -9,7 +9,7 @@
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of Code Aurora Forum, Inc. nor the names of its
* * Neither the name of The Linux Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*

View file

@ -1,4 +1,4 @@
/* Copyright (c) 2011, Code Aurora Forum. All rights reserved.
/* Copyright (c) 2011, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@ -9,7 +9,7 @@
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of Code Aurora Forum, Inc. nor the names of its
* * Neither the name of The Linux Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*

View file

@ -1,4 +1,4 @@
/* Copyright (c) 2011, Code Aurora Forum. All rights reserved.
/* Copyright (c) 2011, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@ -9,7 +9,7 @@
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of Code Aurora Forum, Inc. nor the names of its
* * Neither the name of The Linux Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*

View file

@ -1,4 +1,4 @@
/* Copyright (c) 2011, Code Aurora Forum. All rights reserved.
/* Copyright (c) 2011, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@ -9,7 +9,7 @@
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of Code Aurora Forum, Inc. nor the names of its
* * Neither the name of The Linux Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*

View file

@ -1,4 +1,4 @@
/* Copyright (c) 2011, Code Aurora Forum. All rights reserved.
/* Copyright (c) 2011-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
@ -9,7 +9,7 @@
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of Code Aurora Forum, Inc. nor the names of its
* * Neither the name of The Linux Foundation, nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
@ -98,7 +98,7 @@ static void loc_rpc_global_cb(void* user, CLIENT* clnt, enum rpc_reset_event eve
}
extern "C" LocApiAdapter* getLocApiAdapter(LocEng &locEng)
LocApiAdapter* getLocApiAdapter(LocEng &locEng)
{
return new LocApiRpcAdapter(locEng);
}
@ -119,8 +119,10 @@ const rpc_loc_event_mask_type LocApiRpcAdapter::locBits[] =
LocApiRpcAdapter::LocApiRpcAdapter(LocEng &locEng) :
LocApiAdapter(locEng),
client_handle(RPC_LOC_CLIENT_HANDLE_INVALID),
eMask(convertMask(locEng.eventMask))
eMask(convertMask(locEng.eventMask)),
dataEnableLastSet(-1)
{
memset(apnLastSet, 0, sizeof(apnLastSet));
loc_api_glue_init();
}
@ -298,9 +300,7 @@ LocApiRpcAdapter::stopFix() {
}
enum loc_api_adapter_err
LocApiRpcAdapter::setPositionMode(LocPositionMode mode,
GpsPositionRecurrence recurrence, uint32_t min_interval,
uint32_t preferred_accuracy, uint32_t preferred_time)
LocApiRpcAdapter::setPositionMode(const LocPosMode *posMode)
{
rpc_loc_ioctl_data_u_type ioctl_data;
rpc_loc_fix_criteria_s_type *fix_criteria_ptr;
@ -308,10 +308,13 @@ LocApiRpcAdapter::setPositionMode(LocPositionMode mode,
rpc_loc_operation_mode_e_type op_mode;
int ret_val;
LOGD ("loc_eng_set_position mode, client = %d, interval = %d, mode = %d\n",
(int32) client_handle, min_interval, mode);
if (NULL != posMode)
fixCriteria = *posMode;
switch (mode)
ALOGD ("loc_eng_set_position mode, client = %d, interval = %d, mode = %d\n",
(int32) client_handle, fixCriteria.min_interval, fixCriteria.mode);
switch (fixCriteria.mode)
{
case LOC_POSITION_MODE_MS_BASED:
op_mode = RPC_LOC_OPER_MODE_MSB;
@ -329,6 +332,7 @@ LocApiRpcAdapter::setPositionMode(LocPositionMode mode,
op_mode = RPC_LOC_OPER_MODE_DATA_OPTIMAL;
break;
case LOC_POSITION_MODE_RESERVED_4:
case LOC_POSITION_MODE_RESERVED_5:
op_mode = RPC_LOC_OPER_MODE_MSA;
fix_criteria_ptr->preferred_response_time = 0;
break;
@ -339,29 +343,22 @@ LocApiRpcAdapter::setPositionMode(LocPositionMode mode,
fix_criteria_ptr = &ioctl_data.rpc_loc_ioctl_data_u_type_u.fix_criteria;
fix_criteria_ptr->valid_mask = RPC_LOC_FIX_CRIT_VALID_PREFERRED_OPERATION_MODE |
RPC_LOC_FIX_CRIT_VALID_RECURRENCE_TYPE;
fix_criteria_ptr->min_interval = min_interval;
fix_criteria_ptr->min_interval = fixCriteria.min_interval;
fix_criteria_ptr->preferred_operation_mode = op_mode;
if (min_interval > 0) {
fix_criteria_ptr->min_interval = min_interval;
fix_criteria_ptr->valid_mask |= RPC_LOC_FIX_CRIT_VALID_MIN_INTERVAL;
}else if(min_interval == 0)
{
/*If the framework passes in 0 transalate it into the maximum frequency we can report positions
which is 1 Hz or once very second */
fix_criteria_ptr->min_interval = MIN_POSSIBLE_FIX_INTERVAL;
fix_criteria_ptr->valid_mask |= RPC_LOC_FIX_CRIT_VALID_MIN_INTERVAL;
}
if (preferred_accuracy > 0) {
fix_criteria_ptr->preferred_accuracy = preferred_accuracy;
fix_criteria_ptr->min_interval = fixCriteria.min_interval;
fix_criteria_ptr->valid_mask |= RPC_LOC_FIX_CRIT_VALID_MIN_INTERVAL;
if (fixCriteria.preferred_accuracy > 0) {
fix_criteria_ptr->preferred_accuracy = fixCriteria.preferred_accuracy;
fix_criteria_ptr->valid_mask |= RPC_LOC_FIX_CRIT_VALID_PREFERRED_ACCURACY;
}
if (preferred_time > 0) {
fix_criteria_ptr->preferred_response_time = preferred_time;
if (fixCriteria.preferred_time > 0) {
fix_criteria_ptr->preferred_response_time = fixCriteria.preferred_time;
fix_criteria_ptr->valid_mask |= RPC_LOC_FIX_CRIT_VALID_PREFERRED_RESPONSE_TIME;
}
switch (recurrence) {
switch (fixCriteria.recurrence) {
case GPS_POSITION_RECURRENCE_SINGLE:
fix_criteria_ptr->recurrence_type = RPC_LOC_SINGLE_FIX;
break;
@ -484,20 +481,42 @@ LocApiRpcAdapter::informNiResponse(GpsUserResponseType userResponse,
}
enum loc_api_adapter_err
LocApiRpcAdapter::setAPN(char* apn, int len)
LocApiRpcAdapter::setAPN(char* apn, int len, boolean force)
{
rpc_loc_ioctl_data_u_type ioctl_data = {RPC_LOC_IOCTL_SET_LBS_APN_PROFILE, {0}};
ioctl_data.rpc_loc_ioctl_data_u_type_u.apn_profiles[0].srv_system_type = LOC_APN_PROFILE_SRV_SYS_MAX;
ioctl_data.rpc_loc_ioctl_data_u_type_u.apn_profiles[0].pdp_type = LOC_APN_PROFILE_PDN_TYPE_IPV4;
memcpy(&(ioctl_data.rpc_loc_ioctl_data_u_type_u.apn_profiles[0].apn_name), apn, len+1);
enum loc_api_adapter_err rtv = LOC_API_ADAPTER_ERR_SUCCESS;
int size = sizeof(apnLastSet);
if (force || memcmp(apnLastSet, apn, size)) {
if (len < size) {
// size will be not larger than its original value
size = len + 1;
}
memcpy(apnLastSet, apn, size);
return convertErr(
loc_eng_ioctl (client_handle,
RPC_LOC_IOCTL_SET_LBS_APN_PROFILE,
&ioctl_data,
LOC_IOCTL_DEFAULT_TIMEOUT,
NULL)
);
if (false == navigating) {
rpc_loc_ioctl_data_u_type ioctl_data = {RPC_LOC_IOCTL_SET_LBS_APN_PROFILE, {0}};
ioctl_data.rpc_loc_ioctl_data_u_type_u.apn_profiles[0].srv_system_type = LOC_APN_PROFILE_SRV_SYS_MAX;
ioctl_data.rpc_loc_ioctl_data_u_type_u.apn_profiles[0].pdp_type = LOC_APN_PROFILE_PDN_TYPE_IPV4;
memcpy(&(ioctl_data.rpc_loc_ioctl_data_u_type_u.apn_profiles[0].apn_name), apn, size);
rtv = convertErr(
loc_eng_ioctl (client_handle,
RPC_LOC_IOCTL_SET_LBS_APN_PROFILE,
&ioctl_data,
LOC_IOCTL_DEFAULT_TIMEOUT,
NULL)
);
}
}
return rtv;
}
void LocApiRpcAdapter::setInSession(bool inSession)
{
LocApiAdapter::setInSession(inSession);
if (false == navigating) {
enableData(dataEnableLastSet, true);
setAPN(apnLastSet, sizeof(apnLastSet)-1, true);
}
}
enum loc_api_adapter_err
@ -567,18 +586,26 @@ LocApiRpcAdapter::setServer(unsigned int ip, int port, LocServerType type)
}
enum loc_api_adapter_err
LocApiRpcAdapter::enableData(int enable)
LocApiRpcAdapter::enableData(int enable, boolean force)
{
rpc_loc_ioctl_data_u_type ioctl_data = {RPC_LOC_IOCTL_SET_DATA_ENABLE, {0}};
enum loc_api_adapter_err rtv = LOC_API_ADAPTER_ERR_SUCCESS;
if (force || dataEnableLastSet != enable) {
dataEnableLastSet = enable;
ioctl_data.rpc_loc_ioctl_data_u_type_u.data_enable = enable;
return convertErr(
loc_eng_ioctl (client_handle,
RPC_LOC_IOCTL_SET_DATA_ENABLE,
&ioctl_data,
LOC_IOCTL_DEFAULT_TIMEOUT,
NULL)
);
if (false == navigating) {
rpc_loc_ioctl_data_u_type ioctl_data = {RPC_LOC_IOCTL_SET_DATA_ENABLE, {0}};
ioctl_data.rpc_loc_ioctl_data_u_type_u.data_enable = enable;
rtv = convertErr(
loc_eng_ioctl (client_handle,
RPC_LOC_IOCTL_SET_DATA_ENABLE,
&ioctl_data,
LOC_IOCTL_DEFAULT_TIMEOUT,
NULL)
);
}
}
return rtv;
}
enum loc_api_adapter_err
@ -598,9 +625,13 @@ LocApiRpcAdapter::deleteAidingData(GpsAidingData bits)
void LocApiRpcAdapter::reportPosition(const rpc_loc_parsed_position_s_type *location_report_ptr)
{
GpsLocation location = {0};
LocPosTechMask tech_Mask = LOC_POS_TECH_MASK_DEFAULT;
UlpLocation location = {0};
GpsLocationExtended locationExtended = {0};
location.size = sizeof(location);
locationExtended.size = sizeof(locationExtended);
if (location_report_ptr->valid_mask & RPC_LOC_POS_VALID_SESSION_STATUS)
{
// Process the position from final and intermediate reports
@ -613,56 +644,89 @@ void LocApiRpcAdapter::reportPosition(const rpc_loc_parsed_position_s_type *loca
(location_report_ptr->latitude != 0 ||
location_report_ptr->longitude != 0))
{
location.flags |= GPS_LOCATION_HAS_LAT_LONG;
location.latitude = location_report_ptr->latitude;
location.longitude = location_report_ptr->longitude;
location.gpsLocation.flags |= GPS_LOCATION_HAS_LAT_LONG;
location.gpsLocation.latitude = location_report_ptr->latitude;
location.gpsLocation.longitude = location_report_ptr->longitude;
// Time stamp (UTC)
if (location_report_ptr->valid_mask & RPC_LOC_POS_VALID_TIMESTAMP_UTC)
{
location.timestamp = location_report_ptr->timestamp_utc;
location.gpsLocation.timestamp = location_report_ptr->timestamp_utc;
}
// Altitude
if (location_report_ptr->valid_mask & RPC_LOC_POS_VALID_ALTITUDE_WRT_ELLIPSOID )
{
location.flags |= GPS_LOCATION_HAS_ALTITUDE;
location.altitude = location_report_ptr->altitude_wrt_ellipsoid;
location.gpsLocation.flags |= GPS_LOCATION_HAS_ALTITUDE;
location.gpsLocation.altitude = location_report_ptr->altitude_wrt_ellipsoid;
}
// Speed
if ((location_report_ptr->valid_mask & RPC_LOC_POS_VALID_SPEED_HORIZONTAL) &&
(location_report_ptr->valid_mask & RPC_LOC_POS_VALID_SPEED_VERTICAL))
{
location.flags |= GPS_LOCATION_HAS_SPEED;
location.speed = sqrt(location_report_ptr->speed_horizontal * location_report_ptr->speed_horizontal +
location.gpsLocation.flags |= GPS_LOCATION_HAS_SPEED;
location.gpsLocation.speed = sqrt(location_report_ptr->speed_horizontal * location_report_ptr->speed_horizontal +
location_report_ptr->speed_vertical * location_report_ptr->speed_vertical);
}
// Heading
if (location_report_ptr->valid_mask & RPC_LOC_POS_VALID_HEADING)
{
location.flags |= GPS_LOCATION_HAS_BEARING;
location.bearing = location_report_ptr->heading;
location.gpsLocation.flags |= GPS_LOCATION_HAS_BEARING;
location.gpsLocation.bearing = location_report_ptr->heading;
}
// Uncertainty (circular)
if ( (location_report_ptr->valid_mask & RPC_LOC_POS_VALID_HOR_UNC_CIRCULAR) )
{
location.flags |= GPS_LOCATION_HAS_ACCURACY;
location.accuracy = location_report_ptr->hor_unc_circular;
location.gpsLocation.flags |= GPS_LOCATION_HAS_ACCURACY;
location.gpsLocation.accuracy = location_report_ptr->hor_unc_circular;
}
// Technology Mask
tech_Mask |= location_report_ptr->technology_mask;
//Mark the location source as from GNSS
location.gpsLocation.flags |= LOCATION_HAS_SOURCE_INFO;
location.position_source = ULP_LOCATION_IS_FROM_GNSS;
if (location_report_ptr->valid_mask & RPC_LOC_POS_VALID_ALTITUDE_WRT_MEAN_SEA_LEVEL)
{
locationExtended.flags |= GPS_LOCATION_EXTENDED_HAS_ALTITUDE_MEAN_SEA_LEVEL;
locationExtended.altitudeMeanSeaLevel = location_report_ptr->altitude_wrt_mean_sea_level;
}
if (location_report_ptr->valid_mask & RPC_LOC_POS_VALID_MAGNETIC_VARIATION )
{
locationExtended.flags |= GPS_LOCATION_EXTENDED_HAS_MAG_DEV;
locationExtended.magneticDeviation = location_report_ptr->magnetic_deviation;
}
if (location_report_ptr->valid_mask & RPC_LOC_POS_VALID_VERTICAL_UNC)
{
locationExtended.flags |= GPS_LOCATION_EXTENDED_HAS_VERT_UNC;
locationExtended.vert_unc = location_report_ptr->vert_unc;
}
if (location_report_ptr->valid_mask & RPC_LOC_POS_VALID_SPEED_UNC)
{
locationExtended.flags |= GPS_LOCATION_EXTENDED_HAS_SPEED_UNC;
locationExtended.speed_unc = location_report_ptr->speed_unc;
}
LOC_LOGV("reportPosition: fire callback\n");
LocApiAdapter::reportPosition(location,
locationExtended,
locEngHandle.extPosInfo((void*)location_report_ptr),
(location_report_ptr->session_status == RPC_LOC_SESS_STATUS_IN_PROGESS ?
LOC_SESS_INTERMEDIATE : LOC_SESS_SUCCESS));
LOC_SESS_INTERMEDIATE : LOC_SESS_SUCCESS),
tech_Mask);
}
}
else
{
LocApiAdapter::reportPosition(location,
locationExtended,
NULL,
LOC_SESS_FAILURE);
LOC_LOGV("loc_eng_report_position: ignore position report when session status = %d\n", location_report_ptr->session_status);
@ -677,6 +741,8 @@ void LocApiRpcAdapter::reportPosition(const rpc_loc_parsed_position_s_type *loca
void LocApiRpcAdapter::reportSv(const rpc_loc_gnss_info_s_type *gnss_report_ptr)
{
GpsSvStatus SvStatus = {0};
GpsLocationExtended locationExtended = {0};
locationExtended.size = sizeof(locationExtended);
int num_svs_max = 0;
const rpc_loc_sv_info_s_type *sv_info_ptr;
@ -760,9 +826,20 @@ void LocApiRpcAdapter::reportSv(const rpc_loc_gnss_info_s_type *gnss_report_ptr)
}
}
if ((gnss_report_ptr->valid_mask & RPC_LOC_GNSS_INFO_VALID_POS_DOP) &&
(gnss_report_ptr->valid_mask & RPC_LOC_GNSS_INFO_VALID_HOR_DOP) &&
(gnss_report_ptr->valid_mask & RPC_LOC_GNSS_INFO_VALID_VERT_DOP))
{
locationExtended.flags |= GPS_LOCATION_EXTENDED_HAS_DOP;
locationExtended.pdop = gnss_report_ptr->position_dop;
locationExtended.hdop = gnss_report_ptr->horizontal_dop;
locationExtended.vdop = gnss_report_ptr->vertical_dop;
}
if (SvStatus.num_svs >= 0)
{
LocApiAdapter::reportSv(SvStatus,
locationExtended,
locEngHandle.extSvInfo((void*)gnss_report_ptr));
}
}
@ -881,13 +958,22 @@ LocApiRpcAdapter::setXtraData(char* data, int length)
return convertErr(rpc_ret_val);
}
#ifdef FEATURE_IPV6
enum loc_api_adapter_err
LocApiRpcAdapter::atlOpenStatus(int handle, int is_succ, char* apn, AGpsBearerType bearer, AGpsType agpsType)
#else
enum loc_api_adapter_err
LocApiRpcAdapter::atlOpenStatus(int handle, int is_succ, char* apn, AGpsType agpsType)
#endif
{
rpc_loc_server_open_status_e_type open_status = is_succ ? RPC_LOC_SERVER_OPEN_SUCCESS : RPC_LOC_SERVER_OPEN_FAIL;
rpc_loc_ioctl_data_u_type ioctl_data;
#ifdef FEATURE_IPV6
if (AGPS_TYPE_INVALID == agpsType) {
#else
if (false) {
#endif
rpc_loc_server_open_status_s_type *conn_open_status_ptr =
&ioctl_data.rpc_loc_ioctl_data_u_type_u.conn_open_status;
@ -924,6 +1010,7 @@ LocApiRpcAdapter::atlOpenStatus(int handle, int is_succ, char* apn, AGpsBearerTy
conn_multi_open_status_ptr->apn_name[0] = 0;
}
#ifdef FEATURE_IPV6
switch(bearer)
{
case AGPS_APN_BEARER_IPV4:
@ -938,7 +1025,9 @@ LocApiRpcAdapter::atlOpenStatus(int handle, int is_succ, char* apn, AGpsBearerTy
default:
conn_multi_open_status_ptr->pdp_type = RPC_LOC_SERVER_PDP_PPP;
}
#else
conn_multi_open_status_ptr->pdp_type = RPC_LOC_SERVER_PDP_IP;
#endif
LOC_LOGD("ATL RPC_LOC_IOCTL_INFORM_SERVER_MULTI_OPEN_STATUS open %s, APN name = [%s], pdp_type = %d\n",
log_succ_fail_string(is_succ),
apn,
@ -992,16 +1081,22 @@ void LocApiRpcAdapter::ATLEvent(const rpc_loc_server_request_s_type *server_requ
agps_type = AGPS_TYPE_SUPL;
LOC_LOGV("ATLEvent: event - RPC_LOC_SERVER_REQUEST_MULTI_OPEN\n type - AGPS_TYPE_SUPL\n handle - %d", connHandle);
} else {
#ifdef FEATURE_IPV6
agps_type = AGPS_TYPE_WWAN_ANY;
LOC_LOGV("ATLEvent: event - RPC_LOC_SERVER_REQUEST_MULTI_OPEN\n type - AGPS_TYPE_WWAN_ANY\n handle - %d", connHandle);
#else
break;
#endif
}
requestATL(connHandle, agps_type);
break;
#ifdef FEATURE_IPV6
case RPC_LOC_SERVER_REQUEST_OPEN:
connHandle = server_request_ptr->payload.rpc_loc_server_request_u_type_u.open_req.conn_handle;
LOC_LOGV("ATLEvent: event - RPC_LOC_SERVER_REQUEST_OPEN\n handle - %d", connHandle);
requestATL(connHandle, AGPS_TYPE_INVALID);
break;
#endif
case RPC_LOC_SERVER_REQUEST_CLOSE:
connHandle = server_request_ptr->payload.rpc_loc_server_request_u_type_u.close_req.conn_handle;
LOC_LOGV("ATLEvent: event - RPC_LOC_SERVER_REQUEST_CLOSE\n handle - %d", connHandle);

View file

@ -1,4 +1,4 @@
/* Copyright (c) 2011, Code Aurora Forum. All rights reserved.
/* Copyright (c) 2011, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@ -9,7 +9,7 @@
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of Code Aurora Forum, Inc. nor the names of its
* * Neither the name of The Linux Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*

View file

@ -1,4 +1,4 @@
/* Copyright (c) 2011 Code Aurora Forum. All rights reserved.
/* Copyright (c) 2011 The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@ -9,7 +9,7 @@
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of Code Aurora Forum, Inc. nor the names of its
* * Neither the name of The Linux Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*

View file

@ -1,4 +1,4 @@
/* Copyright (c) 2011, Code Aurora Forum. All rights reserved.
/* 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
@ -9,7 +9,7 @@
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of Code Aurora Forum, Inc. nor the names of its
* * Neither the name of The Linux Foundation, nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
@ -62,8 +62,8 @@
/* Logging Improvement */
#include "log_util.h"
/* Uncomment to force LOGD messages */
// #define LOGD LOGI
/* Uncomment to force ALOGD messages */
// #define ALOGD ALOGI
/*=====================================================================
External declarations
@ -316,30 +316,23 @@ rpc_loc_client_handle_type loc_open (
rpc_loc_open_args args;
args.event_reg_mask = event_reg_mask;
int i;
int i, j = LOC_API_CB_MAX_CLIENTS;
for (i = 0; i < LOC_API_CB_MAX_CLIENTS; i++)
{
if (loc_glue_callback_table[i].cb_func == event_callback ||
loc_glue_callback_table[i].user == userData)
if (loc_glue_callback_table[i].user == userData)
{
LOC_LOGW("Client already opened service (callback=%p)...\n",
event_callback);
break;
} else if (j == LOC_API_CB_MAX_CLIENTS &&
loc_glue_callback_table[i].user == NULL) {
j = i;
}
}
if (i == LOC_API_CB_MAX_CLIENTS)
{
for (i = 0; i < LOC_API_CB_MAX_CLIENTS; i++)
{
if (loc_glue_callback_table[i].cb_func == NULL)
{
loc_glue_callback_table[i].cb_func = event_callback;
loc_glue_callback_table[i].rpc_cb = rpc_cb;
loc_glue_callback_table[i].user = userData;
break;
}
}
i = j;
}
if (i == LOC_API_CB_MAX_CLIENTS)
@ -348,6 +341,10 @@ rpc_loc_client_handle_type loc_open (
return RPC_LOC_CLIENT_HANDLE_INVALID;
}
loc_glue_callback_table[i].cb_func = event_callback;
loc_glue_callback_table[i].rpc_cb = rpc_cb;
loc_glue_callback_table[i].user = userData;
args.event_callback = loc_glue_callback_table[i].cb_id;
LOC_LOGV("cb_id=%d, func=0x%x", i, (unsigned int) event_callback);
@ -405,6 +402,7 @@ void loc_clear(rpc_loc_client_handle_type handle) {
loc_glue_callback_table[i].cb_func = NULL;
loc_glue_callback_table[i].rpc_cb = NULL;
loc_glue_callback_table[i].handle = -1;
loc_glue_callback_table[i].user = NULL;
break;
}
}

View file

@ -1,4 +1,4 @@
/* Copyright (c) 2011, Code Aurora Forum. All rights reserved.
/* 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
@ -9,7 +9,7 @@
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of Code Aurora Forum, Inc. nor the names of its
* * Neither the name of The Linux Foundation, nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
@ -195,7 +195,7 @@ void loc_api_callback_process_sync_call(
{
int i;
LOGV("loc_handle = 0x%lx, loc_event = 0x%lx", loc_handle, loc_event);
ALOGV("loc_handle = 0x%lx, loc_event = 0x%lx", loc_handle, loc_event);
for (i = 0; i < loc_sync_data.num_of_slots; i++)
{
loc_sync_call_slot_s_type *slot = &loc_sync_data.slots[i];
@ -211,7 +211,7 @@ void loc_api_callback_process_sync_call(
slot->loc_cb_received_event_mask = loc_event;
LOGV("signal slot %d in_use %d, loc_handle 0x%lx, event_mask 0x%1x, ioctl_type %d", i, slot->in_use, slot->loc_handle, (int) slot->loc_cb_wait_event_mask, (int) slot->ioctl_type);
ALOGV("signal slot %d in_use %d, loc_handle 0x%lx, event_mask 0x%1x, ioctl_type %d", i, slot->in_use, slot->loc_handle, (int) slot->loc_cb_wait_event_mask, (int) slot->ioctl_type);
pthread_cond_signal(&slot->loc_cb_arrived_cond);
slot->signal_sent = 1;
@ -252,21 +252,19 @@ static int loc_lock_a_slot()
loc_sync_call_slot_s_type *slot = &loc_sync_data.slots[i];
if (pthread_mutex_trylock(&slot->lock) == EBUSY)
{
LOGV("trylock EBUSY : %d", i);
ALOGV("trylock EBUSY : %d", i);
continue;
}
if (!slot->in_use && !slot->not_available)
{
select_id = i;
slot->in_use = 1;
slot->signal_sent = 0;
/* Return from here and leave the mutex locked.
* will unlock it in loc_unlock_slot()
*/
break;
}
/* LOGV("slot %d in_use = %d, not_available = %d : %d", i, slot->in_use, slot->not_available, i); */
/* ALOGV("slot %d in_use = %d, not_available = %d : %d", i, slot->in_use, slot->not_available, i); */
pthread_mutex_unlock(&slot->lock);
}
@ -278,7 +276,7 @@ static int loc_lock_a_slot()
FUNCTION loc_unlock_slot
DESCRIPTION
Frees a buffer slot after the synchronous API call
Unlocks a buffer slot
DEPENDENCIES
N/A
@ -292,13 +290,58 @@ SIDE EFFECTS
===========================================================================*/
static void loc_unlock_slot(int select_id)
{
loc_sync_data.slots[select_id].in_use = 0;
pthread_mutex_unlock(&loc_sync_data.slots[select_id].lock);
}
/*===========================================================================
FUNCTION loc_lock_slot
DESCRIPTION
Locks a specific slot that was previously locked from loc_lock_a_slot
DEPENDENCIES
N/A
RETURN VALUE
None
SIDE EFFECTS
N/A
===========================================================================*/
static void loc_lock_slot(int select_id)
{
pthread_mutex_lock(&loc_sync_data.slots[select_id].lock);
}
/*===========================================================================
FUNCTION loc_set_slot_in_use
DESCRIPTION
Sets the in_use flag of slot to true or false.
Should be called only after the slot is locked
DEPENDENCIES
N/A
RETURN VALUE
None
SIDE EFFECTS
N/A
===========================================================================*/
static void loc_set_slot_in_use(int select_id, boolean in_use)
{
loc_sync_data.slots[select_id].in_use = in_use;
if (in_use == 1)
loc_sync_data.slots[select_id].signal_sent = 0;
}
/*===========================================================================
FUNCTION loc_api_save_callback
DESCRIPTION
@ -399,7 +442,7 @@ static int loc_api_wait_callback(
)
{
int ret_val = RPC_LOC_API_SUCCESS; /* the return value of this function: 0 = no error */
int rc; /* return code from pthread calls */
int rc = 0; /* return code from pthread calls */
struct timespec expire_time;
@ -417,7 +460,7 @@ static int loc_api_wait_callback(
if (rc == ETIMEDOUT)
{
ret_val = RPC_LOC_API_TIMEOUT; /* Timed out */
LOGE("TIMEOUT: %d", select_id);
ALOGE("TIMEOUT: %d", select_id);
}
else {
/* Obtained the first awaited callback */
@ -462,29 +505,38 @@ int loc_api_sync_ioctl
if (select_id < 0 || select_id >= loc_sync_data.num_of_slots)
{
LOGE("slot not available ioctl_type = %s",
ALOGE("slot not available ioctl_type = %s",
loc_get_ioctl_type_name(ioctl_type));
return rc;
}
loc_set_slot_in_use(select_id, 1); // set slot in use to true
// Select the callback we are waiting for
loc_api_save_callback(select_id, handle, 0, ioctl_type);
loc_unlock_slot(select_id); // slot is unlocked, but in_use is still true
// we want to avoid keeping the slot locked during the loc_ioctl because the rpc
// framework will also lock a different mutex during this call, and typically
// locking two different mutexes at the same time can lead to deadlock.
rc = loc_ioctl(handle, ioctl_type, ioctl_data_ptr);
loc_lock_slot(select_id);
if (rc != RPC_LOC_API_SUCCESS)
{
LOGE("loc_ioctl failed select_id = %d, ioctl_type %s, returned %s",
ALOGE("loc_ioctl failed select_id = %d, ioctl_type %s, returned %s",
select_id, loc_get_ioctl_type_name(ioctl_type), loc_get_ioctl_status_name(rc));
}
else {
LOGV("select_id = %d, ioctl_type %d, returned RPC_LOC_API_SUCCESS",
ALOGV("select_id = %d, ioctl_type %d, returned RPC_LOC_API_SUCCESS",
select_id, ioctl_type);
// Wait for the callback of loc_ioctl
if ((rc = loc_api_wait_callback(select_id, timeout_msec / 1000, NULL, &callback_data)) != 0)
{
// Callback waiting failed
LOGE("callback wait failed select_id = %d, ioctl_type %s, returned %s",
ALOGE("callback wait failed select_id = %d, ioctl_type %s, returned %s",
select_id, loc_get_ioctl_type_name(ioctl_type), loc_get_ioctl_status_name(rc));
}
else
@ -493,15 +545,16 @@ int loc_api_sync_ioctl
if (callback_data.status != RPC_LOC_API_SUCCESS)
{
rc = callback_data.status;
LOGE("callback status failed select_id = %d, ioctl_type %s, returned %s",
ALOGE("callback status failed select_id = %d, ioctl_type %s, returned %s",
select_id, loc_get_ioctl_type_name(ioctl_type), loc_get_ioctl_status_name(rc));
} else {
LOGV("callback status success select_id = %d, ioctl_type %d, returned %d",
ALOGV("callback status success select_id = %d, ioctl_type %d, returned %d",
select_id, ioctl_type, rc);
}
} /* wait callback */
} /* loc_ioctl */
loc_set_slot_in_use(select_id, 0); // set slot in use to false
loc_unlock_slot(select_id);
return rc;

View file

@ -1,4 +1,4 @@
/* Copyright (c) 2011, Code Aurora Forum. All rights reserved.
/* Copyright (c) 2011, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@ -9,7 +9,7 @@
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of Code Aurora Forum, Inc. nor the names of its
* * Neither the name of The Linux Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*

View file

View file

@ -1,4 +1,4 @@
/* Copyright (c) 2011, Code Aurora Forum. All rights reserved.
/* Copyright (c) 2011, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@ -9,7 +9,7 @@
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of Code Aurora Forum, Inc. nor the names of its
* * Neither the name of The Linux Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*

View file

@ -1,4 +1,4 @@
/* Copyright (c) 2011, Code Aurora Forum. All rights reserved.
/* Copyright (c) 2011, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@ -9,7 +9,7 @@
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of Code Aurora Forum, Inc. nor the names of its
* * Neither the name of The Linux Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*

View file

@ -1,4 +1,4 @@
/* Copyright (c) 2011, Code Aurora Forum. All rights reserved.
/* Copyright (c) 2011, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@ -9,7 +9,7 @@
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of Code Aurora Forum, Inc. nor the names of its
* * Neither the name of The Linux Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*

View file

@ -1,4 +1,4 @@
/* Copyright (c) 2011, Code Aurora Forum. All rights reserved.
/* Copyright (c) 2011, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@ -9,7 +9,7 @@
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of Code Aurora Forum, Inc. nor the names of its
* * Neither the name of The Linux Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*

View file

@ -1,4 +1,4 @@
/* Copyright (c) 2011, Code Aurora Forum. All rights reserved.
/* Copyright (c) 2011, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@ -9,7 +9,7 @@
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of Code Aurora Forum, Inc. nor the names of its
* * Neither the name of The Linux Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*

View file

@ -1,4 +1,4 @@
/* Copyright (c) 2011, Code Aurora Forum. All rights reserved.
/* Copyright (c) 2011, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@ -9,7 +9,7 @@
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of Code Aurora Forum, Inc. nor the names of its
* * Neither the name of The Linux Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*

View file

@ -1,4 +1,4 @@
/* Copyright (c) 2011, Code Aurora Forum. All rights reserved.
/* Copyright (c) 2011, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@ -9,7 +9,7 @@
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of Code Aurora Forum, Inc. nor the names of its
* * Neither the name of The Linux Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*

View file

@ -1,4 +1,4 @@
/* Copyright (c) 2011, Code Aurora Forum. All rights reserved.
/* Copyright (c) 2011, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@ -9,7 +9,7 @@
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of Code Aurora Forum, Inc. nor the names of its
* * Neither the name of The Linux Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*

View file

@ -1,4 +1,4 @@
/* Copyright (c) 2011, Code Aurora Forum. All rights reserved.
/* Copyright (c) 2011, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@ -9,7 +9,7 @@
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of Code Aurora Forum, Inc. nor the names of its
* * Neither the name of The Linux Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*

View file

@ -1,4 +1,4 @@
/* Copyright (c) 2011, Code Aurora Forum. All rights reserved.
/* Copyright (c) 2011, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@ -9,7 +9,7 @@
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of Code Aurora Forum, Inc. nor the names of its
* * Neither the name of The Linux Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*

View file

@ -1,4 +1,4 @@
/* Copyright (c) 2011, Code Aurora Forum. All rights reserved.
/* 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
@ -9,7 +9,7 @@
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of Code Aurora Forum, Inc. nor the names of its
* * Neither the name of The Linux Foundation, nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*

View file

@ -1,4 +1,4 @@
/* Copyright (c) 2011, Code Aurora Forum. All rights reserved.
/* 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
@ -9,7 +9,7 @@
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of Code Aurora Forum, Inc. nor the names of its
* * Neither the name of The Linux Foundation, nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*

View file

@ -1,4 +1,4 @@
/* Copyright (c) 2011, Code Aurora Forum. All rights reserved.
/* 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
@ -9,7 +9,7 @@
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of Code Aurora Forum, Inc. nor the names of its
* * Neither the name of The Linux Foundation, nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*

0
loc_api/libloc_api-rpc/Android.mk Executable file → Normal file
View file

0
loc_api/libloc_api-rpc/gen-1240/Makefile.xdr Executable file → Normal file
View file

0
loc_api/libloc_api-rpc/gen-1240/loc_api.xdr Executable file → Normal file
View file

0
loc_api/libloc_api-rpc/gen-1240/loc_api_cb.xdr Executable file → Normal file
View file

0
loc_api/libloc_api-rpc/gen-1240/loc_api_common.xdr Executable file → Normal file
View file

0
loc_api/libloc_api-rpc/gen-3200/Makefile.xdr Executable file → Normal file
View file

0
loc_api/libloc_api-rpc/gen-3200/loc_api.xdr Executable file → Normal file
View file

0
loc_api/libloc_api-rpc/gen-3200/loc_api_cb.xdr Executable file → Normal file
View file

0
loc_api/libloc_api-rpc/gen-3200/loc_api_common.xdr Executable file → Normal file
View file

0
loc_api/libloc_api/Android.mk Executable file → Normal file
View file

View file

@ -1,4 +1,4 @@
/* Copyright (c) 2009,2011 Code Aurora Forum. All rights reserved.
/* Copyright (c) 2009,2011 The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@ -9,7 +9,7 @@
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of Code Aurora Forum, Inc. nor the names of its
* * Neither the name of The Linux Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*

View file

@ -1,4 +1,4 @@
/* Copyright (c) 2009,2011 Code Aurora Forum. All rights reserved.
/* Copyright (c) 2009,2011 The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@ -9,7 +9,7 @@
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of Code Aurora Forum, Inc. nor the names of its
* * Neither the name of The Linux Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
@ -743,7 +743,7 @@ SIDE EFFECTS
===========================================================================*/
static void loc_eng_report_position (const rpc_loc_parsed_position_s_type *location_report_ptr)
{
GpsLocation location;
UlpLocation location;
LOGV ("loc_eng_report_position: location report, valid mask = 0x%x, sess status = %d\n",
(uint32) location_report_ptr->valid_mask, location_report_ptr->session_status);
@ -831,7 +831,7 @@ static void loc_eng_report_sv (const rpc_loc_gnss_info_s_type *gnss_report_ptr)
{
GpsSvStatus SvStatus;
int num_svs_max, i;
const rpc_loc_sv_info_s_type *sv_info_ptr;
const rpc_loc_sv_info_s_type *sv_info_ptr;
LOGV ("loc_eng_report_sv: valid_mask = 0x%x, num of sv = %d\n",
(uint32) gnss_report_ptr->valid_mask,

View file

@ -1,4 +1,4 @@
/* Copyright (c) 2009,2011 Code Aurora Forum. All rights reserved.
/* Copyright (c) 2009,2011 The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@ -9,7 +9,7 @@
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of Code Aurora Forum, Inc. nor the names of its
* * Neither the name of The Linux Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*

View file

@ -1,4 +1,4 @@
/* Copyright (c) 2009,2011 Code Aurora Forum. All rights reserved.
/* Copyright (c) 2009,2011 The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@ -9,7 +9,7 @@
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of Code Aurora Forum, Inc. nor the names of its
* * Neither the name of The Linux Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*

View file

@ -1,4 +1,4 @@
/* Copyright (c) 2009,2011 Code Aurora Forum. All rights reserved.
/* Copyright (c) 2009,2011 The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@ -9,7 +9,7 @@
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of Code Aurora Forum, Inc. nor the names of its
* * Neither the name of The Linux Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*

View file

@ -1,4 +1,4 @@
/* Copyright (c) 2009,2011 Code Aurora Forum. All rights reserved.
/* Copyright (c) 2009,2011 The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@ -9,7 +9,7 @@
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of Code Aurora Forum, Inc. nor the names of its
* * Neither the name of The Linux Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*

View file

@ -1,4 +1,4 @@
/* Copyright (c) 2009,2011 Code Aurora Forum. All rights reserved.
/* Copyright (c) 2009,2011 The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@ -9,7 +9,7 @@
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of Code Aurora Forum, Inc. nor the names of its
* * Neither the name of The Linux Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*

View file

@ -1,4 +1,4 @@
/* Copyright (c) 2009,2011 Code Aurora Forum. All rights reserved.
/* Copyright (c) 2009,2011 The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@ -9,7 +9,7 @@
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of Code Aurora Forum, Inc. nor the names of its
* * Neither the name of The Linux Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*

View file

@ -1,4 +1,4 @@
/* Copyright (c) 2009,2011 Code Aurora Forum. All rights reserved.
/* Copyright (c) 2009,2011 The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@ -9,7 +9,7 @@
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of Code Aurora Forum, Inc. nor the names of its
* * Neither the name of The Linux Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*

38
loc_api/libloc_api_50001/Android.mk Executable file → Normal file
View file

@ -1,12 +1,6 @@
ifneq ($(BUILD_TINY_ANDROID),true)
#Compile this library only for builds with the latest modem image
BIT_ENABLED_BOARD_PLATFORM_LIST := msm7630_fusion
BIT_ENABLED_BOARD_PLATFORM_LIST += msm8660
ifeq ($(call is-board-platform-in-list,$(BIT_ENABLED_BOARD_PLATFORM_LIST)),true)
FEATURE_GNSS_BIT_API := true
endif # is-board-platform-in-list
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
@ -31,6 +25,14 @@ 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
LOCAL_C_INCLUDES:= \
$(TARGET_OUT_HEADERS)/gps.utils
@ -44,7 +46,8 @@ LOCAL_COPY_HEADERS:= \
loc_eng_agps.h \
loc_eng_msg.h \
loc_eng_msg_id.h \
loc_eng_log.h
loc_eng_log.h \
loc_ulp.h
LOCAL_PRELINK_MODULE := false
@ -61,19 +64,15 @@ LOCAL_SHARED_LIBRARIES := \
libcutils \
liblog \
libloc_adapter \
libgps.utils \
libdl
libgps.utils
LOCAL_SRC_FILES += \
loc_eng.cpp \
loc_eng_agps.cpp \
loc_eng_xtra.cpp \
loc_eng_ni.cpp \
loc_eng_log.cpp
ifeq ($(FEATURE_GNSS_BIT_API), true)
LOCAL_CFLAGS += -DFEATURE_GNSS_BIT_API
endif # FEATURE_GNSS_BIT_API
loc_eng_log.cpp \
loc_eng_nmea.cpp
LOCAL_SRC_FILES += \
loc_eng_dmn_conn.cpp \
@ -86,6 +85,10 @@ LOCAL_CFLAGS += \
-fno-short-enums \
-D_ANDROID_
ifeq ($(FEATURE_IPV6), true)
LOCAL_CFLAGS += -DFEATURE_IPV6
endif #FEATURE_IPV6
LOCAL_C_INCLUDES:= \
$(TARGET_OUT_HEADERS)/gps.utils \
hardware/qcom/gps/loc_api/ulp/inc
@ -118,9 +121,14 @@ LOCAL_CFLAGS += \
-fno-short-enums \
-D_ANDROID_ \
ifeq ($(FEATURE_IPV6), true)
LOCAL_CFLAGS += -DFEATURE_IPV6
endif #FEATURE_IPV6
## Includes
LOCAL_C_INCLUDES:= \
$(TARGET_OUT_HEADERS)/gps.utils
$(TARGET_OUT_HEADERS)/gps.utils \
hardware/qcom/gps/loc_api/ulp/inc
LOCAL_PRELINK_MODULE := false
LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/hw

View file

@ -1,4 +1,4 @@
/* Copyright (c) 2011, Code Aurora Forum. All rights reserved.
/* 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
@ -9,7 +9,7 @@
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of Code Aurora Forum, Inc. nor the names of its
* * Neither the name of The Linux Foundation, nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
@ -45,11 +45,13 @@ LocEng::LocEng(void* caller,
gps_acquire_wakelock acqwl,
gps_release_wakelock relwl,
loc_msg_sender msgSender,
loc_msg_sender msgUlpSender,
loc_ext_parser posParser,
loc_ext_parser svParser) :
owner(caller),
eventMask(emask), acquireWakelock(acqwl),
releaseWakeLock(relwl), sendMsge(msgSender),
sendUlpMsg(msgUlpSender),
extPosInfo(NULL == posParser ? noProc : posParser),
extSvInfo(NULL == svParser ? noProc : svParser)
{
@ -57,7 +59,7 @@ LocEng::LocEng(void* caller,
}
LocApiAdapter::LocApiAdapter(LocEng &locEng) :
locEngHandle(locEng)
locEngHandle(locEng), fixCriteria(), navigating(false)
{
LOC_LOGD("LocApiAdapter created");
}
@ -75,21 +77,14 @@ LocApiAdapter* LocApiAdapter::getLocApiAdapter(LocEng &locEng)
handle = dlopen ("libloc_api_v02.so", RTLD_NOW);
if (!handle) {
LOC_LOGI("%s: dlopen(libloc_api_v02.so) failed, trying to load libloc_api-rpc-qc.so", __FUNCTION__);
handle = dlopen ("libloc_api-rpc-qc.so", RTLD_NOW);
}
else
LOC_LOGE("%s: dlopen(libloc_api_v02.so) succeeded.", __FUNCTION__);
if (!handle) {
LOC_LOGI("%s: dlopen(libloc_api-rpc-qc.so) failed, constructing LocApiAdapter", __FUNCTION__);
adapter = new LocApiAdapter(locEng);
} else {
getLocApiAdapter_t* getHandle = (getLocApiAdapter_t*)dlsym(handle, "getLocApiAdapter");
if (!getHandle) {
LOC_LOGE("%s: dlsym(getLocApiAdapter) failed", __FUNCTION__);
return NULL;
}
adapter = (*getHandle)(locEng);
}
@ -141,21 +136,36 @@ int LocApiAdapter::decodeAddress(char *addr_string, int string_size,
return idxOutput;
}
void LocApiAdapter::reportPosition(GpsLocation &location,
void LocApiAdapter::reportPosition(UlpLocation &location,
GpsLocationExtended &locationExtended,
void* locationExt,
enum loc_sess_status status)
enum loc_sess_status status,
LocPosTechMask loc_technology_mask )
{
loc_eng_msg_report_position *msg(new loc_eng_msg_report_position(locEngHandle.owner,
location,
locationExtended,
locationExt,
status));
locEngHandle.sendMsge(locEngHandle.owner, msg);
status,
loc_technology_mask));
if (locEngHandle.sendUlpMsg) {
locEngHandle.sendUlpMsg(locEngHandle.owner, msg);
} else {
locEngHandle.sendMsge(locEngHandle.owner, msg);
}
}
void LocApiAdapter::reportSv(GpsSvStatus &svStatus, void* svExt)
void LocApiAdapter::reportSv(GpsSvStatus &svStatus, GpsLocationExtended &locationExtended, void* svExt)
{
loc_eng_msg_report_sv *msg(new loc_eng_msg_report_sv(locEngHandle.owner, svStatus, svExt));
locEngHandle.sendMsge(locEngHandle.owner, msg);
loc_eng_msg_report_sv *msg(new loc_eng_msg_report_sv(locEngHandle.owner, svStatus, locationExtended, svExt));
//We want to send SV info to ULP to help it in determining GNSS signal strength
//ULP will forward the SV reports to HAL without any modifications
if (locEngHandle.sendUlpMsg) {
locEngHandle.sendUlpMsg(locEngHandle.owner, msg);
} else {
locEngHandle.sendMsge(locEngHandle.owner, msg);
}
}
void LocApiAdapter::reportStatus(GpsStatusValue status)
@ -192,9 +202,9 @@ void LocApiAdapter::requestXtraData()
void LocApiAdapter::requestTime()
{
LOC_LOGD("loc_event_cb: XTRA time download request... not supported");
// loc_eng_msg *msg(new loc_eng_msg(locEngHandle.owner, LOC_ENG_MSG_REQUEST_TIME));
// locEngHandle.sendMsge(locEngHandle.owner, msg);
LOC_LOGD("loc_event_cb: XTRA time download request");
loc_eng_msg *msg(new loc_eng_msg(locEngHandle.owner, LOC_ENG_MSG_REQUEST_TIME));
locEngHandle.sendMsge(locEngHandle.owner, msg);
}
void LocApiAdapter::requestLocation()

View file

@ -1,4 +1,4 @@
/* Copyright (c) 2011, Code Aurora Forum. All rights reserved.
/* 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
@ -9,7 +9,7 @@
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of Code Aurora Forum, Inc. nor the names of its
* * Neither the name of The Linux Foundation, nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
@ -32,9 +32,13 @@
#include <ctype.h>
#include <hardware/gps.h>
#include <loc.h>
#include <loc_eng_log.h>
#include <log_util.h>
#include <loc_eng_msg.h>
#define MIN_POSSIBLE_FIX_INTERVAL 1000 /* msec */
#define MAX_APN_LEN 100
#define MAX_URL_LEN 256
#define smaller_of(a, b) (((a) > (b)) ? (b) : (a))
enum loc_api_adapter_err {
LOC_API_ADAPTER_ERR_SUCCESS = 0,
@ -85,6 +89,7 @@ struct LocEng {
const gps_acquire_wakelock acquireWakelock;
const gps_release_wakelock releaseWakeLock;
const loc_msg_sender sendMsge;
const loc_msg_sender sendUlpMsg;
const loc_ext_parser extPosInfo;
const loc_ext_parser extSvInfo;
@ -93,6 +98,7 @@ struct LocEng {
gps_acquire_wakelock acqwl,
gps_release_wakelock relwl,
loc_msg_sender msgSender,
loc_msg_sender msgUlpSender,
loc_ext_parser posParser,
loc_ext_parser svParser);
};
@ -100,6 +106,8 @@ struct LocEng {
class LocApiAdapter {
protected:
const LocEng locEngHandle;
LocPosMode fixCriteria;
bool navigating;
LocApiAdapter(LocEng &locEng);
@ -114,10 +122,14 @@ public:
static int decodeAddress(char *addr_string, int string_size,
const char *data, int data_size);
void reportPosition(GpsLocation &location,
void reportPosition(UlpLocation &location,
GpsLocationExtended &locationExtended,
void* locationExt,
enum loc_sess_status status);
void reportSv(GpsSvStatus &svStatus, void* svExt);
enum loc_sess_status status,
LocPosTechMask loc_technology_mask = LOC_POS_TECH_MASK_DEFAULT);
void reportSv(GpsSvStatus &svStatus,
GpsLocationExtended &locationExtended,
void* svExt);
void reportStatus(GpsStatusValue status);
void reportNmea(const char* nmea, int length);
void reportAgpsStatus(AGpsStatus &agpsStatus);
@ -159,7 +171,7 @@ public:
inline virtual enum loc_api_adapter_err
setXtraData(char* data, int length)
{LOC_LOGW("%s: default implementation invoked", __func__); return LOC_API_ADAPTER_ERR_SUCCESS;}
#ifdef QCOM_FEATURE_IPV6
#ifdef FEATURE_IPV6
inline virtual enum loc_api_adapter_err
atlOpenStatus(int handle, int is_succ, char* apn, AGpsBearerType bear, AGpsType agpsType)
{LOC_LOGW("%s: default implementation invoked", __func__); return LOC_API_ADAPTER_ERR_SUCCESS;}
@ -172,9 +184,7 @@ public:
atlCloseStatus(int handle, int is_succ)
{LOC_LOGW("%s: default implementation invoked", __func__); return LOC_API_ADAPTER_ERR_SUCCESS;}
inline virtual enum loc_api_adapter_err
setPositionMode(LocPositionMode mode, GpsPositionRecurrence recurrence,
uint32_t min_interval, uint32_t preferred_accuracy,
uint32_t preferred_time)
setPositionMode(const LocPosMode *posMode)
{LOC_LOGW("%s: default implementation invoked", __func__); return LOC_API_ADAPTER_ERR_SUCCESS;}
inline virtual enum loc_api_adapter_err
setServer(const char* url, int len)
@ -189,16 +199,37 @@ public:
inline virtual enum loc_api_adapter_err
setSUPLVersion(uint32_t version)
{LOC_LOGW("%s: default implementation invoked", __func__); return LOC_API_ADAPTER_ERR_SUCCESS;}
inline virtual enum loc_api_adapter_err
setLPPConfig(uint32_t profile)
{LOC_LOGW("%s: default implementation invoked", __func__);
return LOC_API_ADAPTER_ERR_SUCCESS; }
inline virtual enum loc_api_adapter_err
setSensorControlConfig(int sensorUsage)
{LOC_LOGW("%s: default implementation invoked", __func__); return LOC_API_ADAPTER_ERR_SUCCESS;}
inline virtual enum loc_api_adapter_err
setSensorProperties(float gyroBiasVarianceRandomWalk)
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)
{LOC_LOGW("%s: default implementation invoked", __func__); return LOC_API_ADAPTER_ERR_SUCCESS;}
inline virtual enum loc_api_adapter_err
setSensorPerfControlConfig(int controlMode, int accelSamplesPerBatch, int accelBatchesPerSec,
int gyroSamplesPerBatch, int gyroBatchesPerSec)
int gyroSamplesPerBatch, int gyroBatchesPerSec,
int accelSamplesPerBatchHigh, int accelBatchesPerSecHigh,
int gyroSamplesPerBatchHigh, int gyroBatchesPerSecHigh, int algorithmConfig)
{LOC_LOGW("%s: default implementation invoked", __func__); return LOC_API_ADAPTER_ERR_SUCCESS;}
inline virtual enum loc_api_adapter_err
setExtPowerConfig(int isBatteryCharging)
{LOC_LOGW("%s: default implementation invoked", __func__); return LOC_API_ADAPTER_ERR_SUCCESS;}
inline virtual enum loc_api_adapter_err
setAGLONASSProtocol(unsigned long aGlonassProtocol)
{LOC_LOGW("%s: default implementation invoked", __func__); return LOC_API_ADAPTER_ERR_SUCCESS;}
inline const LocPosMode& getPositionMode() const {return fixCriteria;}
inline bool isInSession() { return navigating; }
inline virtual void setInSession(bool inSession) { navigating = inSession; }
};
extern "C" LocApiAdapter* getLocApiAdapter(LocEng &locEng);

View file

@ -1,4 +1,4 @@
/* Copyright (c) 2011 Code Aurora Forum. All rights reserved.
/* Copyright (c) 2011 The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@ -9,7 +9,7 @@
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of Code Aurora Forum, Inc. nor the names of its
* * Neither the name of The Linux Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*

View file

@ -1,4 +1,4 @@
/* Copyright (c) 2011, Code Aurora Forum. All rights reserved.
/* Copyright (c) 2011-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
@ -9,7 +9,7 @@
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of Code Aurora Forum, Inc. nor the names of its
* * Neither the name of The Linux Foundation, nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
@ -31,16 +31,28 @@
#define LOG_TAG "LocSvc_afw"
#include <hardware/gps.h>
#include <dlfcn.h>
#include <loc_ulp.h>
#include <loc_eng.h>
#include <loc_target.h>
#include <loc_log.h>
#include <fcntl.h>
#include <errno.h>
#include <msg_q.h>
#include <dlfcn.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
#include <cutils/properties.h>
//Globals defns
static const ulpInterface * loc_eng_ulp_inf = NULL;
static const ulpInterface * loc_eng_get_ulp_inf(void);
static gps_location_callback gps_loc_cb = NULL;
static gps_sv_status_callback gps_sv_cb = NULL;
static void loc_cb(GpsLocation* location, void* locExt);
static void loc_cb(UlpLocation* location, void* locExt);
static void sv_cb(GpsSvStatus* sv_status, void* svExt);
static const GpsGeofencingInterface* get_geofence_interface(void);
@ -56,10 +68,19 @@ static void loc_delete_aiding_data(GpsAidingData f);
static int loc_set_position_mode(GpsPositionMode mode, GpsPositionRecurrence recurrence,
uint32_t min_interval, uint32_t preferred_accuracy,
uint32_t preferred_time);
//ULP/Hybrid provider Function definitions
static int loc_ulp_network_init(UlpNetworkLocationCallbacks *callbacks);
static int loc_ulp_send_network_position(UlpNetworkPositionReport *position_report);
static int loc_ulp_phone_context_init(UlpPhoneContextCallbacks *callback);
static int loc_ulp_phone_context_settings_update(UlpPhoneContextSettings *settings);
static int loc_ulp_engine_update_criteria(UlpLocationCriteria criteria);
static const void* loc_get_extension(const char* name);
#ifdef QCOM_FEATURE_ULP
static int loc_update_criteria(UlpLocationCriteria criteria);
#endif
static ulp_location_callback ulp_loc_cb = NULL;
static int loc_ulp_engine_init(UlpEngineCallbacks* callbacks);
static int loc_ulp_engine_start();
static int loc_ulp_engine_stop();
// Defines the GpsInterface in gps.h
static const GpsInterface sLocEngInterface =
@ -74,14 +95,11 @@ static const GpsInterface sLocEngInterface =
loc_delete_aiding_data,
loc_set_position_mode,
loc_get_extension
#ifdef QCOM_FEATURE_ULP
,loc_update_criteria
#endif
};
// Function declarations for sLocEngAGpsInterface
static void loc_agps_init(AGpsCallbacks* callbacks);
#ifdef QCOM_FEATURE_IPV6
#ifdef FEATURE_IPV6
static int loc_agps_open(AGpsType agpsType,
const char* apn, AGpsBearerType bearerType);
static int loc_agps_closed(AGpsType agpsType);
@ -141,7 +159,15 @@ static const AGpsRilInterface sLocEngAGpsRilInterface =
loc_agps_ril_update_network_availability
};
#ifdef QCOM_FEATURE_ULP
static const UlpEngineInterface sLocEngUlpEngInterface =
{
sizeof(UlpEngineInterface),
loc_ulp_engine_init,
loc_ulp_engine_update_criteria,
loc_ulp_engine_start,
loc_ulp_engine_stop
};
static bool loc_inject_raw_command(char* command, int length);
static const InjectRawCmdInterface sLocEngInjectRawCmdInterface =
@ -149,9 +175,23 @@ static const InjectRawCmdInterface sLocEngInjectRawCmdInterface =
sizeof(InjectRawCmdInterface),
loc_inject_raw_command
};
#endif
//ULP/Hybrid provider interfaces
static const UlpNetworkInterface sUlpNetworkInterface =
{
sizeof(UlpNetworkInterface),
loc_ulp_network_init,
loc_ulp_send_network_position
};
static const UlpPhoneContextInterface sLocEngUlpPhoneContextInterface =
{
sizeof(UlpPhoneContextInterface),
loc_ulp_phone_context_init,
loc_ulp_phone_context_settings_update
};
static loc_eng_data_s_type loc_afw_data;
static UlpCallbacks ulp_cb_data;
static int gss_fd = 0;
/*===========================================================================
@ -195,20 +235,43 @@ const GpsInterface* gps_get_hardware_interface ()
// for gps.c
extern "C" const GpsInterface* get_gps_interface()
{
char baseband[PROPERTY_VALUE_MAX];
property_get("ro.baseband", baseband, "msm");
if (strcmp(baseband,"apq") == 0)
{
targetEnumType target = TARGET_OTHER;
loc_eng_read_config();
//We load up libulp module at this point itself
loc_eng_ulp_inf = loc_eng_get_ulp_inf();
target = get_target();
LOC_LOGD("Target name check returned %s", loc_get_target_name(target));
//APQ8064 and APQ8030
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);
}
LOC_LOGD("GSS open success! CAPABILITIES %0x\n", gps_conf.CAPABILITIES);
}
//MPQ8064
else if(target == TARGET_MPQ8064) {
LOC_LOGE("No GPS HW on this target (MPQ8064). Not returning interface");
return NULL;
}
return &sLocEngInterface;
}
static void loc_free_msg(void* msg)
{
delete (loc_eng_msg*)msg;
}
void loc_ulp_msg_sender(void* loc_eng_data_p, void* msg)
{
LocEngContext* loc_eng_context = (LocEngContext*)((loc_eng_data_s_type*)loc_eng_data_p)->context;
msg_q_snd((void*)loc_eng_context->ulp_q, msg, loc_free_msg);
}
/*===========================================================================
FUNCTION loc_init
@ -228,7 +291,13 @@ SIDE EFFECTS
===========================================================================*/
static int loc_init(GpsCallbacks* callbacks)
{
int retVal = -1;
ENTRY_LOG();
if(callbacks == NULL) {
LOC_LOGE("loc_init failed. cb = NULL\n");
EXIT_LOG(%d, retVal);
return retVal;
}
LOC_API_ADAPTER_EVENT_MASK_T event =
LOC_API_ADAPTER_BIT_PARSED_POSITION_REPORT |
LOC_API_ADAPTER_BIT_SATELLITE_REPORT |
@ -247,14 +316,36 @@ static int loc_init(GpsCallbacks* callbacks)
callbacks->release_wakelock_cb, /* release_wakelock_cb */
callbacks->create_thread_cb, /* create_thread_cb */
NULL, /* location_ext_parser */
NULL /* sv_ext_parser */};
NULL, /* sv_ext_parser */
callbacks->request_utc_time_cb /* request_utc_time_cb */};
gps_loc_cb = callbacks->location_cb;
gps_sv_cb = callbacks->sv_status_cb;
int ret_val = loc_eng_init(loc_afw_data, &clientCallbacks, event);
if (loc_eng_ulp_inf == NULL)
retVal = loc_eng_init(loc_afw_data, &clientCallbacks, event,
NULL);
else
retVal = loc_eng_init(loc_afw_data, &clientCallbacks, event,
loc_ulp_msg_sender);
EXIT_LOG(%d, ret_val);
return ret_val;
if (ulp_cb_data.phone_context_cb) {
//ULP initilization already occurred so redo intializations here
//to restore callback table
loc_eng_ulp_phone_context_init(loc_afw_data, ulp_cb_data.phone_context_cb);
}
if (ulp_cb_data.network_location_cb) {
loc_eng_ulp_network_init(loc_afw_data, ulp_cb_data.network_location_cb);
}
int ret_val1 = loc_eng_ulp_init(loc_afw_data, loc_eng_ulp_inf);
//Initialize the cached min_interval
loc_afw_data.min_interval_cached = ULP_MIN_INTERVAL_INVALID;
LOC_LOGD("loc_eng_ulp_init returned %d\n",ret_val1);
EXIT_LOG(%d, retVal);
return retVal;
}
/*===========================================================================
@ -279,6 +370,15 @@ static void loc_cleanup()
loc_eng_cleanup(loc_afw_data);
gps_loc_cb = NULL;
gps_sv_cb = NULL;
/*
* if (get_target() == TARGET_NAME_APQ8064_STANDALONE)
* {
* close(gss_fd);
* LOC_LOGD("GSS shutdown.\n");
* }
*/
EXIT_LOG(%s, VOID_RET);
}
@ -326,8 +426,27 @@ SIDE EFFECTS
static int loc_stop()
{
ENTRY_LOG();
int ret_val = loc_eng_stop(loc_afw_data);
int ret_val = -1;
if (loc_afw_data.ulp_initialized) {
//ULP initialized so we need to simulate REMOVE_CRITERIA for
//last client to libulp and we dont need to send loc_eng_stop
UlpLocationCriteria native_criteria;
native_criteria.valid_mask = (ULP_CRITERIA_HAS_ACTION | ULP_CRITERIA_HAS_PROVIDER_SOURCE | ULP_CRITERIA_HAS_RECURRENCE_TYPE |
ULP_CRITERIA_HAS_MIN_INTERVAL);
native_criteria.provider_source = ULP_PROVIDER_SOURCE_GNSS;
native_criteria.min_distance = 0; //This is not used by ULP engine so leaving it 0 for now
native_criteria.recurrence_type = loc_afw_data.recurrence_type_cached;
loc_afw_data.recurrence_type_cached = ULP_LOC_RECURRENCE_PERIODIC;
//For a GPS client horizontal_accuracy & power_consumption are irrelevant
native_criteria.preferred_horizontal_accuracy = ULP_HORZ_ACCURACY_DONT_CARE;
native_criteria.preferred_power_consumption = ULP_POWER_REQ_DONT_CARE;
native_criteria.action = ULP_REMOVE_CRITERIA;
native_criteria.min_interval = loc_afw_data.min_interval_cached;
loc_afw_data.min_interval_cached = ULP_MIN_INTERVAL_INVALID;
ret_val = loc_eng_update_criteria(loc_afw_data, native_criteria);
} else {
ret_val = loc_eng_stop(loc_afw_data);
}
EXIT_LOG(%d, ret_val);
return ret_val;
}
@ -355,21 +474,46 @@ static int loc_set_position_mode(GpsPositionMode mode,
uint32_t preferred_time)
{
ENTRY_LOG();
LocPositionMode locMode;
switch (mode) {
case GPS_POSITION_MODE_MS_BASED:
locMode = LOC_POSITION_MODE_MS_BASED;
break;
case GPS_POSITION_MODE_MS_ASSISTED:
locMode = LOC_POSITION_MODE_MS_ASSISTED;
break;
default:
locMode = LOC_POSITION_MODE_STANDALONE;
break;
int ret_val = -1;
if (!loc_afw_data.ulp_initialized) {
LocPositionMode locMode;
switch (mode) {
case GPS_POSITION_MODE_MS_BASED:
locMode = LOC_POSITION_MODE_MS_BASED;
break;
case GPS_POSITION_MODE_MS_ASSISTED:
locMode = LOC_POSITION_MODE_MS_ASSISTED;
break;
default:
locMode = LOC_POSITION_MODE_STANDALONE;
break;
}
LocPosMode params(locMode, recurrence, min_interval,
preferred_accuracy, preferred_time, NULL, NULL);
ret_val = loc_eng_set_position_mode(loc_afw_data, params);
} else {
//ULP initialized so suppress set_position_mode updates to loc_eng
UlpLocationCriteria native_criteria;
native_criteria.valid_mask = (ULP_CRITERIA_HAS_ACTION | ULP_CRITERIA_HAS_PROVIDER_SOURCE | ULP_CRITERIA_HAS_RECURRENCE_TYPE |
ULP_CRITERIA_HAS_MIN_INTERVAL);
native_criteria.provider_source = ULP_PROVIDER_SOURCE_GNSS;
native_criteria.min_distance = 0; //This is not used by ULP engine so leaving it 0 for now
if (LOC_POSITION_MODE_MS_ASSISTED == mode)
native_criteria.recurrence_type = ULP_LOC_RECURRENCE_SINGLE;
else
native_criteria.recurrence_type = ULP_LOC_RECURRENCE_PERIODIC;
//For a GPS client horizontal_accuracy & power_consumption are irrelevant
native_criteria.preferred_horizontal_accuracy = ULP_HORZ_ACCURACY_DONT_CARE;
native_criteria.preferred_power_consumption = ULP_POWER_REQ_DONT_CARE;
native_criteria.action = ULP_ADD_CRITERIA;
native_criteria.min_interval = min_interval;
loc_afw_data.min_interval_cached = min_interval; //cache a copy
loc_afw_data.recurrence_type_cached = native_criteria.recurrence_type; //cache a copy
ret_val = loc_eng_update_criteria(loc_afw_data, native_criteria);
}
int ret_val = loc_eng_set_position_mode(loc_afw_data, locMode,
recurrence, min_interval,
preferred_accuracy, preferred_time);
EXIT_LOG(%d, ret_val);
return ret_val;
@ -395,7 +539,6 @@ static int loc_inject_time(GpsUtcTime time, int64_t timeReference, int uncertain
{
ENTRY_LOG();
int ret_val = loc_eng_inject_time(loc_afw_data, time, timeReference, uncertainty);
EXIT_LOG(%d, ret_val);
return ret_val;
}
@ -419,9 +562,32 @@ SIDE EFFECTS
===========================================================================*/
static int loc_inject_location(double latitude, double longitude, float accuracy)
{
static bool initialized = false;
static bool enable_cpi = true;
ENTRY_LOG();
int ret_val = loc_eng_inject_location(loc_afw_data, latitude, longitude, accuracy);
if(!initialized)
{
char value[PROPERTY_VALUE_MAX];
memset(value, 0, sizeof(value));
(void)property_get("persist.gps.qc_nlp_in_use", value, "0");
if(0 == strcmp(value, "1"))
{
enable_cpi = false;
LOC_LOGI("GPS HAL coarse position injection disabled");
}
else
{
LOC_LOGI("GPS HAL coarse position injection enabled");
}
initialized = true;
}
int ret_val = 0;
if(enable_cpi)
{
ret_val = loc_eng_inject_location(loc_afw_data, latitude, longitude, accuracy);
}
EXIT_LOG(%d, ret_val);
return ret_val;
}
@ -455,7 +621,6 @@ static void loc_delete_aiding_data(GpsAidingData f)
EXIT_LOG(%s, VOID_RET);
}
#ifdef QCOM_FEATURE_ULP
/*===========================================================================
FUNCTION loc_update_criteria
@ -472,7 +637,7 @@ SIDE EFFECTS
N/A
===========================================================================*/
static int loc_update_criteria(UlpLocationCriteria criteria)
int loc_ulp_engine_update_criteria(UlpLocationCriteria criteria)
{
ENTRY_LOG();
int ret_val = loc_eng_update_criteria(loc_afw_data, criteria);
@ -480,7 +645,6 @@ static int loc_update_criteria(UlpLocationCriteria criteria)
EXIT_LOG(%d, ret_val);
return ret_val;
}
#endif
const GpsGeofencingInterface* get_geofence_interface(void)
{
@ -532,11 +696,12 @@ SIDE EFFECTS
N/A
===========================================================================*/
static const void* loc_get_extension(const char* name)
const void* loc_get_extension(const char* name)
{
ENTRY_LOG();
const void* ret_val = NULL;
LOC_LOGD("%s:%d] For Interface = %s\n",__func__, __LINE__, name);
if (strcmp(name, GPS_XTRA_INTERFACE) == 0)
{
ret_val = &sLocEngXTRAInterface;
@ -554,24 +719,38 @@ static const void* loc_get_extension(const char* name)
else if (strcmp(name, AGPS_RIL_INTERFACE) == 0)
{
ret_val = &sLocEngAGpsRilInterface;
char baseband[PROPERTY_VALUE_MAX];
property_get("ro.baseband", baseband, "msm");
if (strcmp(baseband, "csfb") == 0)
{
ret_val = &sLocEngAGpsRilInterface;
}
}
else if (strcmp(name, GPS_GEOFENCING_INTERFACE) == 0)
else if (strcmp(name, ULP_ENGINE_INTERFACE) == 0)
{
ret_val = get_geofence_interface();
ret_val = &sLocEngUlpEngInterface;
}
#ifdef QCOM_FEATURE_ULP
else if (strcmp(name, ULP_RAW_CMD_INTERFACE) == 0)
{
ret_val = &sLocEngInjectRawCmdInterface;
}
#endif
else if(strcmp(name, ULP_PHONE_CONTEXT_INTERFACE) == 0)
{
ret_val = &sLocEngUlpPhoneContextInterface;
}
else if(strcmp(name, ULP_NETWORK_INTERFACE) == 0)
{
ret_val = &sUlpNetworkInterface;
}
else if (strcmp(name, GPS_GEOFENCING_INTERFACE) == 0)
{
ret_val = get_geofence_interface();
}
else
{
LOC_LOGE ("get_extension: Invalid interface passed in\n");
}
EXIT_LOG(%p, ret_val);
return ret_val;
}
@ -616,7 +795,7 @@ SIDE EFFECTS
N/A
===========================================================================*/
#ifdef QCOM_FEATURE_IPV6
#ifdef FEATURE_IPV6
static int loc_agps_open(AGpsType agpsType,
const char* apn, AGpsBearerType bearerType)
{
@ -654,7 +833,7 @@ SIDE EFFECTS
N/A
===========================================================================*/
#ifdef QCOM_FEATURE_IPV6
#ifdef FEATURE_IPV6
static int loc_agps_closed(AGpsType agpsType)
{
ENTRY_LOG();
@ -691,7 +870,7 @@ SIDE EFFECTS
N/A
===========================================================================*/
#ifdef QCOM_FEATURE_IPV6
#ifdef FEATURE_IPV6
int loc_agps_open_failed(AGpsType agpsType)
{
ENTRY_LOG();
@ -875,7 +1054,6 @@ static void loc_agps_ril_update_network_availability(int available, const char*
EXIT_LOG(%s, VOID_RET);
}
#ifdef QCOM_FEATURE_ULP
/*===========================================================================
FUNCTION loc_inject_raw_command
@ -899,19 +1077,21 @@ static bool loc_inject_raw_command(char* command, int length)
EXIT_LOG(%s, loc_logger_boolStr[ret_val!=0]);
return ret_val;
}
#endif
static void loc_cb(GpsLocation* location, void* locExt)
static void loc_cb(UlpLocation* location, void* locExt)
{
ENTRY_LOG();
if (NULL != gps_loc_cb && NULL != location) {
#ifdef QCOM_FEATURE_ULP
if (NULL != location) {
CALLBACK_LOG_CALLFLOW("location_cb - from", %d, location->position_source);
#else
CALLBACK_LOG_CALLFLOW("location_cb - at", %llu, location->timestamp);
#endif
gps_loc_cb(location);
if (ULP_LOCATION_IS_FROM_GNSS == location->position_source ) {
if (NULL != gps_loc_cb) {
gps_loc_cb(&location->gpsLocation);
}
} else {
if (NULL != ulp_loc_cb) {
ulp_loc_cb(location);
}
}
}
EXIT_LOG(%s, VOID_RET);
}
@ -925,3 +1105,219 @@ static void sv_cb(GpsSvStatus* sv_status, void* svExt)
}
EXIT_LOG(%s, VOID_RET);
}
/*===========================================================================
FUNCTION loc_eng_get_ulp_inf
DESCRIPTION
This function checks if ULP is enabled, and loads the libulp2.so and
returns its interface
DEPENDENCIES
None
RETURN VALUE
interface pointer to libulp: no error
NULL: errors
SIDE EFFECTS
N/A
===========================================================================*/
const ulpInterface * loc_eng_get_ulp_inf(void)
{
ENTRY_LOG();
void *handle;
const char *error;
get_ulp_interface* get_ulp_inf;
const ulpInterface* loc_eng_ulpInf = NULL;
dlerror(); /* Clear any existing error */
handle = dlopen ("libulp2.so", RTLD_NOW);
if (!handle)
{
if ((error = dlerror()) != NULL) {
LOC_LOGE ("%s, dlopen for libulp.so failed, error = %s\n", __func__, error);
}
goto exit;
}
dlerror(); /* Clear any existing error */
get_ulp_inf = (get_ulp_interface*) dlsym(handle, "ulp_get_interface");
if ((error = dlerror()) != NULL) {
LOC_LOGE ("%s, dlsym for ulpInterface failed, error = %s\n", __func__, error);
goto exit;
}
// Initialize the ULP interface
loc_eng_ulpInf = get_ulp_inf();
exit:
EXIT_LOG(%d, loc_eng_ulpInf == NULL);
return loc_eng_ulpInf;
}
/*===========================================================================
FUNCTION loc_ulp_network_init
DESCRIPTION
Initialize the ULP network interface.
DEPENDENCIES
NONE
RETURN VALUE
0
SIDE EFFECTS
N/A
===========================================================================*/
static int loc_ulp_phone_context_init(UlpPhoneContextCallbacks *callbacks)
{
ENTRY_LOG();
int ret_val = -1;
if (loc_afw_data.context) {
ret_val = loc_eng_ulp_phone_context_init(loc_afw_data, callbacks);
} else
{
ulp_cb_data.phone_context_cb = callbacks;
}
EXIT_LOG(%d, ret_val);
return ret_val;
}
/*===========================================================================
FUNCTION loc_ulp_phone_context_settings_update
DESCRIPTION
This is used to inform the ULP module of phone settings changes carried out
by the users
DEPENDENCIES
N/A
RETURN VALUE
0: success
SIDE EFFECTS
N/A
===========================================================================*/
static int loc_ulp_phone_context_settings_update(UlpPhoneContextSettings *settings)
{
ENTRY_LOG();
int ret_val = -1;
ret_val = loc_eng_ulp_phone_context_settings_update(loc_afw_data, settings);
EXIT_LOG(%d, ret_val);
return ret_val;
}
/*===========================================================================
FUNCTION loc_ulp_network_init
DESCRIPTION
Initialize the ULP network interface.
DEPENDENCIES
NONE
RETURN VALUE
0
SIDE EFFECTS
N/A
===========================================================================*/
static int loc_ulp_network_init(UlpNetworkLocationCallbacks *callbacks)
{
ENTRY_LOG();
int ret_val = -1;
if (loc_afw_data.context) {
ret_val = loc_eng_ulp_network_init(loc_afw_data, callbacks);
} else
{
ulp_cb_data.network_location_cb = callbacks;
}
EXIT_LOG(%d, ret_val);
return ret_val;
}
/*===========================================================================
FUNCTION loc_eng_ulp_send_network_position
DESCRIPTION
Ulp send data
DEPENDENCIES
NONE
RETURN VALUE
0
SIDE EFFECTS
N/A
===========================================================================*/
int loc_ulp_send_network_position(UlpNetworkPositionReport *position_report)
{
ENTRY_LOG();
int ret_val = -1;
ret_val = loc_eng_ulp_send_network_position(loc_afw_data, position_report);
EXIT_LOG(%d, ret_val);
return ret_val;
}
/*===========================================================================
FUNCTION loc_ulp_engine_init
DESCRIPTION
Initialize the ULP Engine interface.
DEPENDENCIES
NONE
RETURN VALUE
0
SIDE EFFECTS
N/A
===========================================================================*/
static int loc_ulp_engine_init(UlpEngineCallbacks* callbacks)
{
int retVal = -1;
ENTRY_LOG();
if(callbacks == NULL) {
LOC_LOGE("loc_ulp_engine_init failed. cb = NULL\n");
EXIT_LOG(%d, retVal);
return retVal;
}
//Intilize the ulp call back cache at this point
memset(&ulp_cb_data, 0, sizeof(UlpCallbacks));
ulp_loc_cb = callbacks->location_cb;
retVal = 0;
EXIT_LOG(%d, retVal);
return retVal;
}
static int loc_ulp_engine_start()
{
ENTRY_LOG();
int ret_val = loc_eng_start(loc_afw_data);
EXIT_LOG(%d, ret_val);
return ret_val;
}
static int loc_ulp_engine_stop()
{
ENTRY_LOG();
int ret_val = loc_eng_stop(loc_afw_data);
EXIT_LOG(%d, ret_val);
return ret_val;
}

View file

@ -1,4 +1,4 @@
/* Copyright (c) 2011, Code Aurora Forum. All rights reserved.
/* 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
@ -9,7 +9,7 @@
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of Code Aurora Forum, Inc. nor the names of its
* * Neither the name of The Linux Foundation, nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
@ -37,6 +37,9 @@ extern "C" {
#include <ctype.h>
#include <cutils/properties.h>
#include <hardware/gps.h>
#include <loc_ulp.h>
#define MIN_POSSIBLE_FIX_INTERVAL 1000 /* msec */
typedef enum loc_server_type {
LOC_AGPS_CDMA_PDE_SERVER,
@ -52,10 +55,11 @@ typedef enum loc_position_mode_type {
LOC_POSITION_MODE_RESERVED_1,
LOC_POSITION_MODE_RESERVED_2,
LOC_POSITION_MODE_RESERVED_3,
LOC_POSITION_MODE_RESERVED_4
LOC_POSITION_MODE_RESERVED_4,
LOC_POSITION_MODE_RESERVED_5
} LocPositionMode;
typedef void (*loc_location_cb_ext) (GpsLocation* location, void* locExt);
typedef void (*loc_location_cb_ext) (UlpLocation* location, void* locExt);
typedef void (*loc_sv_status_cb_ext) (GpsSvStatus* sv_status, void* svExt);
typedef void* (*loc_ext_parser)(void* data);
@ -70,14 +74,30 @@ typedef struct {
gps_create_thread create_thread_cb;
loc_ext_parser location_ext_parser;
loc_ext_parser sv_ext_parser;
gps_request_utc_time request_utc_time_cb;
} LocCallbacks;
typedef struct {
UlpNetworkLocationCallbacks* network_location_cb;
UlpPhoneContextCallbacks* phone_context_cb;
} UlpCallbacks;
enum loc_sess_status {
LOC_SESS_SUCCESS,
LOC_SESS_INTERMEDIATE,
LOC_SESS_FAILURE
};
typedef uint32_t LocPosTechMask;
#define LOC_POS_TECH_MASK_DEFAULT ((LocPosTechMask)0x00000000)
#define LOC_POS_TECH_MASK_SATELLITE ((LocPosTechMask)0x00000001)
#define LOC_POS_TECH_MASK_CELLID ((LocPosTechMask)0x00000002)
#define LOC_POS_TECH_MASK_WIFI ((LocPosTechMask)0x00000004)
#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)
void loc_ulp_msg_sender(void* loc_eng_data_p, void* msg);
#ifdef __cplusplus
}

File diff suppressed because it is too large Load diff

View file

@ -1,4 +1,4 @@
/* Copyright (c) 2009,2011 Code Aurora Forum. All rights reserved.
/* Copyright (c) 2009-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
@ -9,7 +9,7 @@
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of Code Aurora Forum, Inc. nor the names of its
* * Neither the name of The Linux Foundation, nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
@ -36,6 +36,7 @@ extern "C" {
// Uncomment to keep all LOG messages (LOGD, LOGI, LOGV, etc.)
#define MAX_NUM_ATL_CONNECTIONS 2
// Define boolean type to be used by libgps on loc api module
typedef unsigned char boolean;
@ -67,9 +68,10 @@ typedef unsigned char boolean;
#define FAILURE FALSE
#define INVALID_ATL_CONNECTION_HANDLE -1
#define MAX_APN_LEN 100
#define MAX_URL_LEN 256
#define smaller_of(a, b) (((a) > (b)) ? (b) : (a))
enum loc_nmea_provider_e_type {
NMEA_PROVIDER_AP = 0, // Application Processor Provider of NMEA
NMEA_PROVIDER_MP // Modem Processor Provider of NMEA
};
enum loc_mute_session_e_type {
LOC_MUTE_SESS_NONE = 0,
@ -77,6 +79,21 @@ enum loc_mute_session_e_type {
LOC_MUTE_SESS_IN_SESSION
};
struct LocEngContext {
// Data variables used by deferred action thread
const void* deferred_q;
const void* ulp_q;
const pthread_t deferred_action_thread;
static LocEngContext* get(gps_create_thread threadCreator);
void drop();
static pthread_mutex_t lock;
static pthread_cond_t cond;
private:
int counter;
static LocEngContext *me;
LocEngContext(gps_create_thread threadCreator);
};
// Module data
typedef struct
{
@ -89,6 +106,9 @@ typedef struct
gps_ni_notify_callback ni_notify_cb;
gps_acquire_wakelock acquire_wakelock_cb;
gps_release_wakelock release_wakelock_cb;
gps_request_utc_time request_utc_time_cb;
ulp_network_location_request ulp_network_callback;
ulp_request_phone_context ulp_phone_context_req_cb;
boolean intermediateFix;
AGpsStatusValue agps_status;
// used to defer stopping the GPS engine until AGPS data calls are done
@ -97,11 +117,10 @@ typedef struct
loc_eng_xtra_data_s_type xtra_module_data;
loc_eng_ni_data_s_type loc_eng_ni_data;
boolean navigating;
// AGPS state machines
AgpsStateMachine* agnss_nif;
AgpsStateMachine* internet_nif;
AgpsStateMachine* wifi_nif;
// GPS engine status
GpsStatusValue engine_status;
@ -112,11 +131,16 @@ typedef struct
void* context;
loc_eng_msg_position_mode position_mode;
// For muting session broadcast
loc_mute_session_e_type mute_session_state;
// For nmea generation
boolean generateNmea;
uint32_t sv_used_mask;
float hdop;
float pdop;
float vdop;
// Address buffers, for addressing setting before init
int supl_host_set;
char supl_host_buf[101];
@ -127,12 +151,60 @@ typedef struct
int mpc_host_set;
char mpc_host_buf[101];
int mpc_port_buf;
bool ulp_initialized;
uint32_t min_interval_cached;
UlpRecurrenceCriteria recurrence_type_cached;
} loc_eng_data_s_type;
#include "ulp.h"
/* GPS.conf support */
typedef struct loc_gps_cfg_s
{
unsigned long INTERMEDIATE_POS;
unsigned long ACCURACY_THRES;
unsigned long ENABLE_WIPER;
unsigned long SUPL_VER;
unsigned long CAPABILITIES;
unsigned long QUIPC_ENABLED;
unsigned long LPP_PROFILE;
uint8_t NMEA_PROVIDER;
unsigned long A_GLONASS_POS_PROTOCOL_SELECT;
} loc_gps_cfg_s_type;
typedef struct
{
uint8_t GYRO_BIAS_RANDOM_WALK_VALID;
double GYRO_BIAS_RANDOM_WALK;
unsigned long SENSOR_ACCEL_BATCHES_PER_SEC;
unsigned long SENSOR_ACCEL_SAMPLES_PER_BATCH;
unsigned long SENSOR_GYRO_BATCHES_PER_SEC;
unsigned long SENSOR_GYRO_SAMPLES_PER_BATCH;
unsigned long SENSOR_ACCEL_BATCHES_PER_SEC_HIGH;
unsigned long SENSOR_ACCEL_SAMPLES_PER_BATCH_HIGH;
unsigned long SENSOR_GYRO_BATCHES_PER_SEC_HIGH;
unsigned long SENSOR_GYRO_SAMPLES_PER_BATCH_HIGH;
unsigned long SENSOR_CONTROL_MODE;
unsigned long SENSOR_USAGE;
unsigned long SENSOR_ALGORITHM_CONFIG_MASK;
uint8_t ACCEL_RANDOM_WALK_SPECTRAL_DENSITY_VALID;
double ACCEL_RANDOM_WALK_SPECTRAL_DENSITY;
uint8_t ANGLE_RANDOM_WALK_SPECTRAL_DENSITY_VALID;
double ANGLE_RANDOM_WALK_SPECTRAL_DENSITY;
uint8_t RATE_RANDOM_WALK_SPECTRAL_DENSITY_VALID;
double RATE_RANDOM_WALK_SPECTRAL_DENSITY;
uint8_t VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY_VALID;
double VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY;
} loc_sap_cfg_s_type;
extern loc_gps_cfg_s_type gps_conf;
extern loc_sap_cfg_s_type sap_conf;
int loc_eng_init(loc_eng_data_s_type &loc_eng_data,
LocCallbacks* callbacks,
LOC_API_ADAPTER_EVENT_MASK_T event);
LOC_API_ADAPTER_EVENT_MASK_T event,
void (*loc_external_msg_sender) (void*, void*));
int loc_eng_ulp_init(loc_eng_data_s_type &loc_eng_data, const ulpInterface * loc_eng_ulpInf);
int loc_eng_start(loc_eng_data_s_type &loc_eng_data);
int loc_eng_stop(loc_eng_data_s_type &loc_eng_data);
void loc_eng_cleanup(loc_eng_data_s_type &loc_eng_data);
@ -145,19 +217,15 @@ int loc_eng_inject_location(loc_eng_data_s_type &loc_eng_data,
void loc_eng_delete_aiding_data(loc_eng_data_s_type &loc_eng_data,
GpsAidingData f);
int loc_eng_set_position_mode(loc_eng_data_s_type &loc_eng_data,
LocPositionMode mode, GpsPositionRecurrence recurrence,
uint32_t min_interval, uint32_t preferred_accuracy,
uint32_t preferred_time);
LocPosMode &params);
const void* loc_eng_get_extension(loc_eng_data_s_type &loc_eng_data,
const char* name);
#ifdef QCOM_FEATURE_ULP
int loc_eng_update_criteria(loc_eng_data_s_type &loc_eng_data,
UlpLocationCriteria criteria);
#endif
void loc_eng_agps_init(loc_eng_data_s_type &loc_eng_data,
AGpsCallbacks* callbacks);
#ifdef QCOM_FEATURE_IPV6
#ifdef FEATURE_IPV6
int loc_eng_agps_open(loc_eng_data_s_type &loc_eng_data, AGpsType agpsType,
const char* apn, AGpsBearerType bearerType);
int loc_eng_agps_closed(loc_eng_data_s_type &loc_eng_data, AGpsType agpsType);
@ -196,7 +264,15 @@ extern void loc_eng_ni_request_handler(loc_eng_data_s_type &loc_eng_data,
const GpsNiNotification *notif,
const void* passThrough);
extern void loc_eng_ni_reset_on_engine_restart(loc_eng_data_s_type &loc_eng_data);
int loc_eng_ulp_network_init(loc_eng_data_s_type &loc_eng_data, UlpNetworkLocationCallbacks *callbacks);
int loc_eng_ulp_phone_context_settings_update(loc_eng_data_s_type &loc_eng_data,
UlpPhoneContextSettings *settings);
int loc_eng_ulp_phone_context_init(loc_eng_data_s_type &loc_eng_data,
UlpPhoneContextCallbacks *callback);
int loc_eng_ulp_send_network_position(loc_eng_data_s_type &loc_eng_data,
UlpNetworkPositionReport *position_report);
int loc_eng_read_config(void);
#ifdef __cplusplus
}
#endif /* __cplusplus */

View file

@ -1,4 +1,4 @@
/* Copyright (c) 2011, Code Aurora Forum. All rights reserved.
/* 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
@ -9,7 +9,7 @@
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of Code Aurora Forum, Inc. nor the names of its
* * Neither the name of The Linux Foundation, nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
@ -87,7 +87,7 @@ const int Notification::BROADCAST_INACTIVE = 0x80000002;
//======================================================================
// Subscriber: BITSubscriber / ATLSubscriber
// Subscriber: BITSubscriber / ATLSubscriber / WIFISubscriber
//======================================================================
bool Subscriber::forMe(Notification &notification)
{
@ -120,14 +120,17 @@ bool BITSubscriber::notifyRsrcStatus(Notification &notification)
case RSRC_UNSUBSCRIBE:
case RSRC_RELEASED:
loc_eng_dmn_conn_loc_api_server_data_conn(
LOC_ENG_IF_REQUEST_SENDER_ID_GPSONE_DAEMON,
GPSONE_LOC_API_IF_RELEASE_SUCCESS);
break;
case RSRC_DENIED:
loc_eng_dmn_conn_loc_api_server_data_conn(
LOC_ENG_IF_REQUEST_SENDER_ID_GPSONE_DAEMON,
GPSONE_LOC_API_IF_FAILURE);
break;
case RSRC_GRANTED:
loc_eng_dmn_conn_loc_api_server_data_conn(
LOC_ENG_IF_REQUEST_SENDER_ID_GPSONE_DAEMON,
GPSONE_LOC_API_IF_REQUEST_SUCCESS);
break;
default:
@ -150,20 +153,38 @@ bool ATLSubscriber::notifyRsrcStatus(Notification &notification)
((LocApiAdapter*)mLocAdapter)->atlCloseStatus(ID, 1);
break;
case RSRC_DENIED:
{
#ifdef FEATURE_IPV6
AGpsType type = mBackwardCompatibleMode ?
AGPS_TYPE_INVALID : mStateMachine->getType();
((LocApiAdapter*)mLocAdapter)->atlOpenStatus(ID, 0,
(char*)mStateMachine->getAPN(),
#ifdef QCOM_FEATURE_IPV6
mStateMachine->getBearer(),
type);
#else
AGpsType type = mStateMachine->getType();
((LocApiAdapter*)mLocAdapter)->atlOpenStatus(ID, 0,
(char*)mStateMachine->getAPN(),
type);
#endif
mStateMachine->getType());
}
break;
case RSRC_GRANTED:
{
#ifdef FEATURE_IPV6
AGpsType type = mBackwardCompatibleMode ?
AGPS_TYPE_INVALID : mStateMachine->getType();
((LocApiAdapter*)mLocAdapter)->atlOpenStatus(ID, 1,
(char*)mStateMachine->getAPN(),
#ifdef QCOM_FEATURE_IPV6
mStateMachine->getBearer(),
type);
#else
AGpsType type = mStateMachine->getType();
((LocApiAdapter*)mLocAdapter)->atlOpenStatus(ID, 1,
(char*)mStateMachine->getAPN(),
type);
#endif
mStateMachine->getType());
}
break;
default:
notify = false;
@ -173,6 +194,39 @@ bool ATLSubscriber::notifyRsrcStatus(Notification &notification)
return notify;
}
#ifdef FEATURE_IPV6
bool WIFISubscriber::notifyRsrcStatus(Notification &notification)
{
bool notify = forMe(notification);
if (notify) {
switch(notification.rsrcStatus)
{
case RSRC_UNSUBSCRIBE:
break;
case RSRC_RELEASED:
loc_eng_dmn_conn_loc_api_server_data_conn(
senderId,
GPSONE_LOC_API_IF_RELEASE_SUCCESS);
break;
case RSRC_DENIED:
loc_eng_dmn_conn_loc_api_server_data_conn(
senderId,
GPSONE_LOC_API_IF_FAILURE);
break;
case RSRC_GRANTED:
loc_eng_dmn_conn_loc_api_server_data_conn(
senderId,
GPSONE_LOC_API_IF_REQUEST_SUCCESS);
break;
default:
notify = false;
}
}
return notify;
}
#endif
//======================================================================
// AgpsState: AgpsReleasedState / AgpsPendingState / AgpsAcquiredState
@ -276,23 +330,25 @@ AgpsState* AgpsPendingState::onRsrcEvent(AgpsRsrcStatus event, void* data)
Subscriber* subscriber = (Subscriber*) data;
if (subscriber->waitForCloseComplete()) {
subscriber->setInactive();
if (!mStateMachine->hasActiveSubscribers()) {
// no more subscribers, move to RELEASED state
nextState = mReleasingState;
}
} else {
// auto notify this subscriber of the unsubscribe
Notification notification(subscriber, event, true);
mStateMachine->notifySubscribers(notification);
}
// now check if there is any subscribers left
if (!mStateMachine->hasSubscribers()) {
// no more subscribers, move to RELEASED state
nextState = mReleasedState;
// now check if there is any subscribers left
if (!mStateMachine->hasSubscribers()) {
// no more subscribers, move to RELEASED state
nextState = mReleasedState;
// tell connecivity service we can release NIF
mStateMachine->sendRsrcRequest(GPS_RELEASE_AGPS_DATA_CONN);
}
// tell connecivity service we can release NIF
mStateMachine->sendRsrcRequest(GPS_RELEASE_AGPS_DATA_CONN);
} else if (!mStateMachine->hasActiveSubscribers()) {
// only inactive subscribers, move to RELEASING state
nextState = mReleasingState;
// tell connecivity service we can release NIF
mStateMachine->sendRsrcRequest(GPS_RELEASE_AGPS_DATA_CONN);
}
}
break;
@ -381,13 +437,13 @@ AgpsState* AgpsAcquiredState::onRsrcEvent(AgpsRsrcStatus event, void* data)
// now check if there is any subscribers left
if (!mStateMachine->hasSubscribers()) {
// no more subscribers, move to RELEASED state
nextState = mReleasingState;
nextState = mReleasedState;
// tell connecivity service we can release NIF
mStateMachine->sendRsrcRequest(GPS_RELEASE_AGPS_DATA_CONN);
} else if (!mStateMachine->hasActiveSubscribers()) {
// no more subscribers, move to RELEASED state
nextState = mReleasedState;
// only inactive subscribers, move to RELEASING state
nextState = mReleasingState;
// tell connecivity service we can release NIF
mStateMachine->sendRsrcRequest(GPS_RELEASE_AGPS_DATA_CONN);
@ -469,21 +525,14 @@ AgpsState* AgpsReleasingState::onRsrcEvent(AgpsRsrcStatus event, void* data)
// now check if there is any subscribers left
if (!mStateMachine->hasSubscribers()) {
// no more subscribers, move to RELEASED state
nextState = mReleasingState;
// tell connecivity service we can release NIF
mStateMachine->sendRsrcRequest(GPS_RELEASE_AGPS_DATA_CONN);
} else if (!mStateMachine->hasActiveSubscribers()) {
// no more subscribers, move to RELEASED state
nextState = mReleasedState;
// tell connecivity service we can release NIF
mStateMachine->sendRsrcRequest(GPS_RELEASE_AGPS_DATA_CONN);
}
}
break;
case RSRC_DENIED:
// A race condition subscriber unsubscribes before AFW denies resource.
case RSRC_RELEASED:
{
nextState = mAcquiredState;
@ -503,7 +552,6 @@ AgpsState* AgpsReleasingState::onRsrcEvent(AgpsRsrcStatus event, void* data)
break;
case RSRC_GRANTED:
case RSRC_DENIED:
default:
LOC_LOGE("%s: unrecognized event %d", whoami(), event);
// no state change.
@ -520,11 +568,13 @@ AgpsState* AgpsReleasingState::onRsrcEvent(AgpsRsrcStatus event, void* data)
//======================================================================
AgpsStateMachine::AgpsStateMachine(void (*servicer)(AGpsStatus* status),
AGpsType type) :
AGpsType type,
bool enforceSingleSubscriber) :
mServicer(servicer), mType(type),
mStatePtr(new AgpsReleasedState(this)),
mAPN(NULL),
mAPNLen(0)
mAPNLen(0),
mEnforceSingleSubscriber(enforceSingleSubscriber)
{
linked_list_init(&mSubscribers);
@ -643,7 +693,7 @@ void AgpsStateMachine::addSubscriber(Subscriber* subscriber) const
void AgpsStateMachine::sendRsrcRequest(AGpsStatusValue action) const
{
Subscriber* s = NULL;
Notification notification(Notification::BROADCAST_ALL);
Notification notification(Notification::BROADCAST_ACTIVE);
linked_list_search(mSubscribers, (void**)&s, hasSubscriber,
(void*)&notification, false);
@ -653,12 +703,15 @@ void AgpsStateMachine::sendRsrcRequest(AGpsStatusValue action) const
nifRequest.type = mType;
nifRequest.status = action;
#ifdef QCOM_FEATURE_IPV6
#ifdef FEATURE_IPV6
if (s == NULL) {
nifRequest.ipv4_addr = INADDR_NONE;
nifRequest.ipv6_addr[0] = 0;
nifRequest.ssid[0] = '\0';
nifRequest.password[0] = '\0';
} else {
s->setIPAddresses(nifRequest.ipv4_addr, (char*)nifRequest.ipv6_addr);
s->setWifiInfo(nifRequest.ssid, nifRequest.password);
}
#else
if (s == NULL) {
@ -675,7 +728,12 @@ void AgpsStateMachine::sendRsrcRequest(AGpsStatusValue action) const
void AgpsStateMachine::subscribeRsrc(Subscriber *subscriber)
{
mStatePtr = mStatePtr->onRsrcEvent(RSRC_SUBSCRIBE, (void*)subscriber);
if (mEnforceSingleSubscriber && hasSubscribers()) {
Notification notification(Notification::BROADCAST_ALL, RSRC_DENIED, true);
notifySubscriber(&notification, subscriber);
} else {
mStatePtr = mStatePtr->onRsrcEvent(RSRC_SUBSCRIBE, (void*)subscriber);
}
}
bool AgpsStateMachine::unsubscribeRsrc(Subscriber *subscriber)

View file

@ -1,4 +1,4 @@
/* Copyright (c) 2011, Code Aurora Forum. All rights reserved.
/* 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
@ -9,7 +9,7 @@
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of Code Aurora Forum, Inc. nor the names of its
* * Neither the name of The Linux Foundation, nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
@ -37,6 +37,7 @@
#include <hardware/gps.h>
#include <linked_list.h>
#include <LocApiAdapter.h>
#include "loc_eng_msg.h"
// forward declaration
class AgpsStateMachine;
@ -149,20 +150,21 @@ class AgpsStateMachine {
char* mAPN;
// for convenience, we don't do strlen each time.
unsigned int mAPNLen;
#ifdef QCOM_FEATURE_IPV6
#ifdef FEATURE_IPV6
// bear
AGpsBearerType mBearer;
#endif
// ipv4 address for routing
bool mEnforceSingleSubscriber;
public:
AgpsStateMachine(void (*servicer)(AGpsStatus* status), AGpsType type);
AgpsStateMachine(void (*servicer)(AGpsStatus* status), AGpsType type, bool enforceSingleSubscriber);
virtual ~AgpsStateMachine();
// self explanatory methods below
void setAPN(const char* apn, unsigned int len);
inline const char* getAPN() const { return (const char*)mAPN; }
#ifdef QCOM_FEATURE_IPV6
#ifdef FEATURE_IPV6
inline void setBearer(AGpsBearerType bearer) { mBearer = bearer; }
inline AGpsBearerType getBearer() const { return mBearer; }
#endif
@ -198,14 +200,16 @@ public:
// multiple clients from modem. In the case of BIT, there is only one
// cilent from BIT daemon.
struct Subscriber {
const int ID;
const uint32_t ID;
const AgpsStateMachine* mStateMachine;
inline Subscriber(const int id,
const AgpsStateMachine* stateMachine) :
ID(id), mStateMachine(stateMachine) {}
inline virtual ~Subscriber() {}
virtual void setIPAddresses(int &v4, char* v6) = 0;
virtual void setIPAddresses(uint32_t &v4, char* v6) = 0;
inline virtual void setWifiInfo(char* ssid, char* password)
{ ssid[0] = 0; password[0] = 0; }
inline virtual bool equals(const Subscriber *s) const
{ return ID == s->ID; }
@ -239,7 +243,7 @@ struct BITSubscriber : public Subscriber {
virtual bool notifyRsrcStatus(Notification &notification);
inline virtual void setIPAddresses(int &v4, char* v6)
inline virtual void setIPAddresses(uint32_t &v4, char* v6)
{ v4 = ID; memcpy(v6, ipv6Addr, sizeof(ipv6Addr)); }
virtual Subscriber* clone()
@ -256,19 +260,72 @@ private:
// ATLSubscriber, created with requests from ATL
struct ATLSubscriber : public Subscriber {
const LocApiAdapter* mLocAdapter;
const bool mBackwardCompatibleMode;
inline ATLSubscriber(const int id,
const AgpsStateMachine* stateMachine,
const LocApiAdapter* adapter) :
Subscriber(id, stateMachine), mLocAdapter(adapter) {}
const LocApiAdapter* adapter,
const bool compatibleMode) :
Subscriber(id, stateMachine), mLocAdapter(adapter),
mBackwardCompatibleMode(compatibleMode){}
virtual bool notifyRsrcStatus(Notification &notification);
inline virtual void setIPAddresses(int &v4, char* v6)
inline virtual void setIPAddresses(uint32_t &v4, char* v6)
{ v4 = INADDR_NONE; v6[0] = 0; }
inline virtual Subscriber* clone()
{
return new ATLSubscriber(ID, mStateMachine, mLocAdapter);
return new ATLSubscriber(ID, mStateMachine, mLocAdapter,
mBackwardCompatibleMode);
}
};
#ifdef FEATURE_IPV6
// WIFISubscriber, created with requests from MSAPM or QuIPC
struct WIFISubscriber : public Subscriber {
char * mSSID;
char * mPassword;
loc_if_req_sender_id_e_type senderId;
bool mIsInactive;
inline WIFISubscriber(const AgpsStateMachine* stateMachine,
char * ssid, char * password, loc_if_req_sender_id_e_type sender_id) :
Subscriber(sender_id, stateMachine),
mSSID(NULL == ssid ? NULL : new char[SSID_BUF_SIZE]),
mPassword(NULL == password ? NULL : new char[SSID_BUF_SIZE]),
senderId(sender_id)
{
if (NULL != mSSID)
strlcpy(mSSID, ssid, SSID_BUF_SIZE);
if (NULL != mPassword)
strlcpy(mPassword, password, SSID_BUF_SIZE);
mIsInactive = false;
}
virtual bool notifyRsrcStatus(Notification &notification);
inline virtual void setIPAddresses(uint32_t &v4, char* v6) {}
inline virtual void setWifiInfo(char* ssid, char* password)
{
if (NULL != mSSID)
strlcpy(ssid, mSSID, SSID_BUF_SIZE);
else
ssid[0] = '\0';
if (NULL != mPassword)
strlcpy(password, mPassword, SSID_BUF_SIZE);
else
password[0] = '\0';
}
inline virtual bool waitForCloseComplete() { return true; }
inline virtual void setInactive() { mIsInactive = true; }
inline virtual bool isInactive() { return mIsInactive; }
virtual Subscriber* clone()
{
return new WIFISubscriber(mStateMachine, mSSID, mPassword, senderId);
}
};
#endif
#endif //__LOC_ENG_AGPS_H__

View file

@ -1,4 +1,4 @@
/* Copyright (c) 2011, Code Aurora Forum. All rights reserved.
/* 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
@ -9,7 +9,7 @@
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of Code Aurora Forum, Inc. nor the names of its
* * Neither the name of The Linux Foundation, nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
@ -33,24 +33,78 @@
#include <fcntl.h>
#include <linux/types.h>
#include <unistd.h>
#include <errno.h>
#include <grp.h>
#include <sys/stat.h>
#include "log_util.h"
#include "loc_eng_dmn_conn_glue_msg.h"
#include "loc_eng_dmn_conn_handler.h"
#include "loc_eng_dmn_conn.h"
#include "loc_eng_msg.h"
static int loc_api_server_msgqid;
static int loc_api_resp_msgqid;
static int quipc_msgqid;
static int msapm_msgqid;
static int msapu_msgqid;
static const char * global_loc_api_q_path = GPSONE_LOC_API_Q_PATH;
static const char * global_loc_api_resp_q_path = GPSONE_LOC_API_RESP_Q_PATH;
static const char * global_quipc_ctrl_q_path = QUIPC_CTRL_Q_PATH;
static const char * global_msapm_ctrl_q_path = MSAPM_CTRL_Q_PATH;
static const char * global_msapu_ctrl_q_path = MSAPU_CTRL_Q_PATH;
static int loc_api_server_proc_init(void *context)
{
loc_api_server_msgqid = loc_eng_dmn_conn_glue_msgget(global_loc_api_q_path, O_RDWR);
//change mode/group for the global_loc_api_q_path pipe
int result = chmod (global_loc_api_q_path, 0660);
if (result != 0)
{
LOC_LOGE("failed to change mode for %s, error = %s\n", global_loc_api_q_path, strerror(errno));
}
struct group * gps_group = getgrnam("gps");
if (gps_group != NULL)
{
result = chown (global_loc_api_q_path, -1, gps_group->gr_gid);
if (result != 0)
{
LOC_LOGE("chown for pipe failed, pipe %s, gid = %d, result = %d, error = %s\n",
global_loc_api_q_path, gps_group->gr_gid, result, strerror(errno));
}
}
else
{
LOC_LOGE("getgrnam for gps failed, error code = %d\n", errno);
}
loc_api_resp_msgqid = loc_eng_dmn_conn_glue_msgget(global_loc_api_resp_q_path, O_RDWR);
//change mode/group for the global_loc_api_resp_q_path pipe
result = chmod (global_loc_api_resp_q_path, 0660);
if (result != 0)
{
LOC_LOGE("failed to change mode for %s, error = %s\n", global_loc_api_resp_q_path, strerror(errno));
}
if (gps_group != NULL)
{
result = chown (global_loc_api_resp_q_path, -1, gps_group->gr_gid);
if (result != 0)
{
LOC_LOGE("chown for pipe failed, pipe %s, gid = %d, result = %d, error = %s\n",
global_loc_api_resp_q_path,
gps_group->gr_gid, result, strerror(errno));
}
}
quipc_msgqid = loc_eng_dmn_conn_glue_msgget(global_quipc_ctrl_q_path, O_RDWR);
msapm_msgqid = loc_eng_dmn_conn_glue_msgget(global_msapm_ctrl_q_path , O_RDWR);
msapu_msgqid = loc_eng_dmn_conn_glue_msgget(global_msapu_ctrl_q_path , O_RDWR);
LOC_LOGD("%s:%d] loc_api_server_msgqid = %d\n", __func__, __LINE__, loc_api_server_msgqid);
return 0;
}
@ -80,6 +134,7 @@ static int loc_api_server_proc(void *context)
LOC_LOGD("%s:%d] %d listening on %s...\n", __func__, __LINE__, cnt, (char *) context);
length = loc_eng_dmn_conn_glue_msgrcv(loc_api_server_msgqid, p_cmsgbuf, sz);
if (length <= 0) {
free(p_cmsgbuf);
LOC_LOGE("%s:%d] fail receiving msg from gpsone_daemon, retry later\n", __func__, __LINE__);
usleep(1000);
return 0;
@ -114,6 +169,9 @@ static int loc_api_server_proc_post(void *context)
LOC_LOGD("%s:%d]\n", __func__, __LINE__);
loc_eng_dmn_conn_glue_msgremove( global_loc_api_q_path, loc_api_server_msgqid);
loc_eng_dmn_conn_glue_msgremove( global_loc_api_resp_q_path, loc_api_resp_msgqid);
loc_eng_dmn_conn_glue_msgremove( global_quipc_ctrl_q_path, quipc_msgqid);
loc_eng_dmn_conn_glue_msgremove( global_msapm_ctrl_q_path, msapm_msgqid);
loc_eng_dmn_conn_glue_msgremove( global_msapu_ctrl_q_path, msapu_msgqid);
return 0;
}
@ -165,16 +223,48 @@ int loc_eng_dmn_conn_loc_api_server_join(void)
return 0;
}
int loc_eng_dmn_conn_loc_api_server_data_conn(int status) {
int loc_eng_dmn_conn_loc_api_server_data_conn(int sender_id, int status) {
struct ctrl_msgbuf cmsgbuf;
LOC_LOGD("%s:%d] quipc_msgqid = %d\n", __func__, __LINE__, quipc_msgqid);
cmsgbuf.ctrl_type = GPSONE_LOC_API_RESPONSE;
cmsgbuf.cmsg.cmsg_response.result = status;
LOC_LOGD("%s:%d] status = %d",__func__, __LINE__, status);
if (loc_eng_dmn_conn_glue_msgsnd(loc_api_resp_msgqid, & cmsgbuf, sizeof(struct ctrl_msgbuf)) < 0) {
LOC_LOGD("%s:%d] error! conn_glue_msgsnd failed\n", __func__, __LINE__);
return -1;
switch (sender_id) {
case LOC_ENG_IF_REQUEST_SENDER_ID_QUIPC: {
LOC_LOGD("%s:%d] sender_id = LOC_ENG_IF_REQUEST_SENDER_ID_QUIPC", __func__, __LINE__);
if (loc_eng_dmn_conn_glue_msgsnd(quipc_msgqid, & cmsgbuf, sizeof(struct ctrl_msgbuf)) < 0) {
LOC_LOGD("%s:%d] error! conn_glue_msgsnd failed\n", __func__, __LINE__);
return -1;
}
break;
}
case LOC_ENG_IF_REQUEST_SENDER_ID_MSAPM: {
LOC_LOGD("%s:%d] sender_id = LOC_ENG_IF_REQUEST_SENDER_ID_MSAPM", __func__, __LINE__);
if (loc_eng_dmn_conn_glue_msgsnd(msapm_msgqid, & cmsgbuf, sizeof(struct ctrl_msgbuf)) < 0) {
LOC_LOGD("%s:%d] error! conn_glue_msgsnd failed\n", __func__, __LINE__);
return -1;
}
break;
}
case LOC_ENG_IF_REQUEST_SENDER_ID_MSAPU: {
LOC_LOGD("%s:%d] sender_id = LOC_ENG_IF_REQUEST_SENDER_ID_MSAPU", __func__, __LINE__);
if (loc_eng_dmn_conn_glue_msgsnd(msapu_msgqid, & cmsgbuf, sizeof(struct ctrl_msgbuf)) < 0) {
LOC_LOGD("%s:%d] error! conn_glue_msgsnd failed\n", __func__, __LINE__);
return -1;
}
break;
}
case LOC_ENG_IF_REQUEST_SENDER_ID_GPSONE_DAEMON: {
LOC_LOGD("%s:%d] sender_id = LOC_ENG_IF_REQUEST_SENDER_ID_GPSONE_DAEMON", __func__, __LINE__);
if (loc_eng_dmn_conn_glue_msgsnd(loc_api_resp_msgqid, & cmsgbuf, sizeof(struct ctrl_msgbuf)) < 0) {
LOC_LOGD("%s:%d] error! conn_glue_msgsnd failed\n", __func__, __LINE__);
return -1;
}
break;
}
default: {
LOC_LOGD("%s:%d] invalid sender ID!", __func__, __LINE__);
}
}
return 0;
}

View file

@ -1,4 +1,4 @@
/* Copyright (c) 2011, Code Aurora Forum. All rights reserved.
/* 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
@ -9,7 +9,7 @@
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of Code Aurora Forum, Inc. nor the names of its
* * Neither the name of The Linux Foundation, nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
@ -35,11 +35,17 @@
#define GPSONE_LOC_API_Q_PATH "/data/misc/gpsone_d/gpsone_loc_api_q"
#define GPSONE_LOC_API_RESP_Q_PATH "/data/misc/gpsone_d/gpsone_loc_api_resp_q"
#define QUIPC_CTRL_Q_PATH "/data/misc/gpsone_d/quipc_ctrl_q"
#define MSAPM_CTRL_Q_PATH "/data/misc/gpsone_d/msapm_ctrl_q"
#define MSAPU_CTRL_Q_PATH "/data/misc/gpsone_d/msapu_ctrl_q"
#else
#define GPSONE_LOC_API_Q_PATH "/tmp/gpsone_loc_api_q"
#define GPSONE_LOC_API_RESP_Q_PATH "/tmp/gpsone_loc_api_resp_q"
#define QUIPC_CTRL_Q_PATH "/tmp/quipc_ctrl_q"
#define MSAPM_CTRL_Q_PATH "/tmp/msapm_ctrl_q"
#define MSAPU_CTRL_Q_PATH "/tmp/msapu_ctrl_q"
#endif
@ -47,7 +53,7 @@ int loc_eng_dmn_conn_loc_api_server_launch(thelper_create_thread create_thread
const char * loc_api_q_path, const char * ctrl_q_path, void *agps_handle);
int loc_eng_dmn_conn_loc_api_server_unblock(void);
int loc_eng_dmn_conn_loc_api_server_join(void);
int loc_eng_dmn_conn_loc_api_server_data_conn(int);
int loc_eng_dmn_conn_loc_api_server_data_conn(int, int);
#endif /* LOC_ENG_DATA_SERVER_H */

View file

@ -1,4 +1,4 @@
/* Copyright (c) 2011, Code Aurora Forum. All rights reserved.
/* Copyright (c) 2011, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@ -9,7 +9,7 @@
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of Code Aurora Forum, Inc. nor the names of its
* * Neither the name of The Linux Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*

View file

@ -1,4 +1,4 @@
/* Copyright (c) 2011, Code Aurora Forum. All rights reserved.
/* Copyright (c) 2011, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@ -9,7 +9,7 @@
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of Code Aurora Forum, Inc. nor the names of its
* * Neither the name of The Linux Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*

View file

@ -1,4 +1,4 @@
/* Copyright (c) 2011, Code Aurora Forum. All rights reserved.
/* 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
@ -9,7 +9,7 @@
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of Code Aurora Forum, Inc. nor the names of its
* * Neither the name of The Linux Foundation, nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
@ -64,13 +64,21 @@ int loc_eng_dmn_conn_glue_pipeget(const char * pipe_name, int mode)
int result;
LOC_LOGD("%s, mode = %d\n", pipe_name, mode);
result = mkfifo(pipe_name, 0666);
result = mkfifo(pipe_name, 0660);
if ((result == -1) && (errno != EEXIST)) {
LOC_LOGE("failed: %s\n", strerror(errno));
return result;
}
// The mode in mkfifo is not honoured and does not provide the
// group permissions. Doing chmod to add group permissions.
result = chmod (pipe_name, 0660);
if (result != 0){
LOC_LOGE ("%s failed to change mode for %s, error = %s\n", __func__,
pipe_name, strerror(errno));
}
fd = open(pipe_name, mode);
if (fd <= 0)
{

View file

@ -1,4 +1,4 @@
/* Copyright (c) 2011, Code Aurora Forum. All rights reserved.
/* Copyright (c) 2011, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@ -9,7 +9,7 @@
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of Code Aurora Forum, Inc. nor the names of its
* * Neither the name of The Linux Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*

View file

@ -1,4 +1,4 @@
/* Copyright (c) 2011, Code Aurora Forum. All rights reserved.
/* 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
@ -9,7 +9,7 @@
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of Code Aurora Forum, Inc. nor the names of its
* * Neither the name of The Linux Foundation, nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
@ -47,15 +47,91 @@ int loc_eng_dmn_conn_loc_api_server_if_request_handler(struct ctrl_msgbuf *pmsg,
return 1;
}
loc_eng_msg_request_bit *msg(
new loc_eng_msg_request_bit(loc_api_handle,
pmsg->cmsg.cmsg_if_request.is_supl,
pmsg->cmsg.cmsg_if_request.ipv4_addr,
(char*)pmsg->cmsg.cmsg_if_request.ipv6_addr));
loc_eng_msg_sender(loc_api_handle, msg);
if (NULL != loc_api_handle) {
loc_if_req_type_e_type type;
switch (pmsg->cmsg.cmsg_if_request.type) {
case IF_REQUEST_TYPE_SUPL:
{
LOC_LOGD("IF_REQUEST_TYPE_SUPL");
type = LOC_ENG_IF_REQUEST_TYPE_SUPL;
break;
}
case IF_REQUEST_TYPE_WIFI:
{
LOC_LOGD("IF_REQUEST_TYPE_WIFI");
type = LOC_ENG_IF_REQUEST_TYPE_WIFI;
break;
}
case IF_REQUEST_TYPE_ANY:
{
LOC_LOGD("IF_REQUEST_TYPE_ANY");
type = LOC_ENG_IF_REQUEST_TYPE_ANY;
break;
}
default:
{
LOC_LOGD("invalid IF_REQUEST_TYPE!");
return -1;
}
}
switch (pmsg->cmsg.cmsg_if_request.sender_id) {
case IF_REQUEST_SENDER_ID_QUIPC:
{
LOC_LOGD("IF_REQUEST_SENDER_ID_QUIPC");
loc_eng_msg_request_wifi *msg(
new loc_eng_msg_request_wifi(loc_api_handle,
type,
LOC_ENG_IF_REQUEST_SENDER_ID_QUIPC,
(char*)pmsg->cmsg.cmsg_if_request.ssid,
(char*)pmsg->cmsg.cmsg_if_request.password));
loc_eng_msg_sender(loc_api_handle, msg);
break;
}
case IF_REQUEST_SENDER_ID_MSAPM:
{
LOC_LOGD("IF_REQUEST_SENDER_ID_MSAPM");
loc_eng_msg_request_wifi *msg(
new loc_eng_msg_request_wifi(loc_api_handle,
type,
LOC_ENG_IF_REQUEST_SENDER_ID_MSAPM,
(char*)pmsg->cmsg.cmsg_if_request.ssid,
(char*)pmsg->cmsg.cmsg_if_request.password));
loc_eng_msg_sender(loc_api_handle, msg);
break;
}
case IF_REQUEST_SENDER_ID_MSAPU:
{
LOC_LOGD("IF_REQUEST_SENDER_ID_MSAPU");
loc_eng_msg_request_wifi *msg(
new loc_eng_msg_request_wifi(loc_api_handle,
type,
LOC_ENG_IF_REQUEST_SENDER_ID_MSAPU,
(char*)pmsg->cmsg.cmsg_if_request.ssid,
(char*)pmsg->cmsg.cmsg_if_request.password));
loc_eng_msg_sender(loc_api_handle, msg);
break;
}
case IF_REQUEST_SENDER_ID_GPSONE_DAEMON:
{
LOC_LOGD("IF_REQUEST_SENDER_ID_GPSONE_DAEMON");
loc_eng_msg_request_bit *msg(
new loc_eng_msg_request_bit(loc_api_handle,
type,
pmsg->cmsg.cmsg_if_request.ipv4_addr,
(char*)pmsg->cmsg.cmsg_if_request.ipv6_addr));
loc_eng_msg_sender(loc_api_handle, msg);
break;
}
default:
{
LOC_LOGD("invalid IF_REQUEST_SENDER_ID!");
return -1;
}
}
}
#else
loc_eng_dmn_conn_loc_api_server_data_conn(GPSONE_LOC_API_IF_REQUEST_SUCCESS);
loc_eng_dmn_conn_loc_api_server_data_conn(LOC_ENG_IF_REQUEST_SENDER_ID_GPSONE_DAEMON, GPSONE_LOC_API_IF_REQUEST_SUCCESS);
#endif
return 0;
}
@ -64,14 +140,88 @@ int loc_eng_dmn_conn_loc_api_server_if_release_handler(struct ctrl_msgbuf *pmsg,
{
LOC_LOGD("%s:%d]\n", __func__, __LINE__);
#ifndef DEBUG_DMN_LOC_API
loc_eng_msg_release_bit *msg(
loc_if_req_type_e_type type;
switch (pmsg->cmsg.cmsg_if_request.type) {
case IF_REQUEST_TYPE_SUPL:
{
LOC_LOGD("IF_REQUEST_TYPE_SUPL");
type = LOC_ENG_IF_REQUEST_TYPE_SUPL;
break;
}
case IF_REQUEST_TYPE_WIFI:
{
LOC_LOGD("IF_REQUEST_TYPE_WIFI");
type = LOC_ENG_IF_REQUEST_TYPE_WIFI;
break;
}
case IF_REQUEST_TYPE_ANY:
{
LOC_LOGD("IF_REQUEST_TYPE_ANY");
type = LOC_ENG_IF_REQUEST_TYPE_ANY;
break;
}
default:
{
LOC_LOGD("invalid IF_REQUEST_TYPE!");
return -1;
}
}
switch (pmsg->cmsg.cmsg_if_request.sender_id) {
case IF_REQUEST_SENDER_ID_QUIPC:
{
LOC_LOGD("IF_REQUEST_SENDER_ID_QUIPC");
loc_eng_msg_release_wifi *msg(
new loc_eng_msg_release_wifi(loc_api_handle,
type,
LOC_ENG_IF_REQUEST_SENDER_ID_QUIPC,
(char*)pmsg->cmsg.cmsg_if_request.ssid,
(char*)pmsg->cmsg.cmsg_if_request.password));
loc_eng_msg_sender(loc_api_handle, msg);
break;
}
case IF_REQUEST_SENDER_ID_MSAPM:
{
LOC_LOGD("IF_REQUEST_SENDER_ID_MSAPM");
loc_eng_msg_release_wifi *msg(
new loc_eng_msg_release_wifi(loc_api_handle,
type,
LOC_ENG_IF_REQUEST_SENDER_ID_MSAPM,
(char*)pmsg->cmsg.cmsg_if_request.ssid,
(char*)pmsg->cmsg.cmsg_if_request.password));
loc_eng_msg_sender(loc_api_handle, msg);
break;
}
case IF_REQUEST_SENDER_ID_MSAPU:
{
LOC_LOGD("IF_REQUEST_SENDER_ID_MSAPU");
loc_eng_msg_release_wifi *msg(
new loc_eng_msg_release_wifi(loc_api_handle,
type,
LOC_ENG_IF_REQUEST_SENDER_ID_MSAPU,
(char*)pmsg->cmsg.cmsg_if_request.ssid,
(char*)pmsg->cmsg.cmsg_if_request.password));
loc_eng_msg_sender(loc_api_handle, msg);
break;
}
case IF_REQUEST_SENDER_ID_GPSONE_DAEMON:
{
LOC_LOGD("IF_REQUEST_SENDER_ID_GPSONE_DAEMON");
loc_eng_msg_release_bit *msg(
new loc_eng_msg_release_bit(loc_api_handle,
pmsg->cmsg.cmsg_if_request.is_supl,
type,
pmsg->cmsg.cmsg_if_request.ipv4_addr,
(char*)pmsg->cmsg.cmsg_if_request.ipv6_addr));
loc_eng_msg_sender(loc_api_handle, msg);
break;
}
default:
{
LOC_LOGD("invalid IF_REQUEST_SENDER_ID!");
return -1;
}
}
#else
loc_eng_dmn_conn_loc_api_server_data_conn(GPSONE_LOC_API_IF_RELEASE_SUCCESS);
loc_eng_dmn_conn_loc_api_server_data_conn(LOC_ENG_IF_REQUEST_SENDER_ID_GPSONE_DAEMON, GPSONE_LOC_API_IF_RELEASE_SUCCESS);
#endif
return 0;
}

View file

@ -1,4 +1,4 @@
/* Copyright (c) 2011, Code Aurora Forum. All rights reserved.
/* 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
@ -9,7 +9,7 @@
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of Code Aurora Forum, Inc. nor the names of its
* * Neither the name of The Linux Foundation, nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
@ -32,6 +32,13 @@
#include <linux/types.h>
#include <arpa/inet.h>
//for SSID_BUF_SIZE
#include <hardware/gps.h>
#ifndef SSID_BUF_SIZE
#define SSID_BUF_SIZE (32+1)
#endif
enum {
/* 0x0 - 0xEF is reserved for daemon internal */
GPSONE_LOC_API_IF_REQUEST = 0xF0,
@ -55,10 +62,27 @@ struct ctrl_msg_unblock {
int reserved;
};
typedef enum {
IF_REQUEST_TYPE_SUPL = 0,
IF_REQUEST_TYPE_WIFI,
IF_REQUEST_TYPE_ANY
} ctrl_if_req_type_e_type;
typedef enum {
IF_REQUEST_SENDER_ID_QUIPC = 0,
IF_REQUEST_SENDER_ID_MSAPM,
IF_REQUEST_SENDER_ID_MSAPU,
IF_REQUEST_SENDER_ID_GPSONE_DAEMON,
IF_REQUEST_SENDER_ID_MODEM
} ctrl_if_req_sender_id_e_type;
struct ctrl_msg_if_request {
unsigned is_supl; /* 1: use Android SUPL connection; 0: use Android default internet connection */
ctrl_if_req_type_e_type type;
ctrl_if_req_sender_id_e_type sender_id;
unsigned long ipv4_addr;
unsigned char ipv6_addr[16];
char ssid[SSID_BUF_SIZE];
char password[SSID_BUF_SIZE];
};
/* do not change this structure */

View file

@ -1,4 +1,4 @@
/* Copyright (c) 2011, Code Aurora Forum. All rights reserved.
/* Copyright (c) 2011, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@ -9,7 +9,7 @@
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of Code Aurora Forum, Inc. nor the names of its
* * Neither the name of The Linux Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*

View file

@ -1,4 +1,4 @@
/* Copyright (c) 2011, Code Aurora Forum. All rights reserved.
/* Copyright (c) 2011, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@ -9,7 +9,7 @@
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of Code Aurora Forum, Inc. nor the names of its
* * Neither the name of The Linux Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*

View file

@ -1,4 +1,4 @@
/* Copyright (c) 2011 Code Aurora Forum. All rights reserved.
/* 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
@ -9,7 +9,7 @@
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of Code Aurora Forum, Inc. nor the names of its
* * Neither the name of The Linux Foundation, nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
@ -31,7 +31,6 @@
#define LOG_TAG "LocSvc_eng"
#include "hardware/gps.h"
#include "loc.h"
#include "loc_log.h"
#include "loc_eng_log.h"
#include "loc_eng_msg_id.h"
@ -88,10 +87,27 @@ static loc_name_val_s_type loc_eng_msgs[] =
NAME_VAL( LOC_ENG_MSG_RELEASE_ATL ),
NAME_VAL( LOC_ENG_MSG_REQUEST_BIT ),
NAME_VAL( LOC_ENG_MSG_RELEASE_BIT ),
NAME_VAL( LOC_ENG_MSG_REQUEST_WIFI ),
NAME_VAL( LOC_ENG_MSG_RELEASE_WIFI ),
NAME_VAL( LOC_ENG_MSG_REQUEST_NI ),
NAME_VAL( LOC_ENG_MSG_INFORM_NI_RESPONSE ),
NAME_VAL( LOC_ENG_MSG_REQUEST_XTRA_DATA ),
NAME_VAL( LOC_ENG_MSG_REQUEST_TIME )
NAME_VAL( LOC_ENG_MSG_REQUEST_TIME ),
NAME_VAL( LOC_ENG_MSG_EXT_POWER_CONFIG ),
NAME_VAL( LOC_ENG_MSG_REQUEST_POSITION ),
NAME_VAL( LOC_ENG_MSG_REQUEST_PHONE_CONTEXT ),
NAME_VAL( LOC_ENG_MSG_REQUEST_NETWORK_POSIITON ),
NAME_VAL( ULP_MSG_UPDATE_CRITERIA ),
NAME_VAL( ULP_MSG_START_FIX ),
NAME_VAL( ULP_MSG_STOP_FIX ),
NAME_VAL( ULP_MSG_INJECT_PHONE_CONTEXT_SETTINGS ),
NAME_VAL( ULP_MSG_INJECT_NETWORK_POSITION ),
NAME_VAL( ULP_MSG_REPORT_QUIPC_POSITION ),
NAME_VAL( ULP_MSG_REQUEST_COARSE_POSITION ),
NAME_VAL( ULP_MSG_MONITOR ),
NAME_VAL( LOC_ENG_MSG_LPP_CONFIG ),
NAME_VAL( ULP_MSG_INJECT_RAW_COMMAND ),
NAME_VAL( LOC_ENG_MSG_A_GLONASS_PROTOCOL )
};
static int loc_eng_msgs_num = sizeof(loc_eng_msgs) / sizeof(loc_name_val_s_type);
@ -111,7 +127,8 @@ static loc_name_val_s_type loc_eng_position_modes[] =
NAME_VAL( LOC_POSITION_MODE_RESERVED_1 ),
NAME_VAL( LOC_POSITION_MODE_RESERVED_2 ),
NAME_VAL( LOC_POSITION_MODE_RESERVED_3 ),
NAME_VAL( LOC_POSITION_MODE_RESERVED_4 )
NAME_VAL( LOC_POSITION_MODE_RESERVED_4 ),
NAME_VAL( LOC_POSITION_MODE_RESERVED_5 )
};
static int loc_eng_position_mode_num = sizeof(loc_eng_position_modes) / sizeof(loc_name_val_s_type);
@ -150,7 +167,7 @@ static loc_name_val_s_type loc_eng_aiding_data_bits[] =
NAME_VAL( GPS_DELETE_SADATA ),
NAME_VAL( GPS_DELETE_RTI ),
NAME_VAL( GPS_DELETE_CELLDB_INFO )
#ifdef QCOM_FEATURE_DELEXT
#ifdef FEATURE_DELEXT
,NAME_VAL( GPS_DELETE_ALMANAC_CORR ),
NAME_VAL( GPS_DELETE_FREQ_BIAS_EST ),
NAME_VAL( GPS_DELETE_EPHEMERIS_GLO ),
@ -172,13 +189,13 @@ const char* loc_get_aiding_data_mask_names(GpsAidingData data)
static loc_name_val_s_type loc_eng_agps_types[] =
{
#ifdef QCOM_FEATURE_IPV6
#ifdef FEATURE_IPV6
NAME_VAL( AGPS_TYPE_INVALID ),
NAME_VAL( AGPS_TYPE_ANY ),
#endif
NAME_VAL( AGPS_TYPE_SUPL ),
NAME_VAL( AGPS_TYPE_C2K )
#ifdef QCOM_FEATURE_IPV6
#ifdef FEATURE_IPV6
,NAME_VAL( AGPS_TYPE_WWAN_ANY )
#endif
};
@ -233,7 +250,7 @@ const char* loc_get_ni_encoding_name(GpsNiEncodingType encoding)
return loc_get_name_from_val(loc_eng_ni_encodings, loc_eng_ni_encoding_num, (long) encoding);
}
#ifdef QCOM_FEATURE_IPV6
#ifdef FEATURE_IPV6
static loc_name_val_s_type loc_eng_agps_bears[] =
{
NAME_VAL( AGPS_APN_BEARER_INVALID ),

View file

@ -1,4 +1,4 @@
/* Copyright (c) 2011 Code Aurora Forum. All rights reserved.
/* 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
@ -9,7 +9,7 @@
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of Code Aurora Forum, Inc. nor the names of its
* * Neither the name of The Linux Foundation, nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
@ -37,7 +37,7 @@ extern "C"
#include <ctype.h>
#include <hardware/gps.h>
#include "loc_eng_msg_id.h"
#include <loc.h>
const char* loc_get_gps_status_name(GpsStatusValue gps_status);
const char* loc_get_msg_name(int id);
@ -48,7 +48,7 @@ const char* loc_get_agps_type_name(AGpsType type);
const char* loc_get_ni_type_name(GpsNiType type);
const char* loc_get_ni_response_name(GpsUserResponseType response);
const char* loc_get_ni_encoding_name(GpsNiEncodingType encoding);
#ifdef QCOM_FEATURE_IPV6
#ifdef FEATURE_IPV6
const char* loc_get_agps_bear_name(AGpsBearerType bear);
#endif
const char* loc_get_server_type_name(LocServerType type);

View file

@ -1,4 +1,4 @@
/* Copyright (c) 2011, Code Aurora Forum. All rights reserved.
/* Copyright (c) 2011, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@ -9,7 +9,7 @@
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of Code Aurora Forum, Inc. nor the names of its
* * Neither the name of The Linux Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*

View file

@ -1,4 +1,4 @@
/* Copyright (c) 2011, Code Aurora Forum. All rights reserved.
/* 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
@ -9,7 +9,7 @@
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of Code Aurora Forum, Inc. nor the names of its
* * Neither the name of The Linux Foundation, nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
@ -31,18 +31,130 @@
#include <hardware/gps.h>
#include <loc_ulp.h>
#include <stdlib.h>
#include <string.h>
#include "log_util.h"
#include "loc.h"
#include "loc_eng_log.h"
#include <loc_eng_log.h>
#include "loc_eng_msg_id.h"
#ifndef SSID_BUF_SIZE
#define SSID_BUF_SIZE (32+1)
#endif
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
struct LocPosMode
{
LocPositionMode mode;
GpsPositionRecurrence recurrence;
uint32_t min_interval;
uint32_t preferred_accuracy;
uint32_t preferred_time;
char credentials[14];
char provider[8];
LocPosMode(LocPositionMode m, GpsPositionRecurrence recr,
uint32_t gap, uint32_t accu, uint32_t time,
const char* cred, const char* prov) :
mode(m), recurrence(recr),
min_interval(gap < MIN_POSSIBLE_FIX_INTERVAL ? MIN_POSSIBLE_FIX_INTERVAL : gap),
preferred_accuracy(accu), preferred_time(time) {
memset(credentials, 0, sizeof(credentials));
memset(provider, 0, sizeof(provider));
if (NULL != cred) {
memcpy(credentials, cred, sizeof(credentials)-1);
}
if (NULL != prov) {
memcpy(provider, prov, sizeof(provider)-1);
}
}
LocPosMode() :
mode(LOC_POSITION_MODE_MS_BASED), recurrence(GPS_POSITION_RECURRENCE_PERIODIC),
min_interval(MIN_POSSIBLE_FIX_INTERVAL), preferred_accuracy(50), preferred_time(120000) {
memset(credentials, 0, sizeof(credentials));
memset(provider, 0, sizeof(provider));
}
inline bool equals(const LocPosMode &anotherMode) const
{
return anotherMode.mode == mode &&
anotherMode.recurrence == recurrence &&
anotherMode.min_interval == min_interval &&
anotherMode.preferred_accuracy == preferred_accuracy &&
anotherMode.preferred_time == preferred_time &&
!strncmp(anotherMode.credentials, credentials, sizeof(credentials)-1) &&
!strncmp(anotherMode.provider, provider, sizeof(provider)-1);
}
inline void logv() const
{
LOC_LOGV ("Position mode: %s\n Position recurrence: %s\n min interval: %d\n preferred accuracy: %d\n preferred time: %d\n credentials: %s provider: %s",
loc_get_position_mode_name(mode),
loc_get_position_recurrence_name(recurrence),
min_interval,
preferred_accuracy,
preferred_time,
credentials,
provider);
}
};
/** Flags to indicate which values are valid in a GpsLocationExtended. */
typedef uint16_t GpsLocationExtendedFlags;
/** GpsLocationExtended has valid pdop, hdop, vdop. */
#define GPS_LOCATION_EXTENDED_HAS_DOP 0x0001
/** GpsLocationExtended has valid altitude mean sea level. */
#define GPS_LOCATION_EXTENDED_HAS_ALTITUDE_MEAN_SEA_LEVEL 0x0002
/** UlpLocation has valid magnetic deviation. */
#define GPS_LOCATION_EXTENDED_HAS_MAG_DEV 0x0004
/** UlpLocation has valid mode indicator. */
#define GPS_LOCATION_EXTENDED_HAS_MODE_IND 0x0008
/** GpsLocationExtended has valid vertical uncertainty */
#define GPS_LOCATION_EXTENDED_HAS_VERT_UNC 0x0010
/** GpsLocationExtended has valid speed uncertainty */
#define GPS_LOCATION_EXTENDED_HAS_SPEED_UNC 0x0020
/** Represents gps location extended. */
typedef struct {
/** set to sizeof(GpsLocationExtended) */
size_t size;
/** Contains GpsLocationExtendedFlags bits. */
uint16_t flags;
/** Contains the Altitude wrt mean sea level */
float altitudeMeanSeaLevel;
/** Contains Position Dilusion of Precision. */
float pdop;
/** Contains Horizontal Dilusion of Precision. */
float hdop;
/** Contains Vertical Dilusion of Precision. */
float vdop;
/** Contains Magnetic Deviation. */
float magneticDeviation;
/** vertical uncertainty in meters */
float vert_unc;
/** speed uncertainty in m/s */
float speed_unc;
} GpsLocationExtended;
typedef enum {
LOC_ENG_IF_REQUEST_TYPE_SUPL = 0,
LOC_ENG_IF_REQUEST_TYPE_WIFI,
LOC_ENG_IF_REQUEST_TYPE_ANY
} loc_if_req_type_e_type;
typedef enum {
LOC_ENG_IF_REQUEST_SENDER_ID_QUIPC = 0,
LOC_ENG_IF_REQUEST_SENDER_ID_MSAPM,
LOC_ENG_IF_REQUEST_SENDER_ID_MSAPU,
LOC_ENG_IF_REQUEST_SENDER_ID_GPSONE_DAEMON,
LOC_ENG_IF_REQUEST_SENDER_ID_MODEM,
LOC_ENG_IF_REQUEST_SENDER_ID_UNKNOWN
} loc_if_req_sender_id_e_type;
struct loc_eng_msg {
const void* owner;
const int msgid;
@ -50,13 +162,24 @@ struct loc_eng_msg {
owner(instance), msgid(id)
{
LOC_LOGV("creating msg %s", loc_get_msg_name(msgid));
LOC_LOGV("creating msg ox%x", msgid);
}
virtual ~loc_eng_msg()
{
LOC_LOGV("deleting msg %s", loc_get_msg_name(msgid));
LOC_LOGV("deleting msg %s (0x%x)", loc_get_msg_name(msgid), msgid);
}
};
struct loc_eng_msg_a_glonass_protocol : public loc_eng_msg {
const unsigned long a_glonass_protocol;
inline loc_eng_msg_a_glonass_protocol(void* instance, unsigned long protocol) :
loc_eng_msg(instance, LOC_ENG_MSG_A_GLONASS_PROTOCOL),
a_glonass_protocol(protocol)
{
LOC_LOGV("A-GLONASS protocol: 0x%lx", protocol);
}
};
struct loc_eng_msg_suple_version : public loc_eng_msg {
const int supl_version;
inline loc_eng_msg_suple_version(void* instance, int version) :
@ -67,6 +190,26 @@ struct loc_eng_msg_suple_version : public loc_eng_msg {
}
};
struct loc_eng_msg_lpp_config : public loc_eng_msg {
const int lpp_config;
inline loc_eng_msg_lpp_config(void *instance, int profile) :
loc_eng_msg(instance, LOC_ENG_MSG_LPP_CONFIG),
lpp_config(profile)
{
LOC_LOGV("lpp profile: %d", profile);
}
};
struct loc_eng_msg_ext_power_config : public loc_eng_msg {
const int isBatteryCharging;
inline loc_eng_msg_ext_power_config(void* instance, int isBattCharging) :
loc_eng_msg(instance, LOC_ENG_MSG_EXT_POWER_CONFIG),
isBatteryCharging(isBattCharging)
{
LOC_LOGV("isBatteryCharging: %d", isBatteryCharging);
}
};
struct loc_eng_msg_sensor_control_config : public loc_eng_msg {
const int sensorsDisabled;
inline loc_eng_msg_sensor_control_config(void* instance, int disabled) :
@ -78,12 +221,51 @@ struct loc_eng_msg_sensor_control_config : public loc_eng_msg {
};
struct loc_eng_msg_sensor_properties : public loc_eng_msg {
const bool gyroBiasVarianceRandomWalk_valid;
const float gyroBiasVarianceRandomWalk;
inline loc_eng_msg_sensor_properties(void* instance, float gyroBiasRandomWalk) :
const bool accelRandomWalk_valid;
const float accelRandomWalk;
const bool angleRandomWalk_valid;
const float angleRandomWalk;
const bool rateRandomWalk_valid;
const float rateRandomWalk;
const bool velocityRandomWalk_valid;
const float velocityRandomWalk;
inline loc_eng_msg_sensor_properties(void* instance, bool gyroBiasRandomWalk_valid, float gyroBiasRandomWalk,
bool accelRandomWalk_valid, float accelRandomWalk,
bool angleRandomWalk_valid, float angleRandomWalk,
bool rateRandomWalk_valid, float rateRandomWalk,
bool velocityRandomWalk_valid, float velocityRandomWalk) :
loc_eng_msg(instance, LOC_ENG_MSG_SET_SENSOR_PROPERTIES),
gyroBiasVarianceRandomWalk(gyroBiasRandomWalk)
gyroBiasVarianceRandomWalk_valid(gyroBiasRandomWalk_valid),
gyroBiasVarianceRandomWalk(gyroBiasRandomWalk),
accelRandomWalk_valid(accelRandomWalk_valid),
accelRandomWalk(accelRandomWalk),
angleRandomWalk_valid(angleRandomWalk_valid),
angleRandomWalk(angleRandomWalk),
rateRandomWalk_valid(rateRandomWalk_valid),
rateRandomWalk(rateRandomWalk),
velocityRandomWalk_valid(velocityRandomWalk_valid),
velocityRandomWalk(velocityRandomWalk)
{
LOC_LOGV("Gyro Bias Random Walk: %f", gyroBiasRandomWalk);
LOC_LOGV("Sensor properties validity, Gyro Random walk: %d Accel Random Walk: %d "
"Angle Random Walk: %d Rate Random Walk: %d "
"Velocity Random Walk: %d",
gyroBiasRandomWalk_valid,
accelRandomWalk_valid,
angleRandomWalk_valid,
rateRandomWalk_valid,
velocityRandomWalk_valid
);
LOC_LOGV("Sensor properties, Gyro Random walk: %f Accel Random Walk: %f "
"Angle Random Walk: %f Rate Random Walk: %f "
"Velocity Random Walk: %f",
gyroBiasRandomWalk,
accelRandomWalk,
angleRandomWalk,
rateRandomWalk,
velocityRandomWalk
);
}
};
@ -93,55 +275,56 @@ struct loc_eng_msg_sensor_perf_control_config : public loc_eng_msg {
const int accelBatchesPerSec;
const int gyroSamplesPerBatch;
const int gyroBatchesPerSec;
const int accelSamplesPerBatchHigh;
const int accelBatchesPerSecHigh;
const int gyroSamplesPerBatchHigh;
const int gyroBatchesPerSecHigh;
const int algorithmConfig;
inline loc_eng_msg_sensor_perf_control_config(void* instance, int controlMode,
int accelSamplesPerBatch, int accelBatchesPerSec,
int gyroSamplesPerBatch, int gyroBatchesPerSec) :
int gyroSamplesPerBatch, int gyroBatchesPerSec,
int accelSamplesPerBatchHigh, int accelBatchesPerSecHigh,
int gyroSamplesPerBatchHigh, int gyroBatchesPerSecHigh,
int algorithmConfig) :
loc_eng_msg(instance, LOC_ENG_MSG_SET_SENSOR_PERF_CONTROL_CONFIG),
controlMode(controlMode),
accelSamplesPerBatch(accelSamplesPerBatch),
accelBatchesPerSec(accelBatchesPerSec),
gyroSamplesPerBatch(gyroSamplesPerBatch),
gyroBatchesPerSec(gyroBatchesPerSec)
gyroBatchesPerSec(gyroBatchesPerSec),
accelSamplesPerBatchHigh(accelSamplesPerBatchHigh),
accelBatchesPerSecHigh(accelBatchesPerSecHigh),
gyroSamplesPerBatchHigh(gyroSamplesPerBatchHigh),
gyroBatchesPerSecHigh(gyroBatchesPerSecHigh),
algorithmConfig(algorithmConfig)
{
LOC_LOGV("Sensor Perf Control Config (performanceControlMode)(%u) "
"accel(#smp,#batches) (%u,%u) gyro(#smp,#batches) (%u,%u)\n",
"accel(#smp,#batches) (%u,%u) gyro(#smp,#batches) (%u,%u), "
"accel_high(#smp,#batches) (%u,%u) gyro_high(#smp,#batches) (%u,%u), "
"algorithmConfig(%u)\n",
controlMode,
accelSamplesPerBatch,
accelBatchesPerSec,
gyroSamplesPerBatch,
gyroBatchesPerSec
gyroBatchesPerSec,
accelSamplesPerBatchHigh,
accelBatchesPerSecHigh,
gyroSamplesPerBatchHigh,
gyroBatchesPerSecHigh,
algorithmConfig
);
}
};
struct loc_eng_msg_position_mode : public loc_eng_msg {
const LocPositionMode pMode;
const GpsPositionRecurrence pRecurrence;
const uint32_t minInterval;
const uint32_t preferredAccuracy;
const uint32_t preferredTime;
inline loc_eng_msg_position_mode() :
loc_eng_msg(NULL, LOC_ENG_MSG_SET_POSITION_MODE),
pMode(LOC_POSITION_MODE_STANDALONE),
pRecurrence(0), minInterval(0),
preferredAccuracy(0), preferredTime(0) {}
const LocPosMode pMode;
inline loc_eng_msg_position_mode(void* instance,
LocPositionMode mode,
GpsPositionRecurrence recurrence,
uint32_t min_interval,
uint32_t preferred_accuracy,
uint32_t preferred_time) :
LocPosMode &mode) :
loc_eng_msg(instance, LOC_ENG_MSG_SET_POSITION_MODE),
pMode(mode), pRecurrence(recurrence), minInterval(min_interval),
preferredAccuracy(preferred_accuracy), preferredTime(preferred_time)
pMode(mode)
{
LOC_LOGV("Position mode: %s\n Position recurrence: %s\n min interval: %d\n preferred accuracy: %d\n preferred time: %d",
loc_get_position_mode_name(pMode),
loc_get_position_recurrence_name(pRecurrence),
minInterval,
preferredAccuracy,
preferredTime);
pMode.logv();
}
};
@ -185,34 +368,45 @@ struct loc_eng_msg_delete_aiding_data : public loc_eng_msg {
};
struct loc_eng_msg_report_position : public loc_eng_msg {
const GpsLocation location;
const UlpLocation location;
const GpsLocationExtended locationExtended;
const void* locationExt;
const enum loc_sess_status status;
inline loc_eng_msg_report_position(void* instance, GpsLocation &loc, void* locExt,
const LocPosTechMask technology_mask;
inline loc_eng_msg_report_position(void* instance, UlpLocation &loc, GpsLocationExtended &locExtended, void* locExt,
enum loc_sess_status st) :
loc_eng_msg(instance, LOC_ENG_MSG_REPORT_POSITION),
location(loc), locationExt(locExt), status(st)
location(loc), locationExtended(locExtended), locationExt(locExt), status(st), technology_mask(LOC_POS_TECH_MASK_DEFAULT)
{
#ifdef QCOM_FEATURE_ULP
LOC_LOGV("flags: %d\n source: %d\n latitude: %f\n longitude: %f\n altitude: %f\n speed: %f\n bearing: %f\n accuracy: %f\n timestamp: %lld\n rawDataSize: %d\n rawData: %p\n Session status: %s",
location.flags, location.position_source, location.latitude, location.longitude,
location.altitude, location.speed, location.bearing, location.accuracy,
location.timestamp, location.rawDataSize, location.rawData,
loc_get_position_sess_status_name(status));
#else
LOC_LOGV("flags: %d\n latitude: %f\n longitude: %f\n altitude: %f\n speed: %f\n bearing: %f\n accuracy: %f\n timestamp: %lld\n Session status: %s",
location.flags, location.latitude, location.longitude,
location.altitude, location.speed, location.bearing, location.accuracy,
location.timestamp, loc_get_position_sess_status_name(status));
#endif
LOC_LOGV("flags: %d\n source: %d\n latitude: %f\n longitude: %f\n altitude: %f\n speed: %f\n bearing: %f\n accuracy: %f\n timestamp: %lld\n rawDataSize: %d\n rawData: %p\n Session status: %d\n Technology mask: %u",
location.gpsLocation.flags, location.position_source,
location.gpsLocation.latitude, location.gpsLocation.longitude,
location.gpsLocation.altitude, location.gpsLocation.speed,
location.gpsLocation.bearing, location.gpsLocation.accuracy,
location.gpsLocation.timestamp, location.rawDataSize,
location.rawData,status,technology_mask);
}
inline loc_eng_msg_report_position(void* instance, UlpLocation &loc, GpsLocationExtended &locExtended, void* locExt,
enum loc_sess_status st, LocPosTechMask technology) :
loc_eng_msg(instance, LOC_ENG_MSG_REPORT_POSITION),
location(loc), locationExtended(locExtended), locationExt(locExt), status(st), technology_mask(technology)
{
LOC_LOGV("flags: %d\n source: %d\n latitude: %f\n longitude: %f\n altitude: %f\n speed: %f\n bearing: %f\n accuracy: %f\n timestamp: %lld\n rawDataSize: %d\n rawData: %p\n Session status: %d\n Technology mask: %u",
location.gpsLocation.flags, location.position_source,
location.gpsLocation.latitude, location.gpsLocation.longitude,
location.gpsLocation.altitude, location.gpsLocation.speed,
location.gpsLocation.bearing, location.gpsLocation.accuracy,
location.gpsLocation.timestamp, location.rawDataSize,
location.rawData,status,technology_mask);
}
};
struct loc_eng_msg_report_sv : public loc_eng_msg {
const GpsSvStatus svStatus;
const GpsLocationExtended locationExtended;
const void* svExt;
inline loc_eng_msg_report_sv(void* instance, GpsSvStatus &sv, void* ext) :
loc_eng_msg(instance, LOC_ENG_MSG_REPORT_SV), svStatus(sv), svExt(ext)
inline loc_eng_msg_report_sv(void* instance, GpsSvStatus &sv, GpsLocationExtended &locExtended, void* ext) :
loc_eng_msg(instance, LOC_ENG_MSG_REPORT_SV), svStatus(sv), locationExtended(locExtended), svExt(ext)
{
LOC_LOGV("num sv: %d\n ephemeris mask: %dxn almanac mask: %x\n used in fix mask: %x\n sv: prn snr elevation azimuth",
svStatus.num_svs, svStatus.ephemeris_mask, svStatus.almanac_mask, svStatus.used_in_fix_mask);
@ -256,23 +450,23 @@ struct loc_eng_msg_report_nmea : public loc_eng_msg {
};
struct loc_eng_msg_request_bit : public loc_eng_msg {
const unsigned int isSupl;
const loc_if_req_type_e_type ifType;
const int ipv4Addr;
char* const ipv6Addr;
inline loc_eng_msg_request_bit(void* instance,
unsigned int is_supl,
loc_if_req_type_e_type type,
int ipv4,
char* ipv6) :
loc_eng_msg(instance, LOC_ENG_MSG_REQUEST_BIT),
isSupl(is_supl), ipv4Addr(ipv4),
ifType(type), ipv4Addr(ipv4),
ipv6Addr(NULL == ipv6 ? NULL : new char[16])
{
if (NULL != ipv6Addr)
memcpy(ipv6Addr, ipv6, 16);
LOC_LOGV("isSupl: %d, ipv4: %d.%d.%d.%d, ipv6: %s", isSupl,
(unsigned char)ipv4>>24,
(unsigned char)ipv4>>16,
(unsigned char)ipv4>>8,
LOC_LOGV("ifType: %d, ipv4: %d.%d.%d.%d, ipv6: %s", ifType,
(unsigned char)(ipv4>>24),
(unsigned char)(ipv4>>16),
(unsigned char)(ipv4>>8),
(unsigned char)ipv4,
NULL != ipv6Addr ? ipv6Addr : "");
}
@ -285,24 +479,61 @@ struct loc_eng_msg_request_bit : public loc_eng_msg {
}
};
struct loc_eng_msg_request_wifi : public loc_eng_msg {
const loc_if_req_type_e_type ifType;
const loc_if_req_sender_id_e_type senderId;
char* const ssid;
char* const password;
inline loc_eng_msg_request_wifi(void* instance,
loc_if_req_type_e_type type,
loc_if_req_sender_id_e_type sender_id,
char* s,
char* p) :
loc_eng_msg(instance, LOC_ENG_MSG_REQUEST_WIFI),
ifType(type), senderId(sender_id),
ssid(NULL == s ? NULL : new char[SSID_BUF_SIZE]),
password(NULL == p ? NULL : new char[SSID_BUF_SIZE])
{
if (NULL != ssid)
strlcpy(ssid, s, SSID_BUF_SIZE);
if (NULL != password)
strlcpy(password, p, SSID_BUF_SIZE);
LOC_LOGV("ifType: %d, senderId: %d, ssid: %s, password: %s",
ifType,
senderId,
NULL != ssid ? ssid : "",
NULL != password ? password : "");
}
inline ~loc_eng_msg_request_wifi()
{
if (NULL != ssid) {
delete[] ssid;
}
if (NULL != password) {
delete[] password;
}
}
};
struct loc_eng_msg_release_bit : public loc_eng_msg {
const unsigned int isSupl;
const loc_if_req_type_e_type ifType;
const int ipv4Addr;
char* const ipv6Addr;
inline loc_eng_msg_release_bit(void* instance,
unsigned int is_supl,
loc_if_req_type_e_type type,
int ipv4,
char* ipv6) :
loc_eng_msg(instance, LOC_ENG_MSG_RELEASE_BIT),
isSupl(is_supl), ipv4Addr(ipv4),
ifType(type), ipv4Addr(ipv4),
ipv6Addr(NULL == ipv6 ? NULL : new char[16])
{
if (NULL != ipv6Addr)
memcpy(ipv6Addr, ipv6, 16);
LOC_LOGV("isSupl: %d, ipv4: %d.%d.%d.%d, ipv6: %s", isSupl,
(unsigned char)ipv4>>24,
(unsigned char)ipv4>>16,
(unsigned char)ipv4>>8,
LOC_LOGV("ifType: %d, ipv4: %d.%d.%d.%d, ipv6: %s", ifType,
(unsigned char)(ipv4>>24),
(unsigned char)(ipv4>>16),
(unsigned char)(ipv4>>8),
(unsigned char)ipv4,
NULL != ipv6Addr ? ipv6Addr : "");
}
@ -315,6 +546,43 @@ struct loc_eng_msg_release_bit : public loc_eng_msg {
}
};
struct loc_eng_msg_release_wifi : public loc_eng_msg {
const loc_if_req_type_e_type ifType;
const loc_if_req_sender_id_e_type senderId;
char* const ssid;
char* const password;
inline loc_eng_msg_release_wifi(void* instance,
loc_if_req_type_e_type type,
loc_if_req_sender_id_e_type sender_id,
char* s,
char* p) :
loc_eng_msg(instance, LOC_ENG_MSG_RELEASE_WIFI),
ifType(type), senderId(sender_id),
ssid(NULL == s ? NULL : new char[SSID_BUF_SIZE]),
password(NULL == p ? NULL : new char[SSID_BUF_SIZE])
{
if (NULL != s)
strlcpy(ssid, s, SSID_BUF_SIZE);
if (NULL != p)
strlcpy(password, p, SSID_BUF_SIZE);
LOC_LOGV("ifType: %d, senderId: %d, ssid: %s, password: %s",
ifType,
senderId,
NULL != ssid ? ssid : "",
NULL != password ? password : "");
}
inline ~loc_eng_msg_release_wifi()
{
if (NULL != ssid) {
delete[] ssid;
}
if (NULL != password) {
delete[] password;
}
}
};
struct loc_eng_msg_request_atl : public loc_eng_msg {
const int handle;
const AGpsType type;
@ -452,7 +720,7 @@ struct loc_eng_msg_inject_xtra_data : public loc_eng_msg {
}
};
#ifdef QCOM_FEATURE_IPV6
#ifdef FEATURE_IPV6
struct loc_eng_msg_atl_open_success : public loc_eng_msg {
const AGpsStatusValue agpsType;
const int length;
@ -502,7 +770,7 @@ struct loc_eng_msg_atl_open_success : public loc_eng_msg {
};
#endif
#ifdef QCOM_FEATURE_IPV6
#ifdef FEATURE_IPV6
struct loc_eng_msg_atl_open_failed : public loc_eng_msg {
const AGpsStatusValue agpsType;
inline loc_eng_msg_atl_open_failed(void* instance,
@ -524,7 +792,7 @@ struct loc_eng_msg_atl_open_failed : public loc_eng_msg {
};
#endif
#ifdef QCOM_FEATURE_IPV6
#ifdef FEATURE_IPV6
struct loc_eng_msg_atl_closed : public loc_eng_msg {
const AGpsStatusValue agpsType;
inline loc_eng_msg_atl_closed(void* instance,
@ -567,6 +835,118 @@ struct loc_eng_msg_set_data_enable : public loc_eng_msg {
}
};
struct loc_eng_msg_request_network_position : public loc_eng_msg {
const UlpNetworkRequestPos networkPosRequest;
inline loc_eng_msg_request_network_position (void* instance, UlpNetworkRequestPos networkPosReq) :
loc_eng_msg(instance, LOC_ENG_MSG_REQUEST_NETWORK_POSIITON),
networkPosRequest(networkPosReq)
{
LOC_LOGV("network position request: desired pos source %d\n request type: %d\n interval ms: %d ",
networkPosReq.desired_position_source,
networkPosReq.request_type,
networkPosReq.interval_ms);
}
};
struct loc_eng_msg_request_phone_context : public loc_eng_msg {
const UlpPhoneContextRequest contextRequest;
inline loc_eng_msg_request_phone_context (void* instance, UlpPhoneContextRequest contextReq) :
loc_eng_msg(instance, LOC_ENG_MSG_REQUEST_PHONE_CONTEXT),
contextRequest(contextReq)
{
LOC_LOGV("phone context request: request type 0x%x context type: 0x%x ",
contextRequest.request_type,
contextRequest.context_type);
}
};
struct ulp_msg_update_criteria : public loc_eng_msg {
const UlpLocationCriteria locationCriteria;
inline ulp_msg_update_criteria (void* instance, UlpLocationCriteria criteria) :
loc_eng_msg(instance, ULP_MSG_UPDATE_CRITERIA),
locationCriteria(criteria)
{
LOC_LOGV("location criteria: aciton %d\n valid mask: %d\n provider source: %d\n accuracy %d\n recurrence type %d\n min interval %d\n power consumption %d\n intermediate pos %d ",
locationCriteria.action,
locationCriteria.valid_mask,
locationCriteria.provider_source,
locationCriteria.preferred_horizontal_accuracy,
locationCriteria.recurrence_type,
locationCriteria.min_interval,
locationCriteria.preferred_power_consumption,
locationCriteria.intermediate_pos_report_enabled);
}
};
struct ulp_msg_inject_raw_command : public loc_eng_msg {
const char* rawCommand;
const int rawCommandLength;
inline ulp_msg_inject_raw_command (void* instance, char* command, int length) :
loc_eng_msg(instance, ULP_MSG_INJECT_RAW_COMMAND),
rawCommand(new char[length]),
rawCommandLength(length)
{
memcpy((void*)rawCommand, (void*)command, length);
LOC_LOGV("inject raw command: command %s\n command length: %d\n ",
rawCommand,
rawCommandLength);
}
inline ~ulp_msg_inject_raw_command()
{
delete[] rawCommand;
}
};
struct ulp_msg_inject_phone_context_settings : public loc_eng_msg {
const UlpPhoneContextSettings phoneSetting;
inline ulp_msg_inject_phone_context_settings(void* instance, UlpPhoneContextSettings setting) :
loc_eng_msg(instance, ULP_MSG_INJECT_PHONE_CONTEXT_SETTINGS),
phoneSetting(setting)
{
LOC_LOGV("context type: %d\n gps enabled: %d\n network position available %d\n wifi setting enabled %d\n battery charging %d"
"is_agps_setting_enabled %d, is_enh_location_services_enabled %d\n",
phoneSetting.context_type,
phoneSetting.is_gps_enabled,
phoneSetting.is_network_position_available,
phoneSetting.is_wifi_setting_enabled,
phoneSetting.is_battery_charging,
phoneSetting.is_agps_enabled,
phoneSetting.is_enh_location_services_enabled);
}
};
struct ulp_msg_inject_network_position : public loc_eng_msg {
const UlpNetworkPositionReport networkPosition;
inline ulp_msg_inject_network_position(void* instance, UlpNetworkPositionReport networkPos) :
loc_eng_msg(instance, ULP_MSG_INJECT_NETWORK_POSITION),
networkPosition(networkPos)
{
LOC_LOGV("flags: %d\n source: %d\n latitude: %f\n longitude: %f\n accuracy %f",
networkPosition.valid_flag,
networkPosition.position.pos_source,
networkPosition.position.latitude,
networkPosition.position.longitude,
networkPosition.position.HEPE);
}
};
struct ulp_msg_report_quipc_position : public loc_eng_msg {
const UlpLocation location;
const int quipc_error_code;
inline ulp_msg_report_quipc_position(void* instance, UlpLocation &loc,
int quipc_err) :
loc_eng_msg(instance, ULP_MSG_REPORT_QUIPC_POSITION),
location(loc), quipc_error_code(quipc_err)
{
LOC_LOGV("flags: %d\n source: %d\n latitude: %f\n longitude: %f\n altitude: %f\n speed: %f\n bearing: %f\n accuracy: %f\n timestamp: %lld\n rawDataSize: %d\n rawData: %p\n Quipc error: %d",
location.gpsLocation.flags, location.position_source, location.gpsLocation.latitude, location.gpsLocation.longitude,
location.gpsLocation.altitude, location.gpsLocation.speed, location.gpsLocation.bearing, location.gpsLocation.accuracy,
location.gpsLocation.timestamp, location.rawDataSize, location.rawData,
quipc_error_code);
}
};
void loc_eng_msg_sender(void* loc_eng_data_p, void* msg);
int loc_eng_msgget(int * p_req_msgq);
int loc_eng_msgremove(int req_msgq);

View file

@ -1,4 +1,4 @@
/* Copyright (c) 2011, Code Aurora Forum. All rights reserved.
/* 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
@ -9,7 +9,7 @@
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of Code Aurora Forum, Inc. nor the names of its
* * Neither the name of The Linux Foundation, nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
@ -76,11 +76,61 @@ enum loc_eng_msg_ids_t {
LOC_ENG_MSG_RELEASE_BIT,
LOC_ENG_MSG_REQUEST_ATL,
LOC_ENG_MSG_RELEASE_ATL,
LOC_ENG_MSG_REQUEST_WIFI,
LOC_ENG_MSG_RELEASE_WIFI,
LOC_ENG_MSG_REQUEST_NI,
LOC_ENG_MSG_INFORM_NI_RESPONSE,
LOC_ENG_MSG_REQUEST_XTRA_DATA,
LOC_ENG_MSG_REQUEST_TIME,
LOC_ENG_MSG_REQUEST_POSITION
LOC_ENG_MSG_REQUEST_POSITION,
LOC_ENG_MSG_EXT_POWER_CONFIG,
// The following messages are added for ulp
LOC_ENG_MSG_REQUEST_PHONE_CONTEXT,
LOC_ENG_MSG_REQUEST_NETWORK_POSIITON,
/* Following messages are for ulp, start at index 0x600 */
// Message is sent by GPS HAL layer to add/remove unique request criteria
ULP_MSG_UPDATE_CRITERIA = 0x600,
// Message is sent by GPS HAL layer to request ULP to start producing position fixes
ULP_MSG_START_FIX,
// Message is sent by Android framework(GpsLocationProvider)
// to request ULP to stop producing position fixes
ULP_MSG_STOP_FIX,
// Message is sent by Android framework(GpsLocationProvider)
// to inject phone context setting include initial phone context setting and subsequent changes
ULP_MSG_INJECT_PHONE_CONTEXT_SETTINGS,
// Message is sent by network provider to INJECT the position in UlpNetworkPositionReport format
ULP_MSG_INJECT_NETWORK_POSITION,
// Message is sent by QUIPC provider in order to report the position in GpsPosition format with QUIPC status
ULP_MSG_REPORT_QUIPC_POSITION,
// Message is sent by QUIPC module in order to request some info from ULP
ULP_MSG_REQUEST_COARSE_POSITION,
// Message is sent to ULP module to re-evaluate its subsystems
ULP_MSG_MONITOR,
// Last ULP MSG
ULP_MSG_LAST = 0x700,
/* Message is sent by HAL to LOC API to configure LTE Positioning
Profile in modem */
LOC_ENG_MSG_LPP_CONFIG,
// Message is sent by Android framework (GpsLocationProvider)
// to inject the raw command
ULP_MSG_INJECT_RAW_COMMAND,
/* Message is sent by HAL to LOC API to select A-GLONASS protocol */
LOC_ENG_MSG_A_GLONASS_PROTOCOL,
};
#ifdef __cplusplus

View file

@ -1,4 +1,4 @@
/* Copyright (c) 2009,2011 Code Aurora Forum. All rights reserved.
/* Copyright (c) 2009-2012, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@ -9,7 +9,7 @@
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of Code Aurora Forum, Inc. nor the names of its
* * Neither the name of The Linux Foundation, nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
@ -249,7 +249,9 @@ void loc_eng_ni_init(loc_eng_data_s_type &loc_eng_data, GpsNiCallbacks *callback
{
ENTRY_LOG_CALLFLOW();
if (NULL == callbacks->notify_cb) {
if(callbacks == NULL)
EXIT_LOG(%s, "loc_eng_ni_init: failed, cb is NULL");
else if (NULL == callbacks->notify_cb) {
EXIT_LOG(%s, "loc_eng_ni_init: failed, no cb.");
} else if (NULL != loc_eng_data.ni_notify_cb) {
EXIT_LOG(%s, "loc_eng_ni_init: already inited.");

View file

@ -1,4 +1,4 @@
/* Copyright (c) 2009,2011 Code Aurora Forum. All rights reserved.
/* Copyright (c) 2009,2011 The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@ -9,7 +9,7 @@
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of Code Aurora Forum, Inc. nor the names of its
* * Neither the name of The Linux Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*

View file

@ -0,0 +1,703 @@
/* Copyright (c) 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.
*
*/
#define LOG_NDDEBUG 0
#define LOG_TAG "LocSvc_eng_nmea"
#include <loc_eng.h>
#include <loc_eng_nmea.h>
#include <math.h>
#include "log_util.h"
/*===========================================================================
FUNCTION loc_eng_nmea_send
DESCRIPTION
send out NMEA sentence
DEPENDENCIES
NONE
RETURN VALUE
Total length of the nmea sentence
SIDE EFFECTS
N/A
===========================================================================*/
void loc_eng_nmea_send(char *pNmea, int length, loc_eng_data_s_type *loc_eng_data_p)
{
struct timeval tv;
gettimeofday(&tv, (struct timezone *) NULL);
int64_t now = tv.tv_sec * 1000LL + tv.tv_usec / 1000;
CALLBACK_LOG_CALLFLOW("nmea_cb", %p, pNmea);
loc_eng_data_p->nmea_cb(now, pNmea, length);
LOC_LOGD("NMEA <%s", pNmea);
}
/*===========================================================================
FUNCTION loc_eng_nmea_put_checksum
DESCRIPTION
Generate NMEA sentences generated based on position report
DEPENDENCIES
NONE
RETURN VALUE
Total length of the nmea sentence
SIDE EFFECTS
N/A
===========================================================================*/
int loc_eng_nmea_put_checksum(char *pNmea, int maxSize)
{
uint8_t checksum = 0;
int length = 0;
pNmea++; //skip the $
while (*pNmea != '\0')
{
checksum ^= *pNmea++;
length++;
}
int checksumLength = snprintf(pNmea,(maxSize-length-1),"*%02X\r\n", checksum);
return (length + checksumLength);
}
/*===========================================================================
FUNCTION loc_eng_nmea_generate_pos
DESCRIPTION
Generate NMEA sentences generated based on position report
DEPENDENCIES
NONE
RETURN VALUE
0
SIDE EFFECTS
N/A
===========================================================================*/
void loc_eng_nmea_generate_pos(loc_eng_data_s_type *loc_eng_data_p,
const UlpLocation &location, const GpsLocationExtended &locationExtended)
{
ENTRY_LOG();
char sentence[NMEA_SENTENCE_MAX_LENGTH] = {0};
char* pMarker = sentence;
int lengthRemaining = sizeof(sentence);
int length = 0;
time_t utcTime(location.gpsLocation.timestamp/1000);
tm * pTm = gmtime(&utcTime);
int utcYear = pTm->tm_year % 100; // 2 digit year
int utcMonth = pTm->tm_mon + 1; // tm_mon starts at zero
int utcDay = pTm->tm_mday;
int utcHours = pTm->tm_hour;
int utcMinutes = pTm->tm_min;
int utcSeconds = pTm->tm_sec;
// ------------------
// ------$GPGSA------
// ------------------
uint32_t svUsedCount = 0;
uint32_t svUsedList[32] = {0};
uint32_t mask = loc_eng_data_p->sv_used_mask;
for (uint8_t i = 1; mask > 0 && svUsedCount < 32; i++)
{
if (mask & 1)
svUsedList[svUsedCount++] = i;
mask = mask >> 1;
}
// clear the cache so they can't be used again
loc_eng_data_p->sv_used_mask = 0;
char fixType;
if (svUsedCount == 0)
fixType = '1'; // no fix
else if (svUsedCount <= 3)
fixType = '2'; // 2D fix
else
fixType = '3'; // 3D fix
length = snprintf(pMarker, lengthRemaining, "$GPGSA,A,%c,", fixType);
if (length < 0 || length >= lengthRemaining)
{
LOC_LOGE("NMEA Error in string formatting");
return;
}
pMarker += length;
lengthRemaining -= length;
for (uint8_t i = 0; i < 12; i++) // only the first 12 sv go in sentence
{
if (i < svUsedCount)
length = snprintf(pMarker, lengthRemaining, "%02d,", svUsedList[i]);
else
length = snprintf(pMarker, lengthRemaining, ",");
if (length < 0 || length >= lengthRemaining)
{
LOC_LOGE("NMEA Error in string formatting");
return;
}
pMarker += length;
lengthRemaining -= length;
}
if (locationExtended.flags & GPS_LOCATION_EXTENDED_HAS_DOP)
{ // dop is in locationExtended, (QMI)
length = snprintf(pMarker, lengthRemaining, "%.1f,%.1f,%.1f",
locationExtended.pdop,
locationExtended.hdop,
locationExtended.vdop);
}
else if (loc_eng_data_p->pdop > 0 && loc_eng_data_p->hdop > 0 && loc_eng_data_p->vdop > 0)
{ // dop was cached from sv report (RPC)
length = snprintf(pMarker, lengthRemaining, "%.1f,%.1f,%.1f",
loc_eng_data_p->pdop,
loc_eng_data_p->hdop,
loc_eng_data_p->vdop);
}
else
{ // no dop
length = snprintf(pMarker, lengthRemaining, ",,");
}
length = loc_eng_nmea_put_checksum(sentence, sizeof(sentence));
loc_eng_nmea_send(sentence, length, loc_eng_data_p);
// ------------------
// ------$GPVTG------
// ------------------
pMarker = sentence;
lengthRemaining = sizeof(sentence);
if (location.gpsLocation.flags & GPS_LOCATION_HAS_BEARING)
{
float magTrack = location.gpsLocation.bearing;
if (locationExtended.flags & GPS_LOCATION_EXTENDED_HAS_MAG_DEV)
{
float magTrack = location.gpsLocation.bearing - locationExtended.magneticDeviation;
if (magTrack < 0.0)
magTrack += 360.0;
else if (magTrack > 360.0)
magTrack -= 360.0;
}
length = snprintf(pMarker, lengthRemaining, "$GPVTG,%.1lf,T,%.1lf,M,", location.gpsLocation.bearing, magTrack);
}
else
{
length = snprintf(pMarker, lengthRemaining, "$GPVTG,,T,,M,");
}
if (length < 0 || length >= lengthRemaining)
{
LOC_LOGE("NMEA Error in string formatting");
return;
}
pMarker += length;
lengthRemaining -= length;
if (location.gpsLocation.flags & GPS_LOCATION_HAS_SPEED)
{
float speedKnots = location.gpsLocation.speed * (3600.0/1852.0);
float speedKmPerHour = location.gpsLocation.speed * 3.6;
length = snprintf(pMarker, lengthRemaining, "%.1lf,N,%.1lf,K,", speedKnots, speedKmPerHour);
}
else
{
length = snprintf(pMarker, lengthRemaining, ",N,,K,");
}
if (length < 0 || length >= lengthRemaining)
{
LOC_LOGE("NMEA Error in string formatting");
return;
}
pMarker += length;
lengthRemaining -= length;
if (!(location.gpsLocation.flags & GPS_LOCATION_HAS_LAT_LONG))
length = snprintf(pMarker, lengthRemaining, "%c", 'N'); // N means no fix
else if (LOC_POSITION_MODE_STANDALONE == loc_eng_data_p->client_handle->getPositionMode().mode)
length = snprintf(pMarker, lengthRemaining, "%c", 'A'); // A means autonomous
else
length = snprintf(pMarker, lengthRemaining, "%c", 'D'); // D means differential
length = loc_eng_nmea_put_checksum(sentence, sizeof(sentence));
loc_eng_nmea_send(sentence, length, loc_eng_data_p);
// ------------------
// ------$GPRMC------
// ------------------
pMarker = sentence;
lengthRemaining = sizeof(sentence);
length = snprintf(pMarker, lengthRemaining, "$GPRMC,%02d%02d%02d,A," ,
utcHours, utcMinutes, utcSeconds);
if (length < 0 || length >= lengthRemaining)
{
LOC_LOGE("NMEA Error in string formatting");
return;
}
pMarker += length;
lengthRemaining -= length;
if (location.gpsLocation.flags & GPS_LOCATION_HAS_LAT_LONG)
{
double latitude = location.gpsLocation.latitude;
double longitude = location.gpsLocation.longitude;
char latHemisphere;
char lonHemisphere;
double latMinutes;
double lonMinutes;
if (latitude > 0)
{
latHemisphere = 'N';
}
else
{
latHemisphere = 'S';
latitude *= -1.0;
}
if (longitude < 0)
{
lonHemisphere = 'W';
longitude *= -1.0;
}
else
{
lonHemisphere = 'E';
}
latMinutes = fmod(latitude * 60.0 , 60.0);
lonMinutes = fmod(longitude * 60.0 , 60.0);
length = snprintf(pMarker, lengthRemaining, "%02d%09.6lf,%c,%03d%09.6lf,%c,",
(uint8_t)floor(latitude), latMinutes, latHemisphere,
(uint8_t)floor(longitude),lonMinutes, lonHemisphere);
}
else
{
length = snprintf(pMarker, lengthRemaining,",,,,");
}
if (length < 0 || length >= lengthRemaining)
{
LOC_LOGE("NMEA Error in string formatting");
return;
}
pMarker += length;
lengthRemaining -= length;
if (location.gpsLocation.flags & GPS_LOCATION_HAS_SPEED)
{
float speedKnots = location.gpsLocation.speed * (3600.0/1852.0);
length = snprintf(pMarker, lengthRemaining, "%.1lf,", speedKnots);
}
else
{
length = snprintf(pMarker, lengthRemaining, ",");
}
if (length < 0 || length >= lengthRemaining)
{
LOC_LOGE("NMEA Error in string formatting");
return;
}
pMarker += length;
lengthRemaining -= length;
if (location.gpsLocation.flags & GPS_LOCATION_HAS_BEARING)
{
length = snprintf(pMarker, lengthRemaining, "%.1lf,", location.gpsLocation.bearing);
}
else
{
length = snprintf(pMarker, lengthRemaining, ",");
}
if (length < 0 || length >= lengthRemaining)
{
LOC_LOGE("NMEA Error in string formatting");
return;
}
pMarker += length;
lengthRemaining -= length;
length = snprintf(pMarker, lengthRemaining, "%2.2d%2.2d%2.2d,",
utcDay, utcMonth, utcYear);
if (length < 0 || length >= lengthRemaining)
{
LOC_LOGE("NMEA Error in string formatting");
return;
}
pMarker += length;
lengthRemaining -= length;
if (locationExtended.flags & GPS_LOCATION_EXTENDED_HAS_MAG_DEV)
{
float magneticVariation = locationExtended.magneticDeviation;
char direction;
if (magneticVariation < 0.0)
{
direction = 'W';
magneticVariation *= -1.0;
}
else
{
direction = 'E';
}
length = snprintf(pMarker, lengthRemaining, "%.1lf,%c,",
magneticVariation, direction);
}
else
{
length = snprintf(pMarker, lengthRemaining, ",,");
}
if (length < 0 || length >= lengthRemaining)
{
LOC_LOGE("NMEA Error in string formatting");
return;
}
pMarker += length;
lengthRemaining -= length;
if (!(location.gpsLocation.flags & GPS_LOCATION_HAS_LAT_LONG))
length = snprintf(pMarker, lengthRemaining, "%c", 'N'); // N means no fix
else if (LOC_POSITION_MODE_STANDALONE == loc_eng_data_p->client_handle->getPositionMode().mode)
length = snprintf(pMarker, lengthRemaining, "%c", 'A'); // A means autonomous
else
length = snprintf(pMarker, lengthRemaining, "%c", 'D'); // D means differential
length = loc_eng_nmea_put_checksum(sentence, sizeof(sentence));
loc_eng_nmea_send(sentence, length, loc_eng_data_p);
// ------------------
// ------$GPGGA------
// ------------------
pMarker = sentence;
lengthRemaining = sizeof(sentence);
length = snprintf(pMarker, lengthRemaining, "$GPGGA,%02d%02d%02d," ,
utcHours, utcMinutes, utcSeconds);
if (length < 0 || length >= lengthRemaining)
{
LOC_LOGE("NMEA Error in string formatting");
return;
}
pMarker += length;
lengthRemaining -= length;
if (location.gpsLocation.flags & GPS_LOCATION_HAS_LAT_LONG)
{
double latitude = location.gpsLocation.latitude;
double longitude = location.gpsLocation.longitude;
char latHemisphere;
char lonHemisphere;
double latMinutes;
double lonMinutes;
if (latitude > 0)
{
latHemisphere = 'N';
}
else
{
latHemisphere = 'S';
latitude *= -1.0;
}
if (longitude < 0)
{
lonHemisphere = 'W';
longitude *= -1.0;
}
else
{
lonHemisphere = 'E';
}
latMinutes = fmod(latitude * 60.0 , 60.0);
lonMinutes = fmod(longitude * 60.0 , 60.0);
length = snprintf(pMarker, lengthRemaining, "%02d%09.6lf,%c,%03d%09.6lf,%c,",
(uint8_t)floor(latitude), latMinutes, latHemisphere,
(uint8_t)floor(longitude),lonMinutes, lonHemisphere);
}
else
{
length = snprintf(pMarker, lengthRemaining,",,,,");
}
if (length < 0 || length >= lengthRemaining)
{
LOC_LOGE("NMEA Error in string formatting");
return;
}
pMarker += length;
lengthRemaining -= length;
char gpsQuality;
if (!(location.gpsLocation.flags & GPS_LOCATION_HAS_LAT_LONG))
gpsQuality = '0'; // 0 means no fix
else if (LOC_POSITION_MODE_STANDALONE == loc_eng_data_p->client_handle->getPositionMode().mode)
gpsQuality = '1'; // 1 means GPS fix
else
gpsQuality = '2'; // 2 means DGPS fix
if (locationExtended.flags & GPS_LOCATION_EXTENDED_HAS_DOP)
{ // dop is in locationExtended, (QMI)
length = snprintf(pMarker, lengthRemaining, "%c,%02d,%.1f,",
gpsQuality, svUsedCount, locationExtended.hdop);
}
else if (loc_eng_data_p->pdop > 0 && loc_eng_data_p->hdop > 0 && loc_eng_data_p->vdop > 0)
{ // dop was cached from sv report (RPC)
length = snprintf(pMarker, lengthRemaining, "%c,%02d,%.1f,",
gpsQuality, svUsedCount, loc_eng_data_p->hdop);
}
else
{ // no hdop
length = snprintf(pMarker, lengthRemaining, "%c,%02d,,",
gpsQuality, svUsedCount);
}
if (length < 0 || length >= lengthRemaining)
{
LOC_LOGE("NMEA Error in string formatting");
return;
}
pMarker += length;
lengthRemaining -= length;
if (locationExtended.flags & GPS_LOCATION_EXTENDED_HAS_ALTITUDE_MEAN_SEA_LEVEL)
{
length = snprintf(pMarker, lengthRemaining, "%.1lf,M,",
locationExtended.altitudeMeanSeaLevel);
}
else
{
length = snprintf(pMarker, lengthRemaining,",,");
}
if (length < 0 || length >= lengthRemaining)
{
LOC_LOGE("NMEA Error in string formatting");
return;
}
pMarker += length;
lengthRemaining -= length;
if ((location.gpsLocation.flags & GPS_LOCATION_HAS_ALTITUDE) &&
(locationExtended.flags & GPS_LOCATION_EXTENDED_HAS_ALTITUDE_MEAN_SEA_LEVEL))
{
length = snprintf(pMarker, lengthRemaining, "%.1lf,M,,",
location.gpsLocation.altitude - locationExtended.altitudeMeanSeaLevel);
}
else
{
length = snprintf(pMarker, lengthRemaining,",,,");
}
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;
loc_eng_data_p->vdop = 0;
EXIT_LOG(%d, 0);
}
/*===========================================================================
FUNCTION loc_eng_nmea_generate_sv
DESCRIPTION
Generate NMEA sentences generated based on sv report
DEPENDENCIES
NONE
RETURN VALUE
0
SIDE EFFECTS
N/A
===========================================================================*/
void loc_eng_nmea_generate_sv(loc_eng_data_s_type *loc_eng_data_p,
const GpsSvStatus &svStatus, const GpsLocationExtended &locationExtended)
{
ENTRY_LOG();
char sentence[NMEA_SENTENCE_MAX_LENGTH] = {0};
char* pMarker = sentence;
int lengthRemaining = sizeof(sentence);
int length = 0;
// ------------------
// ------$GPGSV------
// ------------------
if (svStatus.num_svs <= 0)
{
// no svs in view, so just send a blank $GPGSV sentence
strlcpy(sentence, "$GPGSV,1,1,0,", sizeof(sentence));
length = loc_eng_nmea_put_checksum(sentence, sizeof(sentence));
loc_eng_nmea_send(sentence, length, loc_eng_data_p);
}
else
{
int svCount = svStatus.num_svs;
int sentenceCount = svCount / 4;
if (svStatus.num_svs % 4)
sentenceCount++;
int sentenceNumber = 1;
int svNumber = 1;
while (sentenceNumber <= sentenceCount)
{
pMarker = sentence;
lengthRemaining = sizeof(sentence);
length = snprintf(pMarker, lengthRemaining, "$GPGSV,%d,%d,%02d",
sentenceCount, sentenceNumber, svCount);
if (length < 0 || length >= lengthRemaining)
{
LOC_LOGE("NMEA Error in string formatting");
return;
}
pMarker += length;
lengthRemaining -= length;
for (int i=0; (svNumber <= svCount) && (i < 4); i++, svNumber++)
{
length = snprintf(pMarker, lengthRemaining,",%02d,%02d,%03d,",
svStatus.sv_list[svNumber-1].prn,
(int)(0.5 + svStatus.sv_list[svNumber-1].elevation), //float to int
(int)(0.5 + svStatus.sv_list[svNumber-1].azimuth)); //float to int
if (length < 0 || length >= lengthRemaining)
{
LOC_LOGE("NMEA Error in string formatting");
return;
}
pMarker += length;
lengthRemaining -= length;
if (svStatus.sv_list[svNumber-1].snr > 0)
{
length = snprintf(pMarker, lengthRemaining,"%02d",
(int)(0.5 + svStatus.sv_list[svNumber-1].snr)); //float to int
if (length < 0 || length >= lengthRemaining)
{
LOC_LOGE("NMEA Error in string formatting");
return;
}
pMarker += length;
lengthRemaining -= length;
}
}
length = loc_eng_nmea_put_checksum(sentence, sizeof(sentence));
loc_eng_nmea_send(sentence, length, loc_eng_data_p);
sentenceNumber++;
}
}
if (svStatus.used_in_fix_mask == 0)
{ // No sv used, so there will be no position report, so send
// blank NMEA sentences
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);
}
else
{ // cache the used in fix mask, as it will be needed to send $GPGSA
// during the position report
loc_eng_data_p->sv_used_mask = svStatus.used_in_fix_mask;
// For RPC, the DOP are sent during sv report, so cache them
// now to be sent during position report.
// For QMI, the DOP will be in position report.
if (locationExtended.flags & GPS_LOCATION_EXTENDED_HAS_DOP)
{
loc_eng_data_p->pdop = locationExtended.pdop;
loc_eng_data_p->hdop = locationExtended.hdop;
loc_eng_data_p->vdop = locationExtended.vdop;
}
else
{
loc_eng_data_p->pdop = 0;
loc_eng_data_p->hdop = 0;
loc_eng_data_p->vdop = 0;
}
}
EXIT_LOG(%d, 0);
}

View file

@ -0,0 +1,42 @@
/* Copyright (c) 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_ENG_NMEA_H
#define LOC_ENG_NMEA_H
#include <hardware/gps.h>
#define NMEA_SENTENCE_MAX_LENGTH 200
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);
#endif // LOC_ENG_NMEA_H

View file

@ -1,4 +1,4 @@
/* Copyright (c) 2009,2011 Code Aurora Forum. All rights reserved.
/* Copyright (c) 2009-2012, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@ -9,7 +9,7 @@
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of Code Aurora Forum, Inc. nor the names of its
* * Neither the name of The Linux Foundation, nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
@ -54,12 +54,17 @@ SIDE EFFECTS
int loc_eng_xtra_init (loc_eng_data_s_type &loc_eng_data,
GpsXtraCallbacks* callbacks)
{
loc_eng_xtra_data_s_type *xtra_module_data_ptr;
int ret_val = -1;
loc_eng_xtra_data_s_type *xtra_module_data_ptr;
xtra_module_data_ptr = &loc_eng_data.xtra_module_data;
xtra_module_data_ptr->download_request_cb = callbacks->download_request_cb;
return 0;
if(callbacks == NULL)
LOC_LOGE("loc_eng_xtra_init: failed, cb is NULL");
else {
xtra_module_data_ptr = &loc_eng_data.xtra_module_data;
xtra_module_data_ptr->download_request_cb = callbacks->download_request_cb;
ret_val = 0;
}
return ret_val;
}
/*===========================================================================

View file

@ -1,4 +1,4 @@
/* Copyright (c) 2009,2011 Code Aurora Forum. All rights reserved.
/* Copyright (c) 2009,2011 The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@ -9,7 +9,7 @@
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of Code Aurora Forum, Inc. nor the names of its
* * Neither the name of The Linux Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*

View file

@ -0,0 +1,415 @@
/* 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_ULP_H__
#define __LOC_ULP_H__
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#include <ctype.h>
#include <stdbool.h>
#include <hardware/gps.h>
#define ULP_ENGINE_INTERFACE "ulp-engine-interface"
#define ULP_NETWORK_INTERFACE "ulp-network-interface"
#define ULP_RAW_CMD_INTERFACE "ulp-raw-cmd"
#define ULP_PHONE_CONTEXT_INTERFACE "ulp-phone-context"
/** Location has valid source information. */
#define LOCATION_HAS_SOURCE_INFO 0x0020
/** GpsLocation has valid "is indoor?" flag */
#define GPS_LOCATION_HAS_IS_INDOOR 0x0040
/** GpsLocation has valid floor number */
#define GPS_LOCATION_HAS_FLOOR_NUMBER 0x0080
/** GpsLocation has valid map URL*/
#define GPS_LOCATION_HAS_MAP_URL 0x0100
/** GpsLocation has valid map index */
#define GPS_LOCATION_HAS_MAP_INDEX 0x0200
/** Sizes for indoor fields */
#define GPS_LOCATION_MAP_URL_SIZE 400
#define GPS_LOCATION_MAP_INDEX_SIZE 16
/** Position source is ULP */
#define ULP_LOCATION_IS_FROM_HYBRID 0x0001
/** Position source is GNSS only */
#define ULP_LOCATION_IS_FROM_GNSS 0x0002
#define ULP_MIN_INTERVAL_INVALID 0xffffffff
/** Represents recurrence of location */
typedef enum{
ULP_LOC_RECURRENCE_PERIODIC = 0,
ULP_LOC_RECURRENCE_SINGLE,
}UlpRecurrenceCriteria;
/** Represents horizontal accuracy options */
typedef enum {
ULP_HORZ_ACCURACY_DONT_CARE = 0,
ULP_HORZ_ACCURACY_LOW,
ULP_HORZ_ACCURACY_MED,
ULP_HORZ_ACCURACY_HIGH,
}UlpHorzAccuracyCriteria;
/** Represents accuracy options (for speed, altitude, and
* bearing) */
typedef enum {
ULP_ACCURACY_DONT_CARE = 0,
ULP_ACCURACY_LOW,
ULP_ACCURACY_HIGH,
}UlpAccuracyCriteria;
/** Represents power consumption options */
typedef enum {
ULP_POWER_REQ_DONT_CARE = 0,
ULP_POWER_REQ_LOW,
ULP_POWER_REQ_HIGH,
}UlpPowerCriteria;
/** Represents data usage options */
typedef enum {
ULP_DATA_REQ_DONT_CARE = 0,
ULP_DATA_ALLOW,
ULP_DATA_DENY,
}UlpDataUsageCriteria;
/** Enable the reporting of altitude in location reports */
#define ULP_ENABLE_ALTITUDE_REPORT 0x01
/** Enable the reporting of speed in location reports */
#define ULP_ENABLE_SPEED_REPORT 0x02
/** Enable the reporting of bearing in location reports */
#define ULP_ENABLE_BEARING_REPORT 0x04
#define ULP_CRITERIA_HAS_ACTION 0x00000001
#define ULP_CRITERIA_HAS_PROVIDER_SOURCE 0x00000002
#define ULP_CRITERIA_HAS_RECURRENCE_TYPE 0x00000004
#define ULP_CRITERIA_HAS_PREFERRED_RESPONSE_TIME 0x00000010
#define ULP_CRITERIA_HAS_MIN_INTERVAL 0x00000020
#define ULP_CRITERIA_HAS_MIN_DISTANCE 0x00000040
#define ULP_CRITERIA_HAS_MIN_DIST_SAMPLE_INTERVAL 0x00000080
#define ULP_CRITERIA_HAS_DESIRED_OUTPUT_PARAMETER 0x00000100
#define ULP_CRITERIA_HAS_PREFERRED_HORIZONTAL_ACCURACY 0x00000200
#define ULP_CRITERIA_HAS_PREFERRED_POWER_CONSUMPTION 0x00000400
#define ULP_CRITERIA_HAS_PREFERRED_ALTITUDE_ACCURACY 0x00000800
#define ULP_CRITERIA_HAS_PREFERRED_BEARING_ACCURACY 0x00001000
#define ULP_CRITERIA_HAS_PREFERRED_DATA_USAGE 0x00002000
#define ULP_CRITERIA_HAS_INTERMEDIATE_POS_REPORT_ENABLED 0x00004000
#define ULP_PROVIDER_SOURCE_GNSS 0x00000001
#define ULP_PROVIDER_SOURCE_HYBRID 0x00000002
#define ULP_ADD_CRITERIA 1
#define ULP_REMOVE_CRITERIA 2
typedef struct {
/** set to sizeof(UlpLocation) */
size_t size;
GpsLocation gpsLocation;
/* Provider indicator for HYBRID or GPS */
uint16_t position_source;
/*allows HAL to pass additional information related to the location */
int rawDataSize; /* in # of bytes */
void * rawData;
bool is_indoor;
float floor_number;
char map_url[GPS_LOCATION_MAP_URL_SIZE];
unsigned char map_index[GPS_LOCATION_MAP_INDEX_SIZE];
} UlpLocation;
/** Callback with location information.
*/
typedef void (* ulp_location_callback)(UlpLocation* location);
/** ULP Engine callback structure. */
typedef struct {
/** set to sizeof(UlpCallbacks) */
size_t size;
ulp_location_callback location_cb;
} UlpEngineCallbacks;
typedef struct {
uint32_t valid_mask;
/* delete or add. This is a mandatory field */
int action;
/*via gps or hybrid provider*/
int provider_source;
/** PERIODIC or SINGLE */
UlpRecurrenceCriteria recurrence_type;
/** obtain position within the specified response time */
uint32_t preferred_response_time;
/** Send updates after the specified interval */
uint32_t min_interval;
/** Send updates after device moved a specified distance */
float min_distance;
uint32_t min_dist_sample_interval;
/** Fields specfied in the mask should be reported in the
* position report (altitude, bearing and speed) */
uint32_t desired_output_parameter;
/** Desired accuracy for latitude, longitude */
UlpHorzAccuracyCriteria preferred_horizontal_accuracy;
/** Desired power consumption level */
UlpPowerCriteria preferred_power_consumption;
/** Desired accuracy for altitude */
UlpAccuracyCriteria preferred_altitude_accuracy;
/** Desired accuracy for bearing */
UlpAccuracyCriteria preferred_bearing_accuracy;
UlpDataUsageCriteria preferred_data_usage;
bool intermediate_pos_report_enabled;
} UlpLocationCriteria;
/** Represents the Ulp Egine interface. */
typedef struct {
/** set to sizeof(UlpEngineInterface) */
size_t size;
/**
* Opens the interface and provides the callback routines
* to the implemenation of this interface.
*/
int (*init)( UlpEngineCallbacks* callbacks );
/* set criterias of location requests */
int (*update_criteria) (UlpLocationCriteria criteria );
/** Starts navigating. */
int (*start)( void );
/** Stops navigating. */
int (*stop)( void );
} UlpEngineInterface;
/** Extended interface for raw GPS command support. */
typedef struct {
/** set to sizeof(ExtraCmdInterface) */
size_t size;
/** Injects Android extra cmd into the ulp. Clarify if they are blocking calls */
bool (*inject_raw_cmd)(char* bundle, int bundle_length );
} InjectRawCmdInterface;
/** ULP Network Interface */
/** Request for network position status */
#define ULP_NETWORK_POS_STATUS_REQUEST (0x01)
/** Request for periodic network positions */
#define ULP_NETWORK_POS_START_PERIODIC_REQUEST (0x02)
/** Request last known location */
#define ULP_NETWORK_POS_GET_LAST_KNOWN_LOCATION_REQUEST (0x03)
/** Cancel request */
#define ULP_NETWORK_POS_STOP_REQUEST (0x04)
/** Position was obtained using Wifi Network */
#define ULP_NETWORK_POSITION_SRC_WIFI (0x01)
/** Position was obtained using Cell Network */
#define ULP_NETWORK_POSITION_SRC_CELL (0x02)
/** Position was obtained using an Unknown Network */
#define ULP_NETWORK_POSITION_SRC_UNKNOWN (0x00)
/** Represents the ULP network request */
typedef struct {
/** type of request */
uint16_t request_type;
/** Desired time between network positions/measurements in ms.
* Shall be set to 0 if only one position is requested */
int interval_ms;
/** network position source to be used */
uint16_t desired_position_source;
}UlpNetworkRequestPos;
/** Callback with network position request. */
typedef void (*ulp_network_location_request)(UlpNetworkRequestPos *req);
/** ULP Network callback structure. */
typedef struct {
ulp_network_location_request ulp_network_location_request_cb;
} UlpNetworkLocationCallbacks;
/** represent a network position */
typedef struct {
/** source of the position (Wifi, Cell) */
uint16_t pos_source;
/** latitude in degrees */
double latitude;
/** longitude in degrees */
double longitude;
/** Horzizontal error estimate in meters */
float HEPE;
} UlpNetworkPosition;
/** Represents access point information */
typedef struct {
/** Mac adderess */
char mac_addr[6];
/** signal strength in dbM */
int32_t rssi;
/** Beacon channel for access point */
uint16_t channel;
/** Bit 0 = AP is used by WiFi positioning system
* Bit 1 = AP doesn't broadcast SSID Bit 2 = AP has encrption
* turned on Bit 3 = AP is in infrastructure mode and not in
* ad-hoc/unknown mode */
uint8_t ap_qualifier;
} UlpNetworkAccessPointInfo;
/** Represents Wifi information */
typedef struct {
/** Number of APs in the calculated position (-1 means
* unknown) */
uint8_t num_aps_in_pos;
/** Information of the scanned ap's used in the position estimation*/
UlpNetworkAccessPointInfo *ap_info;
} UlpNetworkWifiInfo;
/** Represent network landscape information */
typedef struct {
/** network type Cell/Wifi */
uint8_t network_type;
/** network information */
union {
UlpNetworkWifiInfo wifi_info;
uint32_t cell_info;
} u;
} UlpNetworkLandscape;
/** network report valid flags */
/** fix time is valid */
#define ULP_NETWORK_POSITION_REPORT_HAS_FIX_TIME (0x01)
/** position is valid */
#define ULP_NETWORK_POSITION_REPORT_HAS_POSITION (0x02)
/** landscape is valid */
#define ULP_NETWORK_POSITION_REPORT_HAS_LANDSCAPE (0x04)
/** Represents the network position report */
typedef struct
{
/** validity flags */
uint16_t valid_flag;
/** time fo network fix */
GpsUtcTime fix_time;
/** network position */
UlpNetworkPosition position;
/** network landscape */
UlpNetworkLandscape landscape_info;
}UlpNetworkPositionReport;
/** represents ULP network interface extension */
typedef struct
{
/** set to sizeof(UlpNetworkInterface) */
size_t size;
/** initialize network interface */
int ( *init)(UlpNetworkLocationCallbacks *callback);
/** send network position */
int ( *ulp_send_network_position)(UlpNetworkPositionReport *position_report);
}UlpNetworkInterface;
/** Information for the ULP Phone context interface */
/** the Location settings context supports only ON_CHANGE
* request type */
#define ULP_PHONE_CONTEXT_GPS_SETTING (0x01)
#define ULP_PHONE_CONTEXT_NETWORK_POSITION_SETTING (0x02)
#define ULP_PHONE_CONTEXT_WIFI_SETTING (0x04)
/** The battery charging state context supports only
* ON_CHANGE request type */
#define ULP_PHONE_CONTEXT_BATTERY_CHARGING_STATE (0x08)
#define ULP_PHONE_CONTEXT_AGPS_SETTING (0x010)
#define ULP_PHONE_CONTEXT_ENH_LOCATION_SERVICES_SETTING (0x020)
/** return phone context only once */
#define ULP_PHONE_CONTEXT_REQUEST_TYPE_SINGLE (0x01)
/** return phone context periodcially */
#define ULP_PHONE_CONTEXT_REQUEST_TYPE_PERIODIC (0x02)
/** return phone context when it changes */
#define ULP_PHONE_CONTEXT_REQUEST_TYPE_ON_CHANGE (0x03)
/** Represents ULP phone context request */
typedef struct {
/** context type requested */
uint16_t context_type;
/** request type */
uint16_t request_type;
/** interval in ms if request type is periodic */
int interval_ms;
}UlpPhoneContextRequest;
/** Callback for phone context request. */
typedef void (*ulp_request_phone_context)(UlpPhoneContextRequest *req);
/** ULP Phone Context callback structure. */
typedef struct {
ulp_request_phone_context ulp_request_phone_context_cb;
}UlpPhoneContextCallbacks;
/** Represents the phone context settings */
typedef struct {
/** Phone context information type */
uint16_t context_type;
/** network information */
/** gps setting */
bool is_gps_enabled;
/** is network positioning enabled */
bool is_network_position_available;
/** is wifi turned on */
bool is_wifi_setting_enabled;
/** is battery being currently charged */
bool is_battery_charging;
/* is agps enabled for single shot */
bool is_agps_enabled;
/* is Enhanced Location Services enabled by user*/
bool is_enh_location_services_enabled;
} UlpPhoneContextSettings;
/** Represent the phone contxt interface */
typedef struct
{
/** set to sizeof(UlpPhoneContextInterface) */
size_t size;
/** Initialize, register callback */
int (*init)(UlpPhoneContextCallbacks *callback);
/** send the phone context settings */
int (*ulp_phone_context_settings_update) (UlpPhoneContextSettings *settings );
}UlpPhoneContextInterface;
//int loc_update_criteria(UlpLocationCriteria criteria);
//const void* loc_get_extension(const char* name);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif //__LOC_ULP_H__

View file

@ -0,0 +1,50 @@
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
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
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,173 @@
/* 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>
/* 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 {
/* 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);
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,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;
}

View file

@ -0,0 +1,68 @@
/* Copyright (c) 2011, 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_SYNC_REQ_H
#define LOC_SYNC_REQ_H
#ifdef __cplusplus
extern "C"
{
#endif
#include <stdbool.h>
#include <stdint.h>
#include "loc_api_v02_client.h"
#define LOC_ENGINE_SYNC_REQUEST_TIMEOUT (1000) // 1 second
/* Init function */
extern void loc_sync_req_init();
/* Process Loc API indications to wake up blocked user threads */
extern void loc_sync_process_ind(
locClientHandleType client_handle, /* handle of the client */
uint32_t ind_id , /* respInd id */
void *ind_payload_ptr /* payload */
);
/* Thread safe synchronous request, using Loc API status return code */
extern 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*/
);
#ifdef __cplusplus
}
#endif
#endif /* LOC_SYNC_REQ_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,293 @@
/* 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)
};
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[] =
{
QMILOCSTATUSENUMT_MIN_ENUM_VAL_V02,
eQMI_LOC_SUCCESS_V02,
eQMI_LOC_GENERAL_FAILURE_V02,
eQMI_LOC_UNSUPPORTED_V02,
eQMI_LOC_INVALID_PARAMETER_V02,
eQMI_LOC_ENGINE_BUSY_V02,
eQMI_LOC_PHONE_OFFLINE_V02,
eQMI_LOC_TIMEOUT_V02,
eQMI_LOC_CONFIG_NOT_SUPPORTED_V02,
eQMI_LOC_INSUFFICIENT_MEMORY_V02,
QMILOCSTATUSENUMT_MAX_ENUM_VAL_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,50 @@
/* Copyright (c) 2011, 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_V02_LOG_H
#define LOC_API_V02_LOG_H
#ifdef __cplusplus
extern "C"
{
#endif
#include <loc_log.h>
#include <loc_api_v02_client.h>
const char* loc_get_v02_event_name(uint32_t event);
const char* loc_get_v02_client_status_name(locClientStatusEnumType status);
const char* loc_get_v02_qmi_status_name(qmiLocStatusEnumT_v02 status);
#ifdef __cplusplus
}
#endif
#endif /* LOC_API_V02_LOG_H */

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

@ -1,4 +1,4 @@
/* Copyright (c) 2011, Code Aurora Forum. All rights reserved.
/* 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
@ -9,7 +9,7 @@
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of Code Aurora Forum, Inc. nor the names of its
* * Neither the name of The Linux Foundation, nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
@ -36,14 +36,7 @@ extern "C"
#endif
#include <hardware/gps.h>
typedef int (ulp_report_position_cb)
(
void* owner,
const GpsLocation* location_report_ptr,
unsigned int ext_data_length,
unsigned char* ext_data
);
#include "loc_eng.h"
/** Represents the standard ulp module interface. */
typedef struct {
@ -51,24 +44,14 @@ typedef struct {
size_t size;
/**
* Starts the ulp module. 0: success
* Starts the libulp module. 0: success
*/
int (*init)( void* owner, ulp_report_position_cb* cb);
int (*init)(loc_eng_data_s_type &loc_eng_data);
/** Starts the ulp engine. 0: success */
int (*start_fix)( void );
/** Stops the ulp engine. 0: success */
int (*stop_fix)( void );
/** Closes the interface */
int (*destroy)( void );
} ulpInterface;
}ulpInterface;
typedef const ulpInterface* (get_ulp_interface) (void);
#ifdef __cplusplus
}
#endif

8
utils/Android.mk Executable file → Normal file
View file

@ -16,12 +16,15 @@ LOCAL_SRC_FILES += \
loc_log.cpp \
loc_cfg.cpp \
msg_q.c \
linked_list.c
linked_list.c \
loc_target.cpp
LOCAL_CFLAGS += \
-fno-short-enums \
-D_ANDROID_
LOCAL_LDFLAGS += -Wl,--export-dynamic
## Includes
LOCAL_C_INCLUDES:=
@ -31,7 +34,8 @@ LOCAL_COPY_HEADERS:= \
loc_cfg.h \
log_util.h \
linked_list.h \
msg_q.h
msg_q.h \
loc_target.h
LOCAL_MODULE := libgps.utils

View file

@ -1,4 +1,4 @@
/* Copyright (c) 2011, Code Aurora Forum. All rights reserved.
/* Copyright (c) 2011, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@ -9,7 +9,7 @@
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of Code Aurora Forum, Inc. nor the names of its
* * Neither the name of The Linux Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*

Some files were not shown because too many files have changed in this diff Show more