From 9f8bcc3b142e28ca7d3c04e556dbb39435ddef1d Mon Sep 17 00:00:00 2001 From: Satheesh Jayakumar Date: Mon, 24 Dec 2012 14:43:42 -0800 Subject: [PATCH] Ulp: Adds interfacing b/w FusedLocationProv & ULP engine Changes for providing the plumbing from UlpService down to the native UlpEngine. Change-Id: I67e48fad47675d9fa9a3026763daa0f248369f60 CRs-Fixed: 443444 --- loc_api/Android.mk | 2 +- .../libloc_api-rpc-glue/Android.mk | 4 - .../src/LocApiRpcAdapter.cpp | 36 +- loc_api/libloc_api/loc_eng.cpp | 10 +- loc_api/libloc_api_50001/Android.mk | 11 +- loc_api/libloc_api_50001/LocApiAdapter.cpp | 14 +- loc_api/libloc_api_50001/LocApiAdapter.h | 6 +- loc_api/libloc_api_50001/loc.cpp | 204 ++++++--- loc_api/libloc_api_50001/loc.h | 5 +- loc_api/libloc_api_50001/loc_eng.cpp | 48 +- loc_api/libloc_api_50001/loc_eng.h | 19 +- loc_api/libloc_api_50001/loc_eng_log.cpp | 4 +- loc_api/libloc_api_50001/loc_eng_msg.h | 58 +-- loc_api/libloc_api_50001/loc_eng_msg_id.h | 5 +- loc_api/libloc_api_50001/loc_eng_nmea.cpp | 48 +- loc_api/libloc_api_50001/loc_eng_nmea.h | 2 +- loc_api/libloc_api_50001/loc_ulp.h | 418 ++++++++++++++++++ loc_api/loc_api_v02/Android.mk | 4 - loc_api/loc_api_v02/LocApiV02Adapter.cpp | 34 +- 19 files changed, 677 insertions(+), 255 deletions(-) create mode 100644 loc_api/libloc_api_50001/loc_ulp.h diff --git a/loc_api/Android.mk b/loc_api/Android.mk index 08e46129..ec271e24 100644 --- a/loc_api/Android.mk +++ b/loc_api/Android.mk @@ -6,7 +6,7 @@ GPS_DIR_LIST := FEATURE_IPV6 := true FEATURE_DELEXT := true -FEATURE_ULP := false +FEATURE_ULP := true # add RPC dirs if RPC is available ifneq ($(TARGET_NO_RPC),true) diff --git a/loc_api/libloc_api-rpc-50001/libloc_api-rpc-glue/Android.mk b/loc_api/libloc_api-rpc-50001/libloc_api-rpc-glue/Android.mk index b12ceae6..ea23dadc 100644 --- a/loc_api/libloc_api-rpc-50001/libloc_api-rpc-glue/Android.mk +++ b/loc_api/libloc_api-rpc-50001/libloc_api-rpc-glue/Android.mk @@ -24,10 +24,6 @@ ifeq ($(FEATURE_IPV6), true) LOCAL_CFLAGS += -DFEATURE_IPV6 endif #FEATURE_IPV6 -ifeq ($(FEATURE_ULP), true) -LOCAL_CFLAGS += -DFEATURE_ULP -endif #FEATURE_ULP - LOCAL_SHARED_LIBRARIES:= \ librpc \ libutils \ diff --git a/loc_api/libloc_api-rpc-50001/libloc_api-rpc-glue/src/LocApiRpcAdapter.cpp b/loc_api/libloc_api-rpc-50001/libloc_api-rpc-glue/src/LocApiRpcAdapter.cpp index af87ab99..bcd82ff2 100644 --- a/loc_api/libloc_api-rpc-50001/libloc_api-rpc-glue/src/LocApiRpcAdapter.cpp +++ b/loc_api/libloc_api-rpc-50001/libloc_api-rpc-glue/src/LocApiRpcAdapter.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2011-2012, The Linux Foundation. All rights reserved. +/* Copyright (c) 2011-2013, The Linux Foundation. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -627,7 +627,7 @@ void LocApiRpcAdapter::reportPosition(const rpc_loc_parsed_position_s_type *loca { LocPosTechMask tech_Mask = LOC_POS_TECH_MASK_DEFAULT; - GpsLocation location = {0}; + UlpLocation location = {0}; GpsLocationExtended locationExtended = {0}; location.size = sizeof(location); @@ -644,54 +644,52 @@ void LocApiRpcAdapter::reportPosition(const rpc_loc_parsed_position_s_type *loca (location_report_ptr->latitude != 0 || location_report_ptr->longitude != 0)) { - location.flags |= GPS_LOCATION_HAS_LAT_LONG; - location.latitude = location_report_ptr->latitude; - location.longitude = location_report_ptr->longitude; + location.gpsLocation.flags |= GPS_LOCATION_HAS_LAT_LONG; + location.gpsLocation.latitude = location_report_ptr->latitude; + location.gpsLocation.longitude = location_report_ptr->longitude; // Time stamp (UTC) if (location_report_ptr->valid_mask & RPC_LOC_POS_VALID_TIMESTAMP_UTC) { - location.timestamp = location_report_ptr->timestamp_utc; + location.gpsLocation.timestamp = location_report_ptr->timestamp_utc; } // Altitude if (location_report_ptr->valid_mask & RPC_LOC_POS_VALID_ALTITUDE_WRT_ELLIPSOID ) { - location.flags |= GPS_LOCATION_HAS_ALTITUDE; - location.altitude = location_report_ptr->altitude_wrt_ellipsoid; + location.gpsLocation.flags |= GPS_LOCATION_HAS_ALTITUDE; + location.gpsLocation.altitude = location_report_ptr->altitude_wrt_ellipsoid; } // Speed if ((location_report_ptr->valid_mask & RPC_LOC_POS_VALID_SPEED_HORIZONTAL) && (location_report_ptr->valid_mask & RPC_LOC_POS_VALID_SPEED_VERTICAL)) { - location.flags |= GPS_LOCATION_HAS_SPEED; - location.speed = sqrt(location_report_ptr->speed_horizontal * location_report_ptr->speed_horizontal + + location.gpsLocation.flags |= GPS_LOCATION_HAS_SPEED; + location.gpsLocation.speed = sqrt(location_report_ptr->speed_horizontal * location_report_ptr->speed_horizontal + location_report_ptr->speed_vertical * location_report_ptr->speed_vertical); } // Heading if (location_report_ptr->valid_mask & RPC_LOC_POS_VALID_HEADING) { - location.flags |= GPS_LOCATION_HAS_BEARING; - location.bearing = location_report_ptr->heading; + location.gpsLocation.flags |= GPS_LOCATION_HAS_BEARING; + location.gpsLocation.bearing = location_report_ptr->heading; } // Uncertainty (circular) if ( (location_report_ptr->valid_mask & RPC_LOC_POS_VALID_HOR_UNC_CIRCULAR) ) { - location.flags |= GPS_LOCATION_HAS_ACCURACY; - location.accuracy = location_report_ptr->hor_unc_circular; + location.gpsLocation.flags |= GPS_LOCATION_HAS_ACCURACY; + location.gpsLocation.accuracy = location_report_ptr->hor_unc_circular; } - // Technology Mask + // Technology Mask tech_Mask |= location_report_ptr->technology_mask; -#ifdef FEATURE_ULP //Mark the location source as from GNSS - location.flags |= LOCATION_HAS_SOURCE_INFO; + location.gpsLocation.flags |= LOCATION_HAS_SOURCE_INFO; location.position_source = ULP_LOCATION_IS_FROM_GNSS; -#endif if (location_report_ptr->valid_mask & RPC_LOC_POS_VALID_ALTITUDE_WRT_MEAN_SEA_LEVEL) { locationExtended.flags |= GPS_LOCATION_EXTENDED_HAS_MAG_DEV; @@ -710,7 +708,7 @@ void LocApiRpcAdapter::reportPosition(const rpc_loc_parsed_position_s_type *loca locEngHandle.extPosInfo((void*)location_report_ptr), (location_report_ptr->session_status == RPC_LOC_SESS_STATUS_IN_PROGESS ? LOC_SESS_INTERMEDIATE : LOC_SESS_SUCCESS), - tech_Mask); + tech_Mask); } } else diff --git a/loc_api/libloc_api/loc_eng.cpp b/loc_api/libloc_api/loc_eng.cpp index 98fef66f..944326b0 100644 --- a/loc_api/libloc_api/loc_eng.cpp +++ b/loc_api/libloc_api/loc_eng.cpp @@ -78,8 +78,8 @@ static int loc_eng_agps_data_conn_failed(); static int loc_eng_agps_set_server(AGpsType type, const char* hostname, int port); -static int32 loc_event_cb (rpc_loc_client_handle_type client_handle, - rpc_loc_event_mask_type loc_event, +static int32 loc_event_cb (rpc_loc_client_handle_type client_handle, + rpc_loc_event_mask_type loc_event, const rpc_loc_event_payload_u_type* loc_event_payload); static void loc_eng_report_position (const rpc_loc_parsed_position_s_type *location_report_ptr); static void loc_eng_report_sv (const rpc_loc_gnss_info_s_type *gnss_report_ptr); @@ -743,7 +743,7 @@ SIDE EFFECTS ===========================================================================*/ static void loc_eng_report_position (const rpc_loc_parsed_position_s_type *location_report_ptr) { - GpsLocation location; + UlpLocation location; LOGV ("loc_eng_report_position: location report, valid mask = 0x%x, sess status = %d\n", (uint32) location_report_ptr->valid_mask, location_report_ptr->session_status); @@ -831,7 +831,7 @@ static void loc_eng_report_sv (const rpc_loc_gnss_info_s_type *gnss_report_ptr) { GpsSvStatus SvStatus; int num_svs_max, i; - const rpc_loc_sv_info_s_type *sv_info_ptr; + const rpc_loc_sv_info_s_type *sv_info_ptr; LOGV ("loc_eng_report_sv: valid_mask = 0x%x, num of sv = %d\n", (uint32) gnss_report_ptr->valid_mask, @@ -1273,7 +1273,7 @@ static void loc_eng_process_atl_deferred_action (int flags) 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)); - + if (flags & DEFERRED_ACTION_AGPS_DATA_CLOSED) { ioctl_data.disc = RPC_LOC_IOCTL_INFORM_SERVER_CLOSE_STATUS; diff --git a/loc_api/libloc_api_50001/Android.mk b/loc_api/libloc_api_50001/Android.mk index 3ea5e918..c91405d3 100755 --- a/loc_api/libloc_api_50001/Android.mk +++ b/loc_api/libloc_api_50001/Android.mk @@ -31,10 +31,6 @@ ifeq ($(FEATURE_DELEXT), true) LOCAL_CFLAGS += -DFEATURE_DELEXT endif #FEATURE_DELEXT -ifeq ($(FEATURE_ULP), true) -LOCAL_CFLAGS += -DFEATURE_ULP -endif #FEATURE_ULP - LOCAL_C_INCLUDES:= \ $(TARGET_OUT_HEADERS)/gps.utils @@ -48,7 +44,8 @@ LOCAL_COPY_HEADERS:= \ loc_eng_agps.h \ loc_eng_msg.h \ loc_eng_msg_id.h \ - loc_eng_log.h + loc_eng_log.h \ + loc_ulp.h LOCAL_PRELINK_MODULE := false @@ -89,10 +86,6 @@ ifeq ($(FEATURE_IPV6), true) LOCAL_CFLAGS += -DFEATURE_IPV6 endif #FEATURE_IPV6 -ifeq ($(FEATURE_ULP), true) -LOCAL_CFLAGS += -DFEATURE_ULP -endif #FEATURE_ULP - LOCAL_C_INCLUDES:= \ $(TARGET_OUT_HEADERS)/gps.utils \ hardware/qcom/gps/loc_api/ulp/inc diff --git a/loc_api/libloc_api_50001/LocApiAdapter.cpp b/loc_api/libloc_api_50001/LocApiAdapter.cpp index aac34df7..8e5b1ee1 100644 --- a/loc_api/libloc_api_50001/LocApiAdapter.cpp +++ b/loc_api/libloc_api_50001/LocApiAdapter.cpp @@ -45,17 +45,13 @@ LocEng::LocEng(void* caller, gps_acquire_wakelock acqwl, gps_release_wakelock relwl, loc_msg_sender msgSender, -#ifdef FEATURE_ULP loc_msg_sender msgUlpSender, -#endif loc_ext_parser posParser, loc_ext_parser svParser) : owner(caller), eventMask(emask), acquireWakelock(acqwl), releaseWakeLock(relwl), sendMsge(msgSender), -#ifdef FEATURE_ULP sendUlpMsg(msgUlpSender), -#endif extPosInfo(NULL == posParser ? noProc : posParser), extSvInfo(NULL == svParser ? noProc : svParser) { @@ -140,7 +136,7 @@ int LocApiAdapter::decodeAddress(char *addr_string, int string_size, return idxOutput; } -void LocApiAdapter::reportPosition(GpsLocation &location, +void LocApiAdapter::reportPosition(UlpLocation &location, GpsLocationExtended &locationExtended, void* locationExt, enum loc_sess_status status, @@ -152,22 +148,17 @@ void LocApiAdapter::reportPosition(GpsLocation &location, locationExt, status, loc_technology_mask)); -#ifdef FEATURE_ULP if (locEngHandle.sendUlpMsg) { locEngHandle.sendUlpMsg(locEngHandle.owner, msg); } else { locEngHandle.sendMsge(locEngHandle.owner, msg); } -#else - locEngHandle.sendMsge(locEngHandle.owner, msg); -#endif } void LocApiAdapter::reportSv(GpsSvStatus &svStatus, GpsLocationExtended &locationExtended, void* svExt) { loc_eng_msg_report_sv *msg(new loc_eng_msg_report_sv(locEngHandle.owner, svStatus, locationExtended, svExt)); -#ifdef FEATURE_ULP //We want to send SV info to ULP to help it in determining GNSS signal strength //ULP will forward the SV reports to HAL without any modifications if (locEngHandle.sendUlpMsg) { @@ -175,9 +166,6 @@ void LocApiAdapter::reportSv(GpsSvStatus &svStatus, GpsLocationExtended &locatio } else { locEngHandle.sendMsge(locEngHandle.owner, msg); } -#else - locEngHandle.sendMsge(locEngHandle.owner, msg); -#endif } void LocApiAdapter::reportStatus(GpsStatusValue status) diff --git a/loc_api/libloc_api_50001/LocApiAdapter.h b/loc_api/libloc_api_50001/LocApiAdapter.h index a94617ed..65fac91a 100644 --- a/loc_api/libloc_api_50001/LocApiAdapter.h +++ b/loc_api/libloc_api_50001/LocApiAdapter.h @@ -89,9 +89,7 @@ struct LocEng { const gps_acquire_wakelock acquireWakelock; const gps_release_wakelock releaseWakeLock; const loc_msg_sender sendMsge; -#ifdef FEATURE_ULP const loc_msg_sender sendUlpMsg; -#endif const loc_ext_parser extPosInfo; const loc_ext_parser extSvInfo; @@ -100,9 +98,7 @@ struct LocEng { gps_acquire_wakelock acqwl, gps_release_wakelock relwl, loc_msg_sender msgSender, -#ifdef FEATURE_ULP loc_msg_sender msgUlpSender, -#endif loc_ext_parser posParser, loc_ext_parser svParser); }; @@ -126,7 +122,7 @@ public: static int decodeAddress(char *addr_string, int string_size, const char *data, int data_size); - void reportPosition(GpsLocation &location, + void reportPosition(UlpLocation &location, GpsLocationExtended &locationExtended, void* locationExt, enum loc_sess_status status, diff --git a/loc_api/libloc_api_50001/loc.cpp b/loc_api/libloc_api_50001/loc.cpp index 11103a38..6592cc5a 100644 --- a/loc_api/libloc_api_50001/loc.cpp +++ b/loc_api/libloc_api_50001/loc.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2011-2012, The Linux Foundation. All rights reserved. +/* Copyright (c) 2011-2013, The Linux Foundation. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -31,6 +31,7 @@ #define LOG_TAG "LocSvc_afw" #include +#include #include #include #include @@ -43,15 +44,13 @@ #include -#ifdef FEATURE_ULP //Globals defns static const ulpInterface * loc_eng_ulp_inf = NULL; static const ulpInterface * loc_eng_get_ulp_inf(void); -#endif static gps_location_callback gps_loc_cb = NULL; static gps_sv_status_callback gps_sv_cb = NULL; -static void loc_cb(GpsLocation* location, void* locExt); +static void loc_cb(UlpLocation* location, void* locExt); static void sv_cb(GpsSvStatus* sv_status, void* svExt); // Function declarations for sLocEngInterface @@ -65,16 +64,19 @@ static void loc_delete_aiding_data(GpsAidingData f); static int loc_set_position_mode(GpsPositionMode mode, GpsPositionRecurrence recurrence, uint32_t min_interval, uint32_t preferred_accuracy, uint32_t preferred_time); -static const void* loc_get_extension(const char* name); -#ifdef FEATURE_ULP //ULP/Hybrid provider Function definitions -static int loc_update_criteria(UlpLocationCriteria criteria); static int loc_ulp_network_init(UlpNetworkLocationCallbacks *callbacks); static int loc_ulp_send_network_position(UlpNetworkPositionReport *position_report); static int loc_ulp_phone_context_init(UlpPhoneContextCallbacks *callback); static int loc_ulp_phone_context_settings_update(UlpPhoneContextSettings *settings); -#endif +static int loc_ulp_engine_update_criteria(UlpLocationCriteria criteria); +static const void* loc_get_extension(const char* name); +static ulp_location_callback ulp_loc_cb = NULL; +static int loc_ulp_engine_init(UlpEngineCallbacks* callbacks); +static int loc_ulp_engine_start(); +static int loc_ulp_engine_stop(); + // Defines the GpsInterface in gps.h static const GpsInterface sLocEngInterface = @@ -89,9 +91,6 @@ static const GpsInterface sLocEngInterface = loc_delete_aiding_data, loc_set_position_mode, loc_get_extension -#ifdef FEATURE_ULP - ,loc_update_criteria -#endif }; // Function declarations for sLocEngAGpsInterface @@ -156,7 +155,16 @@ static const AGpsRilInterface sLocEngAGpsRilInterface = loc_agps_ril_update_network_availability }; -#ifdef FEATURE_ULP +static const UlpEngineInterface sLocEngUlpEngInterface = +{ + sizeof(UlpEngineInterface), + loc_ulp_engine_init, + loc_ulp_engine_update_criteria, + loc_ulp_engine_start, + loc_ulp_engine_stop +}; + + static bool loc_inject_raw_command(char* command, int length); static const InjectRawCmdInterface sLocEngInjectRawCmdInterface = @@ -178,7 +186,7 @@ static const UlpPhoneContextInterface sLocEngUlpPhoneContextInterface = loc_ulp_phone_context_init, loc_ulp_phone_context_settings_update }; -#endif + static loc_eng_data_s_type loc_afw_data; static int gss_fd = 0; @@ -283,12 +291,12 @@ const GpsInterface* gps_get_hardware_interface () extern "C" const GpsInterface* get_gps_interface() { loc_eng_read_config(); -#ifdef FEATURE_ULP + //We load up libulp module at this point itself if ULP configured to be On if(gps_conf.CAPABILITIES & ULP_CAPABILITY) { loc_eng_ulp_inf = loc_eng_get_ulp_inf(); } -#endif + if (get_target_name() == TARGET_NAME_APQ8064_STANDALONE) { gps_conf.CAPABILITIES &= ~(GPS_CAPABILITY_MSA | GPS_CAPABILITY_MSB); @@ -307,13 +315,11 @@ static void loc_free_msg(void* msg) delete (loc_eng_msg*)msg; } -#ifdef FEATURE_ULP void loc_ulp_msg_sender(void* loc_eng_data_p, void* msg) { LocEngContext* loc_eng_context = (LocEngContext*)((loc_eng_data_s_type*)loc_eng_data_p)->context; msg_q_snd((void*)loc_eng_context->ulp_q, msg, loc_free_msg); } -#endif /*=========================================================================== FUNCTION loc_init @@ -364,7 +370,6 @@ static int loc_init(GpsCallbacks* callbacks) gps_loc_cb = callbacks->location_cb; gps_sv_cb = callbacks->sv_status_cb; -#ifdef FEATURE_ULP if (loc_eng_ulp_inf == NULL) retVal = loc_eng_init(loc_afw_data, &clientCallbacks, event, NULL); @@ -373,11 +378,9 @@ static int loc_init(GpsCallbacks* callbacks) loc_ulp_msg_sender); int ret_val1 = loc_eng_ulp_init(loc_afw_data, loc_eng_ulp_inf); + //Initialize the cached min_interval + loc_afw_data.min_interval_cached = ULP_MIN_INTERVAL_INVALID; LOC_LOGD("loc_eng_ulp_init returned %d\n",ret_val1); -#else - retVal = loc_eng_init(loc_afw_data, &clientCallbacks, event, - NULL); -#endif EXIT_LOG(%d, retVal); return retVal; @@ -461,8 +464,26 @@ SIDE EFFECTS static int loc_stop() { ENTRY_LOG(); - int ret_val = loc_eng_stop(loc_afw_data); - + int ret_val = -1; + if (loc_afw_data.ulp_initialized) { + //ULP initialized so we need to simulate REMOVE_CRITERIA for + //last client to libulp and we dont need to send loc_eng_stop + UlpLocationCriteria native_criteria; + native_criteria.valid_mask = (ULP_CRITERIA_HAS_ACTION | ULP_CRITERIA_HAS_PROVIDER_SOURCE | ULP_CRITERIA_HAS_RECURRENCE_TYPE | + ULP_CRITERIA_HAS_MIN_INTERVAL); + native_criteria.provider_source = ULP_PROVIDER_SOURCE_GNSS; + native_criteria.min_distance = 0; //This is not used by ULP engine so leaving it 0 for now + native_criteria.recurrence_type = ULP_LOC_RECURRENCE_PERIODIC; //We let LMS handle SingleShot + //For a GPS client horizontal_accuracy & power_consumption are irrelevant + native_criteria.preferred_horizontal_accuracy = ULP_HORZ_ACCURACY_DONT_CARE; + native_criteria.preferred_power_consumption = ULP_POWER_REQ_DONT_CARE; + native_criteria.action = ULP_REMOVE_CRITERIA; + native_criteria.min_interval = loc_afw_data.min_interval_cached; + loc_afw_data.min_interval_cached = ULP_MIN_INTERVAL_INVALID; + ret_val = loc_eng_update_criteria(loc_afw_data, native_criteria); + } else { + ret_val = loc_eng_stop(loc_afw_data); + } EXIT_LOG(%d, ret_val); return ret_val; } @@ -490,22 +511,40 @@ static int loc_set_position_mode(GpsPositionMode mode, uint32_t preferred_time) { ENTRY_LOG(); - LocPositionMode locMode; - switch (mode) { - case GPS_POSITION_MODE_MS_BASED: - locMode = LOC_POSITION_MODE_MS_BASED; - break; - case GPS_POSITION_MODE_MS_ASSISTED: - locMode = LOC_POSITION_MODE_MS_ASSISTED; - break; - default: - locMode = LOC_POSITION_MODE_STANDALONE; - break; - } + int ret_val = -1; + if (!loc_afw_data.ulp_initialized) { + LocPositionMode locMode; + switch (mode) { + case GPS_POSITION_MODE_MS_BASED: + locMode = LOC_POSITION_MODE_MS_BASED; + break; + case GPS_POSITION_MODE_MS_ASSISTED: + locMode = LOC_POSITION_MODE_MS_ASSISTED; + break; + default: + locMode = LOC_POSITION_MODE_STANDALONE; + break; + } - LocPosMode params(locMode, recurrence, min_interval, - preferred_accuracy, preferred_time, NULL, NULL); - int ret_val = loc_eng_set_position_mode(loc_afw_data, params); + LocPosMode params(locMode, recurrence, min_interval, + preferred_accuracy, preferred_time, NULL, NULL); + ret_val = loc_eng_set_position_mode(loc_afw_data, params); + } else { + //ULP initialized so suppress set_position_mode updates to loc_eng + UlpLocationCriteria native_criteria; + native_criteria.valid_mask = (ULP_CRITERIA_HAS_ACTION | ULP_CRITERIA_HAS_PROVIDER_SOURCE | ULP_CRITERIA_HAS_RECURRENCE_TYPE | + ULP_CRITERIA_HAS_MIN_INTERVAL); + native_criteria.provider_source = ULP_PROVIDER_SOURCE_GNSS; + native_criteria.min_distance = 0; //This is not used by ULP engine so leaving it 0 for now + native_criteria.recurrence_type = ULP_LOC_RECURRENCE_PERIODIC; //We let LMS handle SingleShot + //For a GPS client horizontal_accuracy & power_consumption are irrelevant + native_criteria.preferred_horizontal_accuracy = ULP_HORZ_ACCURACY_DONT_CARE; + native_criteria.preferred_power_consumption = ULP_POWER_REQ_DONT_CARE; + native_criteria.action = ULP_ADD_CRITERIA; + native_criteria.min_interval = min_interval; + loc_afw_data.min_interval_cached = min_interval; //cache a copy + ret_val = loc_eng_update_criteria(loc_afw_data, native_criteria); + } EXIT_LOG(%d, ret_val); return ret_val; @@ -613,7 +652,6 @@ static void loc_delete_aiding_data(GpsAidingData f) EXIT_LOG(%s, VOID_RET); } -#ifdef FEATURE_ULP /*=========================================================================== FUNCTION loc_update_criteria @@ -630,7 +668,7 @@ SIDE EFFECTS N/A ===========================================================================*/ -static int loc_update_criteria(UlpLocationCriteria criteria) +int loc_ulp_engine_update_criteria(UlpLocationCriteria criteria) { ENTRY_LOG(); int ret_val = loc_eng_update_criteria(loc_afw_data, criteria); @@ -638,7 +676,6 @@ static int loc_update_criteria(UlpLocationCriteria criteria) EXIT_LOG(%d, ret_val); return ret_val; } -#endif /*=========================================================================== FUNCTION loc_get_extension @@ -656,11 +693,12 @@ SIDE EFFECTS N/A ===========================================================================*/ -static const void* loc_get_extension(const char* name) +const void* loc_get_extension(const char* name) { ENTRY_LOG(); const void* ret_val = NULL; + LOC_LOGD("%s:%d] For Interface = %s\n",__func__, __LINE__, name); if (strcmp(name, GPS_XTRA_INTERFACE) == 0) { ret_val = &sLocEngXTRAInterface; @@ -685,7 +723,10 @@ static const void* loc_get_extension(const char* name) ret_val = &sLocEngAGpsRilInterface; } } -#ifdef FEATURE_ULP + else if (strcmp(name, ULP_ENGINE_INTERFACE) == 0) + { + ret_val = &sLocEngUlpEngInterface; + } else if (strcmp(name, ULP_RAW_CMD_INTERFACE) == 0) { ret_val = &sLocEngInjectRawCmdInterface; @@ -701,7 +742,7 @@ static const void* loc_get_extension(const char* name) if(gps_conf.CAPABILITIES & ULP_CAPABILITY) ret_val = &sUlpNetworkInterface; } -#endif + else { LOC_LOGE ("get_extension: Invalid interface passed in\n"); @@ -1009,7 +1050,6 @@ static void loc_agps_ril_update_network_availability(int available, const char* EXIT_LOG(%s, VOID_RET); } -#ifdef FEATURE_ULP /*=========================================================================== FUNCTION loc_inject_raw_command @@ -1033,18 +1073,21 @@ static bool loc_inject_raw_command(char* command, int length) EXIT_LOG(%s, loc_logger_boolStr[ret_val!=0]); return ret_val; } -#endif -static void loc_cb(GpsLocation* location, void* locExt) +static void loc_cb(UlpLocation* location, void* locExt) { ENTRY_LOG(); - if (NULL != gps_loc_cb && NULL != location) { -#ifdef FEATURE_ULP + if (NULL != location) { CALLBACK_LOG_CALLFLOW("location_cb - from", %d, location->position_source); -#else - CALLBACK_LOG_CALLFLOW("location_cb - at", %llu, location->timestamp); -#endif - gps_loc_cb(location); + if (ULP_LOCATION_IS_FROM_GNSS == location->position_source ) { + if (NULL != gps_loc_cb) { + gps_loc_cb(&location->gpsLocation); + } + } else { + if (NULL != ulp_loc_cb) { + ulp_loc_cb(location); + } + } } EXIT_LOG(%s, VOID_RET); } @@ -1059,7 +1102,6 @@ static void sv_cb(GpsSvStatus* sv_status, void* svExt) EXIT_LOG(%s, VOID_RET); } -#ifdef FEATURE_ULP /*=========================================================================== FUNCTION loc_eng_get_ulp_inf @@ -1213,4 +1255,54 @@ int loc_ulp_send_network_position(UlpNetworkPositionReport *position_report) EXIT_LOG(%d, ret_val); return ret_val; } -#endif + +/*=========================================================================== +FUNCTION loc_ulp_engine_init + +DESCRIPTION + Initialize the ULP Engine interface. + +DEPENDENCIES + NONE + +RETURN VALUE + 0 + +SIDE EFFECTS + N/A + +===========================================================================*/ +static int loc_ulp_engine_init(UlpEngineCallbacks* callbacks) +{ + int retVal = -1; + ENTRY_LOG(); + if(callbacks == NULL) { + LOC_LOGE("loc_ulp_engine_init failed. cb = NULL\n"); + EXIT_LOG(%d, retVal); + return retVal; + } + ulp_loc_cb = callbacks->location_cb; + retVal = 0; + EXIT_LOG(%d, retVal); + return retVal; +} + +static int loc_ulp_engine_start() +{ + ENTRY_LOG(); + int ret_val = loc_eng_start(loc_afw_data); + + EXIT_LOG(%d, ret_val); + return ret_val; +} + +static int loc_ulp_engine_stop() +{ + ENTRY_LOG(); + int ret_val = loc_eng_stop(loc_afw_data); + + EXIT_LOG(%d, ret_val); + return ret_val; +} + + diff --git a/loc_api/libloc_api_50001/loc.h b/loc_api/libloc_api_50001/loc.h index 93ff73b6..bdf05d57 100644 --- a/loc_api/libloc_api_50001/loc.h +++ b/loc_api/libloc_api_50001/loc.h @@ -37,6 +37,7 @@ extern "C" { #include #include #include +#include #define MIN_POSSIBLE_FIX_INTERVAL 1000 /* msec */ @@ -58,7 +59,7 @@ typedef enum loc_position_mode_type { LOC_POSITION_MODE_RESERVED_5 } LocPositionMode; -typedef void (*loc_location_cb_ext) (GpsLocation* location, void* locExt); +typedef void (*loc_location_cb_ext) (UlpLocation* location, void* locExt); typedef void (*loc_sv_status_cb_ext) (GpsSvStatus* sv_status, void* svExt); typedef void* (*loc_ext_parser)(void* data); @@ -91,9 +92,7 @@ typedef uint32_t LocPosTechMask; #define LOC_POS_TECH_MASK_REFERENCE_LOCATION ((LocPosTechMask)0x00000010) #define LOC_POS_TECH_MASK_INJECTED_COARSE_POSITION ((LocPosTechMask)0x00000020) -#ifdef FEATURE_ULP void loc_ulp_msg_sender(void* loc_eng_data_p, void* msg); -#endif #ifdef __cplusplus } diff --git a/loc_api/libloc_api_50001/loc_eng.cpp b/loc_api/libloc_api_50001/loc_eng.cpp index 5c37cbb6..caa01ec2 100644 --- a/loc_api/libloc_api_50001/loc_eng.cpp +++ b/loc_api/libloc_api_50001/loc_eng.cpp @@ -153,10 +153,10 @@ static void loc_default_parameters(void) LocEngContext::LocEngContext(gps_create_thread threadCreator) : deferred_q((const void*)loc_eng_create_msg_q()), -#ifdef FEATURE_ULP + //TODO: should we conditionally create ulp msg q? ulp_q((const void*)loc_eng_create_msg_q()), -#endif + deferred_action_thread(threadCreator("loc_eng",loc_eng_deferred_action_thread, this)), counter(0) { @@ -193,9 +193,9 @@ void LocEngContext::drop() pthread_cond_wait(&cond, &lock); msg_q_destroy((void**)&deferred_q); -#ifdef FEATURE_ULP + msg_q_destroy((void**)&ulp_q); -#endif + delete me; me = NULL; } @@ -326,15 +326,9 @@ int loc_eng_init(loc_eng_data_s_type &loc_eng_data, LocCallbacks* callbacks, loc_eng_data.generateNmea = false; } -#ifdef FEATURE_ULP LocEng locEngHandle(&loc_eng_data, event, loc_eng_data.acquire_wakelock_cb, loc_eng_data.release_wakelock_cb, loc_eng_msg_sender, loc_external_msg_sender, callbacks->location_ext_parser, callbacks->sv_ext_parser); -#else - LocEng locEngHandle(&loc_eng_data, event, loc_eng_data.acquire_wakelock_cb, - loc_eng_data.release_wakelock_cb, loc_eng_msg_sender, - callbacks->location_ext_parser, callbacks->sv_ext_parser); -#endif loc_eng_data.client_handle = LocApiAdapter::getLocApiAdapter(locEngHandle); if (NULL == loc_eng_data.client_handle) { @@ -475,14 +469,12 @@ void loc_eng_cleanup(loc_eng_data_s_type &loc_eng_data) ((LocEngContext*)(loc_eng_data.context))->drop(); loc_eng_data.context = NULL; -#ifdef FEATURE_ULP // De-initialize ulp if (locEngUlpInf != NULL) { locEngUlpInf = NULL; msg_q_destroy( &loc_eng_data.ulp_q); } -#endif if (loc_eng_data.client_handle != NULL) { @@ -521,7 +513,6 @@ int loc_eng_start(loc_eng_data_s_type &loc_eng_data) ENTRY_LOG_CALLFLOW(); INIT_CHECK(loc_eng_data.context, return -1); -#ifdef FEATURE_ULP if((loc_eng_data.ulp_initialized == true) && (gps_conf.CAPABILITIES & ULP_CAPABILITY)) { //Pass the start messgage to ULP if present & activated @@ -530,7 +521,6 @@ int loc_eng_start(loc_eng_data_s_type &loc_eng_data) msg, loc_eng_free_msg); } else -#endif { loc_eng_msg *msg(new loc_eng_msg(&loc_eng_data, LOC_ENG_MSG_START_FIX)); msg_q_snd((void*)((LocEngContext*)(loc_eng_data.context))->deferred_q, @@ -581,7 +571,6 @@ int loc_eng_stop(loc_eng_data_s_type &loc_eng_data) ENTRY_LOG_CALLFLOW(); INIT_CHECK(loc_eng_data.context, return -1); -#ifdef FEATURE_ULP if((loc_eng_data.ulp_initialized == true) && (gps_conf.CAPABILITIES & ULP_CAPABILITY)) { //Pass the start messgage to ULP if present & activated @@ -590,7 +579,6 @@ int loc_eng_stop(loc_eng_data_s_type &loc_eng_data) msg, loc_eng_free_msg); } else -#endif { loc_eng_msg *msg(new loc_eng_msg(&loc_eng_data, LOC_ENG_MSG_STOP_FIX)); msg_q_snd((void*)((LocEngContext*)(loc_eng_data.context))->deferred_q, @@ -1584,17 +1572,15 @@ static void loc_eng_deferred_action_thread(void* arg) // 2.2.2 we care about inaccuracy; and // 2.2.3 the inaccuracy exceeds our tolerance else if ((LOC_SESS_SUCCESS == rpMsg->status && ( -#ifdef FEATURE_ULP - ((LOCATION_HAS_SOURCE_INFO & rpMsg->location.flags) && + ((LOCATION_HAS_SOURCE_INFO & rpMsg->location.gpsLocation.flags) && ULP_LOCATION_IS_FROM_HYBRID == rpMsg->location.position_source) || -#endif ((LOC_POS_TECH_MASK_SATELLITE & rpMsg->technology_mask) || (LOC_POS_TECH_MASK_SENSORS & rpMsg->technology_mask)))) || (LOC_SESS_INTERMEDIATE == loc_eng_data_p->intermediateFix && - !((rpMsg->location.flags & GPS_LOCATION_HAS_ACCURACY) && + !((rpMsg->location.gpsLocation.flags & GPS_LOCATION_HAS_ACCURACY) && (gps_conf.ACCURACY_THRES != 0) && - (rpMsg->location.accuracy > gps_conf.ACCURACY_THRES)))) { - loc_eng_data_p->location_cb((GpsLocation*)&(rpMsg->location), + (rpMsg->location.gpsLocation.accuracy > gps_conf.ACCURACY_THRES)))) { + loc_eng_data_p->location_cb((UlpLocation*)&(rpMsg->location), (void*)rpMsg->locationExt); reported = true; } @@ -1614,28 +1600,19 @@ static void loc_eng_deferred_action_thread(void* arg) loc_eng_data_p->client_handle->setInSession(false); } -#ifdef FEATURE_ULP if (loc_eng_data_p->generateNmea && rpMsg->location.position_source == ULP_LOCATION_IS_FROM_GNSS) { loc_eng_nmea_generate_pos(loc_eng_data_p, rpMsg->location, rpMsg->locationExtended); } -#else - if (loc_eng_data_p->generateNmea && (LOC_POS_TECH_MASK_SATELLITE & rpMsg->technology_mask)) - { - loc_eng_nmea_generate_pos(loc_eng_data_p, rpMsg->location, rpMsg->locationExtended); - } -#endif -#ifdef FEATURE_ULP // Free the allocated memory for rawData - GpsLocation* gp = (GpsLocation*)&(rpMsg->location); + UlpLocation* gp = (UlpLocation*)&(rpMsg->location); if (gp != NULL && gp->rawData != NULL) { delete (char*)gp->rawData; gp->rawData = NULL; gp->rawDataSize = 0; } -#endif } break; @@ -1908,7 +1885,6 @@ static void loc_eng_deferred_action_thread(void* arg) loc_eng_handle_engine_up(*loc_eng_data_p); break; -#ifdef FEATURE_ULP case LOC_ENG_MSG_REQUEST_NETWORK_POSIITON: { loc_eng_msg_request_network_position *nlprequestmsg = (loc_eng_msg_request_network_position*)msg; @@ -1938,7 +1914,7 @@ static void loc_eng_deferred_action_thread(void* arg) LOC_LOGE("Ulp Phone context request call back not initialized"); } break; -#endif + default: LOC_LOGE("unsupported msgid = %d\n", msg->msgid); break; @@ -1968,7 +1944,7 @@ static void loc_eng_deferred_action_thread(void* arg) EXIT_LOG(%s, VOID_RET); } -#ifdef FEATURE_ULP + /*=========================================================================== FUNCTION loc_eng_ulp_init @@ -2232,7 +2208,7 @@ int loc_eng_ulp_send_network_position(loc_eng_data_s_type &loc_eng_data, EXIT_LOG(%d, ret_val); return ret_val; } -#endif + /*=========================================================================== FUNCTION loc_eng_read_config diff --git a/loc_api/libloc_api_50001/loc_eng.h b/loc_api/libloc_api_50001/loc_eng.h index c67435a0..36da419c 100644 --- a/loc_api/libloc_api_50001/loc_eng.h +++ b/loc_api/libloc_api_50001/loc_eng.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2009-2012, The Linux Foundation. All rights reserved. +/* Copyright (c) 2009-2013, The Linux Foundation. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -82,9 +82,7 @@ enum loc_mute_session_e_type { struct LocEngContext { // Data variables used by deferred action thread const void* deferred_q; -#ifdef FEATURE_ULP const void* ulp_q; -#endif const pthread_t deferred_action_thread; static LocEngContext* get(gps_create_thread threadCreator); void drop(); @@ -109,10 +107,8 @@ typedef struct gps_acquire_wakelock acquire_wakelock_cb; gps_release_wakelock release_wakelock_cb; gps_request_utc_time request_utc_time_cb; -#ifdef FEATURE_ULP ulp_network_location_request ulp_network_callback; ulp_request_phone_context ulp_phone_context_req_cb; -#endif boolean intermediateFix; AGpsStatusValue agps_status; // used to defer stopping the GPS engine until AGPS data calls are done @@ -123,10 +119,8 @@ typedef struct // AGPS state machines AgpsStateMachine* agnss_nif; -#ifdef FEATURE_IPV6 AgpsStateMachine* internet_nif; AgpsStateMachine* wifi_nif; -#endif // GPS engine status GpsStatusValue engine_status; @@ -157,14 +151,11 @@ typedef struct int mpc_host_set; char mpc_host_buf[101]; int mpc_port_buf; -#ifdef FEATURE_ULP bool ulp_initialized; -#endif + uint32_t min_interval_cached; } loc_eng_data_s_type; -#ifdef FEATURE_ULP #include "ulp.h" -#endif /* GPS.conf support */ typedef struct loc_gps_cfg_s @@ -207,9 +198,7 @@ int loc_eng_init(loc_eng_data_s_type &loc_eng_data, LocCallbacks* callbacks, LOC_API_ADAPTER_EVENT_MASK_T event, void (*loc_external_msg_sender) (void*, void*)); -#ifdef FEATURE_ULP int loc_eng_ulp_init(loc_eng_data_s_type &loc_eng_data, const ulpInterface * loc_eng_ulpInf); -#endif 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); @@ -225,10 +214,8 @@ int loc_eng_set_position_mode(loc_eng_data_s_type &loc_eng_data, LocPosMode ¶ms); const void* loc_eng_get_extension(loc_eng_data_s_type &loc_eng_data, const char* name); -#ifdef 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); @@ -271,7 +258,6 @@ 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 FEATURE_ULP int loc_eng_ulp_network_init(loc_eng_data_s_type &loc_eng_data, UlpNetworkLocationCallbacks *callbacks); int loc_eng_ulp_phone_context_settings_update(loc_eng_data_s_type &loc_eng_data, @@ -280,7 +266,6 @@ int loc_eng_ulp_phone_context_init(loc_eng_data_s_type &loc_eng_data, UlpPhoneContextCallbacks *callback); int loc_eng_ulp_send_network_position(loc_eng_data_s_type &loc_eng_data, UlpNetworkPositionReport *position_report); -#endif int loc_eng_read_config(void); #ifdef __cplusplus } diff --git a/loc_api/libloc_api_50001/loc_eng_log.cpp b/loc_api/libloc_api_50001/loc_eng_log.cpp index cb8de3f8..895db1db 100644 --- a/loc_api/libloc_api_50001/loc_eng_log.cpp +++ b/loc_api/libloc_api_50001/loc_eng_log.cpp @@ -95,7 +95,6 @@ static loc_name_val_s_type loc_eng_msgs[] = NAME_VAL( LOC_ENG_MSG_REQUEST_TIME ), NAME_VAL( LOC_ENG_MSG_EXT_POWER_CONFIG ), NAME_VAL( LOC_ENG_MSG_REQUEST_POSITION ), -#ifdef FEATURE_ULP NAME_VAL( LOC_ENG_MSG_REQUEST_PHONE_CONTEXT ), NAME_VAL( LOC_ENG_MSG_REQUEST_NETWORK_POSIITON ), NAME_VAL( ULP_MSG_UPDATE_CRITERIA ), @@ -105,8 +104,9 @@ static loc_name_val_s_type loc_eng_msgs[] = NAME_VAL( ULP_MSG_INJECT_NETWORK_POSITION ), NAME_VAL( ULP_MSG_REPORT_QUIPC_POSITION ), NAME_VAL( ULP_MSG_REQUEST_COARSE_POSITION ), -#endif + NAME_VAL( ULP_MSG_MONITOR ), NAME_VAL( LOC_ENG_MSG_LPP_CONFIG ), + NAME_VAL( ULP_MSG_INJECT_RAW_COMMAND ), NAME_VAL( LOC_ENG_MSG_A_GLONASS_PROTOCOL ) }; static int loc_eng_msgs_num = sizeof(loc_eng_msgs) / sizeof(loc_name_val_s_type); diff --git a/loc_api/libloc_api_50001/loc_eng_msg.h b/loc_api/libloc_api_50001/loc_eng_msg.h index ae146a76..bd86defb 100644 --- a/loc_api/libloc_api_50001/loc_eng_msg.h +++ b/loc_api/libloc_api_50001/loc_eng_msg.h @@ -31,6 +31,7 @@ #include +#include #include #include #include "log_util.h" @@ -108,9 +109,9 @@ typedef uint16_t GpsLocationExtendedFlags; #define GPS_LOCATION_EXTENDED_HAS_DOP 0x0001 /** GpsLocationExtended has valid altitude mean sea level. */ #define GPS_LOCATION_EXTENDED_HAS_ALTITUDE_MEAN_SEA_LEVEL 0x0002 -/** GpsLocation has valid magnetic deviation. */ +/** UlpLocation has valid magnetic deviation. */ #define GPS_LOCATION_EXTENDED_HAS_MAG_DEV 0x0004 -/** GpsLocation has valid mode indicator. */ +/** UlpLocation has valid mode indicator. */ #define GPS_LOCATION_EXTENDED_HAS_MODE_IND 0x0008 /** Represents gps location extended. */ @@ -157,8 +158,7 @@ struct loc_eng_msg { } virtual ~loc_eng_msg() { - LOC_LOGV("deleting msg %s", loc_get_msg_name(msgid)); - LOC_LOGV("deleting msg ox%x", msgid); + LOC_LOGV("deleting msg %s (0x%x)", loc_get_msg_name(msgid), msgid); } }; @@ -360,44 +360,36 @@ struct loc_eng_msg_delete_aiding_data : public loc_eng_msg { }; struct loc_eng_msg_report_position : public loc_eng_msg { - const GpsLocation location; + const UlpLocation location; const GpsLocationExtended locationExtended; const void* locationExt; const enum loc_sess_status status; const LocPosTechMask technology_mask; - inline loc_eng_msg_report_position(void* instance, GpsLocation &loc, GpsLocationExtended &locExtended, void* locExt, + inline loc_eng_msg_report_position(void* instance, UlpLocation &loc, GpsLocationExtended &locExtended, void* locExt, enum loc_sess_status st) : loc_eng_msg(instance, LOC_ENG_MSG_REPORT_POSITION), location(loc), locationExtended(locExtended), locationExt(locExt), status(st), technology_mask(LOC_POS_TECH_MASK_DEFAULT) { -#ifdef 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: %d\n Technology mask: %u", - location.flags, location.position_source, location.latitude, location.longitude, - location.altitude, location.speed, location.bearing, location.accuracy, - location.timestamp, location.rawDataSize, location.rawData,status,technology_mask); -#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: %d\n Technology mask: %u", - location.flags, location.latitude, location.longitude, - location.altitude, location.speed, location.bearing, location.accuracy, - location.timestamp, status,technology_mask); -#endif + location.gpsLocation.flags, location.position_source, + location.gpsLocation.latitude, location.gpsLocation.longitude, + location.gpsLocation.altitude, location.gpsLocation.speed, + location.gpsLocation.bearing, location.gpsLocation.accuracy, + location.gpsLocation.timestamp, location.rawDataSize, + location.rawData,status,technology_mask); } - inline loc_eng_msg_report_position(void* instance, GpsLocation &loc, GpsLocationExtended &locExtended, void* locExt, + inline loc_eng_msg_report_position(void* instance, UlpLocation &loc, GpsLocationExtended &locExtended, void* locExt, enum loc_sess_status st, LocPosTechMask technology) : loc_eng_msg(instance, LOC_ENG_MSG_REPORT_POSITION), location(loc), locationExtended(locExtended), locationExt(locExt), status(st), technology_mask(technology) { -#ifdef 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: %d\n Technology mask: %u", - location.flags, location.position_source, location.latitude, location.longitude, - location.altitude, location.speed, location.bearing, location.accuracy, - location.timestamp, location.rawDataSize, location.rawData,status,technology_mask); -#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: %d\n Technology mask: %u", - location.flags, location.latitude, location.longitude, - location.altitude, location.speed, location.bearing, location.accuracy, - location.timestamp, status,technology_mask); -#endif + location.gpsLocation.flags, location.position_source, + location.gpsLocation.latitude, location.gpsLocation.longitude, + location.gpsLocation.altitude, location.gpsLocation.speed, + location.gpsLocation.bearing, location.gpsLocation.accuracy, + location.gpsLocation.timestamp, location.rawDataSize, + location.rawData,status,technology_mask); } }; @@ -835,7 +827,6 @@ struct loc_eng_msg_set_data_enable : public loc_eng_msg { } }; -#ifdef FEATURE_ULP struct loc_eng_msg_request_network_position : public loc_eng_msg { const UlpNetworkRequestPos networkPosRequest; inline loc_eng_msg_request_network_position (void* instance, UlpNetworkRequestPos networkPosReq) : @@ -933,21 +924,20 @@ struct ulp_msg_inject_network_position : public loc_eng_msg { }; struct ulp_msg_report_quipc_position : public loc_eng_msg { - const GpsLocation location; + const UlpLocation location; const int quipc_error_code; - inline ulp_msg_report_quipc_position(void* instance, GpsLocation &loc, + inline ulp_msg_report_quipc_position(void* instance, UlpLocation &loc, int quipc_err) : loc_eng_msg(instance, ULP_MSG_REPORT_QUIPC_POSITION), location(loc), quipc_error_code(quipc_err) { LOC_LOGV("flags: %d\n source: %d\n latitude: %f\n longitude: %f\n altitude: %f\n speed: %f\n bearing: %f\n accuracy: %f\n timestamp: %lld\n rawDataSize: %d\n rawData: %p\n Quipc error: %d", - location.flags, location.position_source, location.latitude, location.longitude, - location.altitude, location.speed, location.bearing, location.accuracy, - location.timestamp, location.rawDataSize, location.rawData, + location.gpsLocation.flags, location.position_source, location.gpsLocation.latitude, location.gpsLocation.longitude, + location.gpsLocation.altitude, location.gpsLocation.speed, location.gpsLocation.bearing, location.gpsLocation.accuracy, + location.gpsLocation.timestamp, location.rawDataSize, location.rawData, quipc_error_code); } }; -#endif void loc_eng_msg_sender(void* loc_eng_data_p, void* msg); int loc_eng_msgget(int * p_req_msgq); diff --git a/loc_api/libloc_api_50001/loc_eng_msg_id.h b/loc_api/libloc_api_50001/loc_eng_msg_id.h index 6649761b..bcdf2969 100644 --- a/loc_api/libloc_api_50001/loc_eng_msg_id.h +++ b/loc_api/libloc_api_50001/loc_eng_msg_id.h @@ -85,7 +85,6 @@ enum loc_eng_msg_ids_t { LOC_ENG_MSG_REQUEST_POSITION, LOC_ENG_MSG_EXT_POWER_CONFIG, -#ifdef FEATURE_ULP // The following messages are added for ulp LOC_ENG_MSG_REQUEST_PHONE_CONTEXT, LOC_ENG_MSG_REQUEST_NETWORK_POSIITON, @@ -121,16 +120,14 @@ enum loc_eng_msg_ids_t { // Last ULP MSG ULP_MSG_LAST = 0x700, -#endif + /* Message is sent by HAL to LOC API to configure LTE Positioning Profile in modem */ LOC_ENG_MSG_LPP_CONFIG, -#ifdef FEATURE_ULP // Message is sent by Android framework (GpsLocationProvider) // to inject the raw command ULP_MSG_INJECT_RAW_COMMAND, -#endif /* Message is sent by HAL to LOC API to select A-GLONASS protocol */ LOC_ENG_MSG_A_GLONASS_PROTOCOL, diff --git a/loc_api/libloc_api_50001/loc_eng_nmea.cpp b/loc_api/libloc_api_50001/loc_eng_nmea.cpp index d2507a52..e30380c9 100644 --- a/loc_api/libloc_api_50001/loc_eng_nmea.cpp +++ b/loc_api/libloc_api_50001/loc_eng_nmea.cpp @@ -110,7 +110,7 @@ SIDE EFFECTS ===========================================================================*/ void loc_eng_nmea_generate_pos(loc_eng_data_s_type *loc_eng_data_p, - const GpsLocation &location, const GpsLocationExtended &locationExtended) + const UlpLocation &location, const GpsLocationExtended &locationExtended) { ENTRY_LOG(); @@ -119,7 +119,7 @@ void loc_eng_nmea_generate_pos(loc_eng_data_s_type *loc_eng_data_p, int lengthRemaining = sizeof(sentence); int length = 0; - time_t utcTime(location.timestamp/1000); + time_t utcTime(location.gpsLocation.timestamp/1000); tm * pTm = gmtime(&utcTime); int utcYear = pTm->tm_year % 100; // 2 digit year int utcMonth = pTm->tm_mon + 1; // tm_mon starts at zero @@ -207,19 +207,19 @@ void loc_eng_nmea_generate_pos(loc_eng_data_s_type *loc_eng_data_p, pMarker = sentence; lengthRemaining = sizeof(sentence); - if (location.flags & GPS_LOCATION_HAS_BEARING) + if (location.gpsLocation.flags & GPS_LOCATION_HAS_BEARING) { - float magTrack = location.bearing; + float magTrack = location.gpsLocation.bearing; if (locationExtended.flags & GPS_LOCATION_EXTENDED_HAS_MAG_DEV) { - float magTrack = location.bearing - locationExtended.magneticDeviation; + float magTrack = location.gpsLocation.bearing - locationExtended.magneticDeviation; if (magTrack < 0.0) magTrack += 360.0; else if (magTrack > 360.0) magTrack -= 360.0; } - length = snprintf(pMarker, lengthRemaining, "$GPVTG,%.1lf,T,%.1lf,M,", location.bearing, magTrack); + length = snprintf(pMarker, lengthRemaining, "$GPVTG,%.1lf,T,%.1lf,M,", location.gpsLocation.bearing, magTrack); } else { @@ -234,10 +234,10 @@ void loc_eng_nmea_generate_pos(loc_eng_data_s_type *loc_eng_data_p, pMarker += length; lengthRemaining -= length; - if (location.flags & GPS_LOCATION_HAS_SPEED) + if (location.gpsLocation.flags & GPS_LOCATION_HAS_SPEED) { - float speedKnots = location.speed * (3600.0/1852.0); - float speedKmPerHour = location.speed * 3.6; + float speedKnots = location.gpsLocation.speed * (3600.0/1852.0); + float speedKmPerHour = location.gpsLocation.speed * 3.6; length = snprintf(pMarker, lengthRemaining, "%.1lf,N,%.1lf,K,", speedKnots, speedKmPerHour); } @@ -254,7 +254,7 @@ void loc_eng_nmea_generate_pos(loc_eng_data_s_type *loc_eng_data_p, pMarker += length; lengthRemaining -= length; - if (!(location.flags & GPS_LOCATION_HAS_LAT_LONG)) + if (!(location.gpsLocation.flags & GPS_LOCATION_HAS_LAT_LONG)) length = snprintf(pMarker, lengthRemaining, "%c", 'N'); // N means no fix else if (LOC_POSITION_MODE_STANDALONE == loc_eng_data_p->client_handle->getPositionMode().mode) length = snprintf(pMarker, lengthRemaining, "%c", 'A'); // A means autonomous @@ -282,10 +282,10 @@ void loc_eng_nmea_generate_pos(loc_eng_data_s_type *loc_eng_data_p, pMarker += length; lengthRemaining -= length; - if (location.flags & GPS_LOCATION_HAS_LAT_LONG) + if (location.gpsLocation.flags & GPS_LOCATION_HAS_LAT_LONG) { - double latitude = location.latitude; - double longitude = location.longitude; + double latitude = location.gpsLocation.latitude; + double longitude = location.gpsLocation.longitude; char latHemisphere; char lonHemisphere; double latMinutes; @@ -331,9 +331,9 @@ void loc_eng_nmea_generate_pos(loc_eng_data_s_type *loc_eng_data_p, pMarker += length; lengthRemaining -= length; - if (location.flags & GPS_LOCATION_HAS_SPEED) + if (location.gpsLocation.flags & GPS_LOCATION_HAS_SPEED) { - float speedKnots = location.speed * (3600.0/1852.0); + float speedKnots = location.gpsLocation.speed * (3600.0/1852.0); length = snprintf(pMarker, lengthRemaining, "%.1lf,", speedKnots); } else @@ -349,9 +349,9 @@ void loc_eng_nmea_generate_pos(loc_eng_data_s_type *loc_eng_data_p, pMarker += length; lengthRemaining -= length; - if (location.flags & GPS_LOCATION_HAS_BEARING) + if (location.gpsLocation.flags & GPS_LOCATION_HAS_BEARING) { - length = snprintf(pMarker, lengthRemaining, "%.1lf,", location.bearing); + length = snprintf(pMarker, lengthRemaining, "%.1lf,", location.gpsLocation.bearing); } else { @@ -407,7 +407,7 @@ void loc_eng_nmea_generate_pos(loc_eng_data_s_type *loc_eng_data_p, pMarker += length; lengthRemaining -= length; - if (!(location.flags & GPS_LOCATION_HAS_LAT_LONG)) + if (!(location.gpsLocation.flags & GPS_LOCATION_HAS_LAT_LONG)) length = snprintf(pMarker, lengthRemaining, "%c", 'N'); // N means no fix else if (LOC_POSITION_MODE_STANDALONE == loc_eng_data_p->client_handle->getPositionMode().mode) length = snprintf(pMarker, lengthRemaining, "%c", 'A'); // A means autonomous @@ -435,10 +435,10 @@ void loc_eng_nmea_generate_pos(loc_eng_data_s_type *loc_eng_data_p, pMarker += length; lengthRemaining -= length; - if (location.flags & GPS_LOCATION_HAS_LAT_LONG) + if (location.gpsLocation.flags & GPS_LOCATION_HAS_LAT_LONG) { - double latitude = location.latitude; - double longitude = location.longitude; + double latitude = location.gpsLocation.latitude; + double longitude = location.gpsLocation.longitude; char latHemisphere; char lonHemisphere; double latMinutes; @@ -485,7 +485,7 @@ void loc_eng_nmea_generate_pos(loc_eng_data_s_type *loc_eng_data_p, lengthRemaining -= length; char gpsQuality; - if (!(location.flags & GPS_LOCATION_HAS_LAT_LONG)) + if (!(location.gpsLocation.flags & GPS_LOCATION_HAS_LAT_LONG)) gpsQuality = '0'; // 0 means no fix else if (LOC_POSITION_MODE_STANDALONE == loc_eng_data_p->client_handle->getPositionMode().mode) gpsQuality = '1'; // 1 means GPS fix @@ -534,11 +534,11 @@ void loc_eng_nmea_generate_pos(loc_eng_data_s_type *loc_eng_data_p, pMarker += length; lengthRemaining -= length; - if ((location.flags & GPS_LOCATION_HAS_ALTITUDE) && + if ((location.gpsLocation.flags & GPS_LOCATION_HAS_ALTITUDE) && (locationExtended.flags & GPS_LOCATION_EXTENDED_HAS_ALTITUDE_MEAN_SEA_LEVEL)) { length = snprintf(pMarker, lengthRemaining, "%.1lf,M,,", - location.altitude - locationExtended.altitudeMeanSeaLevel); + location.gpsLocation.altitude - locationExtended.altitudeMeanSeaLevel); } else { diff --git a/loc_api/libloc_api_50001/loc_eng_nmea.h b/loc_api/libloc_api_50001/loc_eng_nmea.h index 29ca6c5e..69305937 100644 --- a/loc_api/libloc_api_50001/loc_eng_nmea.h +++ b/loc_api/libloc_api_50001/loc_eng_nmea.h @@ -37,6 +37,6 @@ void loc_eng_nmea_send(char *pNmea, int length, loc_eng_data_s_type *loc_eng_data_p); int loc_eng_nmea_put_checksum(char *pNmea, int maxSize); void loc_eng_nmea_generate_sv(loc_eng_data_s_type *loc_eng_data_p, const GpsSvStatus &svStatus, const GpsLocationExtended &locationExtended); -void loc_eng_nmea_generate_pos(loc_eng_data_s_type *loc_eng_data_p, const GpsLocation &location, const GpsLocationExtended &locationExtended); +void loc_eng_nmea_generate_pos(loc_eng_data_s_type *loc_eng_data_p, const UlpLocation &location, const GpsLocationExtended &locationExtended); #endif // LOC_ENG_NMEA_H diff --git a/loc_api/libloc_api_50001/loc_ulp.h b/loc_api/libloc_api_50001/loc_ulp.h new file mode 100644 index 00000000..75636993 --- /dev/null +++ b/loc_api/libloc_api_50001/loc_ulp.h @@ -0,0 +1,418 @@ +/* Copyright (c) 2013, The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation, nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef __LOC_ULP_H__ +#define __LOC_ULP_H__ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#include +#include +#include + +#define ULP_ENGINE_INTERFACE "ulp-engine-interface" +#define ULP_NETWORK_INTERFACE "ulp-network-interface" +#define ULP_RAW_CMD_INTERFACE "ulp-raw-cmd" +#define ULP_PHONE_CONTEXT_INTERFACE "ulp-phone-context" + +/** Location has valid source information. */ +#define LOCATION_HAS_SOURCE_INFO 0x0020 +/** GpsLocation has valid "is indoor?" flag */ +#define GPS_LOCATION_HAS_IS_INDOOR 0x0040 +/** GpsLocation has valid floor number */ +#define GPS_LOCATION_HAS_FLOOR_NUMBER 0x0080 +/** GpsLocation has valid map URL*/ +#define GPS_LOCATION_HAS_MAP_URL 0x0100 +/** GpsLocation has valid map index */ +#define GPS_LOCATION_HAS_MAP_INDEX 0x0200 + +/** Sizes for indoor fields */ +#define GPS_LOCATION_MAP_URL_SIZE 400 +#define GPS_LOCATION_MAP_INDEX_SIZE 16 + +/** Position source is ULP */ +#define ULP_LOCATION_IS_FROM_HYBRID 0x0001 +/** Position source is GNSS only */ +#define ULP_LOCATION_IS_FROM_GNSS 0x0002 + +/* Hybrid support, the Android Framework will query to see if this capability is set before using the ulp functionalities in HAL */ +#define ULP_CAPABILITY 0x0000020 + +#define ULP_MIN_INTERVAL_INVALID 0xffffffff + +/** Represents recurrence of location */ +typedef enum{ + ULP_LOC_RECURRENCE_PERIODIC = 0, + ULP_LOC_RECURRENCE_SINGLE, +}UlpRecurrenceCriteria; + +/** Represents horizontal accuracy options */ +typedef enum { + ULP_HORZ_ACCURACY_DONT_CARE = 0, + ULP_HORZ_ACCURACY_LOW, + ULP_HORZ_ACCURACY_MED, + ULP_HORZ_ACCURACY_HIGH, +}UlpHorzAccuracyCriteria; + +/** Represents accuracy options (for speed, altitude, and + * bearing) */ +typedef enum { + ULP_ACCURACY_DONT_CARE = 0, + ULP_ACCURACY_LOW, + ULP_ACCURACY_HIGH, +}UlpAccuracyCriteria; + +/** Represents power consumption options */ +typedef enum { + ULP_POWER_REQ_DONT_CARE = 0, + ULP_POWER_REQ_LOW, + ULP_POWER_REQ_HIGH, +}UlpPowerCriteria; + +/** Represents data usage options */ +typedef enum { + ULP_DATA_REQ_DONT_CARE = 0, + ULP_DATA_ALLOW, + ULP_DATA_DENY, +}UlpDataUsageCriteria; + +/** Enable the reporting of altitude in location reports */ +#define ULP_ENABLE_ALTITUDE_REPORT 0x01 +/** Enable the reporting of speed in location reports */ +#define ULP_ENABLE_SPEED_REPORT 0x02 +/** Enable the reporting of bearing in location reports */ +#define ULP_ENABLE_BEARING_REPORT 0x04 + +#define ULP_CRITERIA_HAS_ACTION 0x00000001 +#define ULP_CRITERIA_HAS_PROVIDER_SOURCE 0x00000002 +#define ULP_CRITERIA_HAS_RECURRENCE_TYPE 0x00000004 +#define ULP_CRITERIA_HAS_PREFERRED_RESPONSE_TIME 0x00000010 +#define ULP_CRITERIA_HAS_MIN_INTERVAL 0x00000020 +#define ULP_CRITERIA_HAS_MIN_DISTANCE 0x00000040 +#define ULP_CRITERIA_HAS_MIN_DIST_SAMPLE_INTERVAL 0x00000080 +#define ULP_CRITERIA_HAS_DESIRED_OUTPUT_PARAMETER 0x00000100 +#define ULP_CRITERIA_HAS_PREFERRED_HORIZONTAL_ACCURACY 0x00000200 +#define ULP_CRITERIA_HAS_PREFERRED_POWER_CONSUMPTION 0x00000400 +#define ULP_CRITERIA_HAS_PREFERRED_ALTITUDE_ACCURACY 0x00000800 +#define ULP_CRITERIA_HAS_PREFERRED_BEARING_ACCURACY 0x00001000 +#define ULP_CRITERIA_HAS_PREFERRED_DATA_USAGE 0x00002000 +#define ULP_CRITERIA_HAS_INTERMEDIATE_POS_REPORT_ENABLED 0x00004000 + +#define ULP_PROVIDER_SOURCE_GNSS 0x00000001 +#define ULP_PROVIDER_SOURCE_HYBRID 0x00000002 + +#define ULP_ADD_CRITERIA 1 +#define ULP_REMOVE_CRITERIA 2 + +typedef struct { + /** set to sizeof(UlpLocation) */ + size_t size; + GpsLocation gpsLocation; + /* Provider indicator for HYBRID or GPS */ + uint16_t position_source; + /*allows HAL to pass additional information related to the location */ + int rawDataSize; /* in # of bytes */ + void * rawData; + bool is_indoor; + float floor_number; + char map_url[GPS_LOCATION_MAP_URL_SIZE]; + unsigned char map_index[GPS_LOCATION_MAP_INDEX_SIZE]; +} UlpLocation; + +/** Callback with location information. + */ +typedef void (* ulp_location_callback)(UlpLocation* location); + +/** ULP Engine callback structure. */ +typedef struct { + /** set to sizeof(UlpCallbacks) */ + size_t size; + ulp_location_callback location_cb; +} UlpEngineCallbacks; + +typedef struct { + + uint32_t valid_mask; + /* delete or add. This is a mandatory field */ + int action; + /*via gps or hybrid provider*/ + int provider_source; + /** PERIODIC or SINGLE */ + UlpRecurrenceCriteria recurrence_type; + /** obtain position within the specified response time */ + uint32_t preferred_response_time; + /** Send updates after the specified interval */ + uint32_t min_interval; + /** Send updates after device moved a specified distance */ + float min_distance; + uint32_t min_dist_sample_interval; + /** Fields specfied in the mask should be reported in the + * position report (altitude, bearing and speed) */ + uint32_t desired_output_parameter; + /** Desired accuracy for latitude, longitude */ + UlpHorzAccuracyCriteria preferred_horizontal_accuracy; + /** Desired power consumption level */ + UlpPowerCriteria preferred_power_consumption; + /** Desired accuracy for altitude */ + UlpAccuracyCriteria preferred_altitude_accuracy; + /** Desired accuracy for bearing */ + UlpAccuracyCriteria preferred_bearing_accuracy; + UlpDataUsageCriteria preferred_data_usage; + bool intermediate_pos_report_enabled; +} UlpLocationCriteria; + +/** Represents the Ulp Egine interface. */ +typedef struct { + /** set to sizeof(UlpEngineInterface) */ + size_t size; + /** + * Opens the interface and provides the callback routines + * to the implemenation of this interface. + */ + int (*init)( UlpEngineCallbacks* callbacks ); + + /* set criterias of location requests */ + int (*update_criteria) (UlpLocationCriteria criteria ); + + /** Starts navigating. */ + int (*start)( void ); + + /** Stops navigating. */ + int (*stop)( void ); +} UlpEngineInterface; + + +/** Extended interface for raw GPS command support. */ +typedef struct { + /** set to sizeof(ExtraCmdInterface) */ + size_t size; + /** Injects Android extra cmd into the ulp. Clarify if they are blocking calls */ + bool (*inject_raw_cmd)(char* bundle, int bundle_length ); + +} InjectRawCmdInterface; + +/** ULP Network Interface */ +/** Request for network position status */ +#define ULP_NETWORK_POS_STATUS_REQUEST (0x01) +/** Request for periodic network positions */ +#define ULP_NETWORK_POS_START_PERIODIC_REQUEST (0x02) +/** Request last known location */ +#define ULP_NETWORK_POS_GET_LAST_KNOWN_LOCATION_REQUEST (0x03) +/** Cancel request */ +#define ULP_NETWORK_POS_STOP_REQUEST (0x04) + +/** Position was obtained using Wifi Network */ +#define ULP_NETWORK_POSITION_SRC_WIFI (0x01) +/** Position was obtained using Cell Network */ +#define ULP_NETWORK_POSITION_SRC_CELL (0x02) +/** Position was obtained using an Unknown Network */ +#define ULP_NETWORK_POSITION_SRC_UNKNOWN (0x00) + +/** Represents the ULP network request */ +typedef struct { + /** type of request */ + uint16_t request_type; + /** Desired time between network positions/measurements in ms. + * Shall be set to 0 if only one position is requested */ + int interval_ms; + /** network position source to be used */ + uint16_t desired_position_source; +}UlpNetworkRequestPos; + +/** Callback with network position request. */ +typedef void (*ulp_network_location_request)(UlpNetworkRequestPos *req); + +/** ULP Network callback structure. */ +typedef struct { + ulp_network_location_request ulp_network_location_request_cb; +} UlpNetworkLocationCallbacks; + +/** represent a network position */ +typedef struct { + /** source of the position (Wifi, Cell) */ + uint16_t pos_source; + /** latitude in degrees */ + double latitude; + /** longitude in degrees */ + double longitude; + /** Horzizontal error estimate in meters */ + uint16_t HEPE; +} UlpNetworkPosition; + +/** Represents access point information */ +typedef struct { + /** Mac adderess */ + char mac_addr[6]; + /** signal strength in dbM */ + int32_t rssi; + /** Beacon channel for access point */ + uint16_t channel; + + /** Bit 0 = AP is used by WiFi positioning system + * Bit 1 = AP doesn't broadcast SSID Bit 2 = AP has encrption + * turned on Bit 3 = AP is in infrastructure mode and not in + * ad-hoc/unknown mode */ + uint8_t ap_qualifier; +} UlpNetworkAccessPointInfo; + +/** Represents Wifi information */ +typedef struct { + /** Number of APs in the calculated position (-1 means + * unknown) */ + uint8_t num_aps_in_pos; + /** Information of the scanned ap's used in the position estimation*/ + UlpNetworkAccessPointInfo *ap_info; +} UlpNetworkWifiInfo; + + +/** Represent network landscape information */ +typedef struct { + /** network type Cell/Wifi */ + uint8_t network_type; + /** network information */ + union { + UlpNetworkWifiInfo wifi_info; + uint32_t cell_info; + } u; +} UlpNetworkLandscape; + +/** network report valid flags */ +/** fix time is valid */ +#define ULP_NETWORK_POSITION_REPORT_HAS_FIX_TIME (0x01) +/** position is valid */ +#define ULP_NETWORK_POSITION_REPORT_HAS_POSITION (0x02) +/** landscape is valid */ +#define ULP_NETWORK_POSITION_REPORT_HAS_LANDSCAPE (0x04) + +/** Represents the network position report */ +typedef struct +{ + /** validity flags */ + uint16_t valid_flag; + /** time fo network fix */ + GpsUtcTime fix_time; + /** network position */ + UlpNetworkPosition position; + /** network landscape */ + UlpNetworkLandscape landscape_info; +}UlpNetworkPositionReport; + +/** represents ULP network interface extension */ +typedef struct +{ + /** set to sizeof(UlpNetworkInterface) */ + size_t size; + /** initialize network interface */ + int ( *init)(UlpNetworkLocationCallbacks *callback); + /** send network position */ + int ( *ulp_send_network_position)(UlpNetworkPositionReport *position_report); +}UlpNetworkInterface; + +/** Information for the ULP Phone context interface */ + +/** the Location settings context supports only ON_CHANGE + * request type */ +#define ULP_PHONE_CONTEXT_GPS_SETTING (0x01) +#define ULP_PHONE_CONTEXT_NETWORK_POSITION_SETTING (0x02) +#define ULP_PHONE_CONTEXT_WIFI_SETTING (0x04) +/** The battery charging state context supports only + * ON_CHANGE request type */ +#define ULP_PHONE_CONTEXT_BATTERY_CHARGING_STATE (0x08) +#define ULP_PHONE_CONTEXT_AGPS_SETTING (0x010) +#define ULP_PHONE_CONTEXT_ENH_LOCATION_SERVICES_SETTING (0x020) + +/** return phone context only once */ +#define ULP_PHONE_CONTEXT_REQUEST_TYPE_SINGLE (0x01) +/** return phone context periodcially */ +#define ULP_PHONE_CONTEXT_REQUEST_TYPE_PERIODIC (0x02) +/** return phone context when it changes */ +#define ULP_PHONE_CONTEXT_REQUEST_TYPE_ON_CHANGE (0x03) + + +/** Represents ULP phone context request */ +typedef struct { + /** context type requested */ + uint16_t context_type; + /** request type */ + uint16_t request_type; + /** interval in ms if request type is periodic */ + int interval_ms; +}UlpPhoneContextRequest; + +/** Callback for phone context request. */ +typedef void (*ulp_request_phone_context)(UlpPhoneContextRequest *req); + +/** ULP Phone Context callback structure. */ +typedef struct { + ulp_request_phone_context ulp_request_phone_context_cb; +}UlpPhoneContextCallbacks; + +/** Represents the phone context settings */ +typedef struct { + /** Phone context information type */ + uint16_t context_type; + + /** network information */ + /** gps setting */ + bool is_gps_enabled; + /** is network positioning enabled */ + bool is_network_position_available; + /** is wifi turned on */ + bool is_wifi_setting_enabled; + /** is battery being currently charged */ + bool is_battery_charging; + /* is agps enabled for single shot */ + bool is_agps_enabled; + /* is Enhanced Location Services enabled by user*/ + bool is_enh_location_services_enabled; +} UlpPhoneContextSettings; + +/** Represent the phone contxt interface */ +typedef struct +{ + /** set to sizeof(UlpPhoneContextInterface) */ + size_t size; + /** Initialize, register callback */ + int (*init)(UlpPhoneContextCallbacks *callback); + /** send the phone context settings */ + int (*ulp_phone_context_settings_update) (UlpPhoneContextSettings *settings ); +}UlpPhoneContextInterface; + + +//int loc_update_criteria(UlpLocationCriteria criteria); +//const void* loc_get_extension(const char* name); + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif //__LOC_ULP_H__ diff --git a/loc_api/loc_api_v02/Android.mk b/loc_api/loc_api_v02/Android.mk index 68dd9f0f..8617f3cb 100644 --- a/loc_api/loc_api_v02/Android.mk +++ b/loc_api/loc_api_v02/Android.mk @@ -36,10 +36,6 @@ ifeq ($(FEATURE_DELEXT), true) LOCAL_CFLAGS += -DFEATURE_DELEXT endif #FEATURE_DELEXT -ifeq ($(FEATURE_ULP), true) -LOCAL_CFLAGS += -DFEATURE_ULP -endif #FEATURE_ULP - ## Includes LOCAL_C_INCLUDES := \ $(TARGET_OUT_HEADERS)/libloc_eng \ diff --git a/loc_api/loc_api_v02/LocApiV02Adapter.cpp b/loc_api/loc_api_v02/LocApiV02Adapter.cpp index ac886f94..9efd820a 100644 --- a/loc_api/loc_api_v02/LocApiV02Adapter.cpp +++ b/loc_api/loc_api_v02/LocApiV02Adapter.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2011-2012, The Linux Foundation. All rights reserved. +/* Copyright (c) 2011-2013, The Linux Foundation. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -1590,10 +1590,10 @@ enum loc_api_adapter_err LocApiV02Adapter :: convertErr( void LocApiV02Adapter :: reportPosition ( const qmiLocEventPositionReportIndMsgT_v02 *location_report_ptr) { - GpsLocation location; + UlpLocation location; LocPosTechMask tech_Mask = LOC_POS_TECH_MASK_DEFAULT; LOC_LOGD("Reporting postion from V2 Adapter\n"); - memset(&location, 0, sizeof (GpsLocation)); + memset(&location, 0, sizeof (UlpLocation)); location.size = sizeof(location); GpsLocationExtended locationExtended; memset(&locationExtended, 0, sizeof (GpsLocationExtended)); @@ -1610,29 +1610,29 @@ void LocApiV02Adapter :: reportPosition ( (location_report_ptr->latitude != 0 || location_report_ptr->longitude!= 0)) { - location.flags |= GPS_LOCATION_HAS_LAT_LONG; - location.latitude = location_report_ptr->latitude; - location.longitude = location_report_ptr->longitude; + location.gpsLocation.flags |= GPS_LOCATION_HAS_LAT_LONG; + location.gpsLocation.latitude = location_report_ptr->latitude; + location.gpsLocation.longitude = location_report_ptr->longitude; // Time stamp (UTC) if(location_report_ptr->timestampUtc_valid == 1) { - location.timestamp = location_report_ptr->timestampUtc; + location.gpsLocation.timestamp = location_report_ptr->timestampUtc; } // Altitude if(location_report_ptr->altitudeWrtEllipsoid_valid == 1 ) { - location.flags |= GPS_LOCATION_HAS_ALTITUDE; - location.altitude = location_report_ptr->altitudeWrtEllipsoid; + location.gpsLocation.flags |= GPS_LOCATION_HAS_ALTITUDE; + location.gpsLocation.altitude = location_report_ptr->altitudeWrtEllipsoid; } // Speed if((location_report_ptr->speedHorizontal_valid == 1) && (location_report_ptr->speedVertical_valid ==1 ) ) { - location.flags |= GPS_LOCATION_HAS_SPEED; - location.speed = sqrt( + location.gpsLocation.flags |= GPS_LOCATION_HAS_SPEED; + location.gpsLocation.speed = sqrt( (location_report_ptr->speedHorizontal * location_report_ptr->speedHorizontal) + (location_report_ptr->speedVertical * @@ -1642,25 +1642,23 @@ void LocApiV02Adapter :: reportPosition ( // Heading if(location_report_ptr->heading_valid == 1) { - location.flags |= GPS_LOCATION_HAS_BEARING; - location.bearing = location_report_ptr->heading; + location.gpsLocation.flags |= GPS_LOCATION_HAS_BEARING; + location.gpsLocation.bearing = location_report_ptr->heading; } // Uncertainty (circular) if( (location_report_ptr->horUncCircular_valid ) ) { - location.flags |= GPS_LOCATION_HAS_ACCURACY; - location.accuracy = location_report_ptr->horUncCircular; + location.gpsLocation.flags |= GPS_LOCATION_HAS_ACCURACY; + location.gpsLocation.accuracy = location_report_ptr->horUncCircular; } // Technology Mask tech_Mask |= location_report_ptr->technologyMask; -#ifdef FEATURE_ULP //Mark the location source as from GNSS - location.flags |= LOCATION_HAS_SOURCE_INFO; + location.gpsLocation.flags |= LOCATION_HAS_SOURCE_INFO; location.position_source = ULP_LOCATION_IS_FROM_GNSS; -#endif if (location_report_ptr->magneticDeviation_valid) { locationExtended.flags |= GPS_LOCATION_EXTENDED_HAS_MAG_DEV;