gps: Initial implementation of msm gps hal

Change-Id: Icf126a0bbb9dec414144b9b405694e41777920d5
This commit is contained in:
Ajay Dudani 2012-07-09 15:27:30 -07:00 committed by Iliyan Malchev
parent 80698b8a3d
commit f77c85bb51
121 changed files with 34065 additions and 422 deletions

0
CleanSpec.mk Normal file → Executable file
View file

11
etc/Android.mk Executable file
View file

@ -0,0 +1,11 @@
#LOCAL_PATH := $(call my-dir)
#include $(CLEAR_VARS)
#LOCAL_MODULE := gps.conf
#LOCAL_MODULE_TAGS := optional
#LOCAL_MODULE_CLASS := ETC
#LOCAL_MODULE_PATH := $(TARGET_OUT_ETC)/
#LOCAL_SRC_FILES := gps.conf
#include $(BUILD_PREBUILT)

91
etc/gps.conf Executable file
View file

@ -0,0 +1,91 @@
#Test
NTP_SERVER=time.gpsonextra.net
#Asia
# NTP_SERVER=asia.pool.ntp.org
#Europe
# NTP_SERVER=europe.pool.ntp.org
#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 = 3
# Intermediate position report, 1=enable, 0=disable
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
# ULP = 0x20
# default = MSA | MSB | SCHEDULING | ULP
CAPABILITIES=0x27
# Accuracy threshold for intermediate positions
# less accurate positions are ignored, 0 for passing all positions
# ACCURACY_THRES=5000
################################
##### AGPS server settings #####
################################
# FOR SUPL SUPPORT, set the following
# SUPL_HOST=supl.host.com or IP
# SUPL_PORT=1234
# FOR C2K PDE SUPPORT, set the following
# 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=0
# 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
################################
# EXTRA SETTINGS
################################
# Enable or Disable Wiper (1=Enable, 0=Disable)
ENABLE_WIPER=1
####################################
# LTE Positioning Profile Settings
####################################
# 0: Enable RRLP on LTE(Default) 1: Enable LPP_User_Plane on LTE
LPP_PROFILE = 0

View file

@ -7,5 +7,27 @@
# 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),)
include $(call all-subdir-makefiles)
endif
LOCAL_PATH := $(call my-dir)
GPS_DIR_LIST :=
# add RPC dirs if RPC is available
ifneq ($(TARGET_NO_RPC),true)
GPS_DIR_LIST += $(LOCAL_PATH)/libloc_api-rpc-50001/
GPS_DIR_LIST += $(LOCAL_PATH)/libloc_api-rpc/
GPS_DIR_LIST += $(LOCAL_PATH)/libloc_api/
else
GPS_DIR_LIST += $(LOCAL_PATH)/loc_api_v02/
endif #TARGET_NO_RPC
GPS_DIR_LIST += $(LOCAL_PATH)/libloc_api_50001/
#call the subfolders
include $(addsuffix Android.mk, $(GPS_DIR_LIST))
endif#BOARD_VENDOR_QCOM_GPS_LOC_API_HARDWARE

0
loc_api/NOTICE Normal file → Executable file
View file

View file

@ -0,0 +1,3 @@
ifeq ($(BOARD_VENDOR_QCOM_GPS_LOC_API_AMSS_VERSION),50001)
include $(call all-subdir-makefiles)
endif

View file

@ -0,0 +1,59 @@
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
RPC_INC:=rpc_inc
source_files:= \
src/loc_api_rpc_glue.c \
src/loc_api_sync_call.c \
src/loc_apicb_appinit.c \
src/loc_api_fixup.c \
src/loc_api_log.c \
src/LocApiRpcAdapter.cpp
LOCAL_SRC_FILES:= $(source_files)
LOCAL_CFLAGS:=-fno-short-enums
LOCAL_CFLAGS+=-DDEBUG -DUSE_QCOM_AUTO_RPC -DUSE_QCOM_AUTO_RPC
LOCAL_CFLAGS+=$(GPS_FEATURES)
# for loc_api_fixup.c
LOCAL_CFLAGS+=-DADD_XDR_FLOAT -DADD_XDR_BOOL
LOCAL_SHARED_LIBRARIES:= \
librpc \
libutils \
libcutils \
libcommondefs \
libgps.utils \
libloc_adapter
LOCAL_STATIC_LIBRARIES := \
libloc_api_rpcgen
LOCAL_PRELINK_MODULE:= false
LOCAL_C_INCLUDES:= \
$(LOCAL_PATH) \
$(LOCAL_PATH)/rpc_inc \
$(TARGET_OUT_HEADERS)/gps.utils \
$(TARGET_OUT_HEADERS)/loc_api/rpcgen/inc \
$(TARGET_OUT_HEADERS)/libcommondefs-rpc \
$(TARGET_OUT_HEADERS)/libcommondefs/rpcgen/inc \
$(TARGET_OUT_HEADERS)/librpc \
$(TARGET_OUT_HEADERS)/libloc-rpc/rpc_inc \
$(TARGET_OUT_HEADERS)/libloc_eng \
hardware/msm7k/librpc
LOCAL_COPY_HEADERS_TO:= libloc_api-rpc-qc/$(RPC_INC)
LOCAL_COPY_HEADERS:= \
$(RPC_INC)/loc_api_rpc_glue.h \
$(RPC_INC)/loc_api_fixup.h \
$(RPC_INC)/loc_api_sync_call.h \
$(RPC_INC)/loc_apicb_appinit.h
LOCAL_MODULE:= libloc_api-rpc-qc
LOCAL_MODULE_TAGS := optional
include $(BUILD_SHARED_LIBRARY)

View file

@ -0,0 +1,102 @@
/* Copyright (c) 2011, Code Aurora Forum. 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 Code Aurora Forum, 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 "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_RPC_ADAPTER_H
#define LOC_API_RPC_ADAPTER_H
#include <rpc/rpc.h>
#include <loc_api_rpc_glue.h>
#include <LocApiAdapter.h>
class LocApiRpcAdapter : public LocApiAdapter {
// RPC communication establishment
rpc_loc_client_handle_type client_handle;
rpc_loc_event_mask_type eMask;
static const rpc_loc_event_mask_type locBits[];
static rpc_loc_event_mask_type convertMask(LOC_API_ADAPTER_EVENT_MASK_T mask);
static enum loc_api_adapter_err convertErr(int rpcErr);
void reportPosition(const rpc_loc_parsed_position_s_type *location_report_ptr);
void reportSv(const rpc_loc_gnss_info_s_type *gnss_report_ptr);
void reportStatus(const rpc_loc_status_event_s_type *status_report_ptr);
void reportNmea(const rpc_loc_nmea_report_s_type *nmea_report_ptr);
void ATLEvent(const rpc_loc_server_request_s_type *server_request_ptr);
void NIEvent(const rpc_loc_ni_event_s_type *ni_req_ptr);
int NIEventFillVerfiyType(GpsNiNotification &notif,
rpc_loc_ni_notify_verify_e_type notif_priv);
GpsNiEncodingType convertNiEncodingType(int loc_encoding);
public:
LocApiRpcAdapter(LocEng &locEng);
~LocApiRpcAdapter();
int locEventCB(rpc_loc_client_handle_type client_handle,
rpc_loc_event_mask_type loc_event,
const rpc_loc_event_payload_u_type* loc_event_payload);
void locRpcGlobalCB(CLIENT* clnt, enum rpc_reset_event event);
// RPC adapter interface implementations
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(LocPositionMode mode, GpsPositionRecurrence recurrence,
uint32_t min_interval, uint32_t preferred_accuracy, uint32_t preferred_time);
virtual enum loc_api_adapter_err
enableData(int enable);
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
setAPN(char* apn, int len);
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);
virtual enum loc_api_adapter_err
atlOpenStatus(int handle, int is_succ, char* apn, AGpsBearerType bear, AGpsType agpsType);
virtual enum loc_api_adapter_err
atlCloseStatus(int handle, int is_succ);
virtual enum loc_api_adapter_err
setSUPLVersion(uint32_t version);
};
#endif //LOC_API_RPC_ADAPTER_H

View file

@ -0,0 +1,69 @@
/* Copyright (c) 2011, Code Aurora Forum. 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 Code Aurora Forum, 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 "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 DEBUG_H
#define DEBUG_H
#include <stdio.h>
#define LOG_TAG "LocSvc_rpc"
#include <utils/Log.h>
#define PRINT(x...) do { \
fprintf(stdout, "%s(%d) ", __FUNCTION__, __LINE__); \
fprintf(stdout, ##x); \
LOGD(x); \
} while(0)
#ifdef DEBUG
#define D PRINT
#else
#define D(x...) do { } while(0)
#endif
#ifdef VERBOSE
#define V PRINT
#else
#define V(x...) do { } while(0)
#endif
#define E(x...) do { \
fprintf(stderr, "%s(%d) ", __FUNCTION__, __LINE__); \
fprintf(stderr, ##x); \
LOGE(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); \
} \
} while(0)
#endif/*DEBUG_H*/

View file

@ -0,0 +1,226 @@
/* Copyright (c) 2011, Code Aurora Forum. 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 Code Aurora Forum, 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 "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_FIXUP_H
#define LOC_API_FIXUP_H
#ifdef __cplusplus
extern "C"
{
#endif
#ifndef NULLPROC
#define NULLPROC 0
#endif /* NULLPROC */
#ifdef ADD_XDR_FLOAT
extern bool_t xdr_float (XDR *__xdrs, float *__fp);
extern bool_t xdr_double (XDR *__xdrs, double *__dp);
#endif /* ADD_XDR_FLOAT */
#ifdef ADD_XDR_BOOL
extern bool_t xdr_bool(XDR *__xdrs, int *__bp);
#endif /* ADD_XDR_BOOL */
#define RPC_LOC_API_MAJOR_VERSION_NUMBER 1
#define RPC_LOC_API_MINOR_VERSION_NUMBER 0
// Return value for loc_open in case of failure.
#define RPC_LOC_CLIENT_HANDLE_INVALID -1
// Return value of loc api calls for loc_close, loc_start_fix, loc_stop_fix and loc_ioctl
// These are also the status for the ioctl callback
#define RPC_LOC_API_SUCCESS 0
#define RPC_LOC_API_GENERAL_FAILURE 1
#define RPC_LOC_API_UNSUPPORTED 2
#define RPC_LOC_API_INVALID_HANDLE 4
#define RPC_LOC_API_INVALID_PARAMETER 5
#define RPC_LOC_API_ENGINE_BUSY 6
#define RPC_LOC_API_PHONE_OFFLINE 7
#define RPC_LOC_API_TIMEOUT 8
// Special return value for loc api calls in case of RPC failure
#define RPC_LOC_API_RPC_FAILURE (-1234)
// Special return value for modem restart incurred RPC failure
#define RPC_LOC_API_RPC_MODEM_RESTART (-1235)
#define RPC_LOC_API_MAX_SV_COUNT 80
#define RPC_LOC_API_MAX_NMEA_STRING_LENGTH 1200
// Maximum server address that will be used in location API
#define RPC_LOC_API_MAX_SERVER_ADDR_LENGTH 256
#define RPC_LOC_API_MAX_NUM_PREDICTED_ORBITS_SERVERS 3
#define RPC_LOC_API_MAX_NUM_NTP_SERVERS 3
#define RPC_LOC_EVENT_PARSED_POSITION_REPORT 0x00000001 // Position report comes in loc_parsed_position_s_type
#define RPC_LOC_EVENT_SATELLITE_REPORT 0x00000002 // Satellite in view report
#define RPC_LOC_EVENT_NMEA_1HZ_REPORT 0x00000004 // NMEA report at 1HZ rate
#define RPC_LOC_EVENT_NMEA_POSITION_REPORT 0x00000008 // NMEA report at position report rate
#define RPC_LOC_EVENT_NI_NOTIFY_VERIFY_REQUEST 0x00000010 // NI notification/verification request
#define RPC_LOC_EVENT_ASSISTANCE_DATA_REQUEST 0x00000020 // Assistance data, eg: time, predicted orbits request
#define RPC_LOC_EVENT_LOCATION_SERVER_REQUEST 0x00000040 // Request for location server
#define RPC_LOC_EVENT_IOCTL_REPORT 0x00000080 // Callback report for loc_ioctl
#define RPC_LOC_EVENT_STATUS_REPORT 0x00000100 // Misc status report: eg, engine state
#define RPC_LOC_POS_VALID_SESSION_STATUS 0x00000001
#define RPC_LOC_POS_VALID_TIMESTAMP_CALENDAR 0x00000002
#define RPC_LOC_POS_VALID_TIMESTAMP_UTC 0x00000004
#define RPC_LOC_POS_VALID_LEAP_SECONDS 0x00000008
#define RPC_LOC_POS_VALID_TIME_UNC 0x00000010
#define RPC_LOC_POS_VALID_LATITUDE 0x00000020
#define RPC_LOC_POS_VALID_LONGITUDE 0x00000040
#define RPC_LOC_POS_VALID_ALTITUDE_WRT_ELLIPSOID 0x00000080
#define RPC_LOC_POS_VALID_ALTITUDE_WRT_MEAN_SEA_LEVEL 0x00000100
#define RPC_LOC_POS_VALID_SPEED_HORIZONTAL 0x00000200
#define RPC_LOC_POS_VALID_SPEED_VERTICAL 0x00000400
#define RPC_LOC_POS_VALID_HEADING 0x00000800
#define RPC_LOC_POS_VALID_HOR_UNC_CIRCULAR 0x00001000
#define RPC_LOC_POS_VALID_HOR_UNC_ELLI_SEMI_MAJ 0x00002000
#define RPC_LOC_POS_VALID_HOR_UNC_ELLI_SEMI_MIN 0x00004000
#define RPC_LOC_POS_VALID_HOR_UNC_ELLI_ORIENT_AZIMUTH 0x00008000
#define RPC_LOC_POS_VALID_VERTICAL_UNC 0x00010000
#define RPC_LOC_POS_VALID_SPEED_UNC 0x00020000
#define RPC_LOC_POS_VALID_HEADING_UNC 0x00040000
#define RPC_LOC_POS_VALID_CONFIDENCE_HORIZONTAL 0x00080000
#define RPC_LOC_POS_VALID_CONFIDENCE_VERTICAL 0x00100000
#define RPC_LOC_POS_VALID_MAGNETIC_VARIATION 0x00200000
#define RPC_LOC_POS_VALID_TECHNOLOGY_MASK 0x00400000
#define RPC_LOC_POS_TECH_SATELLITE 0x00000001
#define RPC_LOC_POS_TECH_CELLID 0x00000002
#define RPC_LOC_POS_TECH_WIFI 0x00000004
#define RPC_LOC_SV_INFO_VALID_SYSTEM 0x00000001
#define RPC_LOC_SV_INFO_VALID_PRN 0x00000002
#define RPC_LOC_SV_INFO_VALID_HEALTH_STATUS 0x00000004
#define RPC_LOC_SV_INFO_VALID_PROCESS_STATUS 0x00000008
#define RPC_LOC_SV_INFO_VALID_HAS_EPH 0x00000010
#define RPC_LOC_SV_INFO_VALID_HAS_ALM 0x00000020
#define RPC_LOC_SV_INFO_VALID_ELEVATION 0x00000040
#define RPC_LOC_SV_INFO_VALID_AZIMUTH 0x00000080
#define RPC_LOC_SV_INFO_VALID_SNR 0x00000100
#define RPC_LOC_GNSS_INFO_VALID_POS_DOP 0x00000001
#define RPC_LOC_GNSS_INFO_VALID_HOR_DOP 0x00000002
#define RPC_LOC_GNSS_INFO_VALID_VERT_DOP 0x00000004
#define RPC_LOC_GNSS_INFO_VALID_ALTITUDE_ASSUMED 0x00000008
#define RPC_LOC_GNSS_INFO_VALID_SV_COUNT 0x00000010
#define RPC_LOC_GNSS_INFO_VALID_SV_LIST 0x00000020
#define RPC_LOC_NI_MAX_REQUESTOR_ID_LENGTH 200
#define RPC_LOC_NI_SUPL_HASH_LENGTH 8
#define RPC_LOC_NI_SUPL_SLP_SESSION_ID_BYTE_LENGTH 4
#define RPC_LOC_NI_MAX_CLIENT_NAME_LENGTH 64
#define RPC_LOC_NI_MAX_EXT_CLIENT_ADDRESS 20
#define RPC_LOC_NI_CODEWORD_LENGTH 20
#define RPC_LOC_NI_SUPL_QOP_VALID 0x01
#define RPC_LOC_NI_SUPL_QOP_VERACC_VALID 0x02
#define RPC_LOC_NI_SUPL_QOP_MAXAGE_VALID 0x04
#define RPC_LOC_NI_SUPL_QOP_DELAY_VALID 0x08
#define RPC_LOC_FIX_CRIT_VALID_RECURRENCE_TYPE 0x00000001
#define RPC_LOC_FIX_CRIT_VALID_PREFERRED_OPERATION_MODE 0x00000002
#define RPC_LOC_FIX_CRIT_VALID_PREFERRED_ACCURACY 0x00000004
#define RPC_LOC_FIX_CRIT_VALID_PREFERRED_RESPONSE_TIME 0x00000008
#define RPC_LOC_FIX_CRIT_VALID_INTERMEDIATE_POS_REPORT_ENABLED 0x00000010
#define RPC_LOC_FIX_CRIT_VALID_NOTIFY_TYPE 0x00000020
#define RPC_LOC_FIX_CRIT_VALID_MIN_INTERVAL 0x00000040
#define RPC_LOC_FIX_CRIT_VALID_MIN_DISTANCE 0x00000080
#define RPC_LOC_FIX_CRIT_VALID_MIN_DIST_SAMPLE_INTERVAL 0x00000100
#define RPC_LOC_ASSIST_POS_VALID_TIMESTAMP_UTC 0x00000001
#define RPC_LOC_ASSIST_POS_VALID_LATITUDE 0x00000002
#define RPC_LOC_ASSIST_POS_VALID_LONGITUDE 0x00000004
#define RPC_LOC_ASSIST_POS_VALID_ALTITUDE_WRT_ELLIPSOID 0x00000008
#define RPC_LOC_ASSIST_POS_VALID_ALTITUDE_WRT_MEAN_SEA_LEVEL 0x00000010
#define RPC_LOC_ASSIST_POS_VALID_HOR_UNC_CIRCULAR 0x00000020
#define RPC_LOC_ASSIST_POS_VALID_VERT_UNC 0x00000040
#define RPC_LOC_ASSIST_POS_VALID_CONFIDENCE_HORIZONTAL 0x00000080
#define RPC_LOC_ASSIST_POS_VALID_CONFIDENCE_VERTICAL 0x00000100
#define RPC_LOC_ASSIST_POS_VALID_TIMESTAMP_AGE 0x00000200
#define RPC_LOC_ASSIST_DATA_ALL 0xFFFFFFFF
#define RPC_LOC_NMEA_MASK_ALL 0xffff
#define RPC_LOC_NMEA_MASK_GGA 0x0001
#define RPC_LOC_NMEA_MASK_RMC 0x0002
#define RPC_LOC_NMEA_MASK_GSV 0x0004
#define RPC_LOC_NMEA_MASK_GSA 0x0008
#define RPC_LOC_NMEA_MASK_VTG 0x0010
/* EFS data access */
#define RPC_LOC_EFS_MAX_PATH_LEN_BYTES 64 /* Max file name length in bytes that can be written*/
#define RPC_LOC_EFS_MAX_FILE_LEN_BYTES 2000 /* Max file size in bytes that can be written */
/* WIPER valid information flag in log report */
#define RPC_LOC_WIPER_LOG_TIME_VALID 0x01
#define RPC_LOC_WIPER_LOG_POS_VALID 0x02
#define RPC_LOC_WIPER_LOG_AP_SET_VALID 0x04
/* General WIPER defines */
#define RPC_LOC_WIPER_MAC_ADDR_LENGTH 6 // Do not change this number since it affects RPC and log packet sizes
#define RPC_LOC_WIPER_MAX_REPORTED_APS_PER_LOG_MSG 50 // Do not change this number since it affects RPC and log packet sizes
/* WIPER AP Qualifier */
#define RPC_LOC_WIPER_AP_QUALIFIER_BEING_USED 0x1 /* AP is being used by WPS */
#define RPC_LOC_WIPER_AP_QUALIFIER_HIDDEN_SSID 0x2 /* AP does not broadcast SSID */
#define RPC_LOC_WIPER_AP_QUALIFIER_PRIVATE 0x4 /* AP has encryption turned on */
#define RPC_LOC_WIPER_AP_QUALIFIER_INFRASTRUCTURE_MODE 0x8 /* AP is in infrastructure mode and not in ad-hoc/unknown mode */
/* flags for notification */
#define RPC_LOC_NI_CLIENT_NAME_PRESENT 0x0001
#define RPC_LOC_NI_CLIENT_EXTADDR_PRESENT 0x0002
#define RPC_LOC_NI_DEF_LOCATION_TYPE_PRESENT 0x0010
#define RPC_LOC_NI_REQUESTOR_ID_PRESENT 0x0020
#define RPC_LOC_NI_CODEWORD_PRESENT 0x0040
#define RPC_LOC_NI_SERVICE_TYPE_ID_PRESENT 0x0080
#define RPC_LOC_NI_ENCODING_TYPE_PRESENT 0x0100
/* below are for RPC_LOC_IOCTL_SET_LBS_APN_PROFILE data */
/* values for apn_profiles[0].srv_system_type */
#define LOC_APN_PROFILE_SRV_SYS_CDMA 0x01
#define LOC_APN_PROFILE_SRV_SYS_HDR 0x02
#define LOC_APN_PROFILE_SRV_SYS_GSM 0x04
#define LOC_APN_PROFILE_SRV_SYS_WCDMA 0x08
#define LOC_APN_PROFILE_SRV_SYS_LTE 0x10
#define LOC_APN_PROFILE_SRV_SYS_MAX 0x1F
/* values for apn_profiles[0].pdp_type */
#define LOC_APN_PROFILE_PDN_TYPE_IPV4 0x01
#define LOC_APN_PROFILE_PDN_TYPE_IPV6 0x02
#define LOC_APN_PROFILE_PDN_TYPE_IPV4V6 0x03
#define LOC_APN_PROFILE_PDN_TYPE_PPP 0x04
#define LOC_APN_PROFILE_PDN_TYPE_MAX 0x04
#ifdef __cplusplus
}
#endif
#endif /* LOC_API_FIXUP_H */

View file

@ -0,0 +1,59 @@
/* Copyright (c) 2011 Code Aurora Forum. 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 Code Aurora Forum, 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 "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_LOG_H
#define LOC_API_LOG_H
#ifdef __cplusplus
extern "C"
{
#endif
#include <ctype.h>
#include "loc_api_rpcgen_common_rpc.h"
extern int loc_callback_log(
rpc_loc_event_mask_type loc_event, /* event mask */
const rpc_loc_event_payload_u_type* loc_event_payload /* payload */
);
extern const char* loc_get_event_atl_open_name(rpc_loc_server_request_e_type loc_event_atl_open);
extern const char* loc_get_event_name(rpc_loc_event_mask_type loc_event_mask);
extern const char* loc_get_ioctl_type_name(rpc_loc_ioctl_e_type ioctl_type);
extern const char* loc_get_ioctl_status_name(uint32 status);
extern const char* loc_get_sess_status_name(rpc_loc_session_status_e_type status);
extern const char* loc_get_engine_state_name(rpc_loc_engine_state_e_type state);
extern const char* loc_get_fix_session_state_name(rpc_loc_fix_session_state_e_type state);
extern const char* loc_get_rpc_reset_event_name(enum rpc_reset_event event);
#ifdef __cplusplus
}
#endif
#endif /* LOC_API_LOG_H */

View file

@ -0,0 +1,123 @@
/* Copyright (c) 2011, Code Aurora Forum. 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 Code Aurora Forum, 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 "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_RPC_GLUE_H
#define LOC_API_RPC_GLUE_H
/* Include RPC headers */
#ifdef USE_LOCAL_RPC
#include "rpc_inc/loc_api_common.h"
#include "rpc_inc/loc_api.h"
#include "rpc_inc/loc_api_cb.h"
#endif
#ifdef USE_QCOM_AUTO_RPC
#include "loc_api_rpcgen_rpc.h"
#include "loc_api_rpcgen_common_rpc.h"
#include "loc_api_rpcgen_cb_rpc.h"
#endif
/* Boolean */
/* Other data types in comdef.h are defined in rpc stubs, so fix it here */
typedef unsigned char boolean;
#define TRUE 1
#define FALSE 0
#include "rpc_inc/loc_api_fixup.h"
#include "rpc_inc/loc_api_sync_call.h"
#include <rpc/clnt.h>
#ifdef __cplusplus
extern "C"
{
#endif
extern int loc_api_glue_init(void);
extern int loc_api_null(void);
typedef int32 (loc_event_cb_f_type)(
void* userData,
rpc_loc_client_handle_type loc_handle, /* handle of the client */
rpc_loc_event_mask_type loc_event, /* event mask */
const rpc_loc_event_payload_u_type* loc_event_payload /* payload */
);
typedef void (loc_reset_notif_cb_f_type)(
void* userData,
CLIENT* clnt,
enum rpc_reset_event event
);
extern rpc_loc_client_handle_type loc_open(
rpc_loc_event_mask_type event_reg_mask,
loc_event_cb_f_type *event_callback,
loc_reset_notif_cb_f_type *rpc_global_cb,
void* userData
);
extern int32 loc_close
(
rpc_loc_client_handle_type handle
);
extern void loc_clear
(
rpc_loc_client_handle_type handle
);
extern int32 loc_start_fix
(
rpc_loc_client_handle_type handle
);
extern int32 loc_stop_fix
(
rpc_loc_client_handle_type handle
);
extern int32 loc_ioctl
(
rpc_loc_client_handle_type handle,
rpc_loc_ioctl_e_type ioctl_type,
rpc_loc_ioctl_data_u_type* ioctl_data
);
extern int loc_eng_ioctl
(
rpc_loc_client_handle_type handle,
rpc_loc_ioctl_e_type ioctl_type,
rpc_loc_ioctl_data_u_type* ioctl_data_ptr,
uint32 timeout_msec,
rpc_loc_ioctl_callback_s_type *cb_data_ptr
);
#ifdef __cplusplus
}
#endif
#endif /* LOC_API_RPC_GLUE_H */

View file

@ -0,0 +1,90 @@
/* Copyright (c) 2011, Code Aurora Forum. 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 Code Aurora Forum, 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 "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_CB_SYNC_H
#define LOC_API_CB_SYNC_H
#ifdef __cplusplus
extern "C"
{
#endif
#include "loc_api_rpc_glue.h"
#define LOC_SYNC_CALL_SLOTS_MAX 8
typedef struct {
pthread_mutex_t lock;
/* Client ID */
rpc_loc_client_handle_type loc_handle;
/* Callback waiting conditional variable */
pthread_cond_t loc_cb_arrived_cond;
/* Callback waiting data block, protected by loc_cb_data_mutex */
boolean in_use;
boolean signal_sent;
boolean not_available;
rpc_loc_event_mask_type loc_cb_wait_event_mask; /* event to wait for */
rpc_loc_ioctl_e_type ioctl_type; /* ioctl to wait for */
rpc_loc_event_payload_u_type loc_cb_received_payload; /* received payload */
rpc_loc_event_mask_type loc_cb_received_event_mask; /* received event */
} loc_sync_call_slot_s_type;
typedef struct {
int num_of_slots;
loc_sync_call_slot_s_type slots[LOC_SYNC_CALL_SLOTS_MAX];
} loc_sync_call_slot_array_s_type;
/* Init function */
void loc_api_sync_call_init();
/* Destroy function */
void loc_api_sync_call_destroy();
/* Process Loc API callbacks to wake up blocked user threads */
void loc_api_callback_process_sync_call(
rpc_loc_client_handle_type loc_handle, /* handle of the client */
rpc_loc_event_mask_type loc_event, /* event mask */
const rpc_loc_event_payload_u_type* loc_event_payload /* payload */
);
/* Reentrant synchronous IOCTL call, using Loc API return code */
int loc_api_sync_ioctl
(
rpc_loc_client_handle_type handle,
rpc_loc_ioctl_e_type ioctl_type,
rpc_loc_ioctl_data_u_type* ioctl_data_ptr,
uint32 timeout_msec,
rpc_loc_ioctl_callback_s_type *cb_data_ptr
);
#ifdef __cplusplus
}
#endif
#endif /* LOC_API_CB_SYNC_H */

View file

@ -0,0 +1,45 @@
/* Copyright (c) 2011, Code Aurora Forum. 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 Code Aurora Forum, 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 "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_APICB_APPINIT_H
#define LOC_APICB_APPINIT_H
#ifdef __cplusplus
extern "C"
{
#endif
/* Initialization function for callbacks */
extern int loc_apicb_app_init();
extern void loc_apicb_app_deinit();
#ifdef __cplusplus
}
#endif
#endif /* LOC_APICB_APPINIT_H */

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,52 @@
/* Copyright (c) 2011, Code Aurora Forum. 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 Code Aurora Forum, 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 "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 <rpc/rpc.h>
#include "loc_api_fixup.h"
#ifdef ADD_XDR_FLOAT
int
xdr_float(xdrp, fp)
XDR *xdrp;
float *fp;
{
return xdr_long(xdrp, (long*)fp);
}
int
xdr_double(xdrp, dp)
XDR *xdrp;
double *dp;
{
return xdr_long(xdrp, (long*)dp + 1)
&& xdr_long(xdrp, (long*)dp);
}
#endif /* ADD_XDR_FLOAT */

View file

@ -0,0 +1,344 @@
/* Copyright (c) 2011 Code Aurora Forum. 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 Code Aurora Forum, 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 "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_api_rpc_glue"
#include "loc_api_log.h"
#include "loc_log.h"
#include "log_util.h"
#include "rpc/rpc.h"
#include "loc_api_fixup.h"
/* Event names */
loc_name_val_s_type loc_event_name[] =
{
NAME_VAL( RPC_LOC_EVENT_PARSED_POSITION_REPORT ),
NAME_VAL( RPC_LOC_EVENT_SATELLITE_REPORT ),
NAME_VAL( RPC_LOC_EVENT_NMEA_1HZ_REPORT ),
NAME_VAL( RPC_LOC_EVENT_NMEA_POSITION_REPORT ),
NAME_VAL( RPC_LOC_EVENT_NI_NOTIFY_VERIFY_REQUEST ),
NAME_VAL( RPC_LOC_EVENT_ASSISTANCE_DATA_REQUEST ),
NAME_VAL( RPC_LOC_EVENT_LOCATION_SERVER_REQUEST ),
NAME_VAL( RPC_LOC_EVENT_IOCTL_REPORT ),
NAME_VAL( RPC_LOC_EVENT_STATUS_REPORT ),
NAME_VAL( RPC_LOC_EVENT_WPS_NEEDED_REQUEST ),
};
int loc_event_num = sizeof loc_event_name / sizeof(loc_name_val_s_type);
/* Event names */
loc_name_val_s_type loc_event_atl_open_name[] =
{
NAME_VAL( RPC_LOC_SERVER_REQUEST_OPEN ),
NAME_VAL( RPC_LOC_SERVER_REQUEST_CLOSE ),
NAME_VAL( RPC_LOC_SERVER_REQUEST_MULTI_OPEN )
};
int loc_event_atl_open_num = sizeof loc_event_atl_open_name / sizeof(loc_name_val_s_type);
/* Finds the first event found in the mask */
const char* loc_get_event_atl_open_name(rpc_loc_server_request_e_type loc_event_atl_open)
{
return loc_get_name_from_val(loc_event_atl_open_name, loc_event_atl_open_num,
(long) loc_event_atl_open);
}
/* IOCTL Type names */
loc_name_val_s_type loc_ioctl_type_name[] =
{
NAME_VAL( RPC_LOC_IOCTL_GET_API_VERSION ),
NAME_VAL( RPC_LOC_IOCTL_SET_FIX_CRITERIA ),
NAME_VAL( RPC_LOC_IOCTL_GET_FIX_CRITERIA ),
NAME_VAL( RPC_LOC_IOCTL_INFORM_NI_USER_RESPONSE ),
NAME_VAL( RPC_LOC_IOCTL_INJECT_PREDICTED_ORBITS_DATA ),
NAME_VAL( RPC_LOC_IOCTL_QUERY_PREDICTED_ORBITS_DATA_VALIDITY ),
NAME_VAL( RPC_LOC_IOCTL_QUERY_PREDICTED_ORBITS_DATA_SOURCE ),
NAME_VAL( RPC_LOC_IOCTL_SET_PREDICTED_ORBITS_DATA_AUTO_DOWNLOAD ),
NAME_VAL( RPC_LOC_IOCTL_INJECT_UTC_TIME ),
NAME_VAL( RPC_LOC_IOCTL_INJECT_RTC_VALUE ),
NAME_VAL( RPC_LOC_IOCTL_INJECT_POSITION ),
NAME_VAL( RPC_LOC_IOCTL_QUERY_ENGINE_STATE ),
NAME_VAL( RPC_LOC_IOCTL_ERROR_ESTIMATE_CONFIG),
NAME_VAL( RPC_LOC_IOCTL_INFORM_SERVER_MULTI_OPEN_STATUS ),
NAME_VAL( RPC_LOC_IOCTL_INFORM_SERVER_OPEN_STATUS ),
NAME_VAL( RPC_LOC_IOCTL_INFORM_SERVER_CLOSE_STATUS ),
NAME_VAL( RPC_LOC_IOCTL_SEND_WIPER_POSITION_REPORT ),
NAME_VAL( RPC_LOC_IOCTL_NOTIFY_WIPER_STATUS ),
NAME_VAL( RPC_LOC_IOCTL_SET_ENGINE_LOCK ),
NAME_VAL( RPC_LOC_IOCTL_GET_ENGINE_LOCK ),
NAME_VAL( RPC_LOC_IOCTL_SET_SBAS_CONFIG ),
NAME_VAL( RPC_LOC_IOCTL_GET_SBAS_CONFIG ),
NAME_VAL( RPC_LOC_IOCTL_SET_NMEA_TYPES ),
NAME_VAL( RPC_LOC_IOCTL_GET_NMEA_TYPES ),
NAME_VAL( RPC_LOC_IOCTL_SET_CDMA_PDE_SERVER_ADDR ),
NAME_VAL( RPC_LOC_IOCTL_GET_CDMA_PDE_SERVER_ADDR ),
NAME_VAL( RPC_LOC_IOCTL_SET_CDMA_MPC_SERVER_ADDR ),
NAME_VAL( RPC_LOC_IOCTL_GET_CDMA_MPC_SERVER_ADDR ),
NAME_VAL( RPC_LOC_IOCTL_SET_UMTS_SLP_SERVER_ADDR ),
NAME_VAL( RPC_LOC_IOCTL_GET_UMTS_SLP_SERVER_ADDR ),
NAME_VAL( RPC_LOC_IOCTL_SET_ON_DEMAND_LPM ),
NAME_VAL( RPC_LOC_IOCTL_GET_ON_DEMAND_LPM ),
NAME_VAL( RPC_LOC_IOCTL_SET_XTRA_T_SESSION_CONTROL ),
NAME_VAL( RPC_LOC_IOCTL_GET_XTRA_T_SESSION_CONTROL ),
NAME_VAL( RPC_LOC_IOCTL_SET_LBS_APN_PROFILE ),
NAME_VAL( RPC_LOC_IOCTL_GET_LBS_APN_PROFILE ),
NAME_VAL( RPC_LOC_IOCTL_SET_XTRA_APN_PROFILE ),
NAME_VAL( RPC_LOC_IOCTL_GET_XTRA_APN_PROFILE ),
NAME_VAL( RPC_LOC_IOCTL_SET_DATA_ENABLE ),
NAME_VAL( RPC_LOC_IOCTL_SET_SUPL_VERSION ),
NAME_VAL( RPC_LOC_IOCTL_GET_SUPL_VERSION ),
NAME_VAL( RPC_LOC_IOCTL_DELETE_ASSIST_DATA ),
NAME_VAL( RPC_LOC_IOCTL_SET_CUSTOM_PDE_SERVER_ADDR ),
NAME_VAL( RPC_LOC_IOCTL_GET_CUSTOM_PDE_SERVER_ADDR ),
};
int loc_ioctl_type_num = sizeof loc_ioctl_type_name / sizeof(loc_name_val_s_type);
/* IOCTL Status names */
loc_name_val_s_type loc_ioctl_status_name[] =
{
NAME_VAL( RPC_LOC_API_SUCCESS ),
NAME_VAL( RPC_LOC_API_GENERAL_FAILURE ),
NAME_VAL( RPC_LOC_API_UNSUPPORTED ),
NAME_VAL( RPC_LOC_API_INVALID_HANDLE ),
NAME_VAL( RPC_LOC_API_INVALID_PARAMETER ),
NAME_VAL( RPC_LOC_API_ENGINE_BUSY ),
NAME_VAL( RPC_LOC_API_PHONE_OFFLINE ),
NAME_VAL( RPC_LOC_API_TIMEOUT ),
NAME_VAL( RPC_LOC_API_RPC_FAILURE ),
NAME_VAL( RPC_LOC_API_RPC_MODEM_RESTART )
};
int loc_ioctl_status_num = sizeof loc_ioctl_status_name / sizeof(loc_name_val_s_type);
/* Fix session status names */
loc_name_val_s_type loc_sess_status_name[] =
{
NAME_VAL( RPC_LOC_SESS_STATUS_SUCCESS ),
NAME_VAL( RPC_LOC_SESS_STATUS_IN_PROGESS ),
NAME_VAL( RPC_LOC_SESS_STATUS_GENERAL_FAILURE ),
NAME_VAL( RPC_LOC_SESS_STATUS_TIMEOUT ),
NAME_VAL( RPC_LOC_SESS_STATUS_USER_END ),
NAME_VAL( RPC_LOC_SESS_STATUS_BAD_PARAMETER ),
NAME_VAL( RPC_LOC_SESS_STATUS_PHONE_OFFLINE ),
NAME_VAL( RPC_LOC_SESS_STATUS_USER_END ),
NAME_VAL( RPC_LOC_SESS_STATUS_ENGINE_LOCKED )
};
int loc_sess_status_num = sizeof loc_sess_status_name / sizeof(loc_name_val_s_type);
/* Engine state names */
loc_name_val_s_type loc_engine_state_name[] =
{
NAME_VAL( RPC_LOC_ENGINE_STATE_ON ),
NAME_VAL( RPC_LOC_ENGINE_STATE_OFF )
};
int loc_engine_state_num = sizeof loc_engine_state_name / sizeof(loc_name_val_s_type);
/* Fix session state names */
loc_name_val_s_type loc_fix_session_state_name[] =
{
NAME_VAL( RPC_LOC_FIX_SESSION_STATE_BEGIN ),
NAME_VAL( RPC_LOC_FIX_SESSION_STATE_END )
};
int loc_fix_session_state_num = sizeof loc_fix_session_state_name / sizeof(loc_name_val_s_type);
static const char* log_final_interm_string(int is_final)
{
return is_final ? "final" : "intermediate";
}
/* Logs parsed report */
static void log_parsed_report(const rpc_loc_parsed_position_s_type *parsed_report)
{
rpc_loc_session_status_e_type status = parsed_report->session_status;
LOC_LOGD("Session status: %s Valid mask: 0x%X\n",
loc_get_sess_status_name(status),
(uint) parsed_report->valid_mask);
LOC_LOGD("Latitude: %.7f (%s)\n", parsed_report->latitude,
log_final_interm_string(
(parsed_report->valid_mask & RPC_LOC_POS_VALID_LATITUDE) &&
parsed_report->session_status == RPC_LOC_SESS_STATUS_SUCCESS));
LOC_LOGD("Longitude: %.7f\n", parsed_report->longitude);
LOC_LOGD("Accuracy: %.7f\n", parsed_report->hor_unc_circular);
}
/* Logs status report */
static void log_status_report(const rpc_loc_status_event_s_type *status_event)
{
rpc_loc_status_event_e_type event = status_event->event;
switch (event) {
case RPC_LOC_STATUS_EVENT_ENGINE_STATE:
LOC_LOGD("Engine state: %s\n",
loc_get_engine_state_name(
status_event->payload.rpc_loc_status_event_payload_u_type_u.engine_state));
break;
case RPC_LOC_STATUS_EVENT_FIX_SESSION_STATE:
LOC_LOGD("Fix session state: %s\n",
loc_get_fix_session_state_name(
status_event->payload.rpc_loc_status_event_payload_u_type_u.fix_session_state));
break;
default:
break;
}
}
/* Logs valid fields in the GNSS SV constellation report */
static void log_satellite_report(const rpc_loc_gnss_info_s_type *gnss)
{
if (gnss->valid_mask & RPC_LOC_GNSS_INFO_VALID_POS_DOP)
{
LOC_LOGV("position dop: %.3f\n", (float) gnss->position_dop);
}
if (gnss->valid_mask & RPC_LOC_GNSS_INFO_VALID_HOR_DOP)
{
LOC_LOGV("horizontal dop: %.3f\n", (float) gnss->horizontal_dop);
}
if (gnss->valid_mask & RPC_LOC_GNSS_INFO_VALID_VERT_DOP)
{
LOC_LOGV("vertical dop: %.3f\n", (float) gnss->vertical_dop);
}
if (gnss->valid_mask & RPC_LOC_GNSS_INFO_VALID_ALTITUDE_ASSUMED)
{
LOC_LOGV("altitude assumed: %d\n", (int) gnss->altitude_assumed);
}
if (gnss->valid_mask & RPC_LOC_GNSS_INFO_VALID_SV_COUNT)
{
LOC_LOGD("sv count: %d\n", (int) gnss->sv_count);
}
if (gnss->valid_mask & RPC_LOC_GNSS_INFO_VALID_SV_LIST)
{
LOC_LOGV("sv list: ");
if (gnss->sv_count)
{
LOC_LOGV("\n\tsys\tprn\thlth\tproc\teph\talm\telev\tazi\tsnr\n");
}
else {
LOC_LOGV("empty\n");
}
int i;
for (i = 0; i < gnss->sv_count; i++)
{
const rpc_loc_sv_info_s_type *sv = &gnss->sv_list.sv_list_val[i];
rpc_loc_sv_info_valid_mask_type mask = sv->valid_mask;
LOC_LOGV(" %d: \t%d\t%d\t%d\t%d\t%d\t%d\t%.3f\t%.3f\t%.3f\n", i,
CHECK_MASK(int, sv->system, mask, RPC_LOC_SV_INFO_VALID_SYSTEM),
CHECK_MASK(int, sv->prn, mask, RPC_LOC_SV_INFO_VALID_PRN),
CHECK_MASK(int, sv->health_status, mask, RPC_LOC_SV_INFO_VALID_HEALTH_STATUS),
CHECK_MASK(int, sv->process_status, mask, RPC_LOC_SV_INFO_VALID_PROCESS_STATUS),
CHECK_MASK(int, sv->has_eph, mask, RPC_LOC_SV_INFO_VALID_HAS_EPH),
CHECK_MASK(int, sv->has_alm, mask, RPC_LOC_SV_INFO_VALID_HAS_ALM),
CHECK_MASK(float, sv->elevation, mask, RPC_LOC_SV_INFO_VALID_ELEVATION),
CHECK_MASK(float, sv->azimuth, mask, RPC_LOC_SV_INFO_VALID_AZIMUTH),
CHECK_MASK(float, sv->snr, mask, RPC_LOC_SV_INFO_VALID_SNR)
);
}
}
}
/* Logs a callback event */
int loc_callback_log(
rpc_loc_event_mask_type loc_event, /* event mask */
const rpc_loc_event_payload_u_type* loc_event_payload /* payload */
)
{
switch (loc_event)
{
case RPC_LOC_EVENT_SATELLITE_REPORT:
log_satellite_report(&loc_event_payload->
rpc_loc_event_payload_u_type_u.gnss_report);
break;
case RPC_LOC_EVENT_STATUS_REPORT:
log_status_report(&loc_event_payload->
rpc_loc_event_payload_u_type_u.status_report);
break;
case RPC_LOC_EVENT_PARSED_POSITION_REPORT:
log_parsed_report(&loc_event_payload->
rpc_loc_event_payload_u_type_u.parsed_location_report);
break;
default:
break;
}
return 0;
}
/* Finds the first event found in the mask */
const char* loc_get_event_name(rpc_loc_event_mask_type loc_event_mask)
{
return loc_get_name_from_mask(loc_event_name, loc_event_num,
(long) loc_event_mask);
}
/* Finds IOCTL type name */
const char* loc_get_ioctl_type_name(rpc_loc_ioctl_e_type ioctl_type)
{
return loc_get_name_from_val(loc_ioctl_type_name, loc_ioctl_type_num,
(long) ioctl_type);
}
/* Finds IOCTL status name */
const char* loc_get_ioctl_status_name(uint32 status)
{
return loc_get_name_from_val(loc_ioctl_status_name, loc_ioctl_status_num,
(long) status);
}
/* Finds session status name */
const char* loc_get_sess_status_name(rpc_loc_session_status_e_type status)
{
return loc_get_name_from_val(loc_sess_status_name, loc_sess_status_num,
(long) status);
}
/* Find engine state name */
const char* loc_get_engine_state_name(rpc_loc_engine_state_e_type state)
{
return loc_get_name_from_val(loc_engine_state_name, loc_engine_state_num,
(long) state);
}
/* Find engine state name */
const char* loc_get_fix_session_state_name(rpc_loc_fix_session_state_e_type state)
{
return loc_get_name_from_val(loc_fix_session_state_name, loc_fix_session_state_num,
(long) state);
}
/* Event names */
loc_name_val_s_type rpc_reset_event_name[] =
{
NAME_VAL( RPC_SUBSYSTEM_RESTART_BEGIN ),
NAME_VAL( RPC_SUBSYSTEM_RESTART_END )
};
int rpc_reset_event_num = sizeof rpc_reset_event_name / sizeof(loc_name_val_s_type);
const char* loc_get_rpc_reset_event_name(enum rpc_reset_event event)
{
return loc_get_name_from_val(rpc_reset_event_name, rpc_reset_event_num, event);
}

View file

@ -0,0 +1,621 @@
/* Copyright (c) 2011, Code Aurora Forum. 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 Code Aurora Forum, 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 "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 FILES FOR MODULE
======================================================================*/
#include <stdio.h>
#include <pthread.h>
#include <errno.h>
#include <string.h>
#include <sys/select.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/mman.h>
#include <unistd.h>
#include <stdlib.h>
#include <assert.h>
#include <loc_api_log.h>
#include <rpc/rpc.h>
/* Include RPC headers */
#include "rpc_inc/loc_api_rpc_glue.h"
/* Callback init */
#include "rpc_inc/loc_apicb_appinit.h"
/* Logging */
#define LOG_TAG "LocSvc_api_rpc_glue"
#define LOG_NDDEBUG 0
#include <utils/Log.h>
/* Logging Improvement */
#include "log_util.h"
/* Uncomment to force LOGD messages */
// #define LOGD LOGI
/*=====================================================================
External declarations
======================================================================*/
CLIENT* loc_api_clnt = NULL;
/* Callback ID and pointer */
#define LOC_API_CB_MAX_CLIENTS 16
typedef struct
{
uint32 cb_id; /* same as rpc/types.h */
loc_event_cb_f_type *cb_func; /* callback func */
loc_reset_notif_cb_f_type *rpc_cb; /* callback from RPC */
rpc_loc_client_handle_type handle; /* stores handle for client closing */
void* user; /* user's own data handle */
} loc_glue_cb_entry_s_type;
loc_glue_cb_entry_s_type loc_glue_callback_table[LOC_API_CB_MAX_CLIENTS];
#define RPC_FUNC_VERSION_BASE(a,b) a ## b
#define RPC_FUNC_VERSION(a,b) RPC_FUNC_VERSION_BASE(a,b)
#define RPC_CALLBACK_FUNC_VERSION_BASE(a,v,b) a ## v ## b
#define RPC_CALLBACK_FUNC_VERSION(a,v,b) RPC_CALLBACK_FUNC_VERSION_BASE(a,v,b)
#define LOC_GLUE_CHECK_INIT(ret_type) \
if (loc_api_clnt == NULL) { EXIT_LOG_CALLFLOW(%d, RPC_LOC_API_RPC_FAILURE); return (ret_type) RPC_LOC_API_RPC_FAILURE; }
#define LOC_GLUE_CHECK_RESULT(stat, ret_type) \
if (stat != RPC_SUCCESS) { \
LOC_LOGE("%s:%d] failure code %d", __func__, __LINE__, stat); \
return (ret_type)((stat == RPC_SUBSYSTEM_RESTART) ? \
RPC_LOC_API_RPC_MODEM_RESTART : RPC_LOC_API_RPC_FAILURE); \
}
/* Callback functions */
/* Returns 1 if successful */
bool_t rpc_loc_event_cb_f_type_svc(
rpc_loc_event_cb_f_type_args *argp,
rpc_loc_event_cb_f_type_rets *ret,
struct svc_req *req)
{
// The lower word of cd_id is the index
int index = argp->cb_id & 0xFFFF;
/* Callback not registered, or unexpected ID (shouldn't happen) */
if (index >= LOC_API_CB_MAX_CLIENTS || loc_glue_callback_table[index].cb_func == NULL)
{
LOC_LOGE("Warning: No callback handler %d.\n", index);
ret->loc_event_cb_f_type_result = 0;
return 1; /* simply return */
}
LOC_LOGV("proc: %x prog: %x vers: %x\n",
(int) req->rq_proc,
(int) req->rq_prog,
(int) req->rq_vers);
LOC_LOGV("Callback received: %x (cb_id=%p handle=%d ret_ptr=%d)\n",
(int) argp->loc_event,
argp->cb_id,
(int) argp->loc_handle,
(int) ret);
/* Forward callback to real callback procedure */
rpc_loc_client_handle_type loc_handle = argp->loc_handle;
rpc_loc_event_mask_type loc_event = argp->loc_event;
const rpc_loc_event_payload_u_type* loc_event_payload =
(const rpc_loc_event_payload_u_type*) argp->loc_event_payload;
/* Gives control to synchronous call handler */
loc_api_callback_process_sync_call(loc_handle, loc_event, loc_event_payload);
int32 rc = (loc_glue_callback_table[index].cb_func)(loc_glue_callback_table[index].user,
loc_handle, loc_event, loc_event_payload);
LOC_LOGV("cb_func=%p", loc_glue_callback_table[index].cb_func);
ret->loc_event_cb_f_type_result = rc;
return 1; /* ok */
}
int loc_apicbprog_freeresult (SVCXPRT *transp, xdrproc_t xdr_result, caddr_t result)
{
xdr_free (xdr_result, result);
/*
* Insert additional freeing code here, if needed
*/
// LOC_LOGD("***** loc_apicbprog_freeresult\n");
return 1;
}
/*===========================================================================
FUNCTION rpc_loc_event_cb_f_type_<version>_svc (MACRO)
DESCRIPTION
Callback function for Loc API
RETURN VALUE
1 for success
0 for failure
===========================================================================*/
bool_t RPC_CALLBACK_FUNC_VERSION(rpc_loc_event_cb_f_type_, RPC_LOC_EVENT_CB_F_TYPE_VERSION, _svc) (
rpc_loc_event_cb_f_type_args *argp,
rpc_loc_event_cb_f_type_rets *ret,
struct svc_req *req)
{
return rpc_loc_event_cb_f_type_svc(argp, ret, req);
}
/*===========================================================================
FUNCTION loc_apicbprog_<version>_freeresult (MACRO)
DESCRIPTION
Free up RPC data structure
RETURN VALUE
1 for success
0 for failure
===========================================================================*/
#define VERSION_CONCAT(MAJOR,MINOR) MAJOR##MINOR
#define loc_apicb_prog_VER_freeresult(M,N) \
int RPC_CALLBACK_FUNC_VERSION(loc_apicbprog_, VERSION_CONCAT(M,N), _freeresult) \
(SVCXPRT *transp, xdrproc_t xdr_result, caddr_t result) \
{ \
return loc_apicbprog_freeresult(transp, xdr_result, result); \
}
/* Define all of the possible minors */
loc_apicb_prog_VER_freeresult(RPC_LOC_API_API_MAJOR_NUM, 0001);
loc_apicb_prog_VER_freeresult(RPC_LOC_API_API_MAJOR_NUM, 0002);
loc_apicb_prog_VER_freeresult(RPC_LOC_API_API_MAJOR_NUM, 0003);
loc_apicb_prog_VER_freeresult(RPC_LOC_API_API_MAJOR_NUM, 0004);
loc_apicb_prog_VER_freeresult(RPC_LOC_API_API_MAJOR_NUM, 0005);
loc_apicb_prog_VER_freeresult(RPC_LOC_API_API_MAJOR_NUM, 0006);
/*===========================================================================
FUNCTION rpc_loc_api_cb_null_<version>_svc (MACRO) [Patch for wrong RPCGEN stubs]
DESCRIPTION
Null callback function for Loc API
RETURN VALUE
1 for success
===========================================================================*/
#define rpc_loc_api_cb_null_VER_svc(M,N) \
bool_t RPC_CALLBACK_FUNC_VERSION(rpc_loc_api_cb_null_, VERSION_CONCAT(M,N), _svc) ( \
void *a, int *b, struct svc_req *req) \
{ \
return 1; \
}
/* Define all of the possible minors */
rpc_loc_api_cb_null_VER_svc(RPC_LOC_API_API_MAJOR_NUM, 0001);
rpc_loc_api_cb_null_VER_svc(RPC_LOC_API_API_MAJOR_NUM, 0002);
rpc_loc_api_cb_null_VER_svc(RPC_LOC_API_API_MAJOR_NUM, 0003);
rpc_loc_api_cb_null_VER_svc(RPC_LOC_API_API_MAJOR_NUM, 0004);
rpc_loc_api_cb_null_VER_svc(RPC_LOC_API_API_MAJOR_NUM, 0005);
rpc_loc_api_cb_null_VER_svc(RPC_LOC_API_API_MAJOR_NUM, 0006);
static void loc_api_glue_rpc_cb(CLIENT* client, enum rpc_reset_event event)
{
int i;
for (i = 0; i < LOC_API_CB_MAX_CLIENTS; i++) {
if (NULL != loc_glue_callback_table[i].rpc_cb) {
loc_glue_callback_table[i].rpc_cb(loc_glue_callback_table[i].user, client, event);
}
}
}
/*===========================================================================
FUNCTION loc_api_glue_init
DESCRIPTION
Initiates the RPC client
RETURN VALUE
1 for success
0 for failure
===========================================================================*/
int loc_api_glue_init(void)
{
if (loc_api_clnt == NULL)
{
/* Initialize data */
int i;
int pid = getpid();
for (i = 0; i < LOC_API_CB_MAX_CLIENTS; i++)
{
loc_glue_callback_table[i].cb_id = i | (pid << 16);
loc_glue_callback_table[i].cb_func = NULL;
loc_glue_callback_table[i].handle = -1;
loc_glue_callback_table[i].rpc_cb = NULL;
loc_glue_callback_table[i].user = NULL;
}
/* Print msg */
LOC_LOGV("Trying to create RPC client...\n");
loc_api_clnt = clnt_create(NULL, LOC_APIPROG, LOC_APIVERS, NULL);
LOC_LOGV("Created loc_api_clnt ---- %x\n", (unsigned int)loc_api_clnt);
if (loc_api_clnt == NULL)
{
LOC_LOGE("Error: cannot create RPC client.\n");
return 0;
}
/* Init RPC callbacks */
loc_api_sync_call_init();
int rc = loc_apicb_app_init();
if (rc >= 0)
{
LOC_LOGD("Loc API RPC client initialized.\n");
clnt_register_reset_notification_cb(loc_api_clnt, loc_api_glue_rpc_cb);
}
else {
LOC_LOGE("Loc API callback initialization failed.\n");
return 0;
}
}
return 1;
}
rpc_loc_client_handle_type loc_open (
rpc_loc_event_mask_type event_reg_mask,
loc_event_cb_f_type *event_callback,
loc_reset_notif_cb_f_type *rpc_cb,
void* userData
)
{
ENTRY_LOG();
LOC_GLUE_CHECK_INIT(rpc_loc_client_handle_type);
rpc_loc_client_handle_type ret_val;
rpc_loc_open_args args;
args.event_reg_mask = event_reg_mask;
int i;
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)
{
LOC_LOGW("Client already opened service (callback=%p)...\n",
event_callback);
break;
}
}
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;
}
}
}
if (i == LOC_API_CB_MAX_CLIENTS)
{
LOC_LOGE("Too many clients opened at once...\n");
return RPC_LOC_CLIENT_HANDLE_INVALID;
}
args.event_callback = loc_glue_callback_table[i].cb_id;
LOC_LOGV("cb_id=%d, func=0x%x", i, (unsigned int) event_callback);
rpc_loc_open_rets rets;
enum clnt_stat stat = RPC_SUCCESS;
EXIT_LOG_CALLFLOW(%s, "loc client open");
stat = RPC_FUNC_VERSION(rpc_loc_open_, RPC_LOC_OPEN_VERSION)(&args, &rets, loc_api_clnt);
LOC_GLUE_CHECK_RESULT(stat, int32);
/* save the handle in the table */
loc_glue_callback_table[i].handle = (rpc_loc_client_handle_type) rets.loc_open_result;
ret_val = (rpc_loc_client_handle_type) rets.loc_open_result;
return ret_val;
}
int32 loc_close
(
rpc_loc_client_handle_type handle
)
{
ENTRY_LOG();
LOC_GLUE_CHECK_INIT(int32);
int32 ret_val;
rpc_loc_close_args args;
args.handle = handle;
rpc_loc_close_rets rets;
enum clnt_stat stat = RPC_SUCCESS;
EXIT_LOG_CALLFLOW(%s, "loc client close");
stat = RPC_FUNC_VERSION(rpc_loc_close_, RPC_LOC_CLOSE_VERSION)(&args, &rets, loc_api_clnt);
loc_clear(handle);
LOC_GLUE_CHECK_RESULT(stat, int32);
ret_val = (int32) rets.loc_close_result;
return ret_val;
}
void loc_clear(rpc_loc_client_handle_type handle) {
/* Clean the client's callback function in callback table */
int i;
for (i = 0; i < LOC_API_CB_MAX_CLIENTS; i++)
{
if (loc_glue_callback_table[i].handle == handle)
{
/* Found the client */
loc_glue_callback_table[i].cb_func = NULL;
loc_glue_callback_table[i].rpc_cb = NULL;
loc_glue_callback_table[i].handle = -1;
break;
}
}
if (i == LOC_API_CB_MAX_CLIENTS)
{
LOC_LOGW("Handle not found (handle=%d)...\n", (int) handle);
}
}
int32 loc_start_fix
(
rpc_loc_client_handle_type handle
)
{
ENTRY_LOG();
LOC_GLUE_CHECK_INIT(int32);
int32 ret_val;
rpc_loc_start_fix_args args;
args.handle = handle;
rpc_loc_start_fix_rets rets;
enum clnt_stat stat = RPC_SUCCESS;
EXIT_LOG_CALLFLOW(%s, "loc start fix");
stat = RPC_FUNC_VERSION(rpc_loc_start_fix_, RPC_LOC_START_FIX_VERSION)(&args, &rets, loc_api_clnt);
LOC_GLUE_CHECK_RESULT(stat, int32);
ret_val = (int32) rets.loc_start_fix_result;
return ret_val;
}
int32 loc_stop_fix
(
rpc_loc_client_handle_type handle
)
{
ENTRY_LOG();
LOC_GLUE_CHECK_INIT(int32);
int32 ret_val;
rpc_loc_stop_fix_args args;
args.handle = handle;
rpc_loc_stop_fix_rets rets;
enum clnt_stat stat = RPC_SUCCESS;
EXIT_LOG_CALLFLOW(%s, "loc stop fix");
stat = RPC_FUNC_VERSION(rpc_loc_stop_fix_, RPC_LOC_STOP_FIX_VERSION)(&args, &rets, loc_api_clnt);
LOC_GLUE_CHECK_RESULT(stat, int32);
ret_val = (int32) rets.loc_stop_fix_result;
return ret_val;
}
int32 loc_ioctl
(
rpc_loc_client_handle_type handle,
rpc_loc_ioctl_e_type ioctl_type,
rpc_loc_ioctl_data_u_type* ioctl_data
)
{
ENTRY_LOG();
LOC_GLUE_CHECK_INIT(int32);
int32 ret_val;
rpc_loc_ioctl_args args;
args.handle = handle;
args.ioctl_data = ioctl_data;
args.ioctl_type = ioctl_type;
if (ioctl_data != NULL)
{
/* Assign ioctl union discriminator */
ioctl_data->disc = ioctl_type;
/* In case the user hasn't filled in other disc fields,
automatically fill them in here */
switch (ioctl_type)
{
case RPC_LOC_IOCTL_GET_API_VERSION:
break;
case RPC_LOC_IOCTL_SET_FIX_CRITERIA:
break;
case RPC_LOC_IOCTL_GET_FIX_CRITERIA:
break;
case RPC_LOC_IOCTL_INFORM_NI_USER_RESPONSE:
break;
case RPC_LOC_IOCTL_INJECT_PREDICTED_ORBITS_DATA:
break;
case RPC_LOC_IOCTL_QUERY_PREDICTED_ORBITS_DATA_VALIDITY:
break;
case RPC_LOC_IOCTL_QUERY_PREDICTED_ORBITS_DATA_SOURCE:
break;
case RPC_LOC_IOCTL_SET_PREDICTED_ORBITS_DATA_AUTO_DOWNLOAD:
break;
case RPC_LOC_IOCTL_INJECT_UTC_TIME:
break;
case RPC_LOC_IOCTL_INJECT_RTC_VALUE:
break;
case RPC_LOC_IOCTL_INJECT_POSITION:
break;
case RPC_LOC_IOCTL_QUERY_ENGINE_STATE:
break;
case RPC_LOC_IOCTL_INFORM_SERVER_OPEN_STATUS:
break;
case RPC_LOC_IOCTL_INFORM_SERVER_CLOSE_STATUS:
break;
case RPC_LOC_IOCTL_SET_ENGINE_LOCK:
break;
case RPC_LOC_IOCTL_GET_ENGINE_LOCK:
break;
case RPC_LOC_IOCTL_SET_SBAS_CONFIG:
break;
case RPC_LOC_IOCTL_GET_SBAS_CONFIG:
break;
case RPC_LOC_IOCTL_SET_NMEA_TYPES:
break;
case RPC_LOC_IOCTL_GET_NMEA_TYPES:
break;
case RPC_LOC_IOCTL_SET_CDMA_PDE_SERVER_ADDR:
case RPC_LOC_IOCTL_SET_CDMA_MPC_SERVER_ADDR:
case RPC_LOC_IOCTL_SET_UMTS_SLP_SERVER_ADDR:
case RPC_LOC_IOCTL_SET_CUSTOM_PDE_SERVER_ADDR:
args.ioctl_data->rpc_loc_ioctl_data_u_type_u.server_addr.addr_info.disc =
args.ioctl_data->rpc_loc_ioctl_data_u_type_u.server_addr.addr_type;
break;
case RPC_LOC_IOCTL_GET_CDMA_PDE_SERVER_ADDR:
case RPC_LOC_IOCTL_GET_CDMA_MPC_SERVER_ADDR:
case RPC_LOC_IOCTL_GET_UMTS_SLP_SERVER_ADDR:
case RPC_LOC_IOCTL_GET_CUSTOM_PDE_SERVER_ADDR:
break;
case RPC_LOC_IOCTL_SET_ON_DEMAND_LPM:
break;
case RPC_LOC_IOCTL_GET_ON_DEMAND_LPM:
break;
case RPC_LOC_IOCTL_DELETE_ASSIST_DATA:
break;
default:
break;
} /* switch */
} /* ioctl_data != NULL */
rpc_loc_ioctl_rets rets;
enum clnt_stat stat = RPC_SUCCESS;
EXIT_LOG_CALLFLOW(%s, loc_get_ioctl_type_name(ioctl_type));
stat = RPC_FUNC_VERSION(rpc_loc_ioctl_, RPC_LOC_IOCTL_VERSION)(&args, &rets, loc_api_clnt);
LOC_GLUE_CHECK_RESULT(stat, int32);
ret_val = (int32) rets.loc_ioctl_result;
return ret_val;
}
/* Returns 0 if error */
int32 loc_api_null(void)
{
LOC_GLUE_CHECK_INIT(int32);
int32 rets;
enum clnt_stat stat = RPC_SUCCESS;
clnt_unregister_reset_notification_cb(loc_api_clnt);
stat = RPC_FUNC_VERSION(rpc_loc_api_null_, RPC_LOC_API_NULL_VERSION)(NULL, &rets, loc_api_clnt);
LOC_GLUE_CHECK_RESULT(stat, int32);
return (int32) rets;
}
/*===========================================================================
FUNCTION loc_eng_ioctl
DESCRIPTION
This function calls loc_ioctl and waits for the callback result before
returning back to the user.
DEPENDENCIES
N/A
RETURN VALUE
TRUE if successful
FALSE if failed
SIDE EFFECTS
N/A
===========================================================================*/
int loc_eng_ioctl
(
rpc_loc_client_handle_type handle,
rpc_loc_ioctl_e_type ioctl_type,
rpc_loc_ioctl_data_u_type* ioctl_data_ptr,
uint32 timeout_msec,
rpc_loc_ioctl_callback_s_type *cb_data_ptr
)
{
int ret_val = RPC_LOC_API_SUCCESS;
ret_val = loc_api_sync_ioctl(handle, ioctl_type, ioctl_data_ptr, timeout_msec, cb_data_ptr);
LOC_LOGD("loc_eng_ioctl result: client = %d, ioctl_type = %s, returt %s\n",
(int32) handle,
loc_get_ioctl_type_name(ioctl_type),
loc_get_ioctl_status_name(ret_val) );
return ret_val;
}

View file

@ -0,0 +1,510 @@
/* Copyright (c) 2011, Code Aurora Forum. 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 Code Aurora Forum, 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 "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 <rpc/rpc.h>
#include <loc_api_rpc_glue.h>
#include "loc_api_sync_call.h"
/* Logging */
#define LOG_TAG "LocSvc_api_rpc_glue"
// #define LOG_NDDEBUG 0
#include <utils/Log.h>
/***************************************************************************
* DATA FOR ASYNCHRONOUS RPC PROCESSING
**************************************************************************/
loc_sync_call_slot_array_s_type loc_sync_data;
pthread_mutex_t loc_sync_call_mutex = PTHREAD_MUTEX_INITIALIZER;
boolean loc_sync_call_inited = 0;
/*===========================================================================
FUNCTION loc_api_sync_call_init
DESCRIPTION
Initialize this module
DEPENDENCIES
N/A
RETURN VALUE
none
SIDE EFFECTS
N/A
===========================================================================*/
void loc_api_sync_call_init()
{
pthread_mutex_lock(&loc_sync_call_mutex);
if (loc_sync_call_inited == 1) {
pthread_mutex_unlock(&loc_sync_call_mutex);
return;
}
loc_sync_call_inited = 1;
loc_sync_data.num_of_slots = LOC_SYNC_CALL_SLOTS_MAX;
int i;
for (i = 0; i < loc_sync_data.num_of_slots; i++)
{
loc_sync_call_slot_s_type *slot = &loc_sync_data.slots[i];
pthread_mutex_init(&slot->lock, NULL);
pthread_cond_init(&slot->loc_cb_arrived_cond, NULL);
slot->not_available = 0;
slot->in_use = 0;
slot->loc_handle = -1;
slot->loc_cb_wait_event_mask = 0; /* event to wait */
slot->loc_cb_received_event_mask = 0; /* received event */
}
pthread_mutex_unlock(&loc_sync_call_mutex);
}
/*===========================================================================
FUNCTION loc_api_sync_call_destroy
DESCRIPTION
Initialize this module
DEPENDENCIES
N/A
RETURN VALUE
none
SIDE EFFECTS
N/A
===========================================================================*/
void loc_api_sync_call_destroy()
{
int i;
pthread_mutex_lock(&loc_sync_call_mutex);
if (loc_sync_call_inited == 0) {
pthread_mutex_unlock(&loc_sync_call_mutex);
return;
}
loc_sync_call_inited = 0;
for (i = 0; i < loc_sync_data.num_of_slots; i++)
{
loc_sync_call_slot_s_type *slot = &loc_sync_data.slots[i];
pthread_mutex_lock(&slot->lock);
slot->not_available = 1;
pthread_mutex_unlock(&slot->lock);
pthread_cond_destroy(&slot->loc_cb_arrived_cond);
pthread_mutex_destroy(&slot->lock);
}
pthread_mutex_unlock(&loc_sync_call_mutex);
}
/*===========================================================================
FUNCTION loc_match_callback
DESCRIPTION
Checks if an awaited event has arrived
RETURN VALUE
TRUE arrived
FALSE not matching
===========================================================================*/
static boolean loc_match_callback(
rpc_loc_event_mask_type wait_mask,
rpc_loc_ioctl_e_type wait_ioctl,
rpc_loc_event_mask_type event_mask,
const rpc_loc_event_payload_u_type *callback_payload
)
{
if ((event_mask & wait_mask) == 0) return FALSE;
if (event_mask != RPC_LOC_EVENT_IOCTL_REPORT || wait_ioctl == 0 ||
( (callback_payload != NULL) &&
callback_payload->rpc_loc_event_payload_u_type_u.ioctl_report.type == wait_ioctl) )
return TRUE;
return FALSE;
}
/*===========================================================================
FUNCTION loc_api_callback_process_sync_call
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_api_callback_process_sync_call(
rpc_loc_client_handle_type loc_handle, /* handle of the client */
rpc_loc_event_mask_type loc_event, /* event mask */
const rpc_loc_event_payload_u_type* loc_event_payload /* payload */
)
{
int i;
LOGV("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];
pthread_mutex_lock(&slot->lock);
if (slot->in_use &&
slot->signal_sent == 0 &&
slot->loc_handle == loc_handle &&
loc_match_callback(slot->loc_cb_wait_event_mask, slot->ioctl_type, loc_event, loc_event_payload))
{
memcpy(&slot->loc_cb_received_payload, loc_event_payload, sizeof (rpc_loc_event_payload_u_type));
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);
pthread_cond_signal(&slot->loc_cb_arrived_cond);
slot->signal_sent = 1;
pthread_mutex_unlock(&slot->lock);
break;
} else {
/* do nothing */
}
pthread_mutex_unlock(&slot->lock);
}
}
/*===========================================================================
FUNCTION loc_lock_a_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_lock_a_slot()
{
int i, select_id = -1; /* no free buffer */
for (i = 0; i < loc_sync_data.num_of_slots; i++)
{
loc_sync_call_slot_s_type *slot = &loc_sync_data.slots[i];
if (pthread_mutex_trylock(&slot->lock) == EBUSY)
{
LOGV("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); */
pthread_mutex_unlock(&slot->lock);
}
return select_id;
}
/*===========================================================================
FUNCTION loc_unlock_slot
DESCRIPTION
Frees a buffer slot after the synchronous API call
DEPENDENCIES
N/A
RETURN VALUE
None
SIDE EFFECTS
N/A
===========================================================================*/
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_api_save_callback
DESCRIPTION
Selects which callback or IOCTL event to wait for.
The event_mask specifies the event(s). If it is RPC_LOC_EVENT_IOCTL_REPORT,
then ioctl_type specifies the IOCTL event.
If ioctl_type is non-zero, RPC_LOC_EVENT_IOCTL_REPORT is automatically added.
DEPENDENCIES
N/A
RETURN VALUE
Select ID (>=0) : successful
-1 : out of buffer
SIDE EFFECTS
N/A
===========================================================================*/
static void loc_api_save_callback(
int select_id, /* Selected slot */
rpc_loc_client_handle_type loc_handle, /* Client handle */
rpc_loc_event_mask_type event_mask, /* Event mask to wait for */
rpc_loc_ioctl_e_type ioctl_type /* IOCTL type to wait for */
)
{
loc_sync_call_slot_s_type *slot = &loc_sync_data.slots[select_id];
slot->loc_handle = loc_handle;
slot->loc_cb_wait_event_mask = event_mask;
slot->ioctl_type = ioctl_type;
if (ioctl_type) slot->loc_cb_wait_event_mask |= RPC_LOC_EVENT_IOCTL_REPORT;
return;
}
/*===========================================================================
FUNCTION loc_save_user_payload
DESCRIPTION
Saves received payload into user data structures
RETURN VALUE
None
===========================================================================*/
static void loc_save_user_payload(
rpc_loc_event_payload_u_type *user_cb_payload,
rpc_loc_ioctl_callback_s_type *user_ioctl_buffer,
const rpc_loc_event_payload_u_type *received_cb_payload
)
{
if (user_cb_payload)
{
memcpy(user_cb_payload, received_cb_payload,
sizeof (rpc_loc_event_payload_u_type));
}
if (user_ioctl_buffer)
{
memcpy(user_ioctl_buffer,
&received_cb_payload->rpc_loc_event_payload_u_type_u.ioctl_report,
sizeof *user_ioctl_buffer);
}
}
/*===========================================================================
FUNCTION loc_api_wait_callback
DESCRIPTION
Waits for a selected callback. The wait expires in timeout_seconds seconds.
If the function is called before an existing wait has finished, it will
immediately return EBUSY.
DEPENDENCIES
N/A
RETURN VALUE
RPC_LOC_API_SUCCESS if successful (0)
RPC_LOC_API_TIMEOUT if timed out
RPC_LOC_API_ENGINE_BUSY if already in a wait
RPC_LOC_API_INVALID_PARAMETER if callback is not yet selected
SIDE EFFECTS
N/A
===========================================================================*/
static int loc_api_wait_callback(
int select_id, /* ID from loc_select_callback() */
int timeout_seconds, /* Timeout in this number of seconds */
rpc_loc_event_payload_u_type *callback_payload, /* Pointer to callback payload buffer, can be NULL */
rpc_loc_ioctl_callback_s_type *ioctl_payload /* Pointer to IOCTL payload, can be NULL */
)
{
int ret_val = RPC_LOC_API_SUCCESS; /* the return value of this function: 0 = no error */
int rc; /* return code from pthread calls */
struct timespec expire_time;
loc_sync_call_slot_s_type *slot = &loc_sync_data.slots[select_id];
clock_gettime(CLOCK_REALTIME, &expire_time);
expire_time.tv_sec += timeout_seconds;
/* Waiting */
while (slot->signal_sent == 0 && rc != ETIMEDOUT) {
rc = pthread_cond_timedwait(&slot->loc_cb_arrived_cond,
&slot->lock, &expire_time);
}
if (rc == ETIMEDOUT)
{
ret_val = RPC_LOC_API_TIMEOUT; /* Timed out */
LOGE("TIMEOUT: %d", select_id);
}
else {
/* Obtained the first awaited callback */
ret_val = RPC_LOC_API_SUCCESS; /* Successful */
loc_save_user_payload(callback_payload, ioctl_payload, &slot->loc_cb_received_payload);
}
return ret_val;
}
/*===========================================================================
FUNCTION loc_api_sync_ioctl
DESCRIPTION
Synchronous IOCTL call (reentrant version)
DEPENDENCIES
N/A
RETURN VALUE
Loc API error code (0 = success)
SIDE EFFECTS
N/A
===========================================================================*/
int loc_api_sync_ioctl
(
rpc_loc_client_handle_type handle,
rpc_loc_ioctl_e_type ioctl_type,
rpc_loc_ioctl_data_u_type* ioctl_data_ptr,
uint32 timeout_msec,
rpc_loc_ioctl_callback_s_type *cb_data_ptr
)
{
int rc = -1;
int select_id;
rpc_loc_ioctl_callback_s_type callback_data;
select_id = loc_lock_a_slot();
if (select_id < 0 || select_id >= loc_sync_data.num_of_slots)
{
LOGE("slot not available ioctl_type = %s",
loc_get_ioctl_type_name(ioctl_type));
return rc;
}
// Select the callback we are waiting for
loc_api_save_callback(select_id, handle, 0, ioctl_type);
rc = loc_ioctl(handle, ioctl_type, ioctl_data_ptr);
if (rc != RPC_LOC_API_SUCCESS)
{
LOGE("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",
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",
select_id, loc_get_ioctl_type_name(ioctl_type), loc_get_ioctl_status_name(rc));
}
else
{
if (cb_data_ptr) memcpy(cb_data_ptr, &callback_data, sizeof *cb_data_ptr);
if (callback_data.status != RPC_LOC_API_SUCCESS)
{
rc = callback_data.status;
LOGE("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",
select_id, ioctl_type, rc);
}
} /* wait callback */
} /* loc_ioctl */
loc_unlock_slot(select_id);
return rc;
}

View file

@ -0,0 +1,86 @@
/* Copyright (c) 2011, Code Aurora Forum. 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 Code Aurora Forum, 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 "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 "rpc/rpc.h"
/* Include RPC headers */
#ifdef USE_LOCAL_RPC
#include "rpc_inc/loc_api_common.h"
#include "rpc_inc/loc_api.h"
#include "rpc_inc/loc_api_cb.h"
#endif
#ifdef USE_QCOM_AUTO_RPC
#include "loc_api_rpcgen_rpc.h"
#include "loc_api_rpcgen_common_rpc.h"
#include "loc_api_rpcgen_cb_rpc.h"
#endif
#include "rpc_inc/loc_api_fixup.h"
#include "loc_apicb_appinit.h"
#define RPC_FUNC_VERSION_BASE(a,b) a ## b
#define RPC_CB_FUNC_VERS(a,b) RPC_FUNC_VERSION_BASE(a,b)
static SVCXPRT* svrPort = NULL;
extern void RPC_CB_FUNC_VERS(loc_apicbprog_,LOC_APICBVERS_0001)(struct svc_req *rqstp, register SVCXPRT *transp);
int loc_apicb_app_init(void)
{
/* Register a callback server to use the loc_apicbprog_* function */
if (svrPort == NULL) {
svrPort = svcrtr_create();
}
if (!svrPort) return -1;
xprt_register(svrPort);
if(svc_register(svrPort, LOC_APICBPROG, LOC_APICBVERS_0001, RPC_CB_FUNC_VERS(loc_apicbprog_,LOC_APICBVERS_0001),0))
{
return 0;
}
else
{
return -1;
}
}
void loc_apicb_app_deinit(void)
{
if (svrPort == NULL)
{
return;
}
svc_unregister(svrPort, LOC_APICBPROG, LOC_APICBVERS_0001);
xprt_unregister(svrPort);
svc_destroy(svrPort);
svrPort = NULL;
}

View file

@ -0,0 +1,35 @@
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
# functions
LOC_RPCGEN_APIS_PATH := $(TARGET_OUT_INTERMEDIATES)/loc_api/libloc_api_rpcgen_intermediates
LOC_RPCGEN_APIS_PATH_FL := ../../../../../$(TARGET_OUT_INTERMEDIATES)/loc_api/libloc_api_rpcgen_intermediates
LOCAL_MODULE := libloc_api_rpcgen
LOCAL_SHARED_LIBRARIES := \
librpc \
libcommondefs
LOCAL_SRC_FILES += \
src/loc_api_rpcgen_cb_xdr.c \
src/loc_api_rpcgen_common_xdr.c \
src/loc_api_rpcgen_cb_svc.c \
src/loc_api_rpcgen_clnt.c \
src/loc_api_rpcgen_xdr.c
LOCAL_C_INCLUDES += hardware/msm7k/librpc
LOCAL_C_INCLUDES += $(LOC_RPCGEN_APIS_PATH)/../../SHARED_LIBRARIES/libcommondefs_intermediates/inc
LOCAL_C_INCLUDES += $(LOCAL_PATH)/inc
LOCAL_C_INCLUDES += $(TARGET_OUT_HEADERS)/libcommondefs/rpcgen/inc
LOCAL_COPY_HEADERS_TO := loc_api/rpcgen/inc
LOCAL_COPY_HEADERS := inc/loc_api_rpcgen_rpc.h
LOCAL_COPY_HEADERS += inc/loc_api_rpcgen_common_rpc.h
LOCAL_COPY_HEADERS += inc/loc_api_rpcgen_cb_rpc.h
LOCAL_COPY_HEADERS += inc/loc_apicb_appinit.h
LOCAL_LDLIBS += -lpthread
LOCAL_PRELINK_MODULE := false
include $(BUILD_STATIC_LIBRARY)

View file

@ -0,0 +1,156 @@
/* Copyright (c) 2011, Code Aurora Forum. 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 Code Aurora Forum, 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 "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.
*
*/
/*
* Please do not edit this file.
* It was generated using rpcgen.
*/
#ifndef _LOC_API_CB_RPC_H_RPCGEN
#define _LOC_API_CB_RPC_H_RPCGEN
#include "librpc.h"
#include "commondefs_rpcgen_rpc.h"
#include "loc_api_rpcgen_common_rpc.h"
#include <pthread.h>
#ifdef __cplusplus
extern "C" {
#endif
struct rpc_loc_event_cb_f_type_args {
rpc_uint32 cb_id;
rpc_loc_client_handle_type loc_handle;
rpc_loc_event_mask_type loc_event;
rpc_loc_event_payload_u_type *loc_event_payload;
};
typedef struct rpc_loc_event_cb_f_type_args rpc_loc_event_cb_f_type_args;
struct rpc_loc_event_cb_f_type_rets {
rpc_int32 loc_event_cb_f_type_result;
};
typedef struct rpc_loc_event_cb_f_type_rets rpc_loc_event_cb_f_type_rets;
#define LOC_APICBVERS 0x00050006
#define LOC_APICBPROG 0x3100008C
#define LOC_APICBVERS_0001 0x00050001
#if defined(__STDC__) || defined(__cplusplus)
#define rpc_loc_event_cb_f_type 1
extern enum clnt_stat rpc_loc_event_cb_f_type_0x00050001(rpc_loc_event_cb_f_type_args *, rpc_loc_event_cb_f_type_rets *, CLIENT *);
extern bool_t rpc_loc_event_cb_f_type_0x00050001_svc(rpc_loc_event_cb_f_type_args *, rpc_loc_event_cb_f_type_rets *, struct svc_req *);
extern int loc_apicbprog_0x00050001_freeresult (SVCXPRT *, xdrproc_t, caddr_t);
#else /* K&R C */
#define rpc_loc_event_cb_f_type 1
extern enum clnt_stat rpc_loc_event_cb_f_type_0x00050001();
extern bool_t rpc_loc_event_cb_f_type_0x00050001_svc();
extern int loc_apicbprog_0x00050001_freeresult ();
#endif /* K&R C */
#define LOC_APICBVERS_0002 0x00050002
#if defined(__STDC__) || defined(__cplusplus)
#define rpc_loc_api_cb_null 0xffffff00
extern enum clnt_stat rpc_loc_api_cb_null_0x00050002(void *, int *, CLIENT *);
extern bool_t rpc_loc_api_cb_null_0x00050002_svc(void *, int *, struct svc_req *);
extern int loc_apicbprog_0x00050002_freeresult (SVCXPRT *, xdrproc_t, caddr_t);
#else /* K&R C */
#define rpc_loc_api_cb_null 0xffffff00
extern enum clnt_stat rpc_loc_api_cb_null_0x00050002();
extern bool_t rpc_loc_api_cb_null_0x00050002_svc();
extern int loc_apicbprog_0x00050002_freeresult ();
#endif /* K&R C */
#define LOC_APICBVERS_0003 0x00050003
#if defined(__STDC__) || defined(__cplusplus)
extern enum clnt_stat rpc_loc_api_cb_null_0x00050003(void *, int *, CLIENT *);
extern bool_t rpc_loc_api_cb_null_0x00050003_svc(void *, int *, struct svc_req *);
extern int loc_apicbprog_0x00050003_freeresult (SVCXPRT *, xdrproc_t, caddr_t);
#else /* K&R C */
extern enum clnt_stat rpc_loc_api_cb_null_0x00050003();
extern bool_t rpc_loc_api_cb_null_0x00050003_svc();
extern int loc_apicbprog_0x00050003_freeresult ();
#endif /* K&R C */
#define LOC_APICBVERS_0004 0x00050004
#if defined(__STDC__) || defined(__cplusplus)
extern enum clnt_stat rpc_loc_api_cb_null_0x00050004(void *, int *, CLIENT *);
extern bool_t rpc_loc_api_cb_null_0x00050004_svc(void *, int *, struct svc_req *);
extern int loc_apicbprog_0x00050004_freeresult (SVCXPRT *, xdrproc_t, caddr_t);
#else /* K&R C */
extern enum clnt_stat rpc_loc_api_cb_null_0x00050004();
extern bool_t rpc_loc_api_cb_null_0x00050004_svc();
extern int loc_apicbprog_0x00050004_freeresult ();
#endif /* K&R C */
#define LOC_APICBVERS_0005 0x00050005
#if defined(__STDC__) || defined(__cplusplus)
extern enum clnt_stat rpc_loc_api_cb_null_0x00050005(void *, int *, CLIENT *);
extern bool_t rpc_loc_api_cb_null_0x00050005_svc(void *, int *, struct svc_req *);
extern int loc_apicbprog_0x00050005_freeresult (SVCXPRT *, xdrproc_t, caddr_t);
#else /* K&R C */
extern enum clnt_stat rpc_loc_api_cb_null_0x00050005();
extern bool_t rpc_loc_api_cb_null_0x00050005_svc();
extern int loc_apicbprog_0x00050005_freeresult ();
#endif /* K&R C */
#define LOC_APICBVERS_0006 0x00050006
#if defined(__STDC__) || defined(__cplusplus)
extern enum clnt_stat rpc_loc_api_cb_null_0x00050006(void *, int *, CLIENT *);
extern bool_t rpc_loc_api_cb_null_0x00050006_svc(void *, int *, struct svc_req *);
extern int loc_apicbprog_0x00050006_freeresult (SVCXPRT *, xdrproc_t, caddr_t);
#else /* K&R C */
extern enum clnt_stat rpc_loc_api_cb_null_0x00050006();
extern bool_t rpc_loc_api_cb_null_0x00050006_svc();
extern int loc_apicbprog_0x00050006_freeresult ();
#endif /* K&R C */
/* the xdr functions */
#if defined(__STDC__) || defined(__cplusplus)
extern bool_t xdr_rpc_loc_event_cb_f_type_args (XDR *, rpc_loc_event_cb_f_type_args*);
extern bool_t xdr_rpc_loc_event_cb_f_type_rets (XDR *, rpc_loc_event_cb_f_type_rets*);
#else /* K&R C */
extern bool_t xdr_rpc_loc_event_cb_f_type_args ();
extern bool_t xdr_rpc_loc_event_cb_f_type_rets ();
#endif /* K&R C */
#ifdef __cplusplus
}
#endif
#endif /* !_LOC_API_CB_RPC_H_RPCGEN */

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,288 @@
/* Copyright (c) 2011, Code Aurora Forum. 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 Code Aurora Forum, 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 "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.
*
*/
/*
* Please do not edit this file.
* It was generated using rpcgen.
*/
#ifndef _LOC_API_RPC_H_RPCGEN
#define _LOC_API_RPC_H_RPCGEN
#include "librpc.h"
#include "commondefs_rpcgen_rpc.h"
#include "loc_api_rpcgen_common_rpc.h"
#include <pthread.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef struct {
u_int rpc_loc_api_api_versions_return_type_len;
rpc_uint32 *rpc_loc_api_api_versions_return_type_val;
} rpc_loc_api_api_versions_return_type;
typedef rpc_uint32 rpc_loc_event_cb_f_type;
struct rpc_loc_open_args {
rpc_loc_event_mask_type event_reg_mask;
rpc_loc_event_cb_f_type event_callback;
};
typedef struct rpc_loc_open_args rpc_loc_open_args;
struct rpc_loc_close_args {
rpc_loc_client_handle_type handle;
};
typedef struct rpc_loc_close_args rpc_loc_close_args;
struct rpc_loc_start_fix_args {
rpc_loc_client_handle_type handle;
};
typedef struct rpc_loc_start_fix_args rpc_loc_start_fix_args;
struct rpc_loc_stop_fix_args {
rpc_loc_client_handle_type handle;
};
typedef struct rpc_loc_stop_fix_args rpc_loc_stop_fix_args;
struct rpc_loc_ioctl_args {
rpc_loc_client_handle_type handle;
rpc_loc_ioctl_e_type ioctl_type;
rpc_loc_ioctl_data_u_type *ioctl_data;
};
typedef struct rpc_loc_ioctl_args rpc_loc_ioctl_args;
struct rpc_loc_api_api_version_s_args {
rpc_boolean len_not_null;
};
typedef struct rpc_loc_api_api_version_s_args rpc_loc_api_api_version_s_args;
struct rpc_loc_api_rpc_glue_code_info_remote_rets {
rpc_uint32 toolvers;
rpc_uint32 features;
rpc_uint32 proghash;
rpc_uint32 cbproghash;
};
typedef struct rpc_loc_api_rpc_glue_code_info_remote_rets rpc_loc_api_rpc_glue_code_info_remote_rets;
struct rpc_loc_open_rets {
rpc_loc_client_handle_type loc_open_result;
};
typedef struct rpc_loc_open_rets rpc_loc_open_rets;
struct rpc_loc_close_rets {
rpc_int32 loc_close_result;
};
typedef struct rpc_loc_close_rets rpc_loc_close_rets;
struct rpc_loc_start_fix_rets {
rpc_int32 loc_start_fix_result;
};
typedef struct rpc_loc_start_fix_rets rpc_loc_start_fix_rets;
struct rpc_loc_stop_fix_rets {
rpc_int32 loc_stop_fix_result;
};
typedef struct rpc_loc_stop_fix_rets rpc_loc_stop_fix_rets;
struct rpc_loc_ioctl_rets {
rpc_int32 loc_ioctl_result;
};
typedef struct rpc_loc_ioctl_rets rpc_loc_ioctl_rets;
struct rpc_loc_api_api_versions_rets {
rpc_loc_api_api_versions_return_type loc_api_api_versions_result;
rpc_uint32 *len;
};
typedef struct rpc_loc_api_api_versions_rets rpc_loc_api_api_versions_rets;
#define LOC_APIVERS 0x00050006
#define LOC_APIPROG 0x3000008C
#define LOC_APIVERS_0001 0x00050001
#if defined(__STDC__) || defined(__cplusplus)
#define rpc_loc_api_null 0
extern enum clnt_stat rpc_loc_api_null_0x00050001(void *, void *, CLIENT *);
extern bool_t rpc_loc_api_null_0x00050001_svc(void *, void *, struct svc_req *);
#define rpc_loc_api_rpc_glue_code_info_remote 1
extern enum clnt_stat rpc_loc_api_rpc_glue_code_info_remote_0x00050001(void *, rpc_loc_api_rpc_glue_code_info_remote_rets *, CLIENT *);
extern bool_t rpc_loc_api_rpc_glue_code_info_remote_0x00050001_svc(void *, rpc_loc_api_rpc_glue_code_info_remote_rets *, struct svc_req *);
#define rpc_loc_open 2
extern enum clnt_stat rpc_loc_open_0x00050001(rpc_loc_open_args *, rpc_loc_open_rets *, CLIENT *);
extern bool_t rpc_loc_open_0x00050001_svc(rpc_loc_open_args *, rpc_loc_open_rets *, struct svc_req *);
#define rpc_loc_close 3
extern enum clnt_stat rpc_loc_close_0x00050001(rpc_loc_close_args *, rpc_loc_close_rets *, CLIENT *);
extern bool_t rpc_loc_close_0x00050001_svc(rpc_loc_close_args *, rpc_loc_close_rets *, struct svc_req *);
#define rpc_loc_start_fix 4
extern enum clnt_stat rpc_loc_start_fix_0x00050001(rpc_loc_start_fix_args *, rpc_loc_start_fix_rets *, CLIENT *);
extern bool_t rpc_loc_start_fix_0x00050001_svc(rpc_loc_start_fix_args *, rpc_loc_start_fix_rets *, struct svc_req *);
#define rpc_loc_stop_fix 5
extern enum clnt_stat rpc_loc_stop_fix_0x00050001(rpc_loc_stop_fix_args *, rpc_loc_stop_fix_rets *, CLIENT *);
extern bool_t rpc_loc_stop_fix_0x00050001_svc(rpc_loc_stop_fix_args *, rpc_loc_stop_fix_rets *, struct svc_req *);
#define rpc_loc_ioctl 6
extern enum clnt_stat rpc_loc_ioctl_0x00050001(rpc_loc_ioctl_args *, rpc_loc_ioctl_rets *, CLIENT *);
extern bool_t rpc_loc_ioctl_0x00050001_svc(rpc_loc_ioctl_args *, rpc_loc_ioctl_rets *, struct svc_req *);
#define rpc_loc_api_api_versions 0xFFFFFFFF
extern enum clnt_stat rpc_loc_api_api_versions_0x00050001(void *, rpc_loc_api_api_versions_rets *, CLIENT *);
extern bool_t rpc_loc_api_api_versions_0x00050001_svc(void *, rpc_loc_api_api_versions_rets *, struct svc_req *);
extern int loc_apiprog_0x00050001_freeresult (SVCXPRT *, xdrproc_t, caddr_t);
#else /* K&R C */
#define rpc_loc_api_null 0
extern enum clnt_stat rpc_loc_api_null_0x00050001();
extern bool_t rpc_loc_api_null_0x00050001_svc();
#define rpc_loc_api_rpc_glue_code_info_remote 1
extern enum clnt_stat rpc_loc_api_rpc_glue_code_info_remote_0x00050001();
extern bool_t rpc_loc_api_rpc_glue_code_info_remote_0x00050001_svc();
#define rpc_loc_open 2
extern enum clnt_stat rpc_loc_open_0x00050001();
extern bool_t rpc_loc_open_0x00050001_svc();
#define rpc_loc_close 3
extern enum clnt_stat rpc_loc_close_0x00050001();
extern bool_t rpc_loc_close_0x00050001_svc();
#define rpc_loc_start_fix 4
extern enum clnt_stat rpc_loc_start_fix_0x00050001();
extern bool_t rpc_loc_start_fix_0x00050001_svc();
#define rpc_loc_stop_fix 5
extern enum clnt_stat rpc_loc_stop_fix_0x00050001();
extern bool_t rpc_loc_stop_fix_0x00050001_svc();
#define rpc_loc_ioctl 6
extern enum clnt_stat rpc_loc_ioctl_0x00050001();
extern bool_t rpc_loc_ioctl_0x00050001_svc();
#define rpc_loc_api_api_versions 0xFFFFFFFF
extern enum clnt_stat rpc_loc_api_api_versions_0x00050001();
extern bool_t rpc_loc_api_api_versions_0x00050001_svc();
extern int loc_apiprog_0x00050001_freeresult ();
#endif /* K&R C */
#define LOC_APIVERS_0002 0x00050002
#if defined(__STDC__) || defined(__cplusplus)
extern enum clnt_stat rpc_loc_api_null_0x00050002(void *, void *, CLIENT *);
extern bool_t rpc_loc_api_null_0x00050002_svc(void *, void *, struct svc_req *);
extern int loc_apiprog_0x00050002_freeresult (SVCXPRT *, xdrproc_t, caddr_t);
#else /* K&R C */
extern enum clnt_stat rpc_loc_api_null_0x00050002();
extern bool_t rpc_loc_api_null_0x00050002_svc();
extern int loc_apiprog_0x00050002_freeresult ();
#endif /* K&R C */
#define LOC_APIVERS_0003 0x00050003
#if defined(__STDC__) || defined(__cplusplus)
extern enum clnt_stat rpc_loc_api_null_0x00050003(void *, void *, CLIENT *);
extern bool_t rpc_loc_api_null_0x00050003_svc(void *, void *, struct svc_req *);
extern int loc_apiprog_0x00050003_freeresult (SVCXPRT *, xdrproc_t, caddr_t);
#else /* K&R C */
extern enum clnt_stat rpc_loc_api_null_0x00050003();
extern bool_t rpc_loc_api_null_0x00050003_svc();
extern int loc_apiprog_0x00050003_freeresult ();
#endif /* K&R C */
#define LOC_APIVERS_0004 0x00050004
#if defined(__STDC__) || defined(__cplusplus)
extern enum clnt_stat rpc_loc_api_null_0x00050004(void *, void *, CLIENT *);
extern bool_t rpc_loc_api_null_0x00050004_svc(void *, void *, struct svc_req *);
extern int loc_apiprog_0x00050004_freeresult (SVCXPRT *, xdrproc_t, caddr_t);
#else /* K&R C */
extern enum clnt_stat rpc_loc_api_null_0x00050004();
extern bool_t rpc_loc_api_null_0x00050004_svc();
extern int loc_apiprog_0x00050004_freeresult ();
#endif /* K&R C */
#define LOC_APIVERS_0005 0x00050005
#if defined(__STDC__) || defined(__cplusplus)
extern enum clnt_stat rpc_loc_api_null_0x00050005(void *, void *, CLIENT *);
extern bool_t rpc_loc_api_null_0x00050005_svc(void *, void *, struct svc_req *);
extern int loc_apiprog_0x00050005_freeresult (SVCXPRT *, xdrproc_t, caddr_t);
#else /* K&R C */
extern enum clnt_stat rpc_loc_api_null_0x00050005();
extern bool_t rpc_loc_api_null_0x00050005_svc();
extern int loc_apiprog_0x00050005_freeresult ();
#endif /* K&R C */
#define LOC_APIVERS_0006 0x00050006
#if defined(__STDC__) || defined(__cplusplus)
extern enum clnt_stat rpc_loc_api_null_0x00050006(void *, void *, CLIENT *);
extern bool_t rpc_loc_api_null_0x00050006_svc(void *, void *, struct svc_req *);
extern int loc_apiprog_0x00050006_freeresult (SVCXPRT *, xdrproc_t, caddr_t);
#else /* K&R C */
extern enum clnt_stat rpc_loc_api_null_0x00050006();
extern bool_t rpc_loc_api_null_0x00050006_svc();
extern int loc_apiprog_0x00050006_freeresult ();
#endif /* K&R C */
/* the xdr functions */
#if defined(__STDC__) || defined(__cplusplus)
extern bool_t xdr_rpc_loc_api_api_versions_return_type (XDR *, rpc_loc_api_api_versions_return_type*);
extern bool_t xdr_rpc_loc_event_cb_f_type (XDR *, rpc_loc_event_cb_f_type*);
extern bool_t xdr_rpc_loc_open_args (XDR *, rpc_loc_open_args*);
extern bool_t xdr_rpc_loc_close_args (XDR *, rpc_loc_close_args*);
extern bool_t xdr_rpc_loc_start_fix_args (XDR *, rpc_loc_start_fix_args*);
extern bool_t xdr_rpc_loc_stop_fix_args (XDR *, rpc_loc_stop_fix_args*);
extern bool_t xdr_rpc_loc_ioctl_args (XDR *, rpc_loc_ioctl_args*);
extern bool_t xdr_rpc_loc_api_api_version_s_args (XDR *, rpc_loc_api_api_version_s_args*);
extern bool_t xdr_rpc_loc_api_rpc_glue_code_info_remote_rets (XDR *, rpc_loc_api_rpc_glue_code_info_remote_rets*);
extern bool_t xdr_rpc_loc_open_rets (XDR *, rpc_loc_open_rets*);
extern bool_t xdr_rpc_loc_close_rets (XDR *, rpc_loc_close_rets*);
extern bool_t xdr_rpc_loc_start_fix_rets (XDR *, rpc_loc_start_fix_rets*);
extern bool_t xdr_rpc_loc_stop_fix_rets (XDR *, rpc_loc_stop_fix_rets*);
extern bool_t xdr_rpc_loc_ioctl_rets (XDR *, rpc_loc_ioctl_rets*);
extern bool_t xdr_rpc_loc_api_api_versions_rets (XDR *, rpc_loc_api_api_versions_rets*);
#else /* K&R C */
extern bool_t xdr_rpc_loc_api_api_versions_return_type ();
extern bool_t xdr_rpc_loc_event_cb_f_type ();
extern bool_t xdr_rpc_loc_open_args ();
extern bool_t xdr_rpc_loc_close_args ();
extern bool_t xdr_rpc_loc_start_fix_args ();
extern bool_t xdr_rpc_loc_stop_fix_args ();
extern bool_t xdr_rpc_loc_ioctl_args ();
extern bool_t xdr_rpc_loc_api_api_version_s_args ();
extern bool_t xdr_rpc_loc_api_rpc_glue_code_info_remote_rets ();
extern bool_t xdr_rpc_loc_open_rets ();
extern bool_t xdr_rpc_loc_close_rets ();
extern bool_t xdr_rpc_loc_start_fix_rets ();
extern bool_t xdr_rpc_loc_stop_fix_rets ();
extern bool_t xdr_rpc_loc_ioctl_rets ();
extern bool_t xdr_rpc_loc_api_api_versions_rets ();
#endif /* K&R C */
#ifdef __cplusplus
}
#endif
#endif /* !_LOC_API_RPC_H_RPCGEN */

View file

@ -0,0 +1,34 @@
/* Copyright (c) 2011, Code Aurora Forum. 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 Code Aurora Forum, 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 "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.
*
*/
/* Initialization function for callbacks */
int loc_apicb_app_init();
void loc_apicb_app_deinit();

View file

@ -0,0 +1,327 @@
/* Copyright (c) 2011, Code Aurora Forum. 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 Code Aurora Forum, 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 "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.
*
*/
/*
* Please do not edit this file.
* It was generated using rpcgen.
*/
#include "loc_api_rpcgen_cb_rpc.h"
#include <stdio.h>
#include <stdlib.h>
#include <rpc/pmap_clnt.h>
#include <string.h>
#include <memory.h>
#include <sys/socket.h>
#include <netinet/in.h>
#ifndef SIG_PF
#define SIG_PF void(*)(int)
#endif
void
loc_apicbprog_0x00050001(struct svc_req *rqstp, register SVCXPRT *transp)
{
union {
rpc_loc_event_cb_f_type_args rpc_loc_event_cb_f_type_0x00050001_arg;
} argument;
union {
rpc_loc_event_cb_f_type_rets rpc_loc_event_cb_f_type_0x00050001_res;
} result;
bool_t retval;
xdrproc_t _xdr_argument, _xdr_result;
bool_t (*local)(char *, void *, struct svc_req *);
switch (rqstp->rq_proc) {
case NULLPROC:
(void) svc_sendreply (transp, (xdrproc_t) xdr_void, (char *)NULL);
return;
case rpc_loc_event_cb_f_type:
_xdr_argument = (xdrproc_t) xdr_rpc_loc_event_cb_f_type_args;
_xdr_result = (xdrproc_t) xdr_rpc_loc_event_cb_f_type_rets;
local = (bool_t (*) (char *, void *, struct svc_req *))rpc_loc_event_cb_f_type_0x00050001_svc;
break;
default:
svcerr_noproc (transp);
return;
}
memset ((char *)&argument, 0, sizeof (argument));
if (!svc_getargs (transp, (xdrproc_t) _xdr_argument, (caddr_t) &argument)) {
svcerr_decode (transp);
return;
}
retval = (bool_t) (*local)((char *)&argument, (void *)&result, rqstp);
if (retval > 0 && !svc_sendreply(transp, (xdrproc_t) _xdr_result, (char *)&result)) {
svcerr_systemerr (transp);
}
if (!svc_freeargs (transp, (xdrproc_t) _xdr_argument, (caddr_t) &argument)) {
fprintf (stderr, "%s", "unable to free arguments");
exit (1);
}
if (!loc_apicbprog_0x00050001_freeresult (transp, _xdr_result, (caddr_t) &result))
fprintf (stderr, "%s", "unable to free results");
return;
}
void
loc_apicbprog_0x00050002(struct svc_req *rqstp, register SVCXPRT *transp)
{
union {
int fill;
} argument;
union {
int rpc_loc_api_cb_null_0x00050002_res;
} result;
bool_t retval;
xdrproc_t _xdr_argument, _xdr_result;
bool_t (*local)(char *, void *, struct svc_req *);
switch (rqstp->rq_proc) {
case NULLPROC:
(void) svc_sendreply (transp, (xdrproc_t) xdr_void, (char *)NULL);
return;
case rpc_loc_api_cb_null:
_xdr_argument = (xdrproc_t) xdr_void;
_xdr_result = (xdrproc_t) xdr_int;
local = (bool_t (*) (char *, void *, struct svc_req *))rpc_loc_api_cb_null_0x00050002_svc;
break;
default:
svcerr_noproc (transp);
return;
}
memset ((char *)&argument, 0, sizeof (argument));
if (!svc_getargs (transp, (xdrproc_t) _xdr_argument, (caddr_t) &argument)) {
svcerr_decode (transp);
return;
}
retval = (bool_t) (*local)((char *)&argument, (void *)&result, rqstp);
if (retval > 0 && !svc_sendreply(transp, (xdrproc_t) _xdr_result, (char *)&result)) {
svcerr_systemerr (transp);
}
if (!svc_freeargs (transp, (xdrproc_t) _xdr_argument, (caddr_t) &argument)) {
fprintf (stderr, "%s", "unable to free arguments");
exit (1);
}
if (!loc_apicbprog_0x00050002_freeresult (transp, _xdr_result, (caddr_t) &result))
fprintf (stderr, "%s", "unable to free results");
return;
}
void
loc_apicbprog_0x00050003(struct svc_req *rqstp, register SVCXPRT *transp)
{
union {
int fill;
} argument;
union {
int rpc_loc_api_cb_null_0x00050003_res;
} result;
bool_t retval;
xdrproc_t _xdr_argument, _xdr_result;
bool_t (*local)(char *, void *, struct svc_req *);
switch (rqstp->rq_proc) {
case NULLPROC:
(void) svc_sendreply (transp, (xdrproc_t) xdr_void, (char *)NULL);
return;
case rpc_loc_api_cb_null:
_xdr_argument = (xdrproc_t) xdr_void;
_xdr_result = (xdrproc_t) xdr_int;
local = (bool_t (*) (char *, void *, struct svc_req *))rpc_loc_api_cb_null_0x00050003_svc;
break;
default:
svcerr_noproc (transp);
return;
}
memset ((char *)&argument, 0, sizeof (argument));
if (!svc_getargs (transp, (xdrproc_t) _xdr_argument, (caddr_t) &argument)) {
svcerr_decode (transp);
return;
}
retval = (bool_t) (*local)((char *)&argument, (void *)&result, rqstp);
if (retval > 0 && !svc_sendreply(transp, (xdrproc_t) _xdr_result, (char *)&result)) {
svcerr_systemerr (transp);
}
if (!svc_freeargs (transp, (xdrproc_t) _xdr_argument, (caddr_t) &argument)) {
fprintf (stderr, "%s", "unable to free arguments");
exit (1);
}
if (!loc_apicbprog_0x00050003_freeresult (transp, _xdr_result, (caddr_t) &result))
fprintf (stderr, "%s", "unable to free results");
return;
}
void
loc_apicbprog_0x00050004(struct svc_req *rqstp, register SVCXPRT *transp)
{
union {
int fill;
} argument;
union {
int rpc_loc_api_cb_null_0x00050004_res;
} result;
bool_t retval;
xdrproc_t _xdr_argument, _xdr_result;
bool_t (*local)(char *, void *, struct svc_req *);
switch (rqstp->rq_proc) {
case NULLPROC:
(void) svc_sendreply (transp, (xdrproc_t) xdr_void, (char *)NULL);
return;
case rpc_loc_api_cb_null:
_xdr_argument = (xdrproc_t) xdr_void;
_xdr_result = (xdrproc_t) xdr_int;
local = (bool_t (*) (char *, void *, struct svc_req *))rpc_loc_api_cb_null_0x00050004_svc;
break;
default:
svcerr_noproc (transp);
return;
}
memset ((char *)&argument, 0, sizeof (argument));
if (!svc_getargs (transp, (xdrproc_t) _xdr_argument, (caddr_t) &argument)) {
svcerr_decode (transp);
return;
}
retval = (bool_t) (*local)((char *)&argument, (void *)&result, rqstp);
if (retval > 0 && !svc_sendreply(transp, (xdrproc_t) _xdr_result, (char *)&result)) {
svcerr_systemerr (transp);
}
if (!svc_freeargs (transp, (xdrproc_t) _xdr_argument, (caddr_t) &argument)) {
fprintf (stderr, "%s", "unable to free arguments");
exit (1);
}
if (!loc_apicbprog_0x00050004_freeresult (transp, _xdr_result, (caddr_t) &result))
fprintf (stderr, "%s", "unable to free results");
return;
}
void
loc_apicbprog_0x00050005(struct svc_req *rqstp, register SVCXPRT *transp)
{
union {
int fill;
} argument;
union {
int rpc_loc_api_cb_null_0x00050005_res;
} result;
bool_t retval;
xdrproc_t _xdr_argument, _xdr_result;
bool_t (*local)(char *, void *, struct svc_req *);
switch (rqstp->rq_proc) {
case NULLPROC:
(void) svc_sendreply (transp, (xdrproc_t) xdr_void, (char *)NULL);
return;
case rpc_loc_api_cb_null:
_xdr_argument = (xdrproc_t) xdr_void;
_xdr_result = (xdrproc_t) xdr_int;
local = (bool_t (*) (char *, void *, struct svc_req *))rpc_loc_api_cb_null_0x00050005_svc;
break;
default:
svcerr_noproc (transp);
return;
}
memset ((char *)&argument, 0, sizeof (argument));
if (!svc_getargs (transp, (xdrproc_t) _xdr_argument, (caddr_t) &argument)) {
svcerr_decode (transp);
return;
}
retval = (bool_t) (*local)((char *)&argument, (void *)&result, rqstp);
if (retval > 0 && !svc_sendreply(transp, (xdrproc_t) _xdr_result, (char *)&result)) {
svcerr_systemerr (transp);
}
if (!svc_freeargs (transp, (xdrproc_t) _xdr_argument, (caddr_t) &argument)) {
fprintf (stderr, "%s", "unable to free arguments");
exit (1);
}
if (!loc_apicbprog_0x00050005_freeresult (transp, _xdr_result, (caddr_t) &result))
fprintf (stderr, "%s", "unable to free results");
return;
}
void
loc_apicbprog_0x00050006(struct svc_req *rqstp, register SVCXPRT *transp)
{
union {
int fill;
} argument;
union {
int rpc_loc_api_cb_null_0x00050006_res;
} result;
bool_t retval;
xdrproc_t _xdr_argument, _xdr_result;
bool_t (*local)(char *, void *, struct svc_req *);
switch (rqstp->rq_proc) {
case NULLPROC:
(void) svc_sendreply (transp, (xdrproc_t) xdr_void, (char *)NULL);
return;
case rpc_loc_api_cb_null:
_xdr_argument = (xdrproc_t) xdr_void;
_xdr_result = (xdrproc_t) xdr_int;
local = (bool_t (*) (char *, void *, struct svc_req *))rpc_loc_api_cb_null_0x00050006_svc;
break;
default:
svcerr_noproc (transp);
return;
}
memset ((char *)&argument, 0, sizeof (argument));
if (!svc_getargs (transp, (xdrproc_t) _xdr_argument, (caddr_t) &argument)) {
svcerr_decode (transp);
return;
}
retval = (bool_t) (*local)((char *)&argument, (void *)&result, rqstp);
if (retval > 0 && !svc_sendreply(transp, (xdrproc_t) _xdr_result, (char *)&result)) {
svcerr_systemerr (transp);
}
if (!svc_freeargs (transp, (xdrproc_t) _xdr_argument, (caddr_t) &argument)) {
fprintf (stderr, "%s", "unable to free arguments");
exit (1);
}
if (!loc_apicbprog_0x00050006_freeresult (transp, _xdr_result, (caddr_t) &result))
fprintf (stderr, "%s", "unable to free results");
return;
}

View file

@ -0,0 +1,60 @@
/* Copyright (c) 2011, Code Aurora Forum. 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 Code Aurora Forum, 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 "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.
*
*/
/*
* Please do not edit this file.
* It was generated using rpcgen.
*/
#include "loc_api_rpcgen_cb_rpc.h"
bool_t
xdr_rpc_loc_event_cb_f_type_args (XDR *xdrs, rpc_loc_event_cb_f_type_args *objp)
{
;
if (!xdr_rpc_uint32 (xdrs, &objp->cb_id))
return FALSE;
if (!xdr_rpc_loc_client_handle_type (xdrs, &objp->loc_handle))
return FALSE;
if (!xdr_rpc_loc_event_mask_type (xdrs, &objp->loc_event))
return FALSE;
if (!xdr_pointer (xdrs, (char **)&objp->loc_event_payload, sizeof (rpc_loc_event_payload_u_type), (xdrproc_t) xdr_rpc_loc_event_payload_u_type))
return FALSE;
return TRUE;
}
bool_t
xdr_rpc_loc_event_cb_f_type_rets (XDR *xdrs, rpc_loc_event_cb_f_type_rets *objp)
{
;
if (!xdr_rpc_int32 (xdrs, &objp->loc_event_cb_f_type_result))
return FALSE;
return TRUE;
}

View file

@ -0,0 +1,155 @@
/* Copyright (c) 2011, Code Aurora Forum. 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 Code Aurora Forum, 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 "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.
*
*/
/*
* Please do not edit this file.
* It was generated using rpcgen.
*/
#include <memory.h> /* for memset */
#include "loc_api_rpcgen_rpc.h"
/* Default timeout can be changed using clnt_control() */
static struct timeval TIMEOUT = { 25, 0 };
enum clnt_stat
rpc_loc_api_null_0x00050001(void *argp, void *clnt_res, CLIENT *clnt)
{
return (clnt_call(clnt, rpc_loc_api_null,
(xdrproc_t) xdr_void, (caddr_t) argp,
(xdrproc_t) xdr_void, (caddr_t) clnt_res,
TIMEOUT));
}
enum clnt_stat
rpc_loc_api_rpc_glue_code_info_remote_0x00050001(void *argp, rpc_loc_api_rpc_glue_code_info_remote_rets *clnt_res, CLIENT *clnt)
{
return (clnt_call(clnt, rpc_loc_api_rpc_glue_code_info_remote,
(xdrproc_t) xdr_void, (caddr_t) argp,
(xdrproc_t) xdr_rpc_loc_api_rpc_glue_code_info_remote_rets, (caddr_t) clnt_res,
TIMEOUT));
}
enum clnt_stat
rpc_loc_open_0x00050001(rpc_loc_open_args *argp, rpc_loc_open_rets *clnt_res, CLIENT *clnt)
{
return (clnt_call(clnt, rpc_loc_open,
(xdrproc_t) xdr_rpc_loc_open_args, (caddr_t) argp,
(xdrproc_t) xdr_rpc_loc_open_rets, (caddr_t) clnt_res,
TIMEOUT));
}
enum clnt_stat
rpc_loc_close_0x00050001(rpc_loc_close_args *argp, rpc_loc_close_rets *clnt_res, CLIENT *clnt)
{
return (clnt_call(clnt, rpc_loc_close,
(xdrproc_t) xdr_rpc_loc_close_args, (caddr_t) argp,
(xdrproc_t) xdr_rpc_loc_close_rets, (caddr_t) clnt_res,
TIMEOUT));
}
enum clnt_stat
rpc_loc_start_fix_0x00050001(rpc_loc_start_fix_args *argp, rpc_loc_start_fix_rets *clnt_res, CLIENT *clnt)
{
return (clnt_call(clnt, rpc_loc_start_fix,
(xdrproc_t) xdr_rpc_loc_start_fix_args, (caddr_t) argp,
(xdrproc_t) xdr_rpc_loc_start_fix_rets, (caddr_t) clnt_res,
TIMEOUT));
}
enum clnt_stat
rpc_loc_stop_fix_0x00050001(rpc_loc_stop_fix_args *argp, rpc_loc_stop_fix_rets *clnt_res, CLIENT *clnt)
{
return (clnt_call(clnt, rpc_loc_stop_fix,
(xdrproc_t) xdr_rpc_loc_stop_fix_args, (caddr_t) argp,
(xdrproc_t) xdr_rpc_loc_stop_fix_rets, (caddr_t) clnt_res,
TIMEOUT));
}
enum clnt_stat
rpc_loc_ioctl_0x00050001(rpc_loc_ioctl_args *argp, rpc_loc_ioctl_rets *clnt_res, CLIENT *clnt)
{
return (clnt_call(clnt, rpc_loc_ioctl,
(xdrproc_t) xdr_rpc_loc_ioctl_args, (caddr_t) argp,
(xdrproc_t) xdr_rpc_loc_ioctl_rets, (caddr_t) clnt_res,
TIMEOUT));
}
enum clnt_stat
rpc_loc_api_api_versions_0x00050001(void *argp, rpc_loc_api_api_versions_rets *clnt_res, CLIENT *clnt)
{
return (clnt_call(clnt, rpc_loc_api_api_versions,
(xdrproc_t) xdr_void, (caddr_t) argp,
(xdrproc_t) xdr_rpc_loc_api_api_versions_rets, (caddr_t) clnt_res,
TIMEOUT));
}
enum clnt_stat
rpc_loc_api_null_0x00050002(void *argp, void *clnt_res, CLIENT *clnt)
{
return (clnt_call(clnt, rpc_loc_api_null,
(xdrproc_t) xdr_void, (caddr_t) argp,
(xdrproc_t) xdr_void, (caddr_t) clnt_res,
TIMEOUT));
}
enum clnt_stat
rpc_loc_api_null_0x00050003(void *argp, void *clnt_res, CLIENT *clnt)
{
return (clnt_call(clnt, rpc_loc_api_null,
(xdrproc_t) xdr_void, (caddr_t) argp,
(xdrproc_t) xdr_void, (caddr_t) clnt_res,
TIMEOUT));
}
enum clnt_stat
rpc_loc_api_null_0x00050004(void *argp, void *clnt_res, CLIENT *clnt)
{
return (clnt_call(clnt, rpc_loc_api_null,
(xdrproc_t) xdr_void, (caddr_t) argp,
(xdrproc_t) xdr_void, (caddr_t) clnt_res,
TIMEOUT));
}
enum clnt_stat
rpc_loc_api_null_0x00050005(void *argp, void *clnt_res, CLIENT *clnt)
{
return (clnt_call(clnt, rpc_loc_api_null,
(xdrproc_t) xdr_void, (caddr_t) argp,
(xdrproc_t) xdr_void, (caddr_t) clnt_res,
TIMEOUT));
}
enum clnt_stat
rpc_loc_api_null_0x00050006(void *argp, void *clnt_res, CLIENT *clnt)
{
return (clnt_call(clnt, rpc_loc_api_null,
(xdrproc_t) xdr_void, (caddr_t) argp,
(xdrproc_t) xdr_void, (caddr_t) clnt_res,
TIMEOUT));
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,199 @@
/* Copyright (c) 2011, Code Aurora Forum. 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 Code Aurora Forum, 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 "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.
*
*/
/*
* Please do not edit this file.
* It was generated using rpcgen.
*/
#include "loc_api_rpcgen_rpc.h"
bool_t
xdr_rpc_loc_api_api_versions_return_type (XDR *xdrs, rpc_loc_api_api_versions_return_type *objp)
{
;
if (!xdr_array (xdrs, (char **)&objp->rpc_loc_api_api_versions_return_type_val, (u_int *) &objp->rpc_loc_api_api_versions_return_type_len, ~0,
sizeof (rpc_uint32), (xdrproc_t) xdr_rpc_uint32))
return FALSE;
return TRUE;
}
bool_t
xdr_rpc_loc_event_cb_f_type (XDR *xdrs, rpc_loc_event_cb_f_type *objp)
{
;
if (!xdr_rpc_uint32 (xdrs, objp))
return FALSE;
return TRUE;
}
bool_t
xdr_rpc_loc_open_args (XDR *xdrs, rpc_loc_open_args *objp)
{
;
if (!xdr_rpc_loc_event_mask_type (xdrs, &objp->event_reg_mask))
return FALSE;
if (!xdr_rpc_loc_event_cb_f_type (xdrs, &objp->event_callback))
return FALSE;
return TRUE;
}
bool_t
xdr_rpc_loc_close_args (XDR *xdrs, rpc_loc_close_args *objp)
{
;
if (!xdr_rpc_loc_client_handle_type (xdrs, &objp->handle))
return FALSE;
return TRUE;
}
bool_t
xdr_rpc_loc_start_fix_args (XDR *xdrs, rpc_loc_start_fix_args *objp)
{
;
if (!xdr_rpc_loc_client_handle_type (xdrs, &objp->handle))
return FALSE;
return TRUE;
}
bool_t
xdr_rpc_loc_stop_fix_args (XDR *xdrs, rpc_loc_stop_fix_args *objp)
{
;
if (!xdr_rpc_loc_client_handle_type (xdrs, &objp->handle))
return FALSE;
return TRUE;
}
bool_t
xdr_rpc_loc_ioctl_args (XDR *xdrs, rpc_loc_ioctl_args *objp)
{
;
if (!xdr_rpc_loc_client_handle_type (xdrs, &objp->handle))
return FALSE;
if (!xdr_rpc_loc_ioctl_e_type (xdrs, &objp->ioctl_type))
return FALSE;
if (!xdr_pointer (xdrs, (char **)&objp->ioctl_data, sizeof (rpc_loc_ioctl_data_u_type), (xdrproc_t) xdr_rpc_loc_ioctl_data_u_type))
return FALSE;
return TRUE;
}
bool_t
xdr_rpc_loc_api_api_version_s_args (XDR *xdrs, rpc_loc_api_api_version_s_args *objp)
{
;
if (!xdr_rpc_boolean (xdrs, &objp->len_not_null))
return FALSE;
return TRUE;
}
bool_t
xdr_rpc_loc_api_rpc_glue_code_info_remote_rets (XDR *xdrs, rpc_loc_api_rpc_glue_code_info_remote_rets *objp)
{
;
if (!xdr_rpc_uint32 (xdrs, &objp->toolvers))
return FALSE;
if (!xdr_rpc_uint32 (xdrs, &objp->features))
return FALSE;
if (!xdr_rpc_uint32 (xdrs, &objp->proghash))
return FALSE;
if (!xdr_rpc_uint32 (xdrs, &objp->cbproghash))
return FALSE;
return TRUE;
}
bool_t
xdr_rpc_loc_open_rets (XDR *xdrs, rpc_loc_open_rets *objp)
{
;
if (!xdr_rpc_loc_client_handle_type (xdrs, &objp->loc_open_result))
return FALSE;
return TRUE;
}
bool_t
xdr_rpc_loc_close_rets (XDR *xdrs, rpc_loc_close_rets *objp)
{
;
if (!xdr_rpc_int32 (xdrs, &objp->loc_close_result))
return FALSE;
return TRUE;
}
bool_t
xdr_rpc_loc_start_fix_rets (XDR *xdrs, rpc_loc_start_fix_rets *objp)
{
;
if (!xdr_rpc_int32 (xdrs, &objp->loc_start_fix_result))
return FALSE;
return TRUE;
}
bool_t
xdr_rpc_loc_stop_fix_rets (XDR *xdrs, rpc_loc_stop_fix_rets *objp)
{
;
if (!xdr_rpc_int32 (xdrs, &objp->loc_stop_fix_result))
return FALSE;
return TRUE;
}
bool_t
xdr_rpc_loc_ioctl_rets (XDR *xdrs, rpc_loc_ioctl_rets *objp)
{
;
if (!xdr_rpc_int32 (xdrs, &objp->loc_ioctl_result))
return FALSE;
return TRUE;
}
bool_t
xdr_rpc_loc_api_api_versions_rets (XDR *xdrs, rpc_loc_api_api_versions_rets *objp)
{
;
if (!xdr_rpc_loc_api_api_versions_return_type (xdrs, &objp->loc_api_api_versions_result))
return FALSE;
if (!xdr_pointer (xdrs, (char **)&objp->len, sizeof (rpc_uint32), (xdrproc_t) xdr_rpc_uint32))
return FALSE;
return TRUE;
}

View file

@ -0,0 +1,74 @@
/* Copyright (c) 2011, Code Aurora Forum. 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 Code Aurora Forum, 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 "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 "librpc.h"
#include "loc_api_rpcgen_rpc.h"
#include "loc_api_rpcgen_cb_rpc.h"
#define RPC_FUNC_VERSION_BASE(a,b) a ## b
#define RPC_CB_FUNC_VERS(a,b) RPC_FUNC_VERSION_BASE(a,b)
static SVCXPRT* svrPort = NULL;
extern void RPC_CB_FUNC_VERS(loc_apicbprog_,LOC_APICBVERS_0001)(struct svc_req *rqstp, register SVCXPRT *transp);
int loc_apicb_app_init(void)
{
/* Register a callback server to use the loc_apicbprog_0x00010001 */
if (svrPort == NULL) {
svrPort = svcrtr_create();
}
if (!svrPort) return -1;
xprt_register(svrPort);
if(svc_register(svrPort, LOC_APICBPROG,LOC_APICBVERS_0001, RPC_CB_FUNC_VERS(loc_apicbprog_,LOC_APICBVERS_0001),0))
{
return 0;
}
else
{
return -1;
}
}
void loc_apicb_app_deinit(void)
{
if (svrPort == NULL)
{
return;
}
svc_unregister(svrPort, LOC_APICBPROG,LOC_APICBVERS_0001);
}

View file

@ -0,0 +1,261 @@
/* Copyright (c) 2011, Code Aurora Forum. 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 Code Aurora Forum, 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 "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.
*
*/
/* LOC_API TOOL VERSION: 4.48 */
/* GENERATED: TUE JUN 14 2011 */
/*=============================================================================
L O C _ A P I . X D R
GENERAL DESCRIPTION
This is an AUTO GENERATED file that provides an xdr compatible definition of
the loc_api API.
---------------------------------------------------------------------------
---------------------------------------------------------------------------
=============================================================================*/
/*=============================================================================
Edit History
AUTO GENERATED
Generated by following versions of Htorpc modules:
Id: //source/qcom/qct/core/mproc/tools/rel/2h09/htorpc/htorpc.pl#1
Id: //source/qcom/qct/core/mproc/tools/rel/2h09/htorpc/lib/Htorpc/Start.pm#1
Id: //source/qcom/qct/core/mproc/tools/rel/2h09/htorpc/lib/Htorpc/Htoxdr.pm#1
Id: //source/qcom/qct/core/mproc/tools/rel/2h09/htorpc/lib/Htorpc/XDR.pm#3
Id: //source/qcom/qct/core/mproc/tools/rel/2h09/htorpc/lib/Htorpc/Output.pm#5
Id: //source/qcom/qct/core/mproc/tools/rel/2h09/htorpc/lib/Htorpc/Parser.pm#1
Id: //source/qcom/qct/core/mproc/tools/rel/2h09/htorpc/lib/Htorpc/Metacomments.pm#1
Id: //source/qcom/qct/core/mproc/tools/rel/2h09/htorpc/lib/Htorpc/SymbolTable.pm#1
loc_api Definition File(s):
Id: //source/qcom/qct/modem/api/gps/main/latest/loc_api.h#24
=============================================================================*/
/*=============================================================================
$Header$
=============================================================================*/
typedef rpc_uint32 rpc_loc_api_api_versions_return_type<>;
/*
* Declare an rpc_uint32 type for each callback type in the API
*/
typedef rpc_uint32 rpc_loc_event_cb_f_type;
/*
* These are struct declarations for the function arguments
*/
struct rpc_loc_open_args {
rpc_loc_event_mask_type event_reg_mask;
rpc_loc_event_cb_f_type event_callback;
};
struct rpc_loc_close_args {
rpc_loc_client_handle_type handle;
};
struct rpc_loc_start_fix_args {
rpc_loc_client_handle_type handle;
};
struct rpc_loc_stop_fix_args {
rpc_loc_client_handle_type handle;
};
struct rpc_loc_ioctl_args {
rpc_loc_client_handle_type handle;
rpc_loc_ioctl_e_type ioctl_type;
rpc_loc_ioctl_data_u_type *ioctl_data;
};
struct rpc_loc_api_api_version_s_args {
rpc_boolean len_not_null;
};
/*
* These are struct declarations for the function results
*/
struct rpc_loc_api_rpc_glue_code_info_remote_rets {
rpc_uint32 toolvers; /* Tool version */
rpc_uint32 features; /* Features turned on in the code.
* 0x00000001 ONCRPC Server Cleanup Support
*/
rpc_uint32 proghash; /* Unique hash value for the API XDR definition */
rpc_uint32 cbproghash; /* Unique hash value for the Callbacks' XDR definition */
};
struct rpc_loc_open_rets {
rpc_loc_client_handle_type loc_open_result;
};
struct rpc_loc_close_rets {
rpc_int32 loc_close_result;
};
struct rpc_loc_start_fix_rets {
rpc_int32 loc_start_fix_result;
};
struct rpc_loc_stop_fix_rets {
rpc_int32 loc_stop_fix_result;
};
struct rpc_loc_ioctl_rets {
rpc_int32 loc_ioctl_result;
};
struct rpc_loc_api_api_versions_rets {
rpc_loc_api_api_versions_return_type loc_api_api_versions_result;
rpc_uint32 *len;
};
/*
* XDR definition of the LOC_API program ( vers. 0x00050006 )
*/
program LOC_APIPROG {
version LOC_APIVERS_0001 {
void
rpc_loc_api_null( void ) = 0;
rpc_loc_api_rpc_glue_code_info_remote_rets
rpc_loc_api_rpc_glue_code_info_remote( void ) = 1;
rpc_loc_open_rets
rpc_loc_open( rpc_loc_open_args ) = 2;
rpc_loc_close_rets
rpc_loc_close( rpc_loc_close_args ) = 3;
rpc_loc_start_fix_rets
rpc_loc_start_fix( rpc_loc_start_fix_args ) = 4;
rpc_loc_stop_fix_rets
rpc_loc_stop_fix( rpc_loc_stop_fix_args ) = 5;
rpc_loc_ioctl_rets
rpc_loc_ioctl( rpc_loc_ioctl_args ) = 6;
rpc_loc_api_api_versions_rets
rpc_loc_api_api_versions( void ) = 0xFFFFFFFF;
} = 0x00050001;
version LOC_APIVERS_0002 {
/* Following elements added in enum rpc_loc_assist_data_request_e_type in 0x00050002
RPC_LOC_ASSIST_DATA_POSITION_INJECTION_REQ
*/
/* Following elements added in enum rpc_loc_ioctl_e_type in 0x00050002
RPC_LOC_IOCTL_GET_XTRA_T_SESSION_CONTROL
RPC_LOC_IOCTL_RESERVED_CMD
RPC_LOC_IOCTL_SET_XTRA_T_SESSION_CONTROL
*/
void
rpc_loc_api_null( void ) = 0;
} = 0x00050002;
version LOC_APIVERS_0003 {
/* Following elements added in enum rpc_loc_ioctl_e_type in 0x00050003
RPC_LOC_IOCTL_SET_DATA_ENABLE
RPC_LOC_IOCTL_SET_LBS_APN_PROFILE
RPC_LOC_IOCTL_GET_XTRA_APN_PROFILE
RPC_LOC_IOCTL_GET_LBS_APN_PROFILE
RPC_LOC_IOCTL_SET_XTRA_APN_PROFILE
*/
void
rpc_loc_api_null( void ) = 0;
} = 0x00050003;
version LOC_APIVERS_0004 {
/* Following elements added in enum rpc_loc_ioctl_e_type in 0x00050004
RPC_LOC_IOCTL_GET_SUPL_VERSION
RPC_LOC_IOCTL_SET_SUPL_VERSION
*/
void
rpc_loc_api_null( void ) = 0;
} = 0x00050004;
version LOC_APIVERS_0005 {
/* Following elements added in enum rpc_loc_server_addr_e_type in 0x00050005
RPC_LOC_SERVER_ADDR_IPV6
*/
/* Following elements added in enum rpc_loc_ioctl_e_type in 0x00050005
RPC_LOC_IOCTL_ERROR_ESTIMATE_CONFIG
*/
void
rpc_loc_api_null( void ) = 0;
} = 0x00050005;
version LOC_APIVERS_0006 {
/* Following elements added in enum rpc_loc_ioctl_e_type in 0x00050006
RPC_LOC_IOCTL_INFORM_SERVER_MULTI_OPEN_STATUS
*/
/* Following elements added in enum rpc_loc_server_request_e_type in 0x00050006
RPC_LOC_SERVER_REQUEST_MULTI_OPEN
*/
void
rpc_loc_api_null( void ) = 0;
} = 0x00050006;
} = 0x3000008C;
const LOC_APIVERS = 0x00050006;

View file

@ -0,0 +1,187 @@
/* Copyright (c) 2011, Code Aurora Forum. 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 Code Aurora Forum, 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 "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.
*
*/
/* LOC_API TOOL VERSION: 4.48 */
/* GENERATED: TUE JUN 14 2011 */
/*=============================================================================
L O C _ A P I _ C B . X D R
GENERAL DESCRIPTION
This is an AUTO GENERATED file that provides an xdr compatible definition of
an api that represents the grouping of the different callback functions the
loc_api API supports.
---------------------------------------------------------------------------
---------------------------------------------------------------------------
=============================================================================*/
/*=============================================================================
Edit History
AUTO GENERATED
Generated by following versions of Htorpc modules:
Id: //source/qcom/qct/core/mproc/tools/rel/2h09/htorpc/htorpc.pl#1
Id: //source/qcom/qct/core/mproc/tools/rel/2h09/htorpc/lib/Htorpc/Start.pm#1
Id: //source/qcom/qct/core/mproc/tools/rel/2h09/htorpc/lib/Htorpc/Htoxdr.pm#1
Id: //source/qcom/qct/core/mproc/tools/rel/2h09/htorpc/lib/Htorpc/XDR.pm#3
Id: //source/qcom/qct/core/mproc/tools/rel/2h09/htorpc/lib/Htorpc/Output.pm#5
Id: //source/qcom/qct/core/mproc/tools/rel/2h09/htorpc/lib/Htorpc/Parser.pm#1
Id: //source/qcom/qct/core/mproc/tools/rel/2h09/htorpc/lib/Htorpc/Metacomments.pm#1
Id: //source/qcom/qct/core/mproc/tools/rel/2h09/htorpc/lib/Htorpc/SymbolTable.pm#1
loc_api Definition File(s):
Id: //source/qcom/qct/modem/api/gps/main/latest/loc_api.h#24
=============================================================================*/
/*=============================================================================
$Header$
=============================================================================*/
/*
* These are struct declarations for the function arguments
*/
struct rpc_loc_event_cb_f_type_args {
rpc_uint32 cb_id;
rpc_loc_client_handle_type loc_handle;
rpc_loc_event_mask_type loc_event;
rpc_loc_event_payload_u_type *loc_event_payload;
};
/*
* These are struct declaratios for the function results
*/
struct rpc_loc_event_cb_f_type_rets {
rpc_int32 loc_event_cb_f_type_result;
};
/*
* XDR definition of the LOC_API callback program ( vers. 0x00050006 )
*/
program LOC_APICBPROG {
version LOC_APICBVERS_0001 {
rpc_loc_event_cb_f_type_rets
rpc_loc_event_cb_f_type( rpc_loc_event_cb_f_type_args ) = 1;
} = 0x00050001;
version LOC_APICBVERS_0002 {
/* Following elements added in enum rpc_loc_assist_data_request_e_type in 0x00050002
RPC_LOC_ASSIST_DATA_POSITION_INJECTION_REQ
*/
/* Following elements added in enum rpc_loc_ioctl_e_type in 0x00050002
RPC_LOC_IOCTL_GET_XTRA_T_SESSION_CONTROL
RPC_LOC_IOCTL_RESERVED_CMD
RPC_LOC_IOCTL_SET_XTRA_T_SESSION_CONTROL
*/
int
rpc_loc_api_cb_null( void ) = 0xffffff00;
} = 0x00050002;
version LOC_APICBVERS_0003 {
/* Following elements added in enum rpc_loc_ioctl_e_type in 0x00050003
RPC_LOC_IOCTL_SET_DATA_ENABLE
RPC_LOC_IOCTL_SET_LBS_APN_PROFILE
RPC_LOC_IOCTL_GET_XTRA_APN_PROFILE
RPC_LOC_IOCTL_GET_LBS_APN_PROFILE
RPC_LOC_IOCTL_SET_XTRA_APN_PROFILE
*/
int
rpc_loc_api_cb_null( void ) = 0xffffff00;
} = 0x00050003;
version LOC_APICBVERS_0004 {
/* Following elements added in enum rpc_loc_ioctl_e_type in 0x00050004
RPC_LOC_IOCTL_GET_SUPL_VERSION
RPC_LOC_IOCTL_SET_SUPL_VERSION
*/
int
rpc_loc_api_cb_null( void ) = 0xffffff00;
} = 0x00050004;
version LOC_APICBVERS_0005 {
/* Following elements added in enum rpc_loc_server_addr_e_type in 0x00050005
RPC_LOC_SERVER_ADDR_IPV6
*/
/* Following elements added in enum rpc_loc_ioctl_e_type in 0x00050005
RPC_LOC_IOCTL_ERROR_ESTIMATE_CONFIG
*/
int
rpc_loc_api_cb_null( void ) = 0xffffff00;
} = 0x00050005;
version LOC_APICBVERS_0006 {
/* Following elements added in enum rpc_loc_ioctl_e_type in 0x00050006
RPC_LOC_IOCTL_INFORM_SERVER_MULTI_OPEN_STATUS
*/
/* Following elements added in enum rpc_loc_server_request_e_type in 0x00050006
RPC_LOC_SERVER_REQUEST_MULTI_OPEN
*/
int
rpc_loc_api_cb_null( void ) = 0xffffff00;
} = 0x00050006;
} = 0x3100008C;
const LOC_APICBVERS = 0x00050006;

File diff suppressed because it is too large Load diff

View file

@ -1,13 +1,7 @@
#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 ($(BUILD_TINY_ANDROID),true)
ifneq ($(BOARD_VENDOR_QCOM_GPS_LOC_API_AMSS_VERSION),50001)
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
@ -63,3 +57,4 @@ LOCAL_MODULE:= libloc_api-rpc
include $(BUILD_STATIC_LIBRARY)
endif
endif

View file

@ -1,12 +1,3 @@
# 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.
CLIENTS:= loc_api
SERVERS:= loc_api_cb
COMMON:= loc_api_common

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

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

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

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

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

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

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

View file

@ -67,8 +67,8 @@ when who what, where, why
#include <utils/Log.h>
/* Comment this out to enable logging */
#undef ALOGD
#define ALOGD(...) {}
#undef LOGD
#define LOGD(...) {}
/*=====================================================================
External declarations
@ -99,17 +99,17 @@ bool_t rpc_loc_event_cb_f_type_0x00040001_svc(
/* Callback not registered, or unexpected ID (shouldn't happen) */
if (loc_api_saved_cb == NULL || argp->cb_id != LOC_API_CB_ID)
{
ALOGD("Warning: No callback handler.\n");
LOGD("Warning: No callback handler.\n");
ret->loc_event_cb_f_type_result = 0;
return 1; /* simply return */
}
ALOGD("proc: %x prog: %x vers: %x\n",
LOGD("proc: %x prog: %x vers: %x\n",
(int) req->rq_proc,
(int) req->rq_prog,
(int) req->rq_vers);
ALOGD("Callback received: %x (handle=%d ret_ptr=%d)\n",
LOGD("Callback received: %x (handle=%d ret_ptr=%d)\n",
(int) argp->loc_event,
(int) argp->loc_handle,
(int) ret);
@ -133,7 +133,7 @@ int loc_apicbprog_freeresult (SVCXPRT *transp, xdrproc_t xdr_result, caddr_t res
/*
* Insert additional freeing code here, if needed
*/
// ALOGD("***** loc_apicbprog_freeresult\n");
// LOGD("***** loc_apicbprog_freeresult\n");
return 1;
}
@ -160,9 +160,9 @@ int loc_api_glue_init(void)
if (loc_api_clnt == NULL)
{
/* Print msg */
ALOGD("Trying to create RPC client...\n");
LOGD("Trying to create RPC client...\n");
loc_api_clnt = clnt_create(NULL, LOC_APIPROG, LOC_APIVERS, NULL);
ALOGD("Created loc_api_clnt ---- %x\n", (unsigned int)loc_api_clnt);
LOGD("Created loc_api_clnt ---- %x\n", (unsigned int)loc_api_clnt);
if (loc_api_clnt == NULL)
{
@ -174,7 +174,7 @@ int loc_api_glue_init(void)
int rc = loc_apicb_app_init();
if (rc >= 0)
{
ALOGD("Loc API callback initialized.\n");
LOGD("Loc API callback initialized.\n");
} else {
fprintf(stderr, "Loc API callback initialization failed.\n");
return 0;

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

View file

@ -1,12 +1,3 @@
# 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.
CLIENTS:= loc_api
SERVERS:= loc_api_cb
COMMON:= loc_api_common

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

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

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

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

View file

@ -67,8 +67,8 @@ when who what, where, why
#include <utils/Log.h>
/* Comment this out to enable logging */
#undef ALOGD
#define ALOGD(...) {}
#undef LOGD
#define LOGD(...) {}
/*=====================================================================
External declarations
@ -99,17 +99,17 @@ bool_t rpc_loc_event_cb_f_type_0x00010001_svc(
/* Callback not registered, or unexpected ID (shouldn't happen) */
if (loc_api_saved_cb == NULL || argp->cb_id != LOC_API_CB_ID)
{
ALOGD("Warning: No callback handler.\n");
LOGD("Warning: No callback handler.\n");
ret->loc_event_cb_f_type_result = 0;
return 1; /* simply return */
}
ALOGD("proc: %x prog: %x vers: %x\n",
LOGD("proc: %x prog: %x vers: %x\n",
(int) req->rq_proc,
(int) req->rq_prog,
(int) req->rq_vers);
ALOGD("Callback received: %x (handle=%d ret_ptr=%d)\n",
LOGD("Callback received: %x (handle=%d ret_ptr=%d)\n",
(int) argp->loc_event,
(int) argp->loc_handle,
(int) ret);
@ -133,7 +133,7 @@ int loc_apicbprog_freeresult (SVCXPRT *transp, xdrproc_t xdr_result, caddr_t res
/*
* Insert additional freeing code here, if needed
*/
// ALOGD("***** loc_apicbprog_freeresult\n");
// LOGD("***** loc_apicbprog_freeresult\n");
return 1;
}
@ -160,9 +160,9 @@ int loc_api_glue_init(void)
if (loc_api_clnt == NULL)
{
/* Print msg */
ALOGD("Trying to create RPC client...\n");
LOGD("Trying to create RPC client...\n");
loc_api_clnt = clnt_create(NULL, LOC_APIPROG, /*LOC_APIVERS*/ 0x00010000, NULL);
ALOGD("Created loc_api_clnt ---- %x\n", (unsigned int)loc_api_clnt);
LOGD("Created loc_api_clnt ---- %x\n", (unsigned int)loc_api_clnt);
if (loc_api_clnt == NULL)
{
@ -174,7 +174,7 @@ int loc_api_glue_init(void)
int rc = loc_apicb_app_init();
if (rc >= 0)
{
ALOGD("Loc API callback initialized.\n");
LOGD("Loc API callback initialized.\n");
} else {
fprintf(stderr, "Loc API callback initialization failed.\n");
return 0;

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

0
loc_api/libloc_api-rpc/inc-1240/loc_api.h Normal file → Executable file
View file

0
loc_api/libloc_api-rpc/inc-1240/loc_api_cb.h Normal file → Executable file
View file

0
loc_api/libloc_api-rpc/inc-1240/loc_api_common.h Normal file → Executable file
View file

0
loc_api/libloc_api-rpc/inc-3200/loc_api.h Normal file → Executable file
View file

0
loc_api/libloc_api-rpc/inc-3200/loc_api_cb.h Normal file → Executable file
View file

0
loc_api/libloc_api-rpc/inc-3200/loc_api_common.h Normal file → Executable file
View file

View file

@ -25,7 +25,7 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
#define PRINT(x...) do { \
fprintf(stdout, "%s(%d) ", __FUNCTION__, __LINE__); \
fprintf(stdout, ##x); \
ALOGD(x); \
LOGD(x); \
} while(0)
#ifdef DEBUG
@ -43,14 +43,14 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
#define E(x...) do { \
fprintf(stderr, "%s(%d) ", __FUNCTION__, __LINE__); \
fprintf(stderr, ##x); \
ALOGE(x); \
LOGE(x); \
} while(0)
#define FAILIF(cond, msg...) do { \
if (__builtin_expect (cond, 0)) { \
fprintf(stderr, "%s:%s:(%d): ", __FILE__, __FUNCTION__, __LINE__); \
fprintf(stderr, ##msg); \
ALOGE(##msg); \
LOGE(##msg); \
} \
} while(0)

View file

@ -1,16 +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.
#Compile the old library version from Google push for Passion builds with old modem image
ifneq ($(BOARD_VENDOR_QCOM_GPS_LOC_API_AMSS_VERSION),50001)
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := gps.$(BOARD_VENDOR_QCOM_GPS_LOC_API_HARDWARE)
LOCAL_MODULE_TAGS := optional
LOCAL_STATIC_LIBRARIES:= \
libloc_api-rpc
@ -40,4 +36,4 @@ LOCAL_C_INCLUDES:= \
LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/hw
include $(BUILD_SHARED_LIBRARY)
endif #BOARD_VENDOR_QCOM_GPS_LOC_API_AMSS_VERSION = 50001

56
loc_api/libloc_api/gps.c Normal file → Executable file
View file

@ -1,29 +1,31 @@
/******************************************************************************
@file: gps.c
@brief:
DESCRIPTION
This file defines the implemenation for GPS hardware abstraction layer.
INITIALIZATION AND SEQUENCING REQUIREMENTS
-----------------------------------------------------------------------------
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.
-----------------------------------------------------------------------------
******************************************************************************/
/* Copyright (c) 2009,2011 Code Aurora Forum. 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 Code Aurora Forum, 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 "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 <hardware/gps.h>
@ -55,7 +57,7 @@ static struct hw_module_methods_t gps_module_methods = {
.open = open_gps
};
struct hw_module_t HAL_MODULE_INFO_SYM = {
const struct hw_module_t HAL_MODULE_INFO_SYM = {
.tag = HARDWARE_MODULE_TAG,
.version_major = 1,
.version_minor = 0,

View file

@ -1,35 +1,31 @@
/******************************************************************************
@file: loc_eng.cpp
@brief:
DESCRIPTION
This file defines the implemenation for GPS hardware abstraction layer.
INITIALIZATION AND SEQUENCING REQUIREMENTS
-----------------------------------------------------------------------------
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.
-----------------------------------------------------------------------------
******************************************************************************/
/*=====================================================================
$Header: $
$DateTime: $
$Author: $
======================================================================*/
/* Copyright (c) 2009,2011 Code Aurora Forum. 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 Code Aurora Forum, 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 "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
@ -57,8 +53,8 @@ $Author: $
#include <utils/Log.h>
// comment this out to enable logging
// #undef ALOGD
// #define ALOGD(...) {}
// #undef LOGD
// #define LOGD(...) {}
#define DEBUG_MOCK_NI 0
@ -150,7 +146,7 @@ const GpsInterface* gps_get_hardware_interface ()
property_get("gps.disable", propBuf, "");
if (propBuf[0] == '1')
{
ALOGD("gps_get_interface returning NULL because gps.disable=1\n");
LOGD("gps_get_interface returning NULL because gps.disable=1\n");
return NULL;
}
@ -240,7 +236,7 @@ static int loc_eng_init(GpsCallbacks* callbacks)
loc_eng_data.deferred_action_thread = callbacks->create_thread_cb("loc_api",
loc_eng_process_deferred_action, NULL);
ALOGD ("loc_eng_init called, client id = %d\n", (int32) loc_eng_data.client_handle);
LOGD ("loc_eng_init called, client id = %d\n", (int32) loc_eng_data.client_handle);
return 0;
}
@ -314,20 +310,20 @@ SIDE EFFECTS
static int loc_eng_start()
{
int ret_val;
ALOGD ("loc_eng_start\n");
LOGD ("loc_eng_start\n");
if (loc_eng_data.position_mode != GPS_POSITION_MODE_STANDALONE &&
loc_eng_data.agps_server_host[0] != 0 &&
loc_eng_data.agps_server_port != 0) {
int result = set_agps_server();
ALOGD ("set_agps_server returned = %d\n", result);
LOGD ("set_agps_server returned = %d\n", result);
}
ret_val = loc_start_fix (loc_eng_data.client_handle);
if (ret_val != RPC_LOC_API_SUCCESS)
{
ALOGD ("loc_eng_start returned error = %d\n", ret_val);
LOGD ("loc_eng_start returned error = %d\n", ret_val);
}
return 0;
@ -354,7 +350,7 @@ static int loc_eng_stop()
{
int ret_val;
ALOGD ("loc_eng_stop\n");
LOGD ("loc_eng_stop\n");
pthread_mutex_lock(&(loc_eng_data.deferred_stop_mutex));
// work around problem with loc_eng_stop when AGPS requests are pending
@ -362,7 +358,7 @@ static int loc_eng_stop()
if (loc_eng_data.agps_request_pending)
{
loc_eng_data.stop_request_pending = true;
ALOGD ("deferring stop until AGPS data call is finished\n");
LOGD ("deferring stop until AGPS data call is finished\n");
pthread_mutex_unlock(&(loc_eng_data.deferred_stop_mutex));
return 0;
}
@ -371,7 +367,7 @@ static int loc_eng_stop()
ret_val = loc_stop_fix (loc_eng_data.client_handle);
if (ret_val != RPC_LOC_API_SUCCESS)
{
ALOGD ("loc_eng_stop returned error = %d\n", ret_val);
LOGD ("loc_eng_stop returned error = %d\n", ret_val);
}
return 0;
@ -382,7 +378,7 @@ static int loc_eng_set_gps_lock(rpc_loc_lock_e_type lock_type)
rpc_loc_ioctl_data_u_type ioctl_data;
boolean ret_val;
ALOGD ("loc_eng_set_gps_lock mode, client = %d, lock_type = %d\n",
LOGD ("loc_eng_set_gps_lock mode, client = %d, lock_type = %d\n",
(int32) loc_eng_data.client_handle, lock_type);
ioctl_data.rpc_loc_ioctl_data_u_type_u.engine_lock = lock_type;
@ -396,7 +392,7 @@ static int loc_eng_set_gps_lock(rpc_loc_lock_e_type lock_type)
if (ret_val != TRUE)
{
ALOGD ("loc_eng_set_gps_lock mode failed\n");
LOGD ("loc_eng_set_gps_lock mode failed\n");
}
return 0;
@ -425,7 +421,7 @@ static int loc_eng_set_position_mode(GpsPositionMode mode, GpsPositionRecurrence
rpc_loc_fix_criteria_s_type *fix_criteria_ptr;
boolean ret_val;
ALOGD ("loc_eng_set_position mode, client = %d, interval = %d, mode = %d\n",
LOGD ("loc_eng_set_position mode, client = %d, interval = %d, mode = %d\n",
(int32) loc_eng_data.client_handle, min_interval, mode);
loc_eng_data.position_mode = mode;
@ -478,7 +474,7 @@ static int loc_eng_set_position_mode(GpsPositionMode mode, GpsPositionRecurrence
if (ret_val != TRUE)
{
ALOGD ("loc_eng_set_position mode failed\n");
LOGD ("loc_eng_set_position mode failed\n");
}
return 0;
@ -506,7 +502,7 @@ static int loc_eng_inject_time (GpsUtcTime time, int64_t timeReference, int unce
rpc_loc_assist_data_time_s_type *time_info_ptr;
boolean ret_val;
ALOGD ("loc_eng_inject_time, uncertainty = %d\n", uncertainty);
LOGD ("loc_eng_inject_time, uncertainty = %d\n", uncertainty);
ioctl_data.disc = RPC_LOC_IOCTL_INJECT_UTC_TIME;
@ -523,7 +519,7 @@ static int loc_eng_inject_time (GpsUtcTime time, int64_t timeReference, int unce
if (ret_val != TRUE)
{
ALOGD ("loc_eng_inject_time failed\n");
LOGD ("loc_eng_inject_time failed\n");
}
return 0;
@ -708,7 +704,7 @@ static int32 loc_event_cb(
const rpc_loc_event_payload_u_type* loc_event_payload
)
{
ALOGV ("loc_event_cb, client = %d, loc_event = 0x%x", (int32) client_handle, (uint32) loc_event);
LOGV ("loc_event_cb, client = %d, loc_event = 0x%x", (int32) client_handle, (uint32) loc_event);
if (client_handle == loc_eng_data.client_handle)
{
pthread_mutex_lock(&loc_eng_data.deferred_action_mutex);
@ -723,7 +719,7 @@ static int32 loc_event_cb(
}
else
{
ALOGD ("loc client mismatch: received = %d, expected = %d \n", (int32) client_handle, (int32) loc_eng_data.client_handle);
LOGD ("loc client mismatch: received = %d, expected = %d \n", (int32) client_handle, (int32) loc_eng_data.client_handle);
}
return RPC_LOC_API_SUCCESS;
@ -749,7 +745,7 @@ static void loc_eng_report_position (const rpc_loc_parsed_position_s_type *locat
{
GpsLocation location;
ALOGV ("loc_eng_report_position: location report, valid mask = 0x%x, sess status = %d\n",
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);
memset (&location, 0, sizeof(location));
@ -800,18 +796,18 @@ static void loc_eng_report_position (const rpc_loc_parsed_position_s_type *locat
if (loc_eng_data.location_cb != NULL)
{
ALOGV ("loc_eng_report_position: fire callback\n");
LOGV ("loc_eng_report_position: fire callback\n");
loc_eng_data.location_cb (&location);
}
}
else
{
ALOGV ("loc_eng_report_position: ignore position report when session status = %d\n", location_report_ptr->session_status);
LOGV ("loc_eng_report_position: ignore position report when session status = %d\n", location_report_ptr->session_status);
}
}
else
{
ALOGV ("loc_eng_report_position: ignore position report when session status is not set\n");
LOGV ("loc_eng_report_position: ignore position report when session status is not set\n");
}
}
@ -837,7 +833,7 @@ static void loc_eng_report_sv (const rpc_loc_gnss_info_s_type *gnss_report_ptr)
int num_svs_max, i;
const rpc_loc_sv_info_s_type *sv_info_ptr;
ALOGV ("loc_eng_report_sv: valid_mask = 0x%x, num of sv = %d\n",
LOGV ("loc_eng_report_sv: valid_mask = 0x%x, num of sv = %d\n",
(uint32) gnss_report_ptr->valid_mask,
gnss_report_ptr->sv_count);
@ -923,7 +919,7 @@ static void loc_eng_report_sv (const rpc_loc_gnss_info_s_type *gnss_report_ptr)
}
}
ALOGV ("num_svs = %d, eph mask = %d, alm mask = %d\n", SvStatus.num_svs, SvStatus.ephemeris_mask, SvStatus.almanac_mask );
LOGV ("num_svs = %d, eph mask = %d, alm mask = %d\n", SvStatus.num_svs, SvStatus.ephemeris_mask, SvStatus.almanac_mask );
if ((SvStatus.num_svs != 0) && (loc_eng_data.sv_status_cb != NULL))
{
loc_eng_data.sv_status_cb(&SvStatus);
@ -950,7 +946,7 @@ static void loc_eng_report_status (const rpc_loc_status_event_s_type *status_rep
{
GpsStatus status;
ALOGV ("loc_eng_report_status: event = %d\n", status_report_ptr->event);
LOGV ("loc_eng_report_status: event = %d\n", status_report_ptr->event);
memset (&status, 0, sizeof(status));
status.size = sizeof(status);
@ -1024,7 +1020,7 @@ SIDE EFFECTS
===========================================================================*/
static void loc_eng_process_conn_request (const rpc_loc_server_request_s_type *server_request_ptr)
{
ALOGD ("loc_event_cb: get loc event location server request, event = %d\n", server_request_ptr->event);
LOGD ("loc_event_cb: get loc event location server request, event = %d\n", server_request_ptr->event);
// Signal DeferredActionThread to send the APN name
pthread_mutex_lock(&loc_eng_data.deferred_action_mutex);
@ -1068,14 +1064,14 @@ SIDE EFFECTS
===========================================================================*/
static void loc_eng_agps_init(AGpsCallbacks* callbacks)
{
ALOGV("loc_eng_agps_init\n");
LOGV("loc_eng_agps_init\n");
loc_eng_data.agps_status_cb = callbacks->status_cb;
}
static int loc_eng_agps_data_conn_open(const char* apn)
{
int apn_len;
ALOGD("loc_eng_agps_data_conn_open: %s\n", apn);
LOGD("loc_eng_agps_data_conn_open: %s\n", apn);
pthread_mutex_lock(&(loc_eng_data.deferred_action_mutex));
@ -1085,7 +1081,7 @@ static int loc_eng_agps_data_conn_open(const char* apn)
if (apn_len >= sizeof(loc_eng_data.apn_name))
{
ALOGD ("loc_eng_set_apn: error, apn name exceeds maximum lenght of 100 chars\n");
LOGD ("loc_eng_set_apn: error, apn name exceeds maximum lenght of 100 chars\n");
apn_len = sizeof(loc_eng_data.apn_name) - 1;
}
@ -1103,7 +1099,7 @@ static int loc_eng_agps_data_conn_open(const char* apn)
static int loc_eng_agps_data_conn_closed()
{
ALOGD("loc_eng_agps_data_conn_closed\n");
LOGD("loc_eng_agps_data_conn_closed\n");
pthread_mutex_lock(&(loc_eng_data.deferred_action_mutex));
/* hold a wake lock while events are pending for deferred_action_thread */
loc_eng_data.acquire_wakelock_cb();
@ -1115,7 +1111,7 @@ static int loc_eng_agps_data_conn_closed()
static int loc_eng_agps_data_conn_failed()
{
ALOGD("loc_eng_agps_data_conn_failed\n");
LOGD("loc_eng_agps_data_conn_failed\n");
pthread_mutex_lock(&(loc_eng_data.deferred_action_mutex));
/* hold a wake lock while events are pending for deferred_action_thread */
@ -1163,7 +1159,7 @@ static int set_agps_server()
server_info_ptr->addr_info.rpc_loc_server_addr_u_type_u.url.addr.addr_val = url;
server_info_ptr->addr_info.rpc_loc_server_addr_u_type_u.url.addr.addr_len = strlen(url);
ALOGD ("set_agps_server, addr = %s\n", server_info_ptr->addr_info.rpc_loc_server_addr_u_type_u.url.addr.addr_val);
LOGD ("set_agps_server, addr = %s\n", server_info_ptr->addr_info.rpc_loc_server_addr_u_type_u.url.addr.addr_val);
#else
char* buf = server_info_ptr->addr_info.rpc_loc_server_addr_u_type_u.url.addr;
int buf_len = sizeof(server_info_ptr->addr_info.rpc_loc_server_addr_u_type_u.url.addr);
@ -1174,7 +1170,7 @@ static int set_agps_server()
(loc_eng_data.agps_server_port & (0x0000ffff)));
server_info_ptr->addr_info.rpc_loc_server_addr_u_type_u.url.length = buf_len;
ALOGD ("set_agps_server, addr = %s\n", buf);
LOGD ("set_agps_server, addr = %s\n", buf);
#endif
ret_val = loc_eng_ioctl (loc_eng_data.client_handle,
@ -1185,19 +1181,19 @@ static int set_agps_server()
if (ret_val != TRUE)
{
ALOGD ("set_agps_server failed\n");
LOGD ("set_agps_server failed\n");
return -1;
}
else
{
ALOGV ("set_agps_server successful\n");
LOGV ("set_agps_server successful\n");
return 0;
}
}
static int loc_eng_agps_set_server(AGpsType type, const char* hostname, int port)
{
ALOGD ("loc_eng_set_default_agps_server, type = %d, hostname = %s, port = %d\n", type, hostname, port);
LOGD ("loc_eng_set_default_agps_server, type = %d, hostname = %s, port = %d\n", type, hostname, port);
if (type != AGPS_TYPE_SUPL)
return -1;
@ -1246,7 +1242,7 @@ static void loc_eng_delete_aiding_data_deferred_action (void)
LOC_IOCTL_DEFAULT_TIMEOUT,
NULL);
ALOGD("loc_eng_ioctl for aiding data deletion returned %d, 1 for success\n", ret_val);
LOGD("loc_eng_ioctl for aiding data deletion returned %d, 1 for success\n", ret_val);
}
/*===========================================================================
@ -1274,7 +1270,7 @@ static void loc_eng_process_atl_deferred_action (int flags)
boolean ret_val;
int agps_status = -1;
ALOGV("loc_eng_process_atl_deferred_action, agps_status = %d\n", loc_eng_data.agps_status);
LOGV("loc_eng_process_atl_deferred_action, agps_status = %d\n", loc_eng_data.agps_status);
memset (&ioctl_data, 0, sizeof (rpc_loc_ioctl_data_u_type));
@ -1304,7 +1300,7 @@ static void loc_eng_process_atl_deferred_action (int flags)
#endif
// Delay this so that PDSM ATL module will behave properly
sleep (1);
ALOGD("loc_eng_ioctl for ATL with apn_name = %s\n", conn_open_status_ptr->apn_name);
LOGD("loc_eng_ioctl for ATL with apn_name = %s\n", conn_open_status_ptr->apn_name);
}
else // data_connection_failed
{
@ -1320,7 +1316,7 @@ static void loc_eng_process_atl_deferred_action (int flags)
LOC_IOCTL_DEFAULT_TIMEOUT,
NULL);
ALOGD("loc_eng_ioctl for ATL returned %d (1 for success)\n", ret_val);
LOGD("loc_eng_ioctl for ATL returned %d (1 for success)\n", ret_val);
}
/*===========================================================================
@ -1368,7 +1364,7 @@ static void loc_eng_process_loc_event (rpc_loc_event_mask_type loc_event,
if (loc_event_payload->rpc_loc_event_payload_u_type_u.assist_data_request.event ==
RPC_LOC_ASSIST_DATA_PREDICTED_ORBITS_REQ)
{
ALOGD ("loc_event_cb: xtra download requst");
LOGD ("loc_event_cb: xtra download requst");
// Call Registered callback
if (loc_eng_data.xtra_module_data.download_request_cb != NULL)
@ -1429,13 +1425,13 @@ static void loc_eng_process_deferred_action (void* arg)
status.size = sizeof(status);
status.type = AGPS_TYPE_SUPL;
ALOGD("loc_eng_process_deferred_action started\n");
LOGD("loc_eng_process_deferred_action started\n");
// make sure we do not run in background scheduling group
set_sched_policy(gettid(), SP_FOREGROUND);
// disable the GPS lock
ALOGD("Setting GPS privacy lock to RPC_LOC_LOCK_NONE\n");
LOGD("Setting GPS privacy lock to RPC_LOC_LOCK_NONE\n");
loc_eng_set_gps_lock(RPC_LOC_LOCK_NONE);
while (1)
@ -1506,10 +1502,10 @@ static void loc_eng_process_deferred_action (void* arg)
loc_eng_data.agps_request_pending = false;
if (loc_eng_data.stop_request_pending)
{
ALOGD ("handling deferred stop\n");
LOGD ("handling deferred stop\n");
if (loc_stop_fix(loc_eng_data.client_handle) != RPC_LOC_API_SUCCESS)
{
ALOGD ("loc_stop_fix failed!\n");
LOGD ("loc_stop_fix failed!\n");
}
}
pthread_mutex_unlock(&(loc_eng_data.deferred_stop_mutex));
@ -1521,10 +1517,10 @@ static void loc_eng_process_deferred_action (void* arg)
}
// reenable the GPS lock
ALOGD("Setting GPS privacy lock to RPC_LOC_LOCK_ALL\n");
LOGD("Setting GPS privacy lock to RPC_LOC_LOCK_ALL\n");
loc_eng_set_gps_lock(RPC_LOC_LOCK_ALL);
ALOGD("loc_eng_process_deferred_action thread exiting\n");
LOGD("loc_eng_process_deferred_action thread exiting\n");
loc_eng_data.release_wakelock_cb();
loc_eng_data.deferred_action_thread = 0;

View file

@ -1,35 +1,31 @@
/******************************************************************************
@file: loc_eng.h
@brief:
DESCRIPTION
This file defines the global data structure used by this module.
INITIALIZATION AND SEQUENCING REQUIREMENTS
-----------------------------------------------------------------------------
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.
-----------------------------------------------------------------------------
******************************************************************************/
/*=====================================================================
$Header: $
$DateTime: $
$Author: $
======================================================================*/
/* Copyright (c) 2009,2011 Code Aurora Forum. 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 Code Aurora Forum, 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 "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_H
#define LOC_ENG_H

View file

@ -1,36 +1,32 @@
/* Copyright (c) 2009,2011 Code Aurora Forum. 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 Code Aurora Forum, 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 "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.
*
*/
/******************************************************************************
@file: loc_eng.cpp
@brief:
DESCRIPTION
This file defines the implemenation for GPS hardware abstraction layer.
INITIALIZATION AND SEQUENCING REQUIREMENTS
-----------------------------------------------------------------------------
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.
-----------------------------------------------------------------------------
******************************************************************************/
/*=====================================================================
$Header: $
$DateTime: $
$Author: $
======================================================================*/
#define LOG_NDDEBUG 0
#include <stdio.h>
@ -52,8 +48,8 @@ $Author: $
#include <utils/Log.h>
// comment this out to enable logging
// #undef ALOGD
// #define ALOGD(...) {}
// #undef LOGD
// #define LOGD(...) {}
// Function declarations
static boolean loc_eng_ioctl_setup_cb(
@ -97,7 +93,7 @@ boolean loc_eng_ioctl(
int rpc_ret_val;
loc_eng_ioctl_data_s_type *ioctl_cb_data_ptr;
ALOGV ("loc_eng_ioctl: client = %d, ioctl_type = %d, cb_data =0x%x\n", (int32) handle, ioctl_type, (uint32) cb_data_ptr);
LOGV ("loc_eng_ioctl: client = %d, ioctl_type = %d, cb_data =0x%x\n", (int32) handle, ioctl_type, (uint32) cb_data_ptr);
ioctl_cb_data_ptr = &(loc_eng_data.ioctl_data);
// Select the callback we are waiting for
@ -109,7 +105,7 @@ boolean loc_eng_ioctl(
ioctl_type,
ioctl_data_ptr);
ALOGV ("loc_eng_ioctl: loc_ioctl returned %d \n", rpc_ret_val);
LOGV ("loc_eng_ioctl: loc_ioctl returned %d \n", rpc_ret_val);
if (rpc_ret_val == RPC_LOC_API_SUCCESS)
{
@ -164,7 +160,7 @@ static boolean loc_eng_ioctl_setup_cb(
pthread_mutex_lock(&ioctl_cb_data_ptr->cb_data_mutex);
if (ioctl_cb_data_ptr->cb_is_selected == TRUE)
{
ALOGD ("loc_eng_ioctl_setup_cb: ERROR, another ioctl in progress \n");
LOGD ("loc_eng_ioctl_setup_cb: ERROR, another ioctl in progress \n");
ret_val = FALSE;
}
else
@ -222,7 +218,7 @@ boolean loc_eng_ioctl_wait_cb(
do {
if (ioctl_cb_data_ptr->cb_is_selected == FALSE)
{
ALOGD ("loc_eng_ioctl_wait_cb: ERROR called when cb_is_waiting is set to FALSE \n");
LOGD ("loc_eng_ioctl_wait_cb: ERROR called when cb_is_waiting is set to FALSE \n");
ret_val = FALSE;
break;
}
@ -240,7 +236,7 @@ boolean loc_eng_ioctl_wait_cb(
// Special case where callback is issued before loc_ioctl ever returns
if (ioctl_cb_data_ptr->cb_has_arrived == TRUE)
{
ALOGD ("loc_eng_ioctl_wait_cb: cb has arrived without waiting \n");
LOGD ("loc_eng_ioctl_wait_cb: cb has arrived without waiting \n");
ret_val = TRUE;
break;
}
@ -260,7 +256,7 @@ boolean loc_eng_ioctl_wait_cb(
ret_val = FALSE;
}
ALOGV ("loc_eng_ioctl_wait_cb: pthread_cond_timedwait returned %d\n", rc);
LOGV ("loc_eng_ioctl_wait_cb: pthread_cond_timedwait returned %d\n", rc);
} while (0);
@ -286,7 +282,7 @@ boolean loc_eng_ioctl_wait_cb(
pthread_mutex_unlock(&ioctl_cb_data_ptr->cb_data_mutex);
ALOGV ("loc_eng_ioctl_wait_cb: returned %d\n", ret_val);
LOGV ("loc_eng_ioctl_wait_cb: returned %d\n", ret_val);
return ret_val;
}
@ -321,13 +317,13 @@ boolean loc_eng_ioctl_process_cb (
pthread_mutex_lock(&ioctl_cb_data_ptr->cb_data_mutex);
if (client_handle != ioctl_cb_data_ptr->client_handle)
{
ALOGD ("loc_eng_ioctl_process_cb: client handle mismatch, received = %d, expected = %d \n",
LOGD ("loc_eng_ioctl_process_cb: client handle mismatch, received = %d, expected = %d \n",
(int32) client_handle, (int32) ioctl_cb_data_ptr->client_handle);
ret_val = FALSE;
}
else if (cb_data_ptr->type != ioctl_cb_data_ptr->ioctl_type)
{
ALOGD ("loc_eng_ioctl_process_cb: ioctl type mismatch, received = %d, expected = %d \n",
LOGD ("loc_eng_ioctl_process_cb: ioctl type mismatch, received = %d, expected = %d \n",
cb_data_ptr->type, ioctl_cb_data_ptr->ioctl_type);
ret_val = FALSE;
}
@ -339,7 +335,7 @@ boolean loc_eng_ioctl_process_cb (
ioctl_cb_data_ptr->cb_has_arrived = TRUE;
ALOGV ("loc_eng_ioctl_process_cb: callback arrived for client = %d, ioctl = %d, status = %d\n",
LOGV ("loc_eng_ioctl_process_cb: callback arrived for client = %d, ioctl = %d, status = %d\n",
(int32) ioctl_cb_data_ptr->client_handle, ioctl_cb_data_ptr->ioctl_type,
(int32) ioctl_cb_data_ptr->cb_payload.status);

View file

@ -1,37 +1,31 @@
/******************************************************************************
@file: loc_eng_ioctl.h
@brief:
DESCRIPTION
This file defines the data structure used by any location client that
waits for the ioctl particular event to occur. Any one IOCTL can be pending
at any time.
INITIALIZATION AND SEQUENCING REQUIREMENTS
-----------------------------------------------------------------------------
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.
-----------------------------------------------------------------------------
******************************************************************************/
/*=====================================================================
$Header: $
$DateTime: $
$Author: $
======================================================================*/
/* Copyright (c) 2009,2011 Code Aurora Forum. 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 Code Aurora Forum, 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 "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_IOCTL_H
#define LOC_ENG_IOCTL_H

View file

@ -1,33 +1,33 @@
/******************************************************************************
@file: loc_eng_ni.cpp
@brief: module for network initiated interactions
DESCRIPTION
LOC_API network initiated operation support
INITIALIZATION AND SEQUENCING REQUIREMENTS
-----------------------------------------------------------------------------
Copyright (c) 2009 QUALCOMM Incorporated.
All Rights Reserved. QUALCOMM Proprietary and Confidential.
-----------------------------------------------------------------------------
******************************************************************************/
/*=====================================================================
EDIT HISTORY FOR MODULE
This section contains comments describing changes made to the module.
Notice that changes are listed in reverse chronological order.
when who what, where, why
-------- --- -------------------------------------------------------
07/30/09 dx Initial version
$Id:
======================================================================*/
/* Copyright (c) 2009,2011 Code Aurora Forum. 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 Code Aurora Forum, 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 "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_NIDEBUG 0
#include <stdio.h>
#include <stdlib.h>
@ -46,8 +46,8 @@ $Id:
#include <utils/Log.h>
// comment this out to enable logging
// #undef ALOGD
// #define ALOGD(...) {}
// #undef LOGD
// #define LOGD(...) {}
/*=============================================================================
*
@ -119,7 +119,7 @@ static void loc_ni_respond(rpc_loc_ni_user_resp_e_type resp,
const rpc_loc_ni_event_s_type *request_pass_back
)
{
ALOGD("Sending NI response: %s\n", respond_from_enum(resp));
LOGD("Sending NI response: %s\n", respond_from_enum(resp));
rpc_loc_ioctl_data_u_type data;
rpc_loc_ioctl_callback_s_type callback_payload;
@ -267,12 +267,12 @@ static void loc_ni_request_handler(const char *msg, const rpc_loc_ni_event_s_typ
loc_ni_respond(response, ni_req); */
#endif
ALOGW("loc_ni_request_handler, notification in progress, new NI request ignored, type: %d",
LOGW("loc_ni_request_handler, notification in progress, new NI request ignored, type: %d",
ni_req->event);
}
else {
/* Print notification */
ALOGD("NI Notification: %s, event: %d", msg, ni_req->event);
LOGD("NI Notification: %s, event: %d", msg, ni_req->event);
pthread_mutex_lock(&loc_eng_ni_data.loc_ni_lock);
@ -366,9 +366,9 @@ static void loc_ni_request_handler(const char *msg, const rpc_loc_ni_event_s_typ
#endif
supl_req->client_name.string_len /* length */
);
ALOGD("SUPL NI: client_name: %s len=%d", notif.text, supl_req->client_name.string_len);
LOGD("SUPL NI: client_name: %s len=%d", notif.text, supl_req->client_name.string_len);
} else {
ALOGD("SUPL NI: client_name not present.");
LOGD("SUPL NI: client_name not present.");
}
// Requestor ID
@ -382,9 +382,9 @@ static void loc_ni_request_handler(const char *msg, const rpc_loc_ni_event_s_typ
#endif
supl_req->requestor_id.string_len /* length */
);
ALOGD("SUPL NI: requestor_id: %s len=%d", notif.requestor_id, supl_req->requestor_id.string_len);
LOGD("SUPL NI: requestor_id: %s len=%d", notif.requestor_id, supl_req->requestor_id.string_len);
} else {
ALOGD("SUPL NI: requestor_id not present.");
LOGD("SUPL NI: requestor_id not present.");
}
// Encoding type
@ -402,20 +402,20 @@ static void loc_ni_request_handler(const char *msg, const rpc_loc_ni_event_s_typ
break;
default:
ALOGE("loc_ni_request_handler, unknown request event: %d", ni_req->event);
LOGE("loc_ni_request_handler, unknown request event: %d", ni_req->event);
return;
}
/* Log requestor ID and text for debugging */
ALOGI("Notification: notif_type: %d, timeout: %d, default_resp: %d", notif.ni_type, notif.timeout, notif.default_response);
ALOGI(" requestor_id: %s (encoding: %d)", notif.requestor_id, notif.requestor_id_encoding);
ALOGI(" text: %s text (encoding: %d)", notif.text, notif.text_encoding);
LOGI("Notification: notif_type: %d, timeout: %d, default_resp: %d", notif.ni_type, notif.timeout, notif.default_response);
LOGI(" requestor_id: %s (encoding: %d)", notif.requestor_id, notif.requestor_id_encoding);
LOGI(" text: %s text (encoding: %d)", notif.text, notif.text_encoding);
/* For robustness, always sets a timeout to clear up the notification status, even though
* the OEM layer in java does not do so.
**/
loc_eng_ni_data.response_time_left = 5 + (notif.timeout != 0 ? notif.timeout : LOC_NI_NO_RESPONSE_TIME);
ALOGI("Automatically sends 'no response' in %d seconds (to clear status)\n", loc_eng_ni_data.response_time_left);
LOGI("Automatically sends 'no response' in %d seconds (to clear status)\n", loc_eng_ni_data.response_time_left);
pthread_mutex_unlock(&loc_eng_ni_data.loc_ni_lock);
@ -440,7 +440,7 @@ RETURN VALUE
===========================================================================*/
int loc_ni_process_user_response(GpsUserResponseType userResponse)
{
ALOGD("NI response from UI: %d", userResponse);
LOGD("NI response from UI: %d", userResponse);
rpc_loc_ni_user_resp_e_type resp;
switch (userResponse)
@ -493,22 +493,22 @@ int loc_eng_ni_callback (
switch (ni_req->event)
{
case RPC_LOC_NI_EVENT_VX_NOTIFY_VERIFY_REQ:
ALOGI("VX Notification");
LOGI("VX Notification");
loc_ni_request_handler("VX Notify", ni_req);
break;
case RPC_LOC_NI_EVENT_UMTS_CP_NOTIFY_VERIFY_REQ:
ALOGI("UMTS CP Notification\n");
LOGI("UMTS CP Notification\n");
loc_ni_request_handler("UMTS CP Notify", ni_req);
break;
case RPC_LOC_NI_EVENT_SUPL_NOTIFY_VERIFY_REQ:
ALOGI("SUPL Notification\n");
LOGI("SUPL Notification\n");
loc_ni_request_handler("SUPL Notify", ni_req);
break;
default:
ALOGE("Unknown NI event: %x\n", (int) ni_req->event);
LOGE("Unknown NI event: %x\n", (int) ni_req->event);
break;
}
}
@ -522,7 +522,7 @@ FUNCTION loc_ni_thread_proc
===========================================================================*/
static void loc_ni_thread_proc(void *unused)
{
ALOGI("Starting Loc NI thread...\n");
LOGI("Starting Loc NI thread...\n");
while (1)
{
@ -563,7 +563,7 @@ SIDE EFFECTS
===========================================================================*/
void loc_eng_ni_init(GpsNiCallbacks *callbacks)
{
ALOGD("loc_eng_ni_init: entered.");
LOGD("loc_eng_ni_init: entered.");
if (!loc_eng_ni_data_init)
{
@ -600,10 +600,10 @@ void loc_eng_ni_respond(int notif_id, GpsUserResponseType user_response)
{
if (notif_id == loc_eng_ni_data.current_notif_id && loc_eng_ni_data.notif_in_progress)
{
ALOGI("loc_eng_ni_respond: send user response %d for notif %d", user_response, notif_id);
LOGI("loc_eng_ni_respond: send user response %d for notif %d", user_response, notif_id);
loc_ni_process_user_response(user_response);
} else {
ALOGE("loc_eng_ni_respond: notif_id %d mismatch or notification not in progress, response: %d",
LOGE("loc_eng_ni_respond: notif_id %d mismatch or notification not in progress, response: %d",
notif_id, user_response);
}
}

View file

@ -1,30 +1,31 @@
/******************************************************************************
@file: loc_eng_ni.cpp
@brief: module for network initiated interactions
DESCRIPTION
LOC_API network initiated operation support
INITIALIZATION AND SEQUENCING REQUIREMENTS
-----------------------------------------------------------------------------
Copyright (c) 2009 QUALCOMM Incorporated.
All Rights Reserved. QUALCOMM Proprietary and Confidential.
-----------------------------------------------------------------------------
******************************************************************************/
/*=====================================================================
EDIT HISTORY FOR MODULE
This section contains comments describing changes made to the module.
Notice that changes are listed in reverse chronological order.
when who what, where, why
-------- --- -------------------------------------------------------
07/30/09 dx Initial version
$Id:
======================================================================*/
/* Copyright (c) 2009,2011 Code Aurora Forum. 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 Code Aurora Forum, 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 "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_NI_H
#define LOC_ENG_NI_H

View file

@ -1,35 +1,32 @@
/******************************************************************************
@file: loc_eng.cpp
@brief:
/* Copyright (c) 2009,2011 Code Aurora Forum. 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 Code Aurora Forum, 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 "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.
*
*/
DESCRIPTION
This file defines the implemenation for GPS hardware abstraction layer.
INITIALIZATION AND SEQUENCING REQUIREMENTS
-----------------------------------------------------------------------------
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.
-----------------------------------------------------------------------------
******************************************************************************/
/*=====================================================================
$Header: $
$DateTime: $
$Author: $
======================================================================*/
#define LOG_NDDEBUG 0
#include <stdio.h>
@ -49,8 +46,8 @@ $Author: $
#include <utils/Log.h>
// comment this out to enable logging
// #undef ALOGD
// #define ALOGD(...) {}
// #undef LOGD
// #define LOGD(...) {}
#define LOC_XTRA_INJECT_DEFAULT_TIMEOUT (3100)
#define XTRA_BLOCK_SIZE (400)
@ -120,7 +117,7 @@ static int qct_loc_eng_inject_xtra_data(char* data, int length)
rpc_loc_ioctl_data_u_type ioctl_data;
rpc_loc_predicted_orbits_data_s_type *predicted_orbits_data_ptr;
ALOGV ("qct_loc_eng_inject_xtra_data, xtra size = %d, data ptr = 0x%x\n", length, (int) data);
LOGV ("qct_loc_eng_inject_xtra_data, xtra size = %d, data ptr = 0x%x\n", length, (int) data);
ioctl_data.disc = RPC_LOC_IOCTL_INJECT_PREDICTED_ORBITS_DATA;
@ -147,8 +144,8 @@ static int qct_loc_eng_inject_xtra_data(char* data, int length)
predicted_orbits_data_ptr->data_ptr.data_ptr_len = predicted_orbits_data_ptr->part_len;
predicted_orbits_data_ptr->data_ptr.data_ptr_val = data + len_injected;
ALOGV ("qct_loc_eng_inject_xtra_data, inject part = %d, len = %d, len = %d\n", predicted_orbits_data_ptr->part, predicted_orbits_data_ptr->part_len, predicted_orbits_data_ptr->data_ptr.data_ptr_len);
ALOGV ("qct_loc_eng_inject_xtra_data, total part = %d, len = %d \n", predicted_orbits_data_ptr->part, predicted_orbits_data_ptr->part_len);
LOGV ("qct_loc_eng_inject_xtra_data, inject part = %d, len = %d, len = %d\n", predicted_orbits_data_ptr->part, predicted_orbits_data_ptr->part_len, predicted_orbits_data_ptr->data_ptr.data_ptr_len);
LOGV ("qct_loc_eng_inject_xtra_data, total part = %d, len = %d \n", predicted_orbits_data_ptr->part, predicted_orbits_data_ptr->part_len);
if (part < total_parts)
{
@ -159,7 +156,7 @@ static int qct_loc_eng_inject_xtra_data(char* data, int length)
if (rpc_ret_val != RPC_LOC_API_SUCCESS)
{
ALOGE ("loc_ioctl for xtra returned %d \n", rpc_ret_val);
LOGE ("loc_ioctl for xtra returned %d \n", rpc_ret_val);
ret_val = EINVAL; // return error
break;
}
@ -176,7 +173,7 @@ static int qct_loc_eng_inject_xtra_data(char* data, int length)
}
len_injected += predicted_orbits_data_ptr->part_len;
ALOGV ("loc_ioctl for xtra len injected %d \n", len_injected);
LOGV ("loc_ioctl for xtra len injected %d \n", len_injected);
}
return ret_val;

View file

@ -1,35 +1,31 @@
/******************************************************************************
@file: loc_eng.h
@brief:
DESCRIPTION
This file defines the data structure used by this XTRA module.
INITIALIZATION AND SEQUENCING REQUIREMENTS
-----------------------------------------------------------------------------
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.
-----------------------------------------------------------------------------
******************************************************************************/
/*=====================================================================
$Header: $
$DateTime: $
$Author: $
======================================================================*/
/* Copyright (c) 2009,2011 Code Aurora Forum. 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 Code Aurora Forum, 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 "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_XTRA_H
#define LOC_ENG_XTRA_H

View file

@ -0,0 +1,131 @@
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)
LOCAL_MODULE := libloc_adapter
LOCAL_MODULE_TAGS := optional
LOCAL_SHARED_LIBRARIES := \
libutils \
libcutils \
libgps.utils
LOCAL_SRC_FILES += \
loc_eng_log.cpp \
LocApiAdapter.cpp
LOCAL_CFLAGS += \
-fno-short-enums \
-D_ANDROID_
LOCAL_C_INCLUDES:= \
$(TARGET_OUT_HEADERS)/gps.utils
LOCAL_COPY_HEADERS_TO:= libloc_eng/
LOCAL_COPY_HEADERS:= \
LocApiAdapter.h \
loc.h \
loc_eng.h \
loc_eng_xtra.h \
loc_eng_ni.h \
loc_eng_agps.h \
loc_eng_msg.h \
loc_eng_msg_id.h \
loc_eng_log.h
LOCAL_PRELINK_MODULE := false
include $(BUILD_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libloc_eng
LOCAL_MODULE_TAGS := optional
LOCAL_SHARED_LIBRARIES := \
libutils \
libcutils \
libloc_adapter \
libgps.utils \
libdl
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
LOCAL_SRC_FILES += \
loc_eng_dmn_conn.cpp \
loc_eng_dmn_conn_handler.cpp \
loc_eng_dmn_conn_thread_helper.c \
loc_eng_dmn_conn_glue_msg.c \
loc_eng_dmn_conn_glue_pipe.c
## Check if RPC is not unsupported
ifneq ($(TARGET_NO_RPC),true)
LOCAL_SHARED_LIBRARIES += libloc_api-rpc-qc
else
LOCAL_SHARED_LIBRARIES += libloc_api_v02
endif #TARGET_NO_RPC
LOCAL_CFLAGS += \
-fno-short-enums \
-D_ANDROID_
LOCAL_C_INCLUDES:= \
$(TARGET_OUT_HEADERS)/gps.utils \
hardware/qcom/gps/loc_api/ulp/inc
LOCAL_PRELINK_MODULE := false
include $(BUILD_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := gps.$(BOARD_VENDOR_QCOM_GPS_LOC_API_HARDWARE)
LOCAL_MODULE_TAGS := optional
## Libs
LOCAL_SHARED_LIBRARIES := \
libutils \
libcutils \
libloc_eng \
libgps.utils
LOCAL_SRC_FILES += \
loc.cpp \
gps.c
LOCAL_CFLAGS += \
-fno-short-enums \
-D_ANDROID_ \
## Includes
LOCAL_C_INCLUDES:= \
$(TARGET_OUT_HEADERS)/gps.utils
LOCAL_PRELINK_MODULE := false
LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/hw
include $(BUILD_SHARED_LIBRARY)
endif # not BUILD_TINY_ANDROID

View file

@ -0,0 +1,196 @@
/* Copyright (c) 2011, Code Aurora Forum. 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 Code Aurora Forum, 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 "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_adapter"
#include <LocApiAdapter.h>
#include "loc_eng_msg.h"
#include "loc_log.h"
#include "loc_eng_ni.h"
static void* noProc(void* data)
{
return NULL;
}
LocEng::LocEng(void* caller,
LOC_API_ADAPTER_EVENT_MASK_T emask,
gps_acquire_wakelock acqwl,
gps_release_wakelock relwl,
loc_msg_sender msgSender,
loc_ext_parser posParser,
loc_ext_parser svParser) :
owner(caller),
eventMask(emask), acquireWakelock(acqwl),
releaseWakeLock(relwl), sendMsge(msgSender),
extPosInfo(NULL == posParser ? noProc : posParser),
extSvInfo(NULL == svParser ? noProc : svParser)
{
LOC_LOGV("LocEng constructor %p, %p", posParser, svParser);
}
LocApiAdapter::LocApiAdapter(LocEng &locEng) :
locEngHandle(locEng)
{
LOC_LOGD("LocApiAdapter created");
}
LocApiAdapter::~LocApiAdapter()
{
LOC_LOGV("LocApiAdapter deleted");
}
int LocApiAdapter::hexcode(char *hexstring, int string_size,
const char *data, int data_size)
{
int i;
for (i = 0; i < data_size; i++)
{
char ch = data[i];
if (i*2 + 3 <= string_size)
{
snprintf(&hexstring[i*2], 3, "%02X", ch);
}
else {
break;
}
}
return i;
}
int LocApiAdapter::decodeAddress(char *addr_string, int string_size,
const char *data, int data_size)
{
const char addr_prefix = 0x91;
int i, idxOutput = 0;
if (!data || !addr_string) { return 0; }
if (data[0] != addr_prefix)
{
LOC_LOGW("decodeAddress: address prefix is not 0x%x but 0x%x", addr_prefix, data[0]);
addr_string[0] = '\0';
return 0; // prefix not correct
}
for (i = 1; i < data_size; i++)
{
unsigned char ch = data[i], low = ch & 0x0F, hi = ch >> 4;
if (low <= 9 && idxOutput < string_size - 1) { addr_string[idxOutput++] = low + '0'; }
if (hi <= 9 && idxOutput < string_size - 1) { addr_string[idxOutput++] = hi + '0'; }
}
addr_string[idxOutput] = '\0'; // Terminates the string
return idxOutput;
}
void LocApiAdapter::reportPosition(GpsLocation &location,
void* locationExt,
enum loc_sess_status status)
{
loc_eng_msg_report_position *msg(new loc_eng_msg_report_position(locEngHandle.owner,
location,
locationExt,
status));
locEngHandle.sendMsge(locEngHandle.owner, msg);
}
void LocApiAdapter::reportSv(GpsSvStatus &svStatus, void* svExt)
{
loc_eng_msg_report_sv *msg(new loc_eng_msg_report_sv(locEngHandle.owner, svStatus, svExt));
locEngHandle.sendMsge(locEngHandle.owner, msg);
}
void LocApiAdapter::reportStatus(GpsStatusValue status)
{
loc_eng_msg_report_status *msg(new loc_eng_msg_report_status(locEngHandle.owner, status));
locEngHandle.sendMsge(locEngHandle.owner, msg);
}
void LocApiAdapter::reportNmea(const char* nmea, int length)
{
loc_eng_msg_report_nmea *msg(new loc_eng_msg_report_nmea(locEngHandle.owner, nmea, length));
locEngHandle.sendMsge(locEngHandle.owner, msg);
}
void LocApiAdapter::requestATL(int connHandle, AGpsType agps_type)
{
loc_eng_msg_request_atl *msg(new loc_eng_msg_request_atl(locEngHandle.owner, connHandle, agps_type));
locEngHandle.sendMsge(locEngHandle.owner, msg);
}
void LocApiAdapter::releaseATL(int connHandle)
{
loc_eng_msg_release_atl *msg(new loc_eng_msg_release_atl(locEngHandle.owner, connHandle));
locEngHandle.sendMsge(locEngHandle.owner, msg);
}
void LocApiAdapter::requestXtraData()
{
LOC_LOGD("XTRA download request");
loc_eng_msg *msg(new loc_eng_msg(locEngHandle.owner, LOC_ENG_MSG_REQUEST_XTRA_DATA));
locEngHandle.sendMsge(locEngHandle.owner, msg);
}
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);
}
void LocApiAdapter::requestLocation()
{
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_POSITION));
// locEngHandle.sendMsge(locEngHandle.owner, msg);
}
void LocApiAdapter::requestNiNotify(GpsNiNotification &notif, const void* data)
{
notif.size = sizeof(notif);
notif.timeout = LOC_NI_NO_RESPONSE_TIME;
loc_eng_msg_request_ni *msg(new loc_eng_msg_request_ni(locEngHandle.owner, notif, data));
locEngHandle.sendMsge(locEngHandle.owner, msg);
}
void LocApiAdapter::handleEngineDownEvent()
{
loc_eng_msg *msg(new loc_eng_msg(locEngHandle.owner, LOC_ENG_MSG_ENGINE_DOWN));
locEngHandle.sendMsge(locEngHandle.owner, msg);
}
void LocApiAdapter::handleEngineUpEvent()
{
loc_eng_msg *msg(new loc_eng_msg(locEngHandle.owner, LOC_ENG_MSG_ENGINE_UP));
locEngHandle.sendMsge(locEngHandle.owner, msg);
}

View file

@ -0,0 +1,205 @@
/* Copyright (c) 2011, Code Aurora Forum. 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 Code Aurora Forum, 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 "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_ADAPTER_H
#define LOC_API_ADAPTER_H
#include <ctype.h>
#include <hardware/gps.h>
#include <loc.h>
#include <log_util.h>
#define MIN_POSSIBLE_FIX_INTERVAL 1000 /* msec */
enum loc_api_adapter_err {
LOC_API_ADAPTER_ERR_SUCCESS = 0,
LOC_API_ADAPTER_ERR_GENERAL_FAILURE = 1,
LOC_API_ADAPTER_ERR_UNSUPPORTED = 2,
LOC_API_ADAPTER_ERR_INVALID_HANDLE = 4,
LOC_API_ADAPTER_ERR_INVALID_PARAMETER = 5,
LOC_API_ADAPTER_ERR_ENGINE_BUSY = 6,
LOC_API_ADAPTER_ERR_PHONE_OFFLINE = 7,
LOC_API_ADAPTER_ERR_TIMEOUT = 8,
LOC_API_ADAPTER_ERR_SERVICE_NOT_PRESENT = 9,
LOC_API_ADAPTER_ERR_ENGINE_DOWN = 100,
LOC_API_ADAPTER_ERR_FAILURE,
LOC_API_ADAPTER_ERR_UNKNOWN
};
enum loc_api_adapter_event_index {
LOC_API_ADAPTER_REPORT_POSITION = 0, // Position report comes in loc_parsed_position_s_type
LOC_API_ADAPTER_REPORT_SATELLITE, // Satellite in view report
LOC_API_ADAPTER_REPORT_NMEA_1HZ, // NMEA report at 1HZ rate
LOC_API_ADAPTER_REPORT_NMEA_POSITION, // NMEA report at position report rate
LOC_API_ADAPTER_REQUEST_NI_NOTIFY_VERIFY, // NI notification/verification request
LOC_API_ADAPTER_REQUEST_ASSISTANCE_DATA, // Assistance data, eg: time, predicted orbits request
LOC_API_ADAPTER_REQUEST_LOCATION_SERVER, // Request for location server
LOC_API_ADAPTER_REPORT_IOCTL, // Callback report for loc_ioctl
LOC_API_ADAPTER_REPORT_STATUS, // Misc status report: eg, engine state
LOC_API_ADAPTER_EVENT_MAX
};
#define LOC_API_ADAPTER_BIT_PARSED_POSITION_REPORT (1<<LOC_API_ADAPTER_REPORT_POSITION)
#define LOC_API_ADAPTER_BIT_SATELLITE_REPORT (1<<LOC_API_ADAPTER_REPORT_SATELLITE)
#define LOC_API_ADAPTER_BIT_NMEA_1HZ_REPORT (1<<LOC_API_ADAPTER_REPORT_NMEA_1HZ)
#define LOC_API_ADAPTER_BIT_NMEA_POSITION_REPORT (1<<LOC_API_ADAPTER_REPORT_NMEA_POSITION)
#define LOC_API_ADAPTER_BIT_NI_NOTIFY_VERIFY_REQUEST (1<<LOC_API_ADAPTER_REQUEST_NI_NOTIFY_VERIFY)
#define LOC_API_ADAPTER_BIT_ASSISTANCE_DATA_REQUEST (1<<LOC_API_ADAPTER_REQUEST_ASSISTANCE_DATA)
#define LOC_API_ADAPTER_BIT_LOCATION_SERVER_REQUEST (1<<LOC_API_ADAPTER_REQUEST_LOCATION_SERVER)
#define LOC_API_ADAPTER_BIT_IOCTL_REPORT (1<<LOC_API_ADAPTER_REPORT_IOCTL)
#define LOC_API_ADAPTER_BIT_STATUS_REPORT (1<<LOC_API_ADAPTER_REPORT_STATUS)
typedef unsigned int LOC_API_ADAPTER_EVENT_MASK_T;
typedef void (*loc_msg_sender)(void* loc_eng_data_p, void* msgp);
struct LocEng {
void* owner;
LOC_API_ADAPTER_EVENT_MASK_T eventMask;
const gps_acquire_wakelock acquireWakelock;
const gps_release_wakelock releaseWakeLock;
const loc_msg_sender sendMsge;
const loc_ext_parser extPosInfo;
const loc_ext_parser extSvInfo;
LocEng(void* caller,
LOC_API_ADAPTER_EVENT_MASK_T emask,
gps_acquire_wakelock acqwl,
gps_release_wakelock relwl,
loc_msg_sender msgSender,
loc_ext_parser posParser,
loc_ext_parser svParser);
};
class LocApiAdapter {
protected:
const LocEng locEngHandle;
LocApiAdapter(LocEng &locEng);
public:
//LocApiAdapter(int q, reportCb_t[LOC_API_ADAPTER_EVENT_MAX] callbackTable);
virtual ~LocApiAdapter();
static int hexcode(char *hexstring, int string_size,
const char *data, int data_size);
static int decodeAddress(char *addr_string, int string_size,
const char *data, int data_size);
void reportPosition(GpsLocation &location,
void* locationExt,
enum loc_sess_status status);
void reportSv(GpsSvStatus &svStatus, void* svExt);
void reportStatus(GpsStatusValue status);
void reportNmea(const char* nmea, int length);
void reportAgpsStatus(AGpsStatus &agpsStatus);
void requestXtraData();
void requestTime();
void requestLocation();
void requestATL(int connHandle, AGpsType agps_type);
void releaseATL(int connHandle);
void requestNiNotify(GpsNiNotification &notify, const void* data);
void handleEngineDownEvent();
void handleEngineUpEvent();
// All below functions are to be defined by adapter specific modules:
// RPC, QMI, etc. The default implementation is empty.
inline virtual enum loc_api_adapter_err
reinit()
{LOC_LOGW("%s: default implementation invoked", __func__); return LOC_API_ADAPTER_ERR_SUCCESS;}
inline virtual enum loc_api_adapter_err
startFix()
{LOC_LOGW("%s: default implementation invoked", __func__); return LOC_API_ADAPTER_ERR_SUCCESS;}
inline virtual enum loc_api_adapter_err
stopFix()
{LOC_LOGW("%s: default implementation invoked", __func__); return LOC_API_ADAPTER_ERR_SUCCESS;}
inline virtual enum loc_api_adapter_err
deleteAidingData(GpsAidingData f)
{LOC_LOGW("%s: default implementation invoked", __func__); return LOC_API_ADAPTER_ERR_SUCCESS;}
inline virtual enum loc_api_adapter_err
enableData(int enable)
{LOC_LOGW("%s: default implementation invoked", __func__); return LOC_API_ADAPTER_ERR_SUCCESS;}
inline virtual enum loc_api_adapter_err
setAPN(char* apn, int len)
{LOC_LOGW("%s: default implementation invoked", __func__); return LOC_API_ADAPTER_ERR_SUCCESS;}
inline virtual enum loc_api_adapter_err
injectPosition(double latitude, double longitude, float accuracy)
{LOC_LOGW("%s: default implementation invoked", __func__); return LOC_API_ADAPTER_ERR_SUCCESS;}
inline virtual enum loc_api_adapter_err
setTime(GpsUtcTime time, int64_t timeReference, int uncertainty)
{LOC_LOGW("%s: default implementation invoked", __func__); return LOC_API_ADAPTER_ERR_SUCCESS;}
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
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;}
#else
inline virtual enum loc_api_adapter_err
atlOpenStatus(int handle, int is_succ, char* apn, AGpsType agpsType)
{LOC_LOGW("%s: default implementation invoked", __func__); return LOC_API_ADAPTER_ERR_SUCCESS;}
#endif
inline virtual enum loc_api_adapter_err
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)
{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)
{LOC_LOGW("%s: default implementation invoked", __func__); return LOC_API_ADAPTER_ERR_SUCCESS;}
inline virtual enum loc_api_adapter_err
setServer(unsigned int ip, int port,
LocServerType type)
{LOC_LOGW("%s: default implementation invoked", __func__); return LOC_API_ADAPTER_ERR_SUCCESS;}
inline virtual enum loc_api_adapter_err
informNiResponse(GpsUserResponseType userResponse, const void* passThroughData)
{LOC_LOGW("%s: default implementation invoked", __func__); return LOC_API_ADAPTER_ERR_SUCCESS;}
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
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)
{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)
{LOC_LOGW("%s: default implementation invoked", __func__); return LOC_API_ADAPTER_ERR_SUCCESS;}
};
LocApiAdapter* getLocApiAdapter(LocEng &locEng);
#endif //LOC_API_RPC_ADAPTER_H

68
loc_api/libloc_api_50001/gps.c Executable file
View file

@ -0,0 +1,68 @@
/* Copyright (c) 2011 Code Aurora Forum. 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 Code Aurora Forum, 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 "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 <hardware/gps.h>
#include <stdlib.h>
extern const GpsInterface* get_gps_interface();
const GpsInterface* gps__get_gps_interface(struct gps_device_t* dev)
{
return get_gps_interface();
}
static int open_gps(const struct hw_module_t* module, char const* name,
struct hw_device_t** device)
{
struct gps_device_t *dev = (struct gps_device_t *) malloc(sizeof(struct gps_device_t));
memset(dev, 0, sizeof(*dev));
dev->common.tag = HARDWARE_DEVICE_TAG;
dev->common.version = 0;
dev->common.module = (struct hw_module_t*)module;
dev->get_gps_interface = gps__get_gps_interface;
*device = (struct hw_device_t*)dev;
return 0;
}
static struct hw_module_methods_t gps_module_methods = {
.open = open_gps
};
struct hw_module_t HAL_MODULE_INFO_SYM = {
.tag = HARDWARE_MODULE_TAG,
.module_api_version = 1,
.hal_api_version = 0,
.id = GPS_HARDWARE_MODULE_ID,
.name = "loc_api GPS Module",
.author = "Qualcomm USA, Inc.",
.methods = &gps_module_methods,
};

870
loc_api/libloc_api_50001/loc.cpp Executable file
View file

@ -0,0 +1,870 @@
/* Copyright (c) 2011, Code Aurora Forum. 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 Code Aurora Forum, 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 "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_afw"
#include <hardware/gps.h>
#include <loc_eng.h>
#include <loc_log.h>
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 sv_cb(GpsSvStatus* sv_status, void* svExt);
// Function declarations for sLocEngInterface
static int loc_init(GpsCallbacks* callbacks);
static int loc_start();
static int loc_stop();
static void loc_cleanup();
static int loc_inject_time(GpsUtcTime time, int64_t timeReference, int uncertainty);
static int loc_inject_location(double latitude, double longitude, float accuracy);
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);
static const void* loc_get_extension(const char* name);
#ifdef QCOM_FEATURE_ULP
static int loc_update_criteria(UlpLocationCriteria criteria);
#endif
// Defines the GpsInterface in gps.h
static const GpsInterface sLocEngInterface =
{
sizeof(GpsInterface),
loc_init,
loc_start,
loc_stop,
loc_cleanup,
loc_inject_time,
loc_inject_location,
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
static int loc_agps_open(AGpsType agpsType,
const char* apn, AGpsBearerType bearerType);
static int loc_agps_closed(AGpsType agpsType);
static int loc_agps_open_failed(AGpsType agpsType);
#else
static int loc_agps_open(const char* apn);
static int loc_agps_closed();
static int loc_agps_open_failed();
#endif
static int loc_agps_set_server(AGpsType type, const char *hostname, int port);
static const AGpsInterface sLocEngAGpsInterface =
{
sizeof(AGpsInterface),
loc_agps_init,
loc_agps_open,
loc_agps_closed,
loc_agps_open_failed,
loc_agps_set_server
};
static int loc_xtra_init(GpsXtraCallbacks* callbacks);
static int loc_xtra_inject_data(char* data, int length);
static const GpsXtraInterface sLocEngXTRAInterface =
{
sizeof(GpsXtraInterface),
loc_xtra_init,
loc_xtra_inject_data
};
static void loc_ni_init(GpsNiCallbacks *callbacks);
static void loc_ni_respond(int notif_id, GpsUserResponseType user_response);
const GpsNiInterface sLocEngNiInterface =
{
sizeof(GpsNiInterface),
loc_ni_init,
loc_ni_respond,
};
static void loc_agps_ril_init( AGpsRilCallbacks* callbacks );
static void loc_agps_ril_set_ref_location(const AGpsRefLocation *agps_reflocation, size_t sz_struct);
static void loc_agps_ril_set_set_id(AGpsSetIDType type, const char* setid);
static void loc_agps_ril_ni_message(uint8_t *msg, size_t len);
static void loc_agps_ril_update_network_state(int connected, int type, int roaming, const char* extra_info);
static void loc_agps_ril_update_network_availability(int avaiable, const char* apn);
static const AGpsRilInterface sLocEngAGpsRilInterface =
{
sizeof(AGpsRilInterface),
loc_agps_ril_init,
loc_agps_ril_set_ref_location,
loc_agps_ril_set_set_id,
loc_agps_ril_ni_message,
loc_agps_ril_update_network_state,
loc_agps_ril_update_network_availability
};
#ifdef QCOM_FEATURE_ULP
static bool loc_inject_raw_command(char* command, int length);
static const InjectRawCmdInterface sLocEngInjectRawCmdInterface =
{
sizeof(InjectRawCmdInterface),
loc_inject_raw_command
};
#endif
static loc_eng_data_s_type loc_afw_data;
/*===========================================================================
FUNCTION gps_get_hardware_interface
DESCRIPTION
Returns the GPS hardware interaface based on LOC API
if GPS is enabled.
DEPENDENCIES
None
RETURN VALUE
0: success
SIDE EFFECTS
N/A
===========================================================================*/
const GpsInterface* gps_get_hardware_interface ()
{
ENTRY_LOG_CALLFLOW();
const GpsInterface* ret_val;
char propBuf[PROPERTY_VALUE_MAX];
// check to see if GPS should be disabled
property_get("gps.disable", propBuf, "");
if (propBuf[0] == '1')
{
LOC_LOGD("gps_get_interface returning NULL because gps.disable=1\n");
ret_val = NULL;
} else {
ret_val = &sLocEngInterface;
}
EXIT_LOG(%p, ret_val);
return ret_val;
}
// for gps.c
extern "C" const GpsInterface* get_gps_interface()
{
return &sLocEngInterface;
}
/*===========================================================================
FUNCTION loc_init
DESCRIPTION
Initialize the location engine, this include setting up global datas
and registers location engien with loc api service.
DEPENDENCIES
None
RETURN VALUE
0: success
SIDE EFFECTS
N/Ax
===========================================================================*/
static int loc_init(GpsCallbacks* callbacks)
{
ENTRY_LOG();
LOC_API_ADAPTER_EVENT_MASK_T event =
LOC_API_ADAPTER_BIT_PARSED_POSITION_REPORT |
LOC_API_ADAPTER_BIT_SATELLITE_REPORT |
LOC_API_ADAPTER_BIT_LOCATION_SERVER_REQUEST |
LOC_API_ADAPTER_BIT_ASSISTANCE_DATA_REQUEST |
LOC_API_ADAPTER_BIT_IOCTL_REPORT |
LOC_API_ADAPTER_BIT_STATUS_REPORT |
LOC_API_ADAPTER_BIT_NMEA_1HZ_REPORT |
LOC_API_ADAPTER_BIT_NI_NOTIFY_VERIFY_REQUEST;
LocCallbacks clientCallbacks = {loc_cb, /* location_cb */
callbacks->status_cb, /* status_cb */
sv_cb, /* sv_status_cb */
callbacks->nmea_cb, /* nmea_cb */
callbacks->set_capabilities_cb, /* set_capabilities_cb */
callbacks->acquire_wakelock_cb, /* acquire_wakelock_cb */
callbacks->release_wakelock_cb, /* release_wakelock_cb */
callbacks->create_thread_cb, /* create_thread_cb */
NULL, /* location_ext_parser */
NULL /* sv_ext_parser */};
gps_loc_cb = callbacks->location_cb;
gps_sv_cb = callbacks->sv_status_cb;
int ret_val = loc_eng_init(loc_afw_data, &clientCallbacks, event);
EXIT_LOG(%d, ret_val);
return ret_val;
}
/*===========================================================================
FUNCTION loc_cleanup
DESCRIPTION
Cleans location engine. The location client handle will be released.
DEPENDENCIES
None
RETURN VALUE
None
SIDE EFFECTS
N/A
===========================================================================*/
static void loc_cleanup()
{
ENTRY_LOG();
loc_eng_cleanup(loc_afw_data);
gps_loc_cb = NULL;
gps_sv_cb = NULL;
EXIT_LOG(%s, VOID_RET);
}
/*===========================================================================
FUNCTION loc_start
DESCRIPTION
Starts the tracking session
DEPENDENCIES
None
RETURN VALUE
0: success
SIDE EFFECTS
N/A
===========================================================================*/
static int loc_start()
{
ENTRY_LOG();
int ret_val = loc_eng_start(loc_afw_data);
EXIT_LOG(%d, ret_val);
return ret_val;
}
/*===========================================================================
FUNCTION loc_stop
DESCRIPTION
Stops the tracking session
DEPENDENCIES
None
RETURN VALUE
0: success
SIDE EFFECTS
N/A
===========================================================================*/
static int loc_stop()
{
ENTRY_LOG();
int ret_val = loc_eng_stop(loc_afw_data);
EXIT_LOG(%d, ret_val);
return ret_val;
}
/*===========================================================================
FUNCTION loc_set_position_mode
DESCRIPTION
Sets the mode and fix frequency for the tracking session.
DEPENDENCIES
None
RETURN VALUE
0: success
SIDE EFFECTS
N/A
===========================================================================*/
static int loc_set_position_mode(GpsPositionMode mode,
GpsPositionRecurrence recurrence,
uint32_t min_interval,
uint32_t preferred_accuracy,
uint32_t preferred_time)
{
ENTRY_LOG();
LocPositionMode locMode;
switch (mode) {
case GPS_POSITION_MODE_MS_BASED:
locMode = LOC_POSITION_MODE_MS_BASED;
break;
case GPS_POSITION_MODE_MS_ASSISTED:
locMode = LOC_POSITION_MODE_MS_ASSISTED;
break;
default:
locMode = LOC_POSITION_MODE_STANDALONE;
break;
}
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;
}
/*===========================================================================
FUNCTION loc_inject_time
DESCRIPTION
This is used by Java native function to do time injection.
DEPENDENCIES
None
RETURN VALUE
0
SIDE EFFECTS
N/A
===========================================================================*/
static int loc_inject_time(GpsUtcTime time, int64_t timeReference, int uncertainty)
{
ENTRY_LOG();
int ret_val = loc_eng_inject_time(loc_afw_data, time, timeReference, uncertainty);
EXIT_LOG(%d, ret_val);
return ret_val;
}
/*===========================================================================
FUNCTION loc_inject_location
DESCRIPTION
This is used by Java native function to do location injection.
DEPENDENCIES
None
RETURN VALUE
0 : Successful
error code : Failure
SIDE EFFECTS
N/A
===========================================================================*/
static int loc_inject_location(double latitude, double longitude, float accuracy)
{
ENTRY_LOG();
int ret_val = loc_eng_inject_location(loc_afw_data, latitude, longitude, accuracy);
EXIT_LOG(%d, ret_val);
return ret_val;
}
/*===========================================================================
FUNCTION loc_delete_aiding_data
DESCRIPTION
This is used by Java native function to delete the aiding data. The function
updates the global variable for the aiding data to be deleted. If the GPS
engine is off, the aiding data will be deleted. Otherwise, the actual action
will happen when gps engine is turned off.
DEPENDENCIES
Assumes the aiding data type specified in GpsAidingData matches with
LOC API specification.
RETURN VALUE
None
SIDE EFFECTS
N/A
===========================================================================*/
static void loc_delete_aiding_data(GpsAidingData f)
{
ENTRY_LOG();
loc_eng_delete_aiding_data(loc_afw_data, f);
EXIT_LOG(%s, VOID_RET);
}
#ifdef QCOM_FEATURE_ULP
/*===========================================================================
FUNCTION loc_update_criteria
DESCRIPTION
This is used to inform the ULP module of new unique criteria that are passed
in by the applications
DEPENDENCIES
N/A
RETURN VALUE
0: success
SIDE EFFECTS
N/A
===========================================================================*/
static int loc_update_criteria(UlpLocationCriteria criteria)
{
ENTRY_LOG();
int ret_val = loc_eng_update_criteria(loc_afw_data, criteria);
EXIT_LOG(%d, ret_val);
return ret_val;
}
#endif
/*===========================================================================
FUNCTION loc_get_extension
DESCRIPTION
Get the gps extension to support XTRA.
DEPENDENCIES
N/A
RETURN VALUE
The GPS extension interface.
SIDE EFFECTS
N/A
===========================================================================*/
static const void* loc_get_extension(const char* name)
{
ENTRY_LOG();
const void* ret_val = NULL;
if (strcmp(name, GPS_XTRA_INTERFACE) == 0)
{
ret_val = &sLocEngXTRAInterface;
}
else if (strcmp(name, AGPS_INTERFACE) == 0)
{
ret_val = &sLocEngAGpsInterface;
}
else if (strcmp(name, GPS_NI_INTERFACE) == 0)
{
ret_val = &sLocEngNiInterface;
}
else if (strcmp(name, AGPS_RIL_INTERFACE) == 0)
{
ret_val = &sLocEngAGpsRilInterface;
}
#ifdef QCOM_FEATURE_ULP
else if (strcmp(name, ULP_RAW_CMD_INTERFACE) == 0)
{
ret_val = &sLocEngInjectRawCmdInterface;
}
#endif
else
{
LOC_LOGE ("get_extension: Invalid interface passed in\n");
}
EXIT_LOG(%p, ret_val);
return ret_val;
}
/*===========================================================================
FUNCTION loc_agps_init
DESCRIPTION
Initialize the AGps interface.
DEPENDENCIES
NONE
RETURN VALUE
0
SIDE EFFECTS
N/A
===========================================================================*/
static void loc_agps_init(AGpsCallbacks* callbacks)
{
ENTRY_LOG();
loc_eng_agps_init(loc_afw_data, callbacks);
EXIT_LOG(%s, VOID_RET);
}
/*===========================================================================
FUNCTION loc_agps_open
DESCRIPTION
This function is called when on-demand data connection opening is successful.
It should inform ARM 9 about the data open result.
DEPENDENCIES
NONE
RETURN VALUE
0
SIDE EFFECTS
N/A
===========================================================================*/
#ifdef QCOM_FEATURE_IPV6
static int loc_agps_open(AGpsType agpsType,
const char* apn, AGpsBearerType bearerType)
{
ENTRY_LOG();
int ret_val = loc_eng_agps_open(loc_afw_data, agpsType, apn, bearerType);
EXIT_LOG(%d, ret_val);
return ret_val;
}
#else
static int loc_agps_open(const char* apn)
{
ENTRY_LOG();
int ret_val = loc_eng_agps_open(loc_afw_data, apn);
EXIT_LOG(%d, ret_val);
return ret_val;
}
#endif
/*===========================================================================
FUNCTION loc_agps_closed
DESCRIPTION
This function is called when on-demand data connection closing is done.
It should inform ARM 9 about the data close result.
DEPENDENCIES
NONE
RETURN VALUE
0
SIDE EFFECTS
N/A
===========================================================================*/
#ifdef QCOM_FEATURE_IPV6
static int loc_agps_closed(AGpsType agpsType)
{
ENTRY_LOG();
int ret_val = loc_eng_agps_closed(loc_afw_data, agpsType);
EXIT_LOG(%d, ret_val);
return ret_val;
}
#else
static int loc_agps_closed()
{
ENTRY_LOG();
int ret_val = loc_eng_agps_closed(loc_afw_data);
EXIT_LOG(%d, ret_val);
return ret_val;
}
#endif
/*===========================================================================
FUNCTION loc_agps_open_failed
DESCRIPTION
This function is called when on-demand data connection opening has failed.
It should inform ARM 9 about the data open result.
DEPENDENCIES
NONE
RETURN VALUE
0
SIDE EFFECTS
N/A
===========================================================================*/
#ifdef QCOM_FEATURE_IPV6
int loc_agps_open_failed(AGpsType agpsType)
{
ENTRY_LOG();
int ret_val = loc_eng_agps_open_failed(loc_afw_data, agpsType);
EXIT_LOG(%d, ret_val);
return ret_val;
}
#else
int loc_agps_open_failed()
{
ENTRY_LOG();
int ret_val = loc_eng_agps_open_failed(loc_afw_data);
EXIT_LOG(%d, ret_val);
return ret_val;
}
#endif
/*===========================================================================
FUNCTION loc_agps_set_server
DESCRIPTION
If loc_eng_set_server is called before loc_eng_init, it doesn't work. This
proxy buffers server settings and calls loc_eng_set_server when the client is
open.
DEPENDENCIES
NONE
RETURN VALUE
0
SIDE EFFECTS
N/A
===========================================================================*/
static int loc_agps_set_server(AGpsType type, const char* hostname, int port)
{
ENTRY_LOG();
LocServerType serverType;
switch (type) {
case AGPS_TYPE_SUPL:
serverType = LOC_AGPS_SUPL_SERVER;
break;
case AGPS_TYPE_C2K:
serverType = LOC_AGPS_CDMA_PDE_SERVER;
break;
}
int ret_val = loc_eng_set_server_proxy(loc_afw_data, serverType, hostname, port);
EXIT_LOG(%d, ret_val);
return ret_val;
}
/*===========================================================================
FUNCTION loc_xtra_init
DESCRIPTION
Initialize XTRA module.
DEPENDENCIES
None
RETURN VALUE
0: success
SIDE EFFECTS
N/A
===========================================================================*/
static int loc_xtra_init(GpsXtraCallbacks* callbacks)
{
ENTRY_LOG();
int ret_val = loc_eng_xtra_init(loc_afw_data, callbacks);
EXIT_LOG(%d, ret_val);
return ret_val;
}
/*===========================================================================
FUNCTION loc_xtra_inject_data
DESCRIPTION
Initialize XTRA module.
DEPENDENCIES
None
RETURN VALUE
0: success
SIDE EFFECTS
N/A
===========================================================================*/
static int loc_xtra_inject_data(char* data, int length)
{
ENTRY_LOG();
int ret_val = loc_eng_xtra_inject_data(loc_afw_data, data, length);
EXIT_LOG(%d, ret_val);
return ret_val;
}
/*===========================================================================
FUNCTION loc_ni_init
DESCRIPTION
This function initializes the NI interface
DEPENDENCIES
NONE
RETURN VALUE
None
SIDE EFFECTS
N/A
===========================================================================*/
void loc_ni_init(GpsNiCallbacks *callbacks)
{
ENTRY_LOG();
loc_eng_ni_init(loc_afw_data, callbacks);
EXIT_LOG(%s, VOID_RET);
}
/*===========================================================================
FUNCTION loc_ni_respond
DESCRIPTION
This function sends an NI respond to the modem processor
DEPENDENCIES
NONE
RETURN VALUE
None
SIDE EFFECTS
N/A
===========================================================================*/
void loc_ni_respond(int notif_id, GpsUserResponseType user_response)
{
ENTRY_LOG();
loc_eng_ni_respond(loc_afw_data, notif_id, user_response);
EXIT_LOG(%s, VOID_RET);
}
// Below stub functions are members of sLocEngAGpsRilInterface
static void loc_agps_ril_init( AGpsRilCallbacks* callbacks ) {}
static void loc_agps_ril_set_ref_location(const AGpsRefLocation *agps_reflocation, size_t sz_struct) {}
static void loc_agps_ril_set_set_id(AGpsSetIDType type, const char* setid) {}
static void loc_agps_ril_ni_message(uint8_t *msg, size_t len) {}
static void loc_agps_ril_update_network_state(int connected, int type, int roaming, const char* extra_info) {}
/*===========================================================================
FUNCTION loc_agps_ril_update_network_availability
DESCRIPTION
Sets data call allow vs disallow flag to modem
This is the only member of sLocEngAGpsRilInterface implemented.
DEPENDENCIES
None
RETURN VALUE
0: success
SIDE EFFECTS
N/A
===========================================================================*/
static void loc_agps_ril_update_network_availability(int available, const char* apn)
{
ENTRY_LOG();
loc_eng_agps_ril_update_network_availability(loc_afw_data, available, apn);
EXIT_LOG(%s, VOID_RET);
}
#ifdef QCOM_FEATURE_ULP
/*===========================================================================
FUNCTION loc_inject_raw_command
DESCRIPTION
This is used to send special test modem commands from the applications
down into the HAL
DEPENDENCIES
N/A
RETURN VALUE
0: success
SIDE EFFECTS
N/A
===========================================================================*/
static bool loc_inject_raw_command(char* command, int length)
{
ENTRY_LOG();
int ret_val = loc_eng_inject_raw_command(loc_afw_data, command, length);
EXIT_LOG(%s, loc_logger_boolStr[ret_val!=0]);
return ret_val;
}
#endif
static void loc_cb(GpsLocation* location, void* locExt)
{
ENTRY_LOG();
if (NULL != gps_loc_cb && NULL != location) {
#ifdef QCOM_FEATURE_ULP
CALLBACK_LOG_CALLFLOW("location_cb - from", %d, location->position_source);
#else
CALLBACK_LOG_CALLFLOW("location_cb - at", %llu, location->timestamp);
#endif
gps_loc_cb(location);
}
EXIT_LOG(%s, VOID_RET);
}
static void sv_cb(GpsSvStatus* sv_status, void* svExt)
{
ENTRY_LOG();
if (NULL != gps_sv_cb) {
CALLBACK_LOG_CALLFLOW("sv_status_cb -", %d, sv_status->num_svs);
gps_sv_cb(sv_status);
}
EXIT_LOG(%s, VOID_RET);
}

86
loc_api/libloc_api_50001/loc.h Executable file
View file

@ -0,0 +1,86 @@
/* Copyright (c) 2011, Code Aurora Forum. 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 Code Aurora Forum, 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 "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_H__
#define __LOC_H__
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#include <ctype.h>
#include <cutils/properties.h>
#include <hardware/gps.h>
typedef enum loc_server_type {
LOC_AGPS_CDMA_PDE_SERVER,
LOC_AGPS_CUSTOM_PDE_SERVER,
LOC_AGPS_MPC_SERVER,
LOC_AGPS_SUPL_SERVER
} LocServerType;
typedef enum loc_position_mode_type {
LOC_POSITION_MODE_STANDALONE,
LOC_POSITION_MODE_MS_BASED,
LOC_POSITION_MODE_MS_ASSISTED,
LOC_POSITION_MODE_RESERVED_1,
LOC_POSITION_MODE_RESERVED_2,
LOC_POSITION_MODE_RESERVED_3,
LOC_POSITION_MODE_RESERVED_4
} LocPositionMode;
typedef void (*loc_location_cb_ext) (GpsLocation* location, void* locExt);
typedef void (*loc_sv_status_cb_ext) (GpsSvStatus* sv_status, void* svExt);
typedef void* (*loc_ext_parser)(void* data);
typedef struct {
loc_location_cb_ext location_cb;
gps_status_callback status_cb;
loc_sv_status_cb_ext sv_status_cb;
gps_nmea_callback nmea_cb;
gps_set_capabilities set_capabilities_cb;
gps_acquire_wakelock acquire_wakelock_cb;
gps_release_wakelock release_wakelock_cb;
gps_create_thread create_thread_cb;
loc_ext_parser location_ext_parser;
loc_ext_parser sv_ext_parser;
} LocCallbacks;
enum loc_sess_status {
LOC_SESS_SUCCESS,
LOC_SESS_INTERMEDIATE,
LOC_SESS_FAILURE
};
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif //__LOC_H__

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,204 @@
/* Copyright (c) 2009,2011 Code Aurora Forum. 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 Code Aurora Forum, 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 "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_H
#define LOC_ENG_H
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
// 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;
#ifndef TRUE
#define TRUE 1
#endif
#ifndef FALSE
#define FALSE 0
#endif
#include <loc.h>
#include <loc_eng_xtra.h>
#include <loc_eng_ni.h>
#include <loc_eng_agps.h>
#include <loc_cfg.h>
#include <loc_log.h>
#include <log_util.h>
#include <loc_eng_msg.h>
#include <loc_eng_agps.h>
#include <LocApiAdapter.h>
// The data connection minimal open time
#define DATA_OPEN_MIN_TIME 1 /* sec */
// The system sees GPS engine turns off after inactive for this period of time
#define GPS_AUTO_OFF_TIME 2 /* secs */
#define SUCCESS TRUE
#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_mute_session_e_type {
LOC_MUTE_SESS_NONE = 0,
LOC_MUTE_SESS_WAIT,
LOC_MUTE_SESS_IN_SESSION
};
// Module data
typedef struct
{
LocApiAdapter *client_handle;
loc_location_cb_ext location_cb;
gps_status_callback status_cb;
loc_sv_status_cb_ext sv_status_cb;
agps_status_callback agps_status_cb;
gps_nmea_callback nmea_cb;
gps_ni_notify_callback ni_notify_cb;
gps_acquire_wakelock acquire_wakelock_cb;
gps_release_wakelock release_wakelock_cb;
boolean intermediateFix;
AGpsStatusValue agps_status;
// used to defer stopping the GPS engine until AGPS data calls are done
boolean agps_request_pending;
boolean stop_request_pending;
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;
// GPS engine status
GpsStatusValue engine_status;
GpsStatusValue fix_session_status;
// Aiding data information to be deleted, aiding data can only be deleted when GPS engine is off
GpsAidingData aiding_data_for_deletion;
void* context;
loc_eng_msg_position_mode position_mode;
// For muting session broadcast
loc_mute_session_e_type mute_session_state;
// Address buffers, for addressing setting before init
int supl_host_set;
char supl_host_buf[101];
int supl_port_buf;
int c2k_host_set;
char c2k_host_buf[101];
int c2k_port_buf;
int mpc_host_set;
char mpc_host_buf[101];
int mpc_port_buf;
} loc_eng_data_s_type;
int loc_eng_init(loc_eng_data_s_type &loc_eng_data,
LocCallbacks* callbacks,
LOC_API_ADAPTER_EVENT_MASK_T event);
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);
int loc_eng_inject_time(loc_eng_data_s_type &loc_eng_data,
GpsUtcTime time, int64_t timeReference,
int uncertainty);
int loc_eng_inject_location(loc_eng_data_s_type &loc_eng_data,
double latitude, double longitude,
float accuracy);
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);
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
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);
int loc_eng_agps_open_failed(loc_eng_data_s_type &loc_eng_data, AGpsType agpsType);
#else
int loc_eng_agps_open(loc_eng_data_s_type &loc_eng_data, const char* apn);
int loc_eng_agps_closed(loc_eng_data_s_type &loc_eng_data);
int loc_eng_agps_open_failed(loc_eng_data_s_type &loc_eng_data);
#endif
int loc_eng_set_server_proxy(loc_eng_data_s_type &loc_eng_data,
LocServerType type, const char *hostname, int port);
void loc_eng_agps_ril_update_network_availability(loc_eng_data_s_type &loc_eng_data,
int avaiable, const char* apn);
bool loc_eng_inject_raw_command(loc_eng_data_s_type &loc_eng_data,
char* command, int length);
void loc_eng_mute_one_session(loc_eng_data_s_type &loc_eng_data);
int loc_eng_xtra_init (loc_eng_data_s_type &loc_eng_data,
GpsXtraCallbacks* callbacks);
int loc_eng_xtra_inject_data(loc_eng_data_s_type &loc_eng_data,
char* data, int length);
extern void loc_eng_ni_init(loc_eng_data_s_type &loc_eng_data,
GpsNiCallbacks *callbacks);
extern void loc_eng_ni_respond(loc_eng_data_s_type &loc_eng_data,
int notif_id, GpsUserResponseType user_response);
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);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif // LOC_ENG_H

View file

@ -0,0 +1,702 @@
/* Copyright (c) 2011, Code Aurora Forum. 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 Code Aurora Forum, 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 "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"
#include <loc_eng_agps.h>
#include <loc_eng_log.h>
#include <log_util.h>
#include <loc_eng_dmn_conn_handler.h>
#include <loc_eng_dmn_conn.h>
//======================================================================
// C callbacks
//======================================================================
// This is given to linked_list_add as the dealloc callback
// data -- an instance of Subscriber
static void deleteObj(void* data)
{
delete (Subscriber*)data;
}
// This is given to linked_list_search() as the comparison callback
// when the state manchine needs to process for particular subscriber
// fromCaller -- caller provides this obj
// fromList -- linked_list_search() function take this one from list
static bool hasSubscriber(void* fromCaller, void* fromList)
{
Notification* notification = (Notification*)fromCaller;
Subscriber* s1 = (Subscriber*)fromList;
return s1->forMe(*notification);
}
// This is gvien to linked_list_search() to notify subscriber objs
// when the state machine needs to inform all subscribers of resource
// status changes, e.g. when resource is GRANTED.
// fromCaller -- caller provides this ptr to a Notification obj.
// fromList -- linked_list_search() function take this one from list
static bool notifySubscriber(void* fromCaller, void* fromList)
{
Notification* notification = (Notification*)fromCaller;
Subscriber* s1 = (Subscriber*)fromList;
// we notify every subscriber indiscriminatively
// each subscriber decides if this notification is interesting.
return s1->notifyRsrcStatus(*notification) &&
// if we do not want to delete the subscriber from the
// the list, we must set this to false so this function
// returns false
notification->postNotifyDelete;
}
//======================================================================
// Notification
//======================================================================
const int Notification::BROADCAST_ALL = 0x80000000;
const int Notification::BROADCAST_ACTIVE = 0x80000001;
const int Notification::BROADCAST_INACTIVE = 0x80000002;
//======================================================================
// Subscriber: BITSubscriber / ATLSubscriber
//======================================================================
bool Subscriber::forMe(Notification &notification)
{
if (NULL != notification.rcver) {
return equals(notification.rcver);
} else {
return Notification::BROADCAST_ALL == notification.groupID ||
(Notification::BROADCAST_ACTIVE == notification.groupID &&
!isInactive()) ||
(Notification::BROADCAST_INACTIVE == notification.groupID &&
isInactive());
}
}
bool BITSubscriber::equals(const Subscriber *s) const
{
BITSubscriber* bitS = (BITSubscriber*)s;
return (ID == bitS->ID &&
(INADDR_NONE != (unsigned int)ID ||
0 == strncmp(ipv6Addr, bitS->ipv6Addr, sizeof(ipv6Addr))));
}
bool BITSubscriber::notifyRsrcStatus(Notification &notification)
{
bool notify = forMe(notification);
if (notify) {
switch(notification.rsrcStatus)
{
case RSRC_UNSUBSCRIBE:
case RSRC_RELEASED:
loc_eng_dmn_conn_loc_api_server_data_conn(
GPSONE_LOC_API_IF_RELEASE_SUCCESS);
break;
case RSRC_DENIED:
loc_eng_dmn_conn_loc_api_server_data_conn(
GPSONE_LOC_API_IF_FAILURE);
break;
case RSRC_GRANTED:
loc_eng_dmn_conn_loc_api_server_data_conn(
GPSONE_LOC_API_IF_REQUEST_SUCCESS);
break;
default:
notify = false;
}
}
return notify;
}
bool ATLSubscriber::notifyRsrcStatus(Notification &notification)
{
bool notify = forMe(notification);
if (notify) {
switch(notification.rsrcStatus)
{
case RSRC_UNSUBSCRIBE:
case RSRC_RELEASED:
((LocApiAdapter*)mLocAdapter)->atlCloseStatus(ID, 1);
break;
case RSRC_DENIED:
((LocApiAdapter*)mLocAdapter)->atlOpenStatus(ID, 0,
(char*)mStateMachine->getAPN(),
#ifdef QCOM_FEATURE_IPV6
mStateMachine->getBearer(),
#endif
mStateMachine->getType());
break;
case RSRC_GRANTED:
((LocApiAdapter*)mLocAdapter)->atlOpenStatus(ID, 1,
(char*)mStateMachine->getAPN(),
#ifdef QCOM_FEATURE_IPV6
mStateMachine->getBearer(),
#endif
mStateMachine->getType());
break;
default:
notify = false;
}
}
return notify;
}
//======================================================================
// AgpsState: AgpsReleasedState / AgpsPendingState / AgpsAcquiredState
//======================================================================
// AgpsReleasedState
class AgpsReleasedState : public AgpsState
{
friend class AgpsStateMachine;
inline AgpsReleasedState(AgpsStateMachine* stateMachine) :
AgpsState(stateMachine)
{ mReleasedState = this; }
inline ~AgpsReleasedState() {}
public:
virtual AgpsState* onRsrcEvent(AgpsRsrcStatus event, void* data);
inline virtual char* whoami() {return (char*)"AgpsReleasedState";}
};
AgpsState* AgpsReleasedState::onRsrcEvent(AgpsRsrcStatus event, void* data)
{
if (mStateMachine->hasSubscribers()) {
LOC_LOGE("Error: %s subscriber list not empty!!!", whoami());
// I don't know how to recover from it. I am adding this rather
// for debugging purpose.
}
AgpsState* nextState = this;;
switch (event)
{
case RSRC_SUBSCRIBE:
{
// no notification until we get RSRC_GRANTED
// but we need to add subscriber to the list
mStateMachine->addSubscriber((Subscriber*)data);
// move the state to PENDING
nextState = mPendingState;
// request from connecivity service for NIF
mStateMachine->sendRsrcRequest(GPS_REQUEST_AGPS_DATA_CONN);
}
break;
case RSRC_UNSUBSCRIBE:
{
// the list should really be empty, nothing to remove.
// but we might as well just tell the client it is
// unsubscribed. False tolerance, right?
Subscriber* subscriber = (Subscriber*) data;
Notification notification(subscriber, event, false);
subscriber->notifyRsrcStatus(notification);
}
// break;
case RSRC_GRANTED:
case RSRC_RELEASED:
case RSRC_DENIED:
default:
LOC_LOGW("%s: unrecognized event %d", whoami(), event);
// no state change.
break;
}
LOC_LOGD("onRsrcEvent, old state %s, new state %s, event %d",
whoami(), nextState->whoami(), event);
return nextState;
}
// AgpsPendingState
class AgpsPendingState : public AgpsState
{
friend class AgpsStateMachine;
inline AgpsPendingState(AgpsStateMachine* stateMachine) :
AgpsState(stateMachine)
{ mPendingState = this; }
inline ~AgpsPendingState() {}
public:
virtual AgpsState* onRsrcEvent(AgpsRsrcStatus event, void* data);
inline virtual char* whoami() {return (char*)"AgpsPendingState";}
};
AgpsState* AgpsPendingState::onRsrcEvent(AgpsRsrcStatus event, void* data)
{
AgpsState* nextState = this;;
switch (event)
{
case RSRC_SUBSCRIBE:
{
// already requested for NIF resource,
// do nothing until we get RSRC_GRANTED indication
// but we need to add subscriber to the list
mStateMachine->addSubscriber((Subscriber*)data);
// no state change.
}
break;
case RSRC_UNSUBSCRIBE:
{
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;
// tell connecivity service we can release NIF
mStateMachine->sendRsrcRequest(GPS_RELEASE_AGPS_DATA_CONN);
}
}
}
break;
case RSRC_GRANTED:
{
nextState = mAcquiredState;
Notification notification(Notification::BROADCAST_ACTIVE, event, false);
// notify all subscribers NIF resource GRANTED
// by setting false, we keep subscribers on the linked list
mStateMachine->notifySubscribers(notification);
}
break;
case RSRC_RELEASED:
// no state change.
// we are expecting either GRANTED or DENIED. Handling RELEASED
// may like break our state machine in race conditions.
break;
case RSRC_DENIED:
{
nextState = mReleasedState;
Notification notification(Notification::BROADCAST_ALL, event, true);
// notify all subscribers NIF resource RELEASED or DENIED
// by setting true, we remove subscribers from the linked list
mStateMachine->notifySubscribers(notification);
}
break;
default:
LOC_LOGE("%s: unrecognized event %d", whoami(), event);
// no state change.
}
LOC_LOGD("onRsrcEvent, old state %s, new state %s, event %d",
whoami(), nextState->whoami(), event);
return nextState;
}
class AgpsAcquiredState : public AgpsState
{
friend class AgpsStateMachine;
inline AgpsAcquiredState(AgpsStateMachine* stateMachine) :
AgpsState(stateMachine)
{ mAcquiredState = this; }
inline ~AgpsAcquiredState() {}
public:
virtual AgpsState* onRsrcEvent(AgpsRsrcStatus event, void* data);
inline virtual char* whoami() { return (char*)"AgpsAcquiredState"; }
};
AgpsState* AgpsAcquiredState::onRsrcEvent(AgpsRsrcStatus event, void* data)
{
AgpsState* nextState = this;
switch (event)
{
case RSRC_SUBSCRIBE:
{
// we already have the NIF resource, simply notify subscriber
Subscriber* subscriber = (Subscriber*) data;
// we have rsrc in hand, so grant it right away
Notification notification(subscriber, RSRC_GRANTED, false);
subscriber->notifyRsrcStatus(notification);
// add subscriber to the list
mStateMachine->addSubscriber(subscriber);
// no state change.
}
break;
case RSRC_UNSUBSCRIBE:
{
Subscriber* subscriber = (Subscriber*) data;
if (subscriber->waitForCloseComplete()) {
subscriber->setInactive();
} 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 = 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_GRANTED:
LOC_LOGW("%s: %d, RSRC_GRANTED already received", whoami(), event);
// no state change.
break;
case RSRC_RELEASED:
{
LOC_LOGW("%s: %d, a force rsrc release", whoami(), event);
nextState = mReleasedState;
Notification notification(Notification::BROADCAST_ALL, event, true);
// by setting true, we remove subscribers from the linked list
mStateMachine->notifySubscribers(notification);
}
break;
case RSRC_DENIED:
// no state change.
// we are expecting RELEASED. Handling DENIED
// may like break our state machine in race conditions.
break;
default:
LOC_LOGE("%s: unrecognized event %d", whoami(), event);
// no state change.
}
LOC_LOGD("onRsrcEvent, old state %s, new state %s, event %d",
whoami(), nextState->whoami(), event);
return nextState;
}
// AgpsPendingState
class AgpsReleasingState : public AgpsState
{
friend class AgpsStateMachine;
inline AgpsReleasingState(AgpsStateMachine* stateMachine) :
AgpsState(stateMachine)
{ mReleasingState = this; }
inline ~AgpsReleasingState() {}
public:
virtual AgpsState* onRsrcEvent(AgpsRsrcStatus event, void* data);
inline virtual char* whoami() {return (char*)"AgpsReleasingState";}
};
AgpsState* AgpsReleasingState::onRsrcEvent(AgpsRsrcStatus event, void* data)
{
AgpsState* nextState = this;;
switch (event)
{
case RSRC_SUBSCRIBE:
{
// already requested for NIF resource,
// do nothing until we get RSRC_GRANTED indication
// but we need to add subscriber to the list
mStateMachine->addSubscriber((Subscriber*)data);
// no state change.
}
break;
case RSRC_UNSUBSCRIBE:
{
Subscriber* subscriber = (Subscriber*) data;
if (subscriber->waitForCloseComplete()) {
subscriber->setInactive();
} 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 = 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_RELEASED:
{
nextState = mAcquiredState;
Notification notification(Notification::BROADCAST_INACTIVE, event, true);
// notify all subscribers that are active NIF resource RELEASE
// by setting false, we keep subscribers on the linked list
mStateMachine->notifySubscribers(notification);
if (mStateMachine->hasSubscribers()) {
nextState = mPendingState;
// request from connecivity service for NIF
mStateMachine->sendRsrcRequest(GPS_REQUEST_AGPS_DATA_CONN);
} else {
nextState = mReleasedState;
}
}
break;
case RSRC_GRANTED:
case RSRC_DENIED:
default:
LOC_LOGE("%s: unrecognized event %d", whoami(), event);
// no state change.
}
LOC_LOGD("onRsrcEvent, old state %s, new state %s, event %d",
whoami(), nextState->whoami(), event);
return nextState;
}
//======================================================================
// AgpsStateMachine
//======================================================================
AgpsStateMachine::AgpsStateMachine(void (*servicer)(AGpsStatus* status),
AGpsType type) :
mServicer(servicer), mType(type),
mStatePtr(new AgpsReleasedState(this)),
mAPN(NULL),
mAPNLen(0)
{
linked_list_init(&mSubscribers);
// setting up mReleasedState
mStatePtr->mPendingState = new AgpsPendingState(this);
mStatePtr->mAcquiredState = new AgpsAcquiredState(this);
mStatePtr->mReleasingState = new AgpsReleasingState(this);
// setting up mAcquiredState
mStatePtr->mAcquiredState->mReleasedState = mStatePtr;
mStatePtr->mAcquiredState->mPendingState = mStatePtr->mPendingState;
mStatePtr->mAcquiredState->mReleasingState = mStatePtr->mReleasingState;
// setting up mPendingState
mStatePtr->mPendingState->mAcquiredState = mStatePtr->mAcquiredState;
mStatePtr->mPendingState->mReleasedState = mStatePtr;
mStatePtr->mPendingState->mReleasingState = mStatePtr->mReleasingState;
// setting up mReleasingState
mStatePtr->mReleasingState->mReleasedState = mStatePtr;
mStatePtr->mReleasingState->mPendingState = mStatePtr->mPendingState;
mStatePtr->mReleasingState->mAcquiredState = mStatePtr->mAcquiredState;
}
AgpsStateMachine::~AgpsStateMachine()
{
dropAllSubscribers();
// free the 3 states. We must read out all 3 pointers first.
// Otherwise we run the risk of getting pointers from already
// freed memory.
AgpsState* acquiredState = mStatePtr->mAcquiredState;
AgpsState* releasedState = mStatePtr->mReleasedState;
AgpsState* pendindState = mStatePtr->mPendingState;
AgpsState* releasingState = mStatePtr->mReleasingState;
delete acquiredState;
delete releasedState;
delete pendindState;
delete releasingState;
linked_list_destroy(&mSubscribers);
if (NULL != mAPN) {
delete[] mAPN;
mAPN = NULL;
}
}
void AgpsStateMachine::setAPN(const char* apn, unsigned int len)
{
if (NULL != mAPN) {
delete mAPN;
}
if (NULL != apn) {
mAPN = new char[len+1];
memcpy(mAPN, apn, len);
mAPN[len] = NULL;
mAPNLen = len;
} else {
mAPN = NULL;
mAPNLen = 0;
}
}
void AgpsStateMachine::onRsrcEvent(AgpsRsrcStatus event)
{
switch (event)
{
case RSRC_GRANTED:
case RSRC_RELEASED:
case RSRC_DENIED:
mStatePtr = mStatePtr->onRsrcEvent(event, NULL);
break;
default:
LOC_LOGW("AgpsStateMachine: unrecognized event %d", event);
break;
}
}
void AgpsStateMachine::notifySubscribers(Notification& notification) const
{
if (notification.postNotifyDelete) {
// just any non NULL value to get started
Subscriber* s = (Subscriber*)~0;
while (NULL != s) {
s = NULL;
// if the last param sets to true, _search will delete
// the node from the list for us. But the problem is
// once that is done, _search returns, leaving the
// rest of the list unprocessed. So we need a loop.
linked_list_search(mSubscribers, (void**)&s, notifySubscriber,
(void*)&notification, true);
}
} else {
// no loop needed if it the last param sets to false, which
// mean nothing gets deleted from the list.
linked_list_search(mSubscribers, NULL, notifySubscriber,
(void*)&notification, false);
}
}
void AgpsStateMachine::addSubscriber(Subscriber* subscriber) const
{
Subscriber* s = NULL;
Notification notification((const Subscriber*)subscriber);
linked_list_search(mSubscribers, (void**)&s,
hasSubscriber, (void*)&notification, false);
if (NULL == s) {
linked_list_add(mSubscribers, subscriber->clone(), deleteObj);
}
}
void AgpsStateMachine::sendRsrcRequest(AGpsStatusValue action) const
{
Subscriber* s = NULL;
Notification notification(Notification::BROADCAST_ALL);
linked_list_search(mSubscribers, (void**)&s, hasSubscriber,
(void*)&notification, false);
if ((NULL == s) == (GPS_RELEASE_AGPS_DATA_CONN == action)) {
AGpsStatus nifRequest;
nifRequest.size = sizeof(nifRequest);
nifRequest.type = mType;
nifRequest.status = action;
#ifdef QCOM_FEATURE_IPV6
if (s == NULL) {
nifRequest.ipv4_addr = INADDR_NONE;
nifRequest.ipv6_addr[0] = 0;
} else {
s->setIPAddresses(nifRequest.ipv4_addr, (char*)nifRequest.ipv6_addr);
}
#else
if (s == NULL) {
nifRequest.ipaddr = INADDR_NONE;
} else {
nifRequest.ipaddr = s->ID;
}
#endif
CALLBACK_LOG_CALLFLOW("agps_cb", %s, loc_get_agps_status_name(action));
(*mServicer)(&nifRequest);
}
}
void AgpsStateMachine::subscribeRsrc(Subscriber *subscriber)
{
mStatePtr = mStatePtr->onRsrcEvent(RSRC_SUBSCRIBE, (void*)subscriber);
}
bool AgpsStateMachine::unsubscribeRsrc(Subscriber *subscriber)
{
Subscriber* s = NULL;
Notification notification((const Subscriber*)subscriber);
linked_list_search(mSubscribers, (void**)&s,
hasSubscriber, (void*)&notification, false);
if (NULL != s) {
mStatePtr = mStatePtr->onRsrcEvent(RSRC_UNSUBSCRIBE, (void*)s);
return true;
}
return false;
}
bool AgpsStateMachine::hasActiveSubscribers() const
{
Subscriber* s = NULL;
Notification notification(Notification::BROADCAST_ACTIVE);
linked_list_search(mSubscribers, (void**)&s,
hasSubscriber, (void*)&notification, false);
return NULL != s;
}

View file

@ -0,0 +1,274 @@
/* Copyright (c) 2011, Code Aurora Forum. 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 Code Aurora Forum, 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 "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_AGPS_H__
#define __LOC_ENG_AGPS_H__
#include <stdbool.h>
#include <ctype.h>
#include <string.h>
#include <arpa/inet.h>
#include <hardware/gps.h>
#include <linked_list.h>
#include <LocApiAdapter.h>
// forward declaration
class AgpsStateMachine;
class Subscriber;
// NIF resource events
typedef enum {
RSRC_SUBSCRIBE,
RSRC_UNSUBSCRIBE,
RSRC_GRANTED,
RSRC_RELEASED,
RSRC_DENIED,
RSRC_STATUS_MAX
} AgpsRsrcStatus;
// information bundle for subscribers
struct Notification {
// goes to every subscriber
static const int BROADCAST_ALL;
// goes to every ACTIVE subscriber
static const int BROADCAST_ACTIVE;
// goes to every INACTIVE subscriber
static const int BROADCAST_INACTIVE;
// go to a specific subscriber
const Subscriber* rcver;
// broadcast
const int groupID;
// the new resource status event
const AgpsRsrcStatus rsrcStatus;
// should the subscriber be deleted after the notification
const bool postNotifyDelete;
// convenient constructor
inline Notification(const int broadcast,
const AgpsRsrcStatus status,
const bool deleteAfterwards) :
rcver(NULL), groupID(broadcast), rsrcStatus(status),
postNotifyDelete(deleteAfterwards) {}
// convenient constructor
inline Notification(const Subscriber* subscriber,
const AgpsRsrcStatus status,
const bool deleteAfterwards) :
rcver(subscriber), groupID(-1), rsrcStatus(status),
postNotifyDelete(deleteAfterwards) {}
// convenient constructor
inline Notification(const int broadcast) :
rcver(NULL), groupID(broadcast), rsrcStatus(RSRC_STATUS_MAX),
postNotifyDelete(false) {}
// convenient constructor
inline Notification(const Subscriber* subscriber) :
rcver(subscriber), groupID(-1), rsrcStatus(RSRC_STATUS_MAX),
postNotifyDelete(false) {}
};
class AgpsState {
// allows AgpsStateMachine to access private data
// no class members are public. We don't want
// anyone but state machine to use state.
friend class AgpsStateMachine;
// state transitions are done here.
// Each state implements its own transitions (of course).
inline virtual AgpsState* onRsrcEvent(AgpsRsrcStatus event, void* data) = 0;
protected:
// handle back to state machine
const AgpsStateMachine* mStateMachine;
// each state has pointers to all 3 states
// one of which is to itself.
AgpsState* mReleasedState;
AgpsState* mAcquiredState;
AgpsState* mPendingState;
AgpsState* mReleasingState;
inline AgpsState(const AgpsStateMachine *stateMachine) :
mStateMachine(stateMachine),
mReleasedState(NULL),
mAcquiredState(NULL),
mPendingState(NULL),
mReleasingState(NULL) {}
virtual ~AgpsState() {}
public:
// for logging purpose
inline virtual char* whoami() = 0;
};
class AgpsStateMachine {
// allows AgpsState to access private data
// each state is really internal data to the
// state machine, so it should be able to
// access anything within the state machine.
friend class AgpsState;
// handle to whoever provides the service
void (* const mServicer)(AGpsStatus* status);
// NIF type: AGNSS or INTERNET.
const AGpsType mType;
// pointer to the current state.
AgpsState* mStatePtr;
// a linked list of subscribers.
void* mSubscribers;
// apn to the NIF. Each state machine tracks
// resource state of a particular NIF. For each
// NIF, there is also an active APN.
char* mAPN;
// for convenience, we don't do strlen each time.
unsigned int mAPNLen;
#ifdef QCOM_FEATURE_IPV6
// bear
AGpsBearerType mBearer;
#endif
// ipv4 address for routing
public:
AgpsStateMachine(void (*servicer)(AGpsStatus* status), AGpsType type);
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
inline void setBearer(AGpsBearerType bearer) { mBearer = bearer; }
inline AGpsBearerType getBearer() const { return mBearer; }
#endif
inline AGpsType getType() const { return (AGpsType)mType; }
// someone, a ATL client or BIT, is asking for NIF
void subscribeRsrc(Subscriber *subscriber);
// someone, a ATL client or BIT, is done with NIF
bool unsubscribeRsrc(Subscriber *subscriber);
// add a subscriber in the linked list, if not already there.
void addSubscriber(Subscriber* subscriber) const;
void onRsrcEvent(AgpsRsrcStatus event);
// put the data together and send the FW
void sendRsrcRequest(AGpsStatusValue action) const;
inline bool hasSubscribers() const
{ return !linked_list_empty(mSubscribers); }
bool hasActiveSubscribers() const;
inline void dropAllSubscribers() const
{ linked_list_flush(mSubscribers); }
// private. Only a state gets to call this.
void notifySubscribers(Notification& notification) const;
};
// each subscriber is a AGPS client. In the case of ATL, there could be
// multiple clients from modem. In the case of BIT, there is only one
// cilent from BIT daemon.
struct Subscriber {
const int 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;
inline virtual bool equals(const Subscriber *s) const
{ return ID == s->ID; }
// notifies a subscriber a new NIF resource status, usually
// either GRANTE, DENIED, or RELEASED
virtual bool notifyRsrcStatus(Notification &notification) = 0;
virtual bool waitForCloseComplete() { return false; }
virtual void setInactive() {}
virtual bool isInactive() { return false; }
virtual Subscriber* clone() = 0;
// checks if this notification is for me, i.e.
// either has my id, or has a broadcast id.
bool forMe(Notification &notification);
};
// BITSubscriber, created with requests from BIT daemon
struct BITSubscriber : public Subscriber {
inline BITSubscriber(const AgpsStateMachine* stateMachine,
unsigned int ipv4, char* ipv6) :
Subscriber(ipv4, stateMachine)
{
if (NULL == ipv6) {
ipv6Addr[0] = NULL;
} else {
memcpy(ipv6Addr, ipv6, sizeof(ipv6Addr));
}
}
virtual bool notifyRsrcStatus(Notification &notification);
inline virtual void setIPAddresses(int &v4, char* v6)
{ v4 = ID; memcpy(v6, ipv6Addr, sizeof(ipv6Addr)); }
virtual Subscriber* clone()
{
return new BITSubscriber(mStateMachine, ID, ipv6Addr);
}
virtual bool equals(const Subscriber *s) const;
private:
char ipv6Addr[16];
};
// ATLSubscriber, created with requests from ATL
struct ATLSubscriber : public Subscriber {
const LocApiAdapter* mLocAdapter;
inline ATLSubscriber(const int id,
const AgpsStateMachine* stateMachine,
const LocApiAdapter* adapter) :
Subscriber(id, stateMachine), mLocAdapter(adapter) {}
virtual bool notifyRsrcStatus(Notification &notification);
inline virtual void setIPAddresses(int &v4, char* v6)
{ v4 = INADDR_NONE; v6[0] = 0; }
inline virtual Subscriber* clone()
{
return new ATLSubscriber(ID, mStateMachine, mLocAdapter);
}
};
#endif //__LOC_ENG_AGPS_H__

View file

@ -0,0 +1,180 @@
/* Copyright (c) 2011, Code Aurora Forum. 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 Code Aurora Forum, 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 "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <linux/stat.h>
#include <fcntl.h>
#include <linux/types.h>
#include <unistd.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"
static int loc_api_server_msgqid;
static int loc_api_resp_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 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);
loc_api_resp_msgqid = loc_eng_dmn_conn_glue_msgget(global_loc_api_resp_q_path, O_RDWR);
LOC_LOGD("%s:%d] loc_api_server_msgqid = %d\n", __func__, __LINE__, loc_api_server_msgqid);
return 0;
}
static int loc_api_server_proc_pre(void *context)
{
return 0;
}
static int loc_api_server_proc(void *context)
{
int length, sz;
int result = 0;
static int cnt = 0;
struct ctrl_msgbuf * p_cmsgbuf;
struct ctrl_msgbuf cmsg_resp;
sz = sizeof(struct ctrl_msgbuf) + 256;
p_cmsgbuf = (struct ctrl_msgbuf *) malloc(sz);
if (!p_cmsgbuf) {
LOC_LOGE("%s:%d] Out of memory\n", __func__, __LINE__);
return -1;
}
cnt ++;
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) {
LOC_LOGE("%s:%d] fail receiving msg from gpsone_daemon, retry later\n", __func__, __LINE__);
usleep(1000);
return 0;
}
LOC_LOGD("%s:%d] received ctrl_type = %d\n", __func__, __LINE__, p_cmsgbuf->ctrl_type);
switch(p_cmsgbuf->ctrl_type) {
case GPSONE_LOC_API_IF_REQUEST:
result = loc_eng_dmn_conn_loc_api_server_if_request_handler(p_cmsgbuf, length);
break;
case GPSONE_LOC_API_IF_RELEASE:
result = loc_eng_dmn_conn_loc_api_server_if_release_handler(p_cmsgbuf, length);
break;
case GPSONE_UNBLOCK:
LOC_LOGD("%s:%d] GPSONE_UNBLOCK\n", __func__, __LINE__);
break;
default:
LOC_LOGE("%s:%d] unsupported ctrl_type = %d\n",
__func__, __LINE__, p_cmsgbuf->ctrl_type);
break;
}
free(p_cmsgbuf);
return 0;
}
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);
return 0;
}
static int loc_eng_dmn_conn_unblock_proc(void)
{
struct ctrl_msgbuf cmsgbuf;
cmsgbuf.ctrl_type = GPSONE_UNBLOCK;
LOC_LOGD("%s:%d]\n", __func__, __LINE__);
loc_eng_dmn_conn_glue_msgsnd(loc_api_server_msgqid, & cmsgbuf, sizeof(cmsgbuf));
return 0;
}
static struct loc_eng_dmn_conn_thelper thelper;
int loc_eng_dmn_conn_loc_api_server_launch(thelper_create_thread create_thread_cb,
const char * loc_api_q_path, const char * resp_q_path, void *agps_handle)
{
int result;
loc_api_handle = agps_handle;
if (loc_api_q_path) global_loc_api_q_path = loc_api_q_path;
if (resp_q_path) global_loc_api_resp_q_path = resp_q_path;
result = loc_eng_dmn_conn_launch_thelper( &thelper,
loc_api_server_proc_init,
loc_api_server_proc_pre,
loc_api_server_proc,
loc_api_server_proc_post,
create_thread_cb,
(char *) global_loc_api_q_path);
if (result != 0) {
LOC_LOGE("%s:%d]\n", __func__, __LINE__);
return -1;
}
return 0;
}
int loc_eng_dmn_conn_loc_api_server_unblock(void)
{
loc_eng_dmn_conn_unblock_thelper(&thelper);
loc_eng_dmn_conn_unblock_proc();
return 0;
}
int loc_eng_dmn_conn_loc_api_server_join(void)
{
loc_eng_dmn_conn_join_thelper(&thelper);
return 0;
}
int loc_eng_dmn_conn_loc_api_server_data_conn(int status) {
struct ctrl_msgbuf cmsgbuf;
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;
}
return 0;
}

View file

@ -0,0 +1,53 @@
/* Copyright (c) 2011, Code Aurora Forum. 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 Code Aurora Forum, 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 "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_DATA_SERVER_H
#define LOC_ENG_DATA_SERVER_H
#include "loc_eng_dmn_conn_thread_helper.h"
#ifdef _ANDROID_
#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"
#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"
#endif
int loc_eng_dmn_conn_loc_api_server_launch(thelper_create_thread create_thread_cb,
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);
#endif /* LOC_ENG_DATA_SERVER_H */

View file

@ -0,0 +1,223 @@
/* Copyright (c) 2011, Code Aurora Forum. 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 Code Aurora Forum, 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 "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 <linux/stat.h>
#include <fcntl.h>
#include <linux/types.h>
#include "log_util.h"
#include "loc_eng_dmn_conn_glue_msg.h"
#include "loc_eng_dmn_conn_handler.h"
/*===========================================================================
FUNCTION loc_eng_dmn_conn_glue_msgget
DESCRIPTION
This function get a message queue
q_path - name path of the message queue
mode -
DEPENDENCIES
None
RETURN VALUE
message queue id
SIDE EFFECTS
N/A
===========================================================================*/
int loc_eng_dmn_conn_glue_msgget(const char * q_path, int mode)
{
int msgqid;
msgqid = loc_eng_dmn_conn_glue_pipeget(q_path, mode);
return msgqid;
}
/*===========================================================================
FUNCTION loc_eng_dmn_conn_glue_msgremove
DESCRIPTION
remove a message queue
q_path - name path of the message queue
msgqid - message queue id
DEPENDENCIES
None
RETURN VALUE
0: success or negative value for failure
SIDE EFFECTS
N/A
===========================================================================*/
int loc_eng_dmn_conn_glue_msgremove(const char * q_path, int msgqid)
{
int result;
result = loc_eng_dmn_conn_glue_piperemove(q_path, msgqid);
return result;
}
/*===========================================================================
FUNCTION loc_eng_dmn_conn_glue_msgsnd
DESCRIPTION
Send a message
msgqid - message queue id
msgp - pointer to the message to be sent
msgsz - size of the message
DEPENDENCIES
None
RETURN VALUE
number of bytes sent out or negative value for failure
SIDE EFFECTS
N/A
===========================================================================*/
int loc_eng_dmn_conn_glue_msgsnd(int msgqid, const void * msgp, size_t msgsz)
{
int result;
struct ctrl_msgbuf *pmsg = (struct ctrl_msgbuf *) msgp;
pmsg->msgsz = msgsz;
result = loc_eng_dmn_conn_glue_pipewrite(msgqid, msgp, msgsz);
if (result != (int) msgsz) {
LOC_LOGE("%s:%d] pipe broken %d, msgsz = %d\n", __func__, __LINE__, result, (int) msgsz);
return -1;
}
return result;
}
/*===========================================================================
FUNCTION loc_eng_dmn_conn_glue_msgrcv
DESCRIPTION
receive a message
msgqid - message queue id
msgp - pointer to the buffer to hold the message
msgsz - size of the buffer
DEPENDENCIES
None
RETURN VALUE
number of bytes received or negative value for failure
SIDE EFFECTS
N/A
===========================================================================*/
int loc_eng_dmn_conn_glue_msgrcv(int msgqid, void *msgp, size_t msgbufsz)
{
int result;
struct ctrl_msgbuf *pmsg = (struct ctrl_msgbuf *) msgp;
result = loc_eng_dmn_conn_glue_piperead(msgqid, &(pmsg->msgsz), sizeof(pmsg->msgsz));
if (result != sizeof(pmsg->msgsz)) {
LOC_LOGE("%s:%d] pipe broken %d\n", __func__, __LINE__, result);
return -1;
}
if (msgbufsz < pmsg->msgsz) {
LOC_LOGE("%s:%d] msgbuf is too small %d < %d\n", __func__, __LINE__, (int) msgbufsz, (int) pmsg->msgsz);
return -1;
}
result = loc_eng_dmn_conn_glue_piperead(msgqid, (uint8_t *) msgp + sizeof(pmsg->msgsz), pmsg->msgsz - sizeof(pmsg->msgsz));
if (result != (int) (pmsg->msgsz - sizeof(pmsg->msgsz))) {
LOC_LOGE("%s:%d] pipe broken %d, msgsz = %d\n", __func__, __LINE__, result, (int) pmsg->msgsz);
return -1;
}
return pmsg->msgsz;
}
/*===========================================================================
FUNCTION loc_eng_dmn_conn_glue_msgunblock
DESCRIPTION
unblock a message queue
msgqid - message queue id
DEPENDENCIES
None
RETURN VALUE
0: success
SIDE EFFECTS
N/A
===========================================================================*/
int loc_eng_dmn_conn_glue_msgunblock(int msgqid)
{
return loc_eng_dmn_conn_glue_pipeunblock(msgqid);
}
/*===========================================================================
FUNCTION loc_eng_dmn_conn_glue_msgflush
DESCRIPTION
flush out the message in a queue
msgqid - message queue id
DEPENDENCIES
None
RETURN VALUE
number of bytes that are flushed out.
SIDE EFFECTS
N/A
===========================================================================*/
int loc_eng_dmn_conn_glue_msgflush(int msgqid)
{
int length;
char buf[128];
do {
length = loc_eng_dmn_conn_glue_piperead(msgqid, buf, 128);
LOC_LOGD("%s:%d] %s\n", __func__, __LINE__, buf);
} while(length);
return length;
}

View file

@ -0,0 +1,51 @@
/* Copyright (c) 2011, Code Aurora Forum. 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 Code Aurora Forum, 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 "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_DMN_CONN_GLUE_MSG_H
#define LOC_ENG_DMN_CONN_GLUE_MSG_H
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#include <linux/types.h>
#include "loc_eng_dmn_conn_glue_pipe.h"
int loc_eng_dmn_conn_glue_msgget(const char * q_path, int mode);
int loc_eng_dmn_conn_glue_msgremove(const char * q_path, int msgqid);
int loc_eng_dmn_conn_glue_msgsnd(int msgqid, const void * msgp, size_t msgsz);
int loc_eng_dmn_conn_glue_msgrcv(int msgqid, void *msgp, size_t msgsz);
int loc_eng_dmn_conn_glue_msgflush(int msgqid);
int loc_eng_dmn_conn_glue_msgunblock(int msgqid);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* LOC_ENG_DMN_CONN_GLUE_MSG_H */

View file

@ -0,0 +1,206 @@
/* Copyright (c) 2011, Code Aurora Forum. 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 Code Aurora Forum, 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 "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 <string.h>
#include <unistd.h>
#include <errno.h>
// #include <linux/stat.h>
#include <fcntl.h>
// #include <linux/types.h>
#include <sys/types.h>
#include <sys/stat.h>
#include "loc_eng_dmn_conn_glue_pipe.h"
#include "log_util.h"
/*===========================================================================
FUNCTION loc_eng_dmn_conn_glue_pipeget
DESCRIPTION
create a named pipe.
pipe_name - pipe name path
mode - mode
DEPENDENCIES
None
RETURN VALUE
0: success or negative value for failure
SIDE EFFECTS
N/A
===========================================================================*/
int loc_eng_dmn_conn_glue_pipeget(const char * pipe_name, int mode)
{
int fd;
int result;
LOC_LOGD("%s, mode = %d\n", pipe_name, mode);
result = mkfifo(pipe_name, 0666);
if ((result == -1) && (errno != EEXIST)) {
LOC_LOGE("failed: %s\n", strerror(errno));
return result;
}
fd = open(pipe_name, mode);
if (fd <= 0)
{
LOC_LOGE("failed: %s\n", strerror(errno));
}
LOC_LOGD("fd = %d, %s\n", fd, pipe_name);
return fd;
}
/*===========================================================================
FUNCTION loc_eng_dmn_conn_glue_piperemove
DESCRIPTION
remove a pipe
pipe_name - pipe name path
fd - fd for the pipe
DEPENDENCIES
None
RETURN VALUE
0: success
SIDE EFFECTS
N/A
===========================================================================*/
int loc_eng_dmn_conn_glue_piperemove(const char * pipe_name, int fd)
{
close(fd);
if (pipe_name) unlink(pipe_name);
LOC_LOGD("fd = %d, %s\n", fd, pipe_name);
return 0;
}
/*===========================================================================
FUNCTION loc_eng_dmn_conn_glue_pipewrite
DESCRIPTION
write to a pipe
fd - fd of a pipe
buf - buffer for the data to write
sz - size of the data in buffer
DEPENDENCIES
None
RETURN VALUE
number of bytes written or negative value for failure
SIDE EFFECTS
N/A
===========================================================================*/
int loc_eng_dmn_conn_glue_pipewrite(int fd, const void * buf, size_t sz)
{
int result;
result = write(fd, buf, sz);
/* @todo check for non EINTR & EAGAIN, shall not do select again, select_tut Law 7) */
/* LOC_LOGD("fd = %d, buf = 0x%lx, size = %d, result = %d\n", fd, (long) buf, (int) sz, (int) result); */
return result;
}
/*===========================================================================
FUNCTION loc_eng_dmn_conn_glue_piperead
DESCRIPTION
read from a pipe
fd - fd for the pipe
buf - buffer to hold the data read from pipe
sz - size of the buffer
DEPENDENCIES
None
RETURN VALUE
number of bytes read from pipe or negative value for failure
SIDE EFFECTS
N/A
===========================================================================*/
int loc_eng_dmn_conn_glue_piperead(int fd, void * buf, size_t sz)
{
int len;
len = read(fd, buf, sz);
/* @todo check for non EINTR & EAGAIN, shall not do select again, select_tut Law 7) */
/* LOC_LOGD("fd = %d, buf = 0x%lx, size = %d, len = %d\n", fd, (long) buf, (int) sz, len); */
return len;
}
/*===========================================================================
FUNCTION loc_eng_dmn_conn_glue_pipeunblock
DESCRIPTION
unblock a pipe
fd - fd for the pipe
DEPENDENCIES
None
RETURN VALUE
0 for success or negative value for failure
SIDE EFFECTS
N/A
===========================================================================*/
int loc_eng_dmn_conn_glue_pipeunblock(int fd)
{
int result;
struct flock flock_v;
LOC_LOGD("\n");
// result = fcntl(fd, F_SETFL, fcntl(fd, F_GETFL, 0) | O_NDELAY);
flock_v.l_type = F_UNLCK;
flock_v.l_len = 32;
result = fcntl(fd, F_SETLK, &flock_v);
if (result < 0) {
LOC_LOGE("fcntl failure, %s\n", strerror(errno));
}
return result;
}

View file

@ -0,0 +1,50 @@
/* Copyright (c) 2011, Code Aurora Forum. 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 Code Aurora Forum, 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 "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_DMN_CONN_GLUE_PIPE_H
#define LOC_ENG_DMN_CONN_GLUE_PIPE_H
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#include <linux/types.h>
int loc_eng_dmn_conn_glue_pipeget(const char * pipe_name, int mode);
int loc_eng_dmn_conn_glue_piperemove(const char * pipe_name, int fd);
int loc_eng_dmn_conn_glue_pipewrite(int fd, const void * buf, size_t sz);
int loc_eng_dmn_conn_glue_piperead(int fd, void * buf, size_t sz);
int loc_eng_dmn_conn_glue_pipeflush(int fd);
int loc_eng_dmn_conn_glue_pipeunblock(int fd);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* LOC_ENG_DMN_CONN_GLUE_PIPE_H */

View file

@ -0,0 +1,78 @@
/* Copyright (c) 2011, Code Aurora Forum. 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 Code Aurora Forum, 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 "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "log_util.h"
#include "loc_eng_msg.h"
#include "loc_eng_dmn_conn.h"
#include "loc_eng_dmn_conn_handler.h"
void* loc_api_handle = NULL;
int loc_eng_dmn_conn_loc_api_server_if_request_handler(struct ctrl_msgbuf *pmsg, int len)
{
LOC_LOGD("%s:%d]\n", __func__, __LINE__);
#ifndef DEBUG_DMN_LOC_API
if (NULL == loc_api_handle) {
LOC_LOGE("%s:%d] NO agps data handle\n", __func__, __LINE__);
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);
#else
loc_eng_dmn_conn_loc_api_server_data_conn(GPSONE_LOC_API_IF_REQUEST_SUCCESS);
#endif
return 0;
}
int loc_eng_dmn_conn_loc_api_server_if_release_handler(struct ctrl_msgbuf *pmsg, int len)
{
LOC_LOGD("%s:%d]\n", __func__, __LINE__);
#ifndef DEBUG_DMN_LOC_API
loc_eng_msg_release_bit *msg(
new loc_eng_msg_release_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);
#else
loc_eng_dmn_conn_loc_api_server_data_conn(GPSONE_LOC_API_IF_RELEASE_SUCCESS);
#endif
return 0;
}

View file

@ -0,0 +1,82 @@
/* Copyright (c) 2011, Code Aurora Forum. 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 Code Aurora Forum, 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 "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_DATA_SERVER_HANDLER
#define LOC_ENG_DATA_SERVER_HANDLER
#include <linux/types.h>
#include <arpa/inet.h>
enum {
/* 0x0 - 0xEF is reserved for daemon internal */
GPSONE_LOC_API_IF_REQUEST = 0xF0,
GPSONE_LOC_API_IF_RELEASE,
GPSONE_LOC_API_RESPONSE,
GPSONE_UNBLOCK,
};
enum {
GPSONE_LOC_API_IF_REQUEST_SUCCESS = 0xF0,
GPSONE_LOC_API_IF_RELEASE_SUCCESS,
GPSONE_LOC_API_IF_FAILURE,
};
struct ctrl_msg_response {
int result;
};
struct ctrl_msg_unblock {
int reserved;
};
struct ctrl_msg_if_request {
unsigned is_supl; /* 1: use Android SUPL connection; 0: use Android default internet connection */
unsigned long ipv4_addr;
unsigned char ipv6_addr[16];
};
/* do not change this structure */
struct ctrl_msgbuf {
size_t msgsz;
uint16_t reserved1;
uint32_t reserved2;
uint8_t ctrl_type;
union {
struct ctrl_msg_response cmsg_response;
struct ctrl_msg_unblock cmsg_unblock;
struct ctrl_msg_if_request cmsg_if_request;
} cmsg;
};
extern void* loc_api_handle;
int loc_eng_dmn_conn_loc_api_server_if_request_handler(struct ctrl_msgbuf *pmsg, int len);
int loc_eng_dmn_conn_loc_api_server_if_release_handler(struct ctrl_msgbuf *pmsg, int len);
#endif /* LOC_ENG_DATA_SERVER_HANDLER */

View file

@ -0,0 +1,398 @@
/* Copyright (c) 2011, Code Aurora Forum. 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 Code Aurora Forum, 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 "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 "log_util.h"
#include "loc_eng_dmn_conn_thread_helper.h"
/*===========================================================================
FUNCTION thelper_signal_init
DESCRIPTION
This function will initialize the conditional variable resources.
thelper - thelper instance
DEPENDENCIES
None
RETURN VALUE
0: success or negative value for failure
SIDE EFFECTS
N/A
===========================================================================*/
int thelper_signal_init(struct loc_eng_dmn_conn_thelper * thelper)
{
int result;
thelper->thread_exit = 0;
thelper->thread_ready = 0;
result = pthread_cond_init( &thelper->thread_cond, NULL);
if (result) {
return result;
}
result = pthread_mutex_init(&thelper->thread_mutex, NULL);
if (result) {
pthread_cond_destroy(&thelper->thread_cond);
}
return result;
}
/*===========================================================================
FUNCTION
DESCRIPTION
This function will destroy the conditional variable resources
thelper - pointer to thelper instance
DEPENDENCIES
None
RETURN VALUE
0: success or negative value for failure
SIDE EFFECTS
N/A
===========================================================================*/
int thelper_signal_destroy(struct loc_eng_dmn_conn_thelper * thelper)
{
int result, ret_result = 0;
result = pthread_cond_destroy( &thelper->thread_cond);
if (result) {
ret_result = result;
}
result = pthread_mutex_destroy(&thelper->thread_mutex);
if (result) {
ret_result = result;
}
return ret_result;
}
/*===========================================================================
FUNCTION thelper_signal_wait
DESCRIPTION
This function will be blocked on the conditional variable until thelper_signal_ready
is called
thelper - pointer to thelper instance
DEPENDENCIES
None
RETURN VALUE
0: success or negative value for failure
SIDE EFFECTS
N/A
===========================================================================*/
int thelper_signal_wait(struct loc_eng_dmn_conn_thelper * thelper)
{
int result = 0;
pthread_mutex_lock(&thelper->thread_mutex);
if (!thelper->thread_ready && !thelper->thread_exit) {
result = pthread_cond_wait(&thelper->thread_cond, &thelper->thread_mutex);
}
if (thelper->thread_exit) {
result = -1;
}
pthread_mutex_unlock(&thelper->thread_mutex);
return result;
}
/*===========================================================================
FUNCTION thelper_signal_ready
DESCRIPTION
This function will wake up the conditional variable
thelper - pointer to thelper instance
DEPENDENCIES
None
RETURN VALUE
0: success or negative value for failure
SIDE EFFECTS
N/A
===========================================================================*/
int thelper_signal_ready(struct loc_eng_dmn_conn_thelper * thelper)
{
int result;
LOC_LOGD("%s:%d] 0x%lx\n", __func__, __LINE__, (long) thelper);
pthread_mutex_lock(&thelper->thread_mutex);
thelper->thread_ready = 1;
result = pthread_cond_signal(&thelper->thread_cond);
pthread_mutex_unlock(&thelper->thread_mutex);
return result;
}
/*===========================================================================
FUNCTION thelper_signal_block
DESCRIPTION
This function will set the thread ready to 0 to block the thelper_signal_wait
thelper - pointer to thelper instance
DEPENDENCIES
None
RETURN VALUE
if thread_ready is set
SIDE EFFECTS
N/A
===========================================================================*/
int thelper_signal_block(struct loc_eng_dmn_conn_thelper * thelper)
{
int result = thelper->thread_ready;
LOC_LOGD("%s:%d] 0x%lx\n", __func__, __LINE__, (long) thelper);
pthread_mutex_lock(&thelper->thread_mutex);
thelper->thread_ready = 0;
pthread_mutex_unlock(&thelper->thread_mutex);
return result;
}
/*===========================================================================
FUNCTION thelper_main
DESCRIPTION
This function is the main thread. It will be launched as a child thread
data - pointer to the instance
DEPENDENCIES
None
RETURN VALUE
NULL
SIDE EFFECTS
N/A
===========================================================================*/
static void * thelper_main(void *data)
{
int result = 0;
struct loc_eng_dmn_conn_thelper * thelper = (struct loc_eng_dmn_conn_thelper *) data;
if (thelper->thread_proc_init) {
result = thelper->thread_proc_init(thelper->thread_context);
if (result < 0) {
thelper->thread_exit = 1;
thelper_signal_ready(thelper);
LOC_LOGE("%s:%d] error: 0x%lx\n", __func__, __LINE__, (long) thelper);
return NULL;
}
}
thelper_signal_ready(thelper);
if (thelper->thread_proc_pre) {
result = thelper->thread_proc_pre(thelper->thread_context);
if (result < 0) {
thelper->thread_exit = 1;
LOC_LOGE("%s:%d] error: 0x%lx\n", __func__, __LINE__, (long) thelper);
return NULL;
}
}
do {
if (thelper->thread_proc) {
result = thelper->thread_proc(thelper->thread_context);
if (result < 0) {
thelper->thread_exit = 1;
LOC_LOGE("%s:%d] error: 0x%lx\n", __func__, __LINE__, (long) thelper);
}
}
} while (thelper->thread_exit == 0);
if (thelper->thread_proc_post) {
result = thelper->thread_proc_post(thelper->thread_context);
}
if (result != 0) {
LOC_LOGE("%s:%d] error: 0x%lx\n", __func__, __LINE__, (long) thelper);
}
return NULL;
}
static void thelper_main_2(void *data)
{
thelper_main(data);
return;
}
/*===========================================================================
FUNCTION loc_eng_dmn_conn_launch_thelper
DESCRIPTION
This function will initialize the thread context and launch the thelper_main
thelper - pointer to thelper instance
thread_proc_init - The initialization function pointer
thread_proc_pre - The function to call before task loop and after initialization
thread_proc - The task loop
thread_proc_post - The function to call after the task loop
context - the context for the above four functions
DEPENDENCIES
None
RETURN VALUE
0: success or negative value for failure
SIDE EFFECTS
N/A
===========================================================================*/
int loc_eng_dmn_conn_launch_thelper(struct loc_eng_dmn_conn_thelper * thelper,
int (*thread_proc_init) (void * context),
int (*thread_proc_pre) (void * context),
int (*thread_proc) (void * context),
int (*thread_proc_post) (void * context),
thelper_create_thread create_thread_cb,
void * context)
{
int result;
thelper_signal_init(thelper);
if (context) {
thelper->thread_context = context;
}
thelper->thread_proc_init = thread_proc_init;
thelper->thread_proc_pre = thread_proc_pre;
thelper->thread_proc = thread_proc;
thelper->thread_proc_post = thread_proc_post;
LOC_LOGD("%s:%d] 0x%lx call pthread_create\n", __func__, __LINE__, (long) thelper);
if (create_thread_cb) {
result = 0;
thelper->thread_id = create_thread_cb("loc_eng_dmn_conn",
thelper_main_2, (void *)thelper);
} else {
result = pthread_create(&thelper->thread_id, NULL,
thelper_main, (void *)thelper);
}
if (result != 0) {
LOC_LOGE("%s:%d] 0x%lx\n", __func__, __LINE__, (long) thelper);
return -1;
}
LOC_LOGD("%s:%d] 0x%lx pthread_create done\n", __func__, __LINE__, (long) thelper);
thelper_signal_wait(thelper);
LOC_LOGD("%s:%d] 0x%lx pthread ready\n", __func__, __LINE__, (long) thelper);
return thelper->thread_exit;
}
/*===========================================================================
FUNCTION loc_eng_dmn_conn_unblock_thelper
DESCRIPTION
This function unblocks thelper_main to release the thread
thelper - pointer to thelper instance
DEPENDENCIES
None
RETURN VALUE
0: success
SIDE EFFECTS
N/A
===========================================================================*/
int loc_eng_dmn_conn_unblock_thelper(struct loc_eng_dmn_conn_thelper * thelper)
{
LOC_LOGD("%s:%d] 0x%lx\n", __func__, __LINE__, (long) thelper);
thelper->thread_exit = 1;
return 0;
}
/*===========================================================================
FUNCTION loc_eng_dmn_conn_join_thelper
thelper - pointer to thelper instance
DESCRIPTION
This function will wait for the thread of thelper_main to finish
DEPENDENCIES
None
RETURN VALUE
0: success or negative value for failure
SIDE EFFECTS
N/A
===========================================================================*/
int loc_eng_dmn_conn_join_thelper(struct loc_eng_dmn_conn_thelper * thelper)
{
int result;
LOC_LOGD("%s:%d] 0x%lx\n", __func__, __LINE__, (long) thelper);
result = pthread_join(thelper->thread_id, NULL);
if (result != 0) {
LOC_LOGE("%s:%d] 0x%lx\n", __func__, __LINE__, (long) thelper);
}
LOC_LOGD("%s:%d] 0x%lx\n", __func__, __LINE__, (long) thelper);
thelper_signal_destroy(thelper);
return result;
}

View file

@ -0,0 +1,74 @@
/* Copyright (c) 2011, Code Aurora Forum. 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 Code Aurora Forum, 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 "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_DMN_CONN_THREAD_HELPER_H__
#define __LOC_ENG_DMN_CONN_THREAD_HELPER_H__
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#include <pthread.h>
struct loc_eng_dmn_conn_thelper {
unsigned char thread_exit;
unsigned char thread_ready;
pthread_cond_t thread_cond;
pthread_mutex_t thread_mutex;
pthread_t thread_id;
void * thread_context;
int (*thread_proc_init) (void * context);
int (*thread_proc_pre) (void * context);
int (*thread_proc) (void * context);
int (*thread_proc_post) (void * context);
};
typedef pthread_t (* thelper_create_thread)(const char* name, void (*start)(void *), void* arg);
int loc_eng_dmn_conn_launch_thelper(struct loc_eng_dmn_conn_thelper * thelper,
int (*thread_proc_init) (void * context),
int (*thread_proc_pre) (void * context),
int (*thread_proc) (void * context),
int (*thread_proc_post) (void * context),
thelper_create_thread create_thread_cb,
void * context);
int loc_eng_dmn_conn_unblock_thelper(struct loc_eng_dmn_conn_thelper * thelper);
int loc_eng_dmn_conn_join_thelper(struct loc_eng_dmn_conn_thelper * thelper);
/* if only need to use signal */
int thelper_signal_init(struct loc_eng_dmn_conn_thelper * thelper);
int thelper_signal_destroy(struct loc_eng_dmn_conn_thelper * thelper);
int thelper_signal_wait(struct loc_eng_dmn_conn_thelper * thelper);
int thelper_signal_ready(struct loc_eng_dmn_conn_thelper * thelper);
int thelper_signal_block(struct loc_eng_dmn_conn_thelper * thelper);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __LOC_ENG_DMN_CONN_THREAD_HELPER_H__ */

View file

@ -0,0 +1,292 @@
/* Copyright (c) 2011 Code Aurora Forum. 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 Code Aurora Forum, 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 "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"
#include "hardware/gps.h"
#include "loc.h"
#include "loc_log.h"
#include "loc_eng_log.h"
#include "loc_eng_msg_id.h"
/* GPS status names */
static loc_name_val_s_type gps_status_name[] =
{
NAME_VAL( GPS_STATUS_NONE ),
NAME_VAL( GPS_STATUS_SESSION_BEGIN ),
NAME_VAL( GPS_STATUS_SESSION_END ),
NAME_VAL( GPS_STATUS_ENGINE_ON ),
NAME_VAL( GPS_STATUS_ENGINE_OFF ),
};
static int gps_status_num = sizeof(gps_status_name) / sizeof(loc_name_val_s_type);
/* Find Android GPS status name */
const char* loc_get_gps_status_name(GpsStatusValue gps_status)
{
return loc_get_name_from_val(gps_status_name, gps_status_num,
(long) gps_status);
}
static loc_name_val_s_type loc_eng_msgs[] =
{
NAME_VAL( LOC_ENG_MSG_QUIT ),
NAME_VAL( LOC_ENG_MSG_ENGINE_DOWN ),
NAME_VAL( LOC_ENG_MSG_ENGINE_UP ),
NAME_VAL( LOC_ENG_MSG_START_FIX ),
NAME_VAL( LOC_ENG_MSG_STOP_FIX ),
NAME_VAL( LOC_ENG_MSG_SET_POSITION_MODE ),
NAME_VAL( LOC_ENG_MSG_SET_TIME ),
NAME_VAL( LOC_ENG_MSG_INJECT_XTRA_DATA ),
NAME_VAL( LOC_ENG_MSG_INJECT_LOCATION ),
NAME_VAL( LOC_ENG_MSG_DELETE_AIDING_DATA ),
NAME_VAL( LOC_ENG_MSG_SET_APN ),
NAME_VAL( LOC_ENG_MSG_SET_SERVER_URL ),
NAME_VAL( LOC_ENG_MSG_SET_SERVER_IPV4 ),
NAME_VAL( LOC_ENG_MSG_ENABLE_DATA ),
NAME_VAL( LOC_ENG_MSG_SUPL_VERSION ),
NAME_VAL( LOC_ENG_MSG_SET_SENSOR_CONTROL_CONFIG ),
NAME_VAL( LOC_ENG_MSG_SET_SENSOR_PROPERTIES ),
NAME_VAL( LOC_ENG_MSG_SET_SENSOR_PERF_CONTROL_CONFIG ),
NAME_VAL( LOC_ENG_MSG_MUTE_SESSION ),
NAME_VAL( LOC_ENG_MSG_ATL_OPEN_SUCCESS ),
NAME_VAL( LOC_ENG_MSG_ATL_CLOSED ),
NAME_VAL( LOC_ENG_MSG_ATL_OPEN_FAILED ),
NAME_VAL( LOC_ENG_MSG_REPORT_POSITION ),
NAME_VAL( LOC_ENG_MSG_REPORT_SV ),
NAME_VAL( LOC_ENG_MSG_REPORT_STATUS ),
NAME_VAL( LOC_ENG_MSG_REPORT_NMEA ),
NAME_VAL( LOC_ENG_MSG_REQUEST_ATL ),
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_NI ),
NAME_VAL( LOC_ENG_MSG_INFORM_NI_RESPONSE ),
NAME_VAL( LOC_ENG_MSG_REQUEST_XTRA_DATA ),
NAME_VAL( LOC_ENG_MSG_REQUEST_TIME )
};
static int loc_eng_msgs_num = sizeof(loc_eng_msgs) / sizeof(loc_name_val_s_type);
/* Find Android GPS status name */
const char* loc_get_msg_name(int id)
{
return loc_get_name_from_val(loc_eng_msgs, loc_eng_msgs_num, (long) id);
}
static loc_name_val_s_type loc_eng_position_modes[] =
{
NAME_VAL( LOC_POSITION_MODE_STANDALONE ),
NAME_VAL( LOC_POSITION_MODE_MS_BASED ),
NAME_VAL( LOC_POSITION_MODE_MS_ASSISTED ),
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 )
};
static int loc_eng_position_mode_num = sizeof(loc_eng_position_modes) / sizeof(loc_name_val_s_type);
const char* loc_get_position_mode_name(GpsPositionMode mode)
{
return loc_get_name_from_val(loc_eng_position_modes, loc_eng_position_mode_num, (long) mode);
}
static loc_name_val_s_type loc_eng_position_recurrences[] =
{
NAME_VAL( GPS_POSITION_RECURRENCE_PERIODIC ),
NAME_VAL( GPS_POSITION_RECURRENCE_SINGLE )
};
static int loc_eng_position_recurrence_num = sizeof(loc_eng_position_recurrences) / sizeof(loc_name_val_s_type);
const char* loc_get_position_recurrence_name(GpsPositionRecurrence recur)
{
return loc_get_name_from_val(loc_eng_position_recurrences, loc_eng_position_recurrence_num, (long) recur);
}
static loc_name_val_s_type loc_eng_aiding_data_bits[] =
{
NAME_VAL( GPS_DELETE_EPHEMERIS ),
NAME_VAL( GPS_DELETE_ALMANAC ),
NAME_VAL( GPS_DELETE_POSITION ),
NAME_VAL( GPS_DELETE_TIME ),
NAME_VAL( GPS_DELETE_IONO ),
NAME_VAL( GPS_DELETE_UTC ),
NAME_VAL( GPS_DELETE_HEALTH ),
NAME_VAL( GPS_DELETE_SVDIR ),
NAME_VAL( GPS_DELETE_SVSTEER ),
NAME_VAL( GPS_DELETE_SADATA ),
NAME_VAL( GPS_DELETE_RTI ),
NAME_VAL( GPS_DELETE_CELLDB_INFO )
#ifdef QCOM_FEATURE_DELEXT
,NAME_VAL( GPS_DELETE_ALMANAC_CORR ),
NAME_VAL( GPS_DELETE_FREQ_BIAS_EST ),
NAME_VAL( GPS_DELETE_EPHEMERIS_GLO ),
NAME_VAL( GPS_DELETE_ALMANAC_GLO ),
NAME_VAL( GPS_DELETE_SVDIR_GLO ),
NAME_VAL( GPS_DELETE_SVSTEER_GLO ),
NAME_VAL( GPS_DELETE_ALMANAC_CORR_GLO ),
NAME_VAL( GPS_DELETE_TIME_GPS ),
NAME_VAL( GPS_DELETE_TIME_GLO )
#endif
};
static int loc_eng_aiding_data_bit_num = sizeof(loc_eng_aiding_data_bits) / sizeof(loc_name_val_s_type);
const char* loc_get_aiding_data_mask_names(GpsAidingData data)
{
return NULL;
}
static loc_name_val_s_type loc_eng_agps_types[] =
{
#ifdef QCOM_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
,NAME_VAL( AGPS_TYPE_WWAN_ANY )
#endif
};
static int loc_eng_agps_type_num = sizeof(loc_eng_agps_types) / sizeof(loc_name_val_s_type);
const char* loc_get_agps_type_name(AGpsType type)
{
return loc_get_name_from_val(loc_eng_agps_types, loc_eng_agps_type_num, (long) type);
}
static loc_name_val_s_type loc_eng_ni_types[] =
{
NAME_VAL( GPS_NI_TYPE_VOICE ),
NAME_VAL( GPS_NI_TYPE_UMTS_SUPL ),
NAME_VAL( GPS_NI_TYPE_UMTS_CTRL_PLANE )
};
static int loc_eng_ni_type_num = sizeof(loc_eng_ni_types) / sizeof(loc_name_val_s_type);
const char* loc_get_ni_type_name(GpsNiType type)
{
return loc_get_name_from_val(loc_eng_ni_types, loc_eng_ni_type_num, (long) type);
}
static loc_name_val_s_type loc_eng_ni_responses[] =
{
NAME_VAL( GPS_NI_RESPONSE_ACCEPT ),
NAME_VAL( GPS_NI_RESPONSE_DENY ),
NAME_VAL( GPS_NI_RESPONSE_DENY )
};
static int loc_eng_ni_reponse_num = sizeof(loc_eng_ni_responses) / sizeof(loc_name_val_s_type);
const char* loc_get_ni_response_name(GpsUserResponseType response)
{
return loc_get_name_from_val(loc_eng_ni_responses, loc_eng_ni_reponse_num, (long) response);
}
static loc_name_val_s_type loc_eng_ni_encodings[] =
{
NAME_VAL( GPS_ENC_NONE ),
NAME_VAL( GPS_ENC_SUPL_GSM_DEFAULT ),
NAME_VAL( GPS_ENC_SUPL_UTF8 ),
NAME_VAL( GPS_ENC_SUPL_UCS2 ),
NAME_VAL( GPS_ENC_UNKNOWN )
};
static int loc_eng_ni_encoding_num = sizeof(loc_eng_ni_encodings) / sizeof(loc_name_val_s_type);
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
static loc_name_val_s_type loc_eng_agps_bears[] =
{
NAME_VAL( AGPS_APN_BEARER_INVALID ),
NAME_VAL( AGPS_APN_BEARER_IPV4 ),
NAME_VAL( AGPS_APN_BEARER_IPV4 ),
NAME_VAL( AGPS_APN_BEARER_IPV4V6 )
};
static int loc_eng_agps_bears_num = sizeof(loc_eng_agps_bears) / sizeof(loc_name_val_s_type);
const char* loc_get_agps_bear_name(AGpsBearerType bearer)
{
return loc_get_name_from_val(loc_eng_agps_bears, loc_eng_agps_bears_num, (long) bearer);
}
#endif
static loc_name_val_s_type loc_eng_server_types[] =
{
NAME_VAL( LOC_AGPS_CDMA_PDE_SERVER ),
NAME_VAL( LOC_AGPS_CUSTOM_PDE_SERVER ),
NAME_VAL( LOC_AGPS_MPC_SERVER ),
NAME_VAL( LOC_AGPS_SUPL_SERVER )
};
static int loc_eng_server_types_num = sizeof(loc_eng_server_types) / sizeof(loc_name_val_s_type);
const char* loc_get_server_type_name(LocServerType type)
{
return loc_get_name_from_val(loc_eng_server_types, loc_eng_server_types_num, (long) type);
}
static loc_name_val_s_type loc_eng_position_sess_status_types[] =
{
NAME_VAL( LOC_SESS_SUCCESS ),
NAME_VAL( LOC_SESS_INTERMEDIATE ),
NAME_VAL( LOC_SESS_FAILURE )
};
static int loc_eng_position_sess_status_num = sizeof(loc_eng_position_sess_status_types) / sizeof(loc_name_val_s_type);
const char* loc_get_position_sess_status_name(enum loc_sess_status status)
{
return loc_get_name_from_val(loc_eng_position_sess_status_types, loc_eng_position_sess_status_num, (long) status);
}
static loc_name_val_s_type loc_eng_agps_status_names[] =
{
NAME_VAL( GPS_REQUEST_AGPS_DATA_CONN ),
NAME_VAL( GPS_RELEASE_AGPS_DATA_CONN ),
NAME_VAL( GPS_AGPS_DATA_CONNECTED ),
NAME_VAL( GPS_AGPS_DATA_CONN_DONE ),
NAME_VAL( GPS_AGPS_DATA_CONN_FAILED )
};
static int loc_eng_agps_status_num = sizeof(loc_eng_agps_status_names) / sizeof(loc_name_val_s_type);
const char* loc_get_agps_status_name(AGpsStatusValue status)
{
return loc_get_name_from_val(loc_eng_agps_status_names, loc_eng_agps_status_num, (long) status);
}

View file

@ -0,0 +1,62 @@
/* Copyright (c) 2011 Code Aurora Forum. 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 Code Aurora Forum, 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 "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_LOG_H
#define LOC_ENG_LOG_H
#ifdef __cplusplus
extern "C"
{
#endif
#include <ctype.h>
#include <hardware/gps.h>
#include "loc_eng_msg_id.h"
const char* loc_get_gps_status_name(GpsStatusValue gps_status);
const char* loc_get_msg_name(int id);
const char* loc_get_position_mode_name(GpsPositionMode mode);
const char* loc_get_position_recurrence_name(GpsPositionRecurrence recur);
const char* loc_get_aiding_data_mask_names(GpsAidingData data);
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
const char* loc_get_agps_bear_name(AGpsBearerType bear);
#endif
const char* loc_get_server_type_name(LocServerType type);
const char* loc_get_position_sess_status_name(enum loc_sess_status status);
const char* loc_get_agps_status_name(AGpsStatusValue status);
#ifdef __cplusplus
}
#endif
#endif /* LOC_ENG_LOG_H */

View file

@ -0,0 +1,133 @@
/* Copyright (c) 2011, Code Aurora Forum. 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 Code Aurora Forum, 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 "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 <fcntl.h>
#include "loc_eng_msg.h"
#include "loc_eng_dmn_conn_glue_msg.h"
#ifdef _ANDROID_
#define LOC_ENG_MSG_REQ_Q_PATH "/data/misc/gpsone_d/loc_eng_msg_req_q"
#else
#define LOC_ENG_MSG_REQ_Q_PATH "/tmp/loc_eng_msg_req_q"
#endif
int loc_eng_msgget(int * p_req_msgq)
{
* p_req_msgq = loc_eng_dmn_conn_glue_msgget(LOC_ENG_MSG_REQ_Q_PATH, O_RDWR);
return 0;
}
int loc_eng_msgremove(int req_msgq)
{
loc_eng_dmn_conn_glue_piperemove(LOC_ENG_MSG_REQ_Q_PATH, req_msgq);
return 0;
}
int loc_eng_msgsnd(int msgqid, void * msgp)
{
int ret = loc_eng_dmn_conn_glue_pipewrite(msgqid, msgp, sizeof(void*));
return ret;
}
int loc_eng_msgsnd_raw(int msgqid, void * msgp, unsigned int msgsz)
{
int result;
struct msgbuf * pmsg = (struct msgbuf *) msgp;
if (msgsz < sizeof(struct msgbuf)) {
LOC_LOGE("%s:%d] msgbuf is too small %d\n", __func__, __LINE__, msgsz);
return -1;
}
pmsg->msgsz = msgsz;
result = loc_eng_dmn_conn_glue_pipewrite(msgqid, msgp, msgsz);
if (result != (int) msgsz) {
LOC_LOGE("%s:%d] pipe broken %d, msgsz = %d\n", __func__, __LINE__, result, (int) msgsz);
return -1;
}
return result;
}
int loc_eng_msgrcv(int msgqid, void ** msgp)
{
int ret = loc_eng_dmn_conn_glue_piperead(msgqid, msgp, sizeof(void*));
return ret;
}
int loc_eng_msgrcv_raw(int msgqid, void *msgp, unsigned int msgsz)
{
int result;
struct msgbuf * pmsg = (struct msgbuf *) msgp;
if (msgsz < sizeof(struct msgbuf)) {
LOC_LOGE("%s:%d] msgbuf is too small %d\n", __func__, __LINE__, msgsz);
return -1;
}
result = loc_eng_dmn_conn_glue_piperead(msgqid, msgp, sizeof(struct msgbuf));
if (result != sizeof(struct msgbuf)) {
LOC_LOGE("%s:%d] pipe broken %d\n", __func__, __LINE__, result);
return -1;
}
if (msgsz < pmsg->msgsz) {
LOC_LOGE("%s:%d] msgbuf is too small %d < %d\n", __func__, __LINE__, (int) msgsz, (int) pmsg->msgsz);
return -1;
}
if (pmsg->msgsz > sizeof(struct msgbuf)) {
/* there is msg body */
msgp += sizeof(struct msgbuf);
result = loc_eng_dmn_conn_glue_piperead(msgqid, msgp, pmsg->msgsz - sizeof(struct msgbuf));
if (result != (int) (pmsg->msgsz - sizeof(struct msgbuf))) {
LOC_LOGE("%s:%d] pipe broken %d, msgid = %p, msgsz = %d\n", __func__, __LINE__, result,
(pmsg->msgid), (int) pmsg->msgsz);
return -1;
}
}
return pmsg->msgsz;
}
int loc_eng_msgflush(int msgqid)
{
return loc_eng_dmn_conn_glue_msgflush(msgqid);
}
int loc_eng_msgunblock(int msgqid)
{
return loc_eng_dmn_conn_glue_pipeunblock(msgqid);
}

View file

@ -0,0 +1,584 @@
/* Copyright (c) 2011, Code Aurora Forum. 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 Code Aurora Forum, 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 "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_MSG_H
#define LOC_ENG_MSG_H
#include <hardware/gps.h>
#include <stdlib.h>
#include <string.h>
#include "log_util.h"
#include "loc.h"
#include "loc_eng_log.h"
#include "loc_eng_msg_id.h"
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
struct loc_eng_msg {
const void* owner;
const int msgid;
inline loc_eng_msg(void* instance, int id) :
owner(instance), msgid(id)
{
LOC_LOGV("creating msg %s", loc_get_msg_name(msgid));
}
virtual ~loc_eng_msg()
{
LOC_LOGV("deleting msg %s", loc_get_msg_name(msgid));
}
};
struct loc_eng_msg_suple_version : public loc_eng_msg {
const int supl_version;
inline loc_eng_msg_suple_version(void* instance, int version) :
loc_eng_msg(instance, LOC_ENG_MSG_SUPL_VERSION),
supl_version(version)
{
LOC_LOGV("SUPL Version: %d", version);
}
};
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) :
loc_eng_msg(instance, LOC_ENG_MSG_SET_SENSOR_CONTROL_CONFIG),
sensorsDisabled(disabled)
{
LOC_LOGV("Sensors Disabled: %d", disabled);
}
};
struct loc_eng_msg_sensor_properties : public loc_eng_msg {
const float gyroBiasVarianceRandomWalk;
inline loc_eng_msg_sensor_properties(void* instance, float gyroBiasRandomWalk) :
loc_eng_msg(instance, LOC_ENG_MSG_SET_SENSOR_PROPERTIES),
gyroBiasVarianceRandomWalk(gyroBiasRandomWalk)
{
LOC_LOGV("Gyro Bias Random Walk: %f", gyroBiasRandomWalk);
}
};
struct loc_eng_msg_sensor_perf_control_config : public loc_eng_msg {
const int controlMode;
const int accelSamplesPerBatch;
const int accelBatchesPerSec;
const int gyroSamplesPerBatch;
const int gyroBatchesPerSec;
inline loc_eng_msg_sensor_perf_control_config(void* instance, int controlMode,
int accelSamplesPerBatch, int accelBatchesPerSec,
int gyroSamplesPerBatch, int gyroBatchesPerSec) :
loc_eng_msg(instance, LOC_ENG_MSG_SET_SENSOR_PERF_CONTROL_CONFIG),
controlMode(controlMode),
accelSamplesPerBatch(accelSamplesPerBatch),
accelBatchesPerSec(accelBatchesPerSec),
gyroSamplesPerBatch(gyroSamplesPerBatch),
gyroBatchesPerSec(gyroBatchesPerSec)
{
LOC_LOGV("Sensor Perf Control Config (performanceControlMode)(%u) "
"accel(#smp,#batches) (%u,%u) gyro(#smp,#batches) (%u,%u)\n",
controlMode,
accelSamplesPerBatch,
accelBatchesPerSec,
gyroSamplesPerBatch,
gyroBatchesPerSec
);
}
};
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) {}
inline loc_eng_msg_position_mode(void* instance,
LocPositionMode mode,
GpsPositionRecurrence recurrence,
uint32_t min_interval,
uint32_t preferred_accuracy,
uint32_t preferred_time) :
loc_eng_msg(instance, LOC_ENG_MSG_SET_POSITION_MODE),
pMode(mode), pRecurrence(recurrence), minInterval(min_interval),
preferredAccuracy(preferred_accuracy), preferredTime(preferred_time)
{
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);
}
};
struct loc_eng_msg_set_time : public loc_eng_msg {
const GpsUtcTime time;
const int64_t timeReference;
const int uncertainty;
inline loc_eng_msg_set_time(void* instance,
GpsUtcTime t,
int64_t tf,
int unc) :
loc_eng_msg(instance, LOC_ENG_MSG_SET_TIME),
time(t), timeReference(tf), uncertainty(unc)
{
LOC_LOGV("time: %lld\n timeReference: %lld\n uncertainty: %d",
time, timeReference, uncertainty);
}
};
struct loc_eng_msg_inject_location : public loc_eng_msg {
const double latitude;
const double longitude;
const float accuracy;
inline loc_eng_msg_inject_location(void* instance, double lat,
double longi, float accur) :
loc_eng_msg(instance, LOC_ENG_MSG_INJECT_LOCATION),
latitude(lat), longitude(longi), accuracy(accur)
{
LOC_LOGV("latitude: %f\n longitude: %f\n accuracy: %f",
latitude, longitude, accuracy);
}
};
struct loc_eng_msg_delete_aiding_data : public loc_eng_msg {
const GpsAidingData type;
inline loc_eng_msg_delete_aiding_data(void* instance, GpsAidingData data) :
loc_eng_msg(instance, LOC_ENG_MSG_DELETE_AIDING_DATA), type(data)
{
LOC_LOGV("aiding data msak %d", type);
}
};
struct loc_eng_msg_report_position : public loc_eng_msg {
const GpsLocation location;
const void* locationExt;
const enum loc_sess_status status;
inline loc_eng_msg_report_position(void* instance, GpsLocation &loc, void* locExt,
enum loc_sess_status st) :
loc_eng_msg(instance, LOC_ENG_MSG_REPORT_POSITION),
location(loc), locationExt(locExt), status(st)
{
#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
}
};
struct loc_eng_msg_report_sv : public loc_eng_msg {
const GpsSvStatus svStatus;
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)
{
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);
for (int i = 0; i < svStatus.num_svs && i < GPS_MAX_SVS; i++) {
LOC_LOGV(" %d: %d %f %f %f\n ",
i,
svStatus.sv_list[i].prn,
svStatus.sv_list[i].snr,
svStatus.sv_list[i].elevation,
svStatus.sv_list[i].azimuth);
}
}
};
struct loc_eng_msg_report_status : public loc_eng_msg {
const GpsStatusValue status;
inline loc_eng_msg_report_status(void* instance, GpsStatusValue engineStatus) :
loc_eng_msg(instance, LOC_ENG_MSG_REPORT_STATUS), status(engineStatus)
{
LOC_LOGV("status: %s", loc_get_gps_status_name(status));
}
};
struct loc_eng_msg_report_nmea : public loc_eng_msg {
char* const nmea;
const int length;
inline loc_eng_msg_report_nmea(void* instance,
const char* data,
int len) :
loc_eng_msg(instance, LOC_ENG_MSG_REPORT_NMEA),
nmea(new char[len]), length(len)
{
memcpy((void*)nmea, (void*)data, len);
LOC_LOGV("length: %d\n nmea: %p - %c%c%c",
length, nmea, nmea[3], nmea[4], nmea[5]);
}
inline ~loc_eng_msg_report_nmea()
{
delete[] nmea;
}
};
struct loc_eng_msg_request_bit : public loc_eng_msg {
const unsigned int isSupl;
const int ipv4Addr;
char* const ipv6Addr;
inline loc_eng_msg_request_bit(void* instance,
unsigned int is_supl,
int ipv4,
char* ipv6) :
loc_eng_msg(instance, LOC_ENG_MSG_REQUEST_BIT),
isSupl(is_supl), 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,
(unsigned char)ipv4,
NULL != ipv6Addr ? ipv6Addr : "");
}
inline ~loc_eng_msg_request_bit()
{
if (NULL != ipv6Addr) {
delete[] ipv6Addr;
}
}
};
struct loc_eng_msg_release_bit : public loc_eng_msg {
const unsigned int isSupl;
const int ipv4Addr;
char* const ipv6Addr;
inline loc_eng_msg_release_bit(void* instance,
unsigned int is_supl,
int ipv4,
char* ipv6) :
loc_eng_msg(instance, LOC_ENG_MSG_RELEASE_BIT),
isSupl(is_supl), 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,
(unsigned char)ipv4,
NULL != ipv6Addr ? ipv6Addr : "");
}
inline ~loc_eng_msg_release_bit()
{
if (NULL != ipv6Addr) {
delete[] ipv6Addr;
}
}
};
struct loc_eng_msg_request_atl : public loc_eng_msg {
const int handle;
const AGpsType type;
inline loc_eng_msg_request_atl(void* instance, int hndl,
AGpsType agps_type) :
loc_eng_msg(instance, LOC_ENG_MSG_REQUEST_ATL),
handle(hndl), type(agps_type)
{
LOC_LOGV("handle: %d\n agps type: %s",
handle,
loc_get_agps_type_name(type));
}
};
struct loc_eng_msg_release_atl : public loc_eng_msg {
const int handle;
inline loc_eng_msg_release_atl(void* instance, int hndl) :
loc_eng_msg(instance, LOC_ENG_MSG_RELEASE_ATL), handle(hndl)
{
LOC_LOGV("handle: %d", handle);
}
};
struct loc_eng_msg_request_ni : public loc_eng_msg {
const GpsNiNotification notify;
const void *passThroughData;
inline loc_eng_msg_request_ni(void* instance,
GpsNiNotification &notif, const void* data) :
loc_eng_msg(instance, LOC_ENG_MSG_REQUEST_NI),
notify(notif), passThroughData(data)
{
LOC_LOGV("id: %d\n type: %s\n flags: %d\n time out: %d\n default response: %s\n requestor id encoding: %s\n text encoding: %s\n passThroughData: %p",
notify.notification_id,
loc_get_ni_type_name(notify.ni_type),
notify.notify_flags,
notify.timeout,
loc_get_ni_response_name(notify.default_response),
loc_get_ni_encoding_name(notify.requestor_id_encoding),
loc_get_ni_encoding_name(notify.text_encoding),
passThroughData);
}
};
struct loc_eng_msg_inform_ni_response : public loc_eng_msg {
const GpsUserResponseType response;
const void *passThroughData;
inline loc_eng_msg_inform_ni_response(void* instance,
GpsUserResponseType resp,
const void* data) :
loc_eng_msg(instance, LOC_ENG_MSG_INFORM_NI_RESPONSE),
response(resp), passThroughData(data)
{
LOC_LOGV("response: %s\n passThroughData: %p",
loc_get_ni_response_name(response),
passThroughData);
}
inline ~loc_eng_msg_inform_ni_response()
{
// this is a bit weird since passThroughData is not
// allocated by this class. But there is no better way.
// passThroughData actually won't be NULL here.
// But better safer than sorry.
if (NULL != passThroughData) {
free((void*)passThroughData);
}
}
};
struct loc_eng_msg_set_apn : public loc_eng_msg {
char* const apn;
inline loc_eng_msg_set_apn(void* instance, const char* name, int len) :
loc_eng_msg(instance, LOC_ENG_MSG_SET_APN),
apn(new char[len+1])
{
memcpy((void*)apn, (void*)name, len);
apn[len] = 0;
LOC_LOGV("apn: %s", apn);
}
inline ~loc_eng_msg_set_apn()
{
delete[] apn;
}
};
struct loc_eng_msg_set_server_ipv4 : public loc_eng_msg {
const unsigned int nl_addr;
const int port;
const LocServerType serverType;
inline loc_eng_msg_set_server_ipv4(void* instance,
unsigned int ip,
int p,
LocServerType type) :
loc_eng_msg(instance, LOC_ENG_MSG_SET_SERVER_IPV4),
nl_addr(ip), port(p), serverType(type)
{
LOC_LOGV("addr: %x\n , port: %d\n type: %s", nl_addr, port, loc_get_server_type_name(serverType));
}
};
struct loc_eng_msg_set_server_url : public loc_eng_msg {
const int len;
char* const url;
inline loc_eng_msg_set_server_url(void* instance,
const char* urlString,
int url_len) :
loc_eng_msg(instance, LOC_ENG_MSG_SET_SERVER_URL),
len(url_len), url(new char[len+1])
{
memcpy((void*)url, (void*)urlString, url_len);
url[len] = 0;
LOC_LOGV("url: %s", url);
}
inline ~loc_eng_msg_set_server_url()
{
delete[] url;
}
};
struct loc_eng_msg_inject_xtra_data : public loc_eng_msg {
char* const data;
const int length;
inline loc_eng_msg_inject_xtra_data(void* instance, char* d, int l) :
loc_eng_msg(instance, LOC_ENG_MSG_INJECT_XTRA_DATA),
data(new char[l]), length(l)
{
memcpy((void*)data, (void*)d, l);
LOC_LOGV("length: %d\n data: %p", length, data);
}
inline ~loc_eng_msg_inject_xtra_data()
{
delete[] data;
}
};
#ifdef QCOM_FEATURE_IPV6
struct loc_eng_msg_atl_open_success : public loc_eng_msg {
const AGpsStatusValue agpsType;
const int length;
char* const apn;
const AGpsBearerType bearerType;
inline loc_eng_msg_atl_open_success(void* instance,
AGpsStatusValue atype,
const char* name,
int len,
AGpsBearerType btype) :
loc_eng_msg(instance, LOC_ENG_MSG_ATL_OPEN_SUCCESS),
agpsType(atype), length(len),
apn(new char[len+1]), bearerType(btype)
{
memcpy((void*)apn, (void*)name, len);
apn[len] = 0;
LOC_LOGV("agps type: %s\n apn: %s\n bearer type: %s",
loc_get_agps_type_name(agpsType),
apn,
loc_get_agps_bear_name(bearerType));
}
inline ~loc_eng_msg_atl_open_success()
{
delete[] apn;
}
};
#else
struct loc_eng_msg_atl_open_success : public loc_eng_msg {
const int length;
char* const apn;
inline loc_eng_msg_atl_open_success(void* instance,
const char* name,
int len) :
loc_eng_msg(instance, LOC_ENG_MSG_ATL_OPEN_SUCCESS),
length(len),
apn(new char[len+1])
{
memcpy((void*)apn, (void*)name, len);
apn[len] = 0;
LOC_LOGV("apn: %s\n",
apn);
}
inline ~loc_eng_msg_atl_open_success()
{
delete[] apn;
}
};
#endif
#ifdef QCOM_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,
AGpsStatusValue atype) :
loc_eng_msg(instance, LOC_ENG_MSG_ATL_OPEN_FAILED),
agpsType(atype)
{
LOC_LOGV("agps type %s",
loc_get_agps_type_name(agpsType));
}
};
#else
struct loc_eng_msg_atl_open_failed : public loc_eng_msg {
inline loc_eng_msg_atl_open_failed(void* instance) :
loc_eng_msg(instance, LOC_ENG_MSG_ATL_OPEN_FAILED)
{
LOC_LOGV("");
}
};
#endif
#ifdef QCOM_FEATURE_IPV6
struct loc_eng_msg_atl_closed : public loc_eng_msg {
const AGpsStatusValue agpsType;
inline loc_eng_msg_atl_closed(void* instance,
AGpsStatusValue atype) :
loc_eng_msg(instance, LOC_ENG_MSG_ATL_CLOSED),
agpsType(atype)
{
LOC_LOGV("agps type %s",
loc_get_agps_type_name(agpsType));
}
};
#else
struct loc_eng_msg_atl_closed : public loc_eng_msg {
inline loc_eng_msg_atl_closed(void* instance) :
loc_eng_msg(instance, LOC_ENG_MSG_ATL_CLOSED)
{
LOC_LOGV("");
}
};
#endif
struct loc_eng_msg_set_data_enable : public loc_eng_msg {
const int enable;
char* const apn;
const int length;
inline loc_eng_msg_set_data_enable(void* instance,
const char* name,
int len,
int yes) :
loc_eng_msg(instance, LOC_ENG_MSG_ENABLE_DATA),
enable(yes), apn(new char[len+1]), length(len)
{
memcpy((void*)apn, (void*)name, len);
apn[len] = 0;
LOC_LOGV("apn: %s\n enable: %d", apn, enable);
}
inline ~loc_eng_msg_set_data_enable()
{
delete[] apn;
}
};
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);
int loc_eng_msgsnd(int msgqid, void * msgp);
int loc_eng_msgrcv(int msgqid, void ** msgp);
int loc_eng_msgsnd_raw(int msgqid, void * msgp, unsigned int msgsz);
int loc_eng_msgrcv_raw(int msgqid, void *msgp, unsigned int msgsz);
int loc_eng_msgflush(int msgqid);
int loc_eng_msgunblock(int msgqid);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* LOC_ENG_MSG_H */

View file

@ -0,0 +1,90 @@
/* Copyright (c) 2011, Code Aurora Forum. 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 Code Aurora Forum, 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 "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_MSG_ID_H
#define LOC_ENG_MSG_ID_H
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
struct msgbuf {
unsigned int msgsz;
void* msgid;
};
enum loc_eng_msg_ids_t {
/* 0x 0 - 0xEF is reserved for daemon internal */
/* 0xF0 - 0x1FF is reserved for daemon & framework communication */
LOC_ENG_MSG_QUIT = 0x200,
LOC_ENG_MSG_ENGINE_DOWN,
LOC_ENG_MSG_ENGINE_UP,
LOC_ENG_MSG_START_FIX,
LOC_ENG_MSG_STOP_FIX,
LOC_ENG_MSG_SET_POSITION_MODE,
LOC_ENG_MSG_SET_TIME,
LOC_ENG_MSG_INJECT_XTRA_DATA,
LOC_ENG_MSG_INJECT_LOCATION,
LOC_ENG_MSG_DELETE_AIDING_DATA,
LOC_ENG_MSG_SET_APN,
LOC_ENG_MSG_SET_SERVER_URL,
LOC_ENG_MSG_SET_SERVER_IPV4,
LOC_ENG_MSG_ENABLE_DATA,
LOC_ENG_MSG_SUPL_VERSION,
LOC_ENG_MSG_SET_SENSOR_CONTROL_CONFIG,
LOC_ENG_MSG_SET_SENSOR_PROPERTIES,
LOC_ENG_MSG_SET_SENSOR_PERF_CONTROL_CONFIG,
LOC_ENG_MSG_MUTE_SESSION,
LOC_ENG_MSG_ATL_OPEN_SUCCESS,
LOC_ENG_MSG_ATL_CLOSED,
LOC_ENG_MSG_ATL_OPEN_FAILED,
LOC_ENG_MSG_REPORT_POSITION,
LOC_ENG_MSG_REPORT_SV,
LOC_ENG_MSG_REPORT_STATUS,
LOC_ENG_MSG_REPORT_NMEA,
LOC_ENG_MSG_REQUEST_BIT,
LOC_ENG_MSG_RELEASE_BIT,
LOC_ENG_MSG_REQUEST_ATL,
LOC_ENG_MSG_RELEASE_ATL,
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
};
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* LOC_ENG_MSG_ID_H */

View file

@ -0,0 +1,313 @@
/* Copyright (c) 2009,2011 Code Aurora Forum. 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 Code Aurora Forum, 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 "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"
#include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
#include <pthread.h>
#include <errno.h>
#include <string.h>
#include <ctype.h>
#include <unistd.h>
#include <time.h>
#include <loc_eng.h>
#include "log_util.h"
/*=============================================================================
*
* DATA DECLARATION
*
*============================================================================*/
/*=============================================================================
*
* FUNCTION DECLARATIONS
*
*============================================================================*/
static void* ni_thread_proc(void *args);
/*===========================================================================
FUNCTION loc_eng_ni_request_handler
DESCRIPTION
Displays the NI request and awaits user input. If a previous request is
in session, it is ignored.
RETURN VALUE
none
===========================================================================*/
void loc_eng_ni_request_handler(loc_eng_data_s_type &loc_eng_data,
const GpsNiNotification *notif,
const void* passThrough)
{
ENTRY_LOG();
char lcs_addr[32]; // Decoded LCS address for UMTS CP NI
loc_eng_ni_data_s_type* loc_eng_ni_data_p = &loc_eng_data.loc_eng_ni_data;
if (NULL == loc_eng_data.ni_notify_cb) {
EXIT_LOG(%s, "loc_eng_ni_init hasn't happened yet.");
return;
}
/* If busy, use default or deny */
if (NULL != loc_eng_ni_data_p->rawRequest)
{
/* XXX Consider sending a NO RESPONSE reply or queue the request */
LOC_LOGW("loc_eng_ni_request_handler, notification in progress, new NI request ignored, type: %d",
notif->ni_type);
if (NULL != passThrough) {
free((void*)passThrough);
}
}
else {
/* Save request */
loc_eng_ni_data_p->rawRequest = (void*)passThrough;
/* Fill in notification */
((GpsNiNotification*)notif)->notification_id = loc_eng_ni_data_p->reqID;
if (notif->notify_flags == GPS_NI_PRIVACY_OVERRIDE)
{
loc_eng_mute_one_session(loc_eng_data);
}
/* Log requestor ID and text for debugging */
LOC_LOGI("Notification: notif_type: %d, timeout: %d, default_resp: %d", notif->ni_type, notif->timeout, notif->default_response);
LOC_LOGI(" requestor_id: %s (encoding: %d)", notif->requestor_id, notif->requestor_id_encoding);
LOC_LOGI(" text: %s text (encoding: %d)", notif->text, notif->text_encoding);
if (notif->extras[0])
{
LOC_LOGI(" extras: %s", notif->extras);
}
/* For robustness, spawn a thread at this point to timeout to clear up the notification status, even though
* the OEM layer in java does not do so.
**/
loc_eng_ni_data_p->respTimeLeft = 5 + (notif->timeout != 0 ? notif->timeout : LOC_NI_NO_RESPONSE_TIME);
LOC_LOGI("Automatically sends 'no response' in %d seconds (to clear status)\n", loc_eng_ni_data_p->respTimeLeft);
int rc = 0;
rc = pthread_create(&loc_eng_ni_data_p->thread, NULL, ni_thread_proc, &loc_eng_data);
if (rc)
{
LOC_LOGE("Loc NI thread is not created.\n");
}
rc = pthread_detach(loc_eng_ni_data_p->thread);
if (rc)
{
LOC_LOGE("Loc NI thread is not detached.\n");
}
CALLBACK_LOG_CALLFLOW("ni_notify_cb - id", %d, notif->notification_id);
loc_eng_data.ni_notify_cb((GpsNiNotification*)notif);
}
EXIT_LOG(%s, VOID_RET);
}
/*===========================================================================
FUNCTION ni_thread_proc
===========================================================================*/
static void* ni_thread_proc(void *args)
{
ENTRY_LOG();
loc_eng_data_s_type* loc_eng_data_p = (loc_eng_data_s_type*)args;
loc_eng_ni_data_s_type* loc_eng_ni_data_p = &loc_eng_data_p->loc_eng_ni_data;
int rc = 0; /* return code from pthread calls */
struct timeval present_time;
struct timespec expire_time;
LOC_LOGD("Starting Loc NI thread...\n");
pthread_mutex_lock(&loc_eng_ni_data_p->tLock);
/* Calculate absolute expire time */
gettimeofday(&present_time, NULL);
expire_time.tv_sec = present_time.tv_sec + loc_eng_ni_data_p->respTimeLeft;
expire_time.tv_nsec = present_time.tv_usec * 1000;
LOC_LOGD("ni_thread_proc-Time out set for abs time %ld with delay %d sec\n",
(long) expire_time.tv_sec, loc_eng_ni_data_p->respTimeLeft );
while (!loc_eng_ni_data_p->respRecvd)
{
rc = pthread_cond_timedwait(&loc_eng_ni_data_p->tCond,
&loc_eng_ni_data_p->tLock,
&expire_time);
if (rc == ETIMEDOUT)
{
loc_eng_ni_data_p->resp = GPS_NI_RESPONSE_NORESP;
LOC_LOGD("ni_thread_proc-Thread time out after valting for specified time. Ret Val %d\n",rc );
break;
}
}
LOC_LOGD("ni_thread_proc-Java layer has sent us a user response and return value from "
"pthread_cond_timedwait = %d\n",rc );
loc_eng_ni_data_p->respRecvd = FALSE; /* Reset the user response flag for the next session*/
// adding this check to support modem restart, in which case, we need the thread
// to exit without calling sending data to loc_eng_msg_q. We made sure that
// rawRequest is NULL in loc_eng_ni_reset_on_engine_restart()
loc_eng_msg_inform_ni_response *msg = NULL;
if (NULL != loc_eng_ni_data_p->rawRequest) {
loc_eng_data_s_type *loc_eng_data_p = (loc_eng_data_s_type*)args;
msg = new loc_eng_msg_inform_ni_response(loc_eng_data_p,
loc_eng_ni_data_p->resp,
loc_eng_ni_data_p->rawRequest);
loc_eng_ni_data_p->rawRequest = NULL;
}
pthread_mutex_unlock(&loc_eng_ni_data_p->tLock);
loc_eng_ni_data_p->respTimeLeft = 0;
loc_eng_ni_data_p->reqID++;
if (NULL != msg) {
loc_eng_msg_sender(loc_eng_data_p, msg);
}
EXIT_LOG(%s, VOID_RET);
return NULL;
}
void loc_eng_ni_reset_on_engine_restart(loc_eng_data_s_type &loc_eng_data)
{
ENTRY_LOG();
loc_eng_ni_data_s_type* loc_eng_ni_data_p = &loc_eng_data.loc_eng_ni_data;
if (NULL == loc_eng_data.ni_notify_cb) {
EXIT_LOG(%s, "loc_eng_ni_init hasn't happened yet.");
return;
}
// only if modem has requested but then died.
if (NULL != loc_eng_ni_data_p->rawRequest) {
free(loc_eng_ni_data_p->rawRequest);
loc_eng_ni_data_p->rawRequest = NULL;
pthread_mutex_lock(&loc_eng_ni_data_p->tLock);
// the goal is to wake up ni_thread_proc
// and let it exit.
loc_eng_ni_data_p->respRecvd = TRUE;
pthread_cond_signal(&loc_eng_ni_data_p->tCond);
pthread_mutex_unlock(&loc_eng_ni_data_p->tLock);
}
EXIT_LOG(%s, VOID_RET);
}
/*===========================================================================
FUNCTION loc_eng_ni_init
DESCRIPTION
This function initializes the NI interface
DEPENDENCIES
NONE
RETURN VALUE
None
SIDE EFFECTS
N/A
===========================================================================*/
void loc_eng_ni_init(loc_eng_data_s_type &loc_eng_data, GpsNiCallbacks *callbacks)
{
ENTRY_LOG_CALLFLOW();
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.");
} else {
loc_eng_ni_data_s_type* loc_eng_ni_data_p = &loc_eng_data.loc_eng_ni_data;
loc_eng_ni_data_p->respTimeLeft = 0;
loc_eng_ni_data_p->respRecvd = FALSE;
loc_eng_ni_data_p->rawRequest = NULL;
loc_eng_ni_data_p->reqID = 0;
pthread_cond_init(&loc_eng_ni_data_p->tCond, NULL);
pthread_mutex_init(&loc_eng_ni_data_p->tLock, NULL);
loc_eng_data.ni_notify_cb = callbacks->notify_cb;
EXIT_LOG(%s, VOID_RET);
}
}
/*===========================================================================
FUNCTION loc_eng_ni_respond
DESCRIPTION
This function receives user response from upper layer framework
DEPENDENCIES
NONE
RETURN VALUE
None
SIDE EFFECTS
N/A
===========================================================================*/
void loc_eng_ni_respond(loc_eng_data_s_type &loc_eng_data,
int notif_id, GpsUserResponseType user_response)
{
ENTRY_LOG_CALLFLOW();
loc_eng_ni_data_s_type* loc_eng_ni_data_p = &loc_eng_data.loc_eng_ni_data;
if (NULL == loc_eng_data.ni_notify_cb) {
EXIT_LOG(%s, "loc_eng_ni_init hasn't happened yet.");
return;
}
if (notif_id == loc_eng_ni_data_p->reqID &&
NULL != loc_eng_ni_data_p->rawRequest)
{
LOC_LOGI("loc_eng_ni_respond: send user response %d for notif %d", user_response, notif_id);
pthread_mutex_lock(&loc_eng_ni_data_p->tLock);
loc_eng_ni_data_p->resp = user_response;
loc_eng_ni_data_p->respRecvd = TRUE;
pthread_cond_signal(&loc_eng_ni_data_p->tCond);
pthread_mutex_unlock(&loc_eng_ni_data_p->tLock);
}
else {
LOC_LOGE("loc_eng_ni_respond: reqID %d and notif_id %d mismatch or rawRequest %p, response: %d",
loc_eng_ni_data_p->reqID, notif_id, loc_eng_ni_data_p->rawRequest, user_response);
}
EXIT_LOG(%s, VOID_RET);
}

View file

@ -0,0 +1,50 @@
/* Copyright (c) 2009,2011 Code Aurora Forum. 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 Code Aurora Forum, 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 "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_NI_H
#define LOC_ENG_NI_H
#include <stdbool.h>
#define LOC_NI_NO_RESPONSE_TIME 20 /* secs */
#define LOC_NI_NOTIF_KEY_ADDRESS "Address"
typedef struct {
pthread_t thread; /* NI thread */
int respTimeLeft; /* examine time for NI response */
bool respRecvd; /* NI User reponse received or not from Java layer*/
void* rawRequest;
int reqID; /* ID to check against response */
GpsUserResponseType resp;
pthread_cond_t tCond;
pthread_mutex_t tLock;
} loc_eng_ni_data_s_type;
#endif /* LOC_ENG_NI_H */

View file

@ -0,0 +1,90 @@
/* Copyright (c) 2009,2011 Code Aurora Forum. 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 Code Aurora Forum, 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 "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"
#include <loc_eng.h>
#include <loc_eng_msg.h>
#include "log_util.h"
/*===========================================================================
FUNCTION loc_eng_xtra_init
DESCRIPTION
Initialize XTRA module.
DEPENDENCIES
N/A
RETURN VALUE
0: success
SIDE EFFECTS
N/A
===========================================================================*/
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;
xtra_module_data_ptr = &loc_eng_data.xtra_module_data;
xtra_module_data_ptr->download_request_cb = callbacks->download_request_cb;
return 0;
}
/*===========================================================================
FUNCTION loc_eng_xtra_inject_data
DESCRIPTION
Injects XTRA file into the engine but buffers the data if engine is busy.
DEPENDENCIES
N/A
RETURN VALUE
0: success
>0: failure
SIDE EFFECTS
N/A
===========================================================================*/
int loc_eng_xtra_inject_data(loc_eng_data_s_type &loc_eng_data,
char* data, int length)
{
loc_eng_msg_inject_xtra_data *msg(new loc_eng_msg_inject_xtra_data(&loc_eng_data,
data, length));
loc_eng_msg_sender(&loc_eng_data, msg);
return 0;
}

View file

@ -0,0 +1,46 @@
/* Copyright (c) 2009,2011 Code Aurora Forum. 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 Code Aurora Forum, 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 "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_XTRA_H
#define LOC_ENG_XTRA_H
#include <hardware/gps.h>
// Module data
typedef struct
{
// loc_eng_ioctl_cb_data_s_type ioctl_cb_data;
gps_xtra_download_request download_request_cb;
// XTRA data buffer
char *xtra_data_for_injection; // NULL if no pending data
int xtra_data_len;
} loc_eng_xtra_data_s_type;
#endif // LOC_ENG_XTRA_H

43
loc_api/loc_api_v02/Android.mk Executable file
View file

@ -0,0 +1,43 @@
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_
## Includes
LOCAL_C_INCLUDES := \
$(TOP)/vendor/qcom/proprietary/qmi-framework/inc \
$(TOP)/vendor/qcom/proprietary/qmi-framework/qcci/inc \
$(TOP)/vendor/qcom/proprietary/qmi-framework/common/inc \
$(TARGET_OUT_HEADERS)/libloc_eng \
$(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

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