diff --git a/etc/Android.mk b/etc/Android.mk index 96dc5d78..025d3f74 100644 --- a/etc/Android.mk +++ b/etc/Android.mk @@ -7,5 +7,6 @@ LOCAL_MODULE_TAGS := optional LOCAL_MODULE_CLASS := ETC LOCAL_MODULE_PATH := $(TARGET_OUT_ETC)/ LOCAL_SRC_FILES := gps.conf + include $(BUILD_PREBUILT) diff --git a/etc/gps.conf b/etc/gps.conf index aeaf96ab..977e7b3a 100755 --- a/etc/gps.conf +++ b/etc/gps.conf @@ -1,8 +1,13 @@ -# Customized XTRA server urls can go here, which will -# override the default urls that are given by the modem -#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 +# XTRA_SERVER_QUERY (1=on, 0=off) +# If XTRA_SERVER_QUERY is on, the XTRA_SERVERs listed +# below will be ignored, and instead the servers will +# be queried from the modem. +XTRA_SERVER_QUERY=1 +# XTRA_SERVERs below are used only if XTRA_SERVER_QUERY +# is off. +XTRA_SERVER_1=http://xtra1.gpsonextra.net/xtra.bin +XTRA_SERVER_2=http://xtra2.gpsonextra.net/xtra.bin +XTRA_SERVER_3=http://xtra3.gpsonextra.net/xtra.bin # Error Estimate # _SET = 1 diff --git a/loc_api/libloc_api_50001/Android.mk b/loc_api/libloc_api_50001/Android.mk index f36ae4fe..9cb32fb8 100644 --- a/loc_api/libloc_api_50001/Android.mk +++ b/loc_api/libloc_api_50001/Android.mk @@ -114,6 +114,10 @@ LOCAL_CFLAGS += \ -fno-short-enums \ -D_ANDROID_ \ +ifeq ($(TARGET_USES_QCOM_BSP), true) +LOCAL_CFLAGS += -DTARGET_USES_QCOM_BSP +endif + ## Includes LOCAL_C_INCLUDES:= \ $(TARGET_OUT_HEADERS)/gps.utils \ diff --git a/loc_api/libloc_api_50001/loc.cpp b/loc_api/libloc_api_50001/loc.cpp index d7362477..868fbafa 100644 --- a/loc_api/libloc_api_50001/loc.cpp +++ b/loc_api/libloc_api_50001/loc.cpp @@ -97,6 +97,43 @@ static const GpsInterface sLocEngInterface = loc_get_extension }; +// Function declarations for sLocEngAGpsInterface +static void loc_agps_init(AGpsCallbacks* callbacks); +static int loc_agps_open(const char* apn); +static int loc_agps_closed(); +static int loc_agps_open_failed(); +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); @@ -254,12 +291,26 @@ static int loc_init(GpsCallbacks* callbacks) EXIT_LOG(%d, retVal); return retVal; } + +#ifdef TARGET_USES_QCOM_BSP LOC_API_ADAPTER_EVENT_MASK_T event = LOC_API_ADAPTER_BIT_PARSED_POSITION_REPORT | LOC_API_ADAPTER_BIT_SATELLITE_REPORT | LOC_API_ADAPTER_BIT_IOCTL_REPORT | LOC_API_ADAPTER_BIT_STATUS_REPORT | LOC_API_ADAPTER_BIT_NMEA_1HZ_REPORT; +#else + 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; +#endif + LocCallbacks clientCallbacks = {loc_cb, /* location_cb */ callbacks->status_cb, /* status_cb */ sv_cb, /* sv_status_cb */ @@ -490,8 +541,15 @@ SIDE EFFECTS ===========================================================================*/ static int loc_inject_time(GpsUtcTime time, int64_t timeReference, int uncertainty) { - //inject time not handled by AFW - return 0; + ENTRY_LOG(); + int ret_val = 0; + + #ifndef TARGET_USES_QCOM_BSP + ret_val = loc_eng_inject_time(loc_afw_data, time, timeReference, uncertainty); + #endif + + EXIT_LOG(%d, ret_val); + return ret_val; } @@ -655,15 +713,21 @@ const void* loc_get_extension(const char* name) LOC_LOGD("%s:%d] For Interface = %s\n",__func__, __LINE__, name); if (strcmp(name, GPS_XTRA_INTERFACE) == 0) { - //xtra not handled by AFW + #ifndef TARGET_USES_QCOM_BSP + ret_val = &sLocEngXTRAInterface; + #endif } else if (strcmp(name, AGPS_INTERFACE) == 0) { - //agps not handled by AFW + #ifndef TARGET_USES_QCOM_BSP + ret_val = &sLocEngAGpsInterface; + #endif } else if (strcmp(name, GPS_NI_INTERFACE) == 0) { - //ni not handled by AFW + #ifndef TARGET_USES_QCOM_BSP + ret_val = &sLocEngNiInterface; + #endif } else if (strcmp(name, AGPS_RIL_INTERFACE) == 0) { @@ -702,6 +766,244 @@ const void* loc_get_extension(const char* name) 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, (AGpsExtCallbacks*)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 + +===========================================================================*/ +static int loc_agps_open(const char* apn) +{ + ENTRY_LOG(); + AGpsType agpsType = AGPS_TYPE_SUPL; + AGpsBearerType bearerType = AGPS_APN_BEARER_IPV4; + int ret_val = loc_eng_agps_open(loc_afw_data, agpsType, apn, bearerType); + + EXIT_LOG(%d, ret_val); + return ret_val; +} + +/*=========================================================================== +FUNCTION loc_agps_closed + +DESCRIPTION + This function is called when on-demand data connection closing is done. +It should inform ARM 9 about the data close result. + +DEPENDENCIES + NONE + +RETURN VALUE + 0 + +SIDE EFFECTS + N/A + +===========================================================================*/ +static int loc_agps_closed() +{ + ENTRY_LOG(); + AGpsType agpsType = AGPS_TYPE_SUPL; + int ret_val = loc_eng_agps_closed(loc_afw_data, agpsType); + + EXIT_LOG(%d, ret_val); + return ret_val; +} + +/*=========================================================================== +FUNCTION loc_agps_open_failed + +DESCRIPTION + This function is called when on-demand data connection opening has failed. +It should inform ARM 9 about the data open result. + +DEPENDENCIES + NONE + +RETURN VALUE + 0 + +SIDE EFFECTS + N/A + +===========================================================================*/ +int loc_agps_open_failed() +{ + ENTRY_LOG(); + AGpsType agpsType = AGPS_TYPE_SUPL; + int ret_val = loc_eng_agps_open_failed(loc_afw_data, agpsType); + + EXIT_LOG(%d, ret_val); + return ret_val; +} + +/*=========================================================================== +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, (GpsXtraExtCallbacks*)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,(GpsNiExtCallbacks*) 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) {}