diff --git a/loc_api/libloc_api_50001/Android.mk b/loc_api/libloc_api_50001/Android.mk index 74fffc3d..07172654 100644 --- a/loc_api/libloc_api_50001/Android.mk +++ b/loc_api/libloc_api_50001/Android.mk @@ -26,7 +26,8 @@ LOCAL_CFLAGS += \ -D_ANDROID_ LOCAL_C_INCLUDES:= \ - $(TARGET_OUT_HEADERS)/gps.utils + $(TARGET_OUT_HEADERS)/gps.utils \ + hardware/qcom/gps/loc_api/libloc_api_50001 LOCAL_COPY_HEADERS_TO:= libloc_eng/ LOCAL_COPY_HEADERS:= \ diff --git a/loc_api/libloc_api_50001/loc.cpp b/loc_api/libloc_api_50001/loc.cpp index fbd556ef..34a0f8c3 100644 --- a/loc_api/libloc_api_50001/loc.cpp +++ b/loc_api/libloc_api_50001/loc.cpp @@ -74,19 +74,7 @@ static void loc_delete_aiding_data(GpsAidingData f); static int loc_set_position_mode(GpsPositionMode mode, GpsPositionRecurrence recurrence, uint32_t min_interval, uint32_t preferred_accuracy, uint32_t preferred_time); - -//ULP/Hybrid provider Function definitions -static int loc_ulp_network_init(UlpNetworkLocationCallbacks *callbacks); -static int loc_ulp_send_network_position(UlpNetworkPositionReport *position_report); -static int loc_ulp_phone_context_init(UlpPhoneContextCallbacks *callback); -static int loc_ulp_phone_context_settings_update(UlpPhoneContextSettings *settings); -static int loc_ulp_engine_update_criteria(UlpLocationCriteria criteria); static const void* loc_get_extension(const char* name); -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 = @@ -158,39 +146,7 @@ static const AGpsRilInterface sLocEngAGpsRilInterface = loc_agps_ril_update_network_availability }; -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 = -{ - sizeof(InjectRawCmdInterface), - loc_inject_raw_command -}; - -//ULP/Hybrid provider interfaces -static const UlpNetworkInterface sUlpNetworkInterface = -{ - sizeof(UlpNetworkInterface), - loc_ulp_network_init, - loc_ulp_send_network_position -}; -static const UlpPhoneContextInterface sLocEngUlpPhoneContextInterface = -{ - sizeof(UlpPhoneContextInterface), - loc_ulp_phone_context_init, - loc_ulp_phone_context_settings_update -}; - static loc_eng_data_s_type loc_afw_data; -static UlpCallbacks ulp_cb_data; static LocCallbacks afw_cb_data; static int gss_fd = 0; @@ -228,6 +184,11 @@ const GpsInterface* gps_get_hardware_interface () ret_val = &sLocEngInterface; } + loc_eng_read_config(); + + //We load up libulp module at this point itself + loc_eng_ulp_inf = loc_eng_get_ulp_inf(); + if (0 != loc_hal_init()) { LOC_LOGE("HAL could not be initialized"); ret_val = NULL; @@ -235,11 +196,6 @@ const GpsInterface* gps_get_hardware_interface () ret_val = &sLocEngInterface; } - loc_eng_read_config(); - - //We load up libulp module at this point itself - loc_eng_ulp_inf = loc_eng_get_ulp_inf(); - EXIT_LOG(%p, ret_val); return ret_val; } @@ -351,8 +307,6 @@ static int loc_hal_init(void) 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); EXIT_LOG(%d, retVal); @@ -438,26 +392,8 @@ static int loc_stop() { ENTRY_LOG(); int ret_val = -1; - if (loc_afw_data.ulp_initialized) { - //ULP initialized so we need to simulate REMOVE_CRITERIA for - //last client to libulp and we dont need to send loc_eng_stop - UlpLocationCriteria native_criteria; - native_criteria.valid_mask = (ULP_CRITERIA_HAS_ACTION | ULP_CRITERIA_HAS_PROVIDER_SOURCE | ULP_CRITERIA_HAS_RECURRENCE_TYPE | - ULP_CRITERIA_HAS_MIN_INTERVAL); - native_criteria.provider_source = ULP_PROVIDER_SOURCE_GNSS; - native_criteria.min_distance = 0; //This is not used by ULP engine so leaving it 0 for now - native_criteria.recurrence_type = loc_afw_data.recurrence_type_cached; - loc_afw_data.recurrence_type_cached = ULP_LOC_RECURRENCE_PERIODIC; - //For a GPS client horizontal_accuracy & power_consumption are irrelevant - native_criteria.preferred_horizontal_accuracy = ULP_HORZ_ACCURACY_DONT_CARE; - native_criteria.preferred_power_consumption = ULP_POWER_REQ_DONT_CARE; - native_criteria.action = ULP_REMOVE_CRITERIA; - native_criteria.min_interval = loc_afw_data.min_interval_cached; - loc_afw_data.min_interval_cached = ULP_MIN_INTERVAL_INVALID; - ret_val = loc_eng_update_criteria(loc_afw_data, native_criteria); - } else { - ret_val = loc_eng_stop(loc_afw_data); - } + ret_val = loc_eng_stop(loc_afw_data); + EXIT_LOG(%d, ret_val); return ret_val; } @@ -486,46 +422,23 @@ static int loc_set_position_mode(GpsPositionMode mode, { ENTRY_LOG(); int ret_val = -1; - if (!loc_afw_data.ulp_initialized) { - LocPositionMode locMode; - switch (mode) { - case GPS_POSITION_MODE_MS_BASED: - locMode = LOC_POSITION_MODE_MS_BASED; - break; - case GPS_POSITION_MODE_MS_ASSISTED: - locMode = LOC_POSITION_MODE_MS_ASSISTED; - break; - default: - locMode = LOC_POSITION_MODE_STANDALONE; - break; - } - - LocPosMode params(locMode, recurrence, min_interval, - preferred_accuracy, preferred_time, NULL, NULL); - ret_val = loc_eng_set_position_mode(loc_afw_data, params); - } else { - //ULP initialized so suppress set_position_mode updates to loc_eng - UlpLocationCriteria native_criteria; - native_criteria.valid_mask = (ULP_CRITERIA_HAS_ACTION | ULP_CRITERIA_HAS_PROVIDER_SOURCE | ULP_CRITERIA_HAS_RECURRENCE_TYPE | - ULP_CRITERIA_HAS_MIN_INTERVAL); - native_criteria.provider_source = ULP_PROVIDER_SOURCE_GNSS; - native_criteria.min_distance = 0; //This is not used by ULP engine so leaving it 0 for now - - if (LOC_POSITION_MODE_MS_ASSISTED == mode) - native_criteria.recurrence_type = ULP_LOC_RECURRENCE_SINGLE; - else - native_criteria.recurrence_type = ULP_LOC_RECURRENCE_PERIODIC; - - //For a GPS client horizontal_accuracy & power_consumption are irrelevant - native_criteria.preferred_horizontal_accuracy = ULP_HORZ_ACCURACY_DONT_CARE; - native_criteria.preferred_power_consumption = ULP_POWER_REQ_DONT_CARE; - native_criteria.action = ULP_ADD_CRITERIA; - native_criteria.min_interval = min_interval; - loc_afw_data.min_interval_cached = min_interval; //cache a copy - loc_afw_data.recurrence_type_cached = native_criteria.recurrence_type; //cache a copy - ret_val = loc_eng_update_criteria(loc_afw_data, native_criteria); + LocPositionMode locMode; + switch (mode) { + case GPS_POSITION_MODE_MS_BASED: + locMode = LOC_POSITION_MODE_MS_BASED; + break; + case GPS_POSITION_MODE_MS_ASSISTED: + locMode = LOC_POSITION_MODE_MS_ASSISTED; + break; + default: + locMode = LOC_POSITION_MODE_STANDALONE; + break; } + LocPosMode params(locMode, recurrence, min_interval, + preferred_accuracy, preferred_time, NULL, NULL); + ret_val = loc_eng_set_position_mode(loc_afw_data, params); + EXIT_LOG(%d, ret_val); return ret_val; } @@ -637,31 +550,6 @@ static void loc_delete_aiding_data(GpsAidingData f) EXIT_LOG(%s, VOID_RET); } -/*=========================================================================== -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 - -===========================================================================*/ -int loc_ulp_engine_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; -} - const GpsGeofencingInterface* get_geofence_interface(void) { ENTRY_LOG(); @@ -695,7 +583,6 @@ exit: EXIT_LOG(%d, geofence_interface == NULL); return geofence_interface; } - /*=========================================================================== FUNCTION loc_get_extension @@ -745,22 +632,6 @@ const void* loc_get_extension(const char* name) ret_val = &sLocEngAGpsRilInterface; } } - else if (strcmp(name, ULP_ENGINE_INTERFACE) == 0) - { - ret_val = &sLocEngUlpEngInterface; - } - else if (strcmp(name, ULP_RAW_CMD_INTERFACE) == 0) - { - ret_val = &sLocEngInjectRawCmdInterface; - } - else if(strcmp(name, ULP_PHONE_CONTEXT_INTERFACE) == 0) - { - ret_val = &sLocEngUlpPhoneContextInterface; - } - else if(strcmp(name, ULP_NETWORK_INTERFACE) == 0) - { - ret_val = &sUlpNetworkInterface; - } else if (strcmp(name, GPS_GEOFENCING_INTERFACE) == 0) { ret_val = get_geofence_interface(); @@ -1042,45 +913,16 @@ static void loc_agps_ril_update_network_availability(int available, const char* EXIT_LOG(%s, VOID_RET); } -/*=========================================================================== -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; -} - static void local_loc_cb(UlpLocation* location, void* locExt) { ENTRY_LOG(); if (NULL != location) { CALLBACK_LOG_CALLFLOW("location_cb - from", %d, location->position_source); - if (ULP_LOCATION_IS_FROM_GNSS == location->position_source ) { - if (NULL != gps_loc_cb) { - gps_loc_cb(&location->gpsLocation); - } else { - LOC_LOGE("Error. GPS not enabled"); - } + + if (NULL != gps_loc_cb) { + gps_loc_cb(&location->gpsLocation); } else { - if (NULL != ulp_loc_cb) { - ulp_loc_cb(location); - } + LOC_LOGE("Error. GPS not enabled"); } } EXIT_LOG(%s, VOID_RET); @@ -1150,158 +992,6 @@ exit: return loc_eng_ulpInf; } -/*=========================================================================== -FUNCTION loc_ulp_network_init - -DESCRIPTION - Initialize the ULP network interface. - -DEPENDENCIES - NONE - -RETURN VALUE - 0 - -SIDE EFFECTS - N/A - -===========================================================================*/ -static int loc_ulp_phone_context_init(UlpPhoneContextCallbacks *callbacks) -{ - ENTRY_LOG(); - int ret_val = -1; - ret_val = loc_eng_ulp_phone_context_init(loc_afw_data, callbacks); - EXIT_LOG(%d, ret_val); - return ret_val; -} -/*=========================================================================== -FUNCTION loc_ulp_phone_context_settings_update - -DESCRIPTION - This is used to inform the ULP module of phone settings changes carried out - by the users -DEPENDENCIES - N/A - -RETURN VALUE - 0: success - -SIDE EFFECTS - N/A - -===========================================================================*/ - -static int loc_ulp_phone_context_settings_update(UlpPhoneContextSettings *settings) -{ - ENTRY_LOG(); - int ret_val = -1; - ret_val = loc_eng_ulp_phone_context_settings_update(loc_afw_data, settings); - EXIT_LOG(%d, ret_val); - return ret_val; -} - -/*=========================================================================== -FUNCTION loc_ulp_network_init - -DESCRIPTION - Initialize the ULP network interface. - -DEPENDENCIES - NONE - -RETURN VALUE - 0 - -SIDE EFFECTS - N/A - -===========================================================================*/ -static int loc_ulp_network_init(UlpNetworkLocationCallbacks *callbacks) -{ - ENTRY_LOG(); - int ret_val = -1; - ret_val = loc_eng_ulp_network_init(loc_afw_data, callbacks); - EXIT_LOG(%d, ret_val); - return ret_val; -} - -/*=========================================================================== -FUNCTION loc_eng_ulp_send_network_position - -DESCRIPTION - Ulp send data - -DEPENDENCIES - NONE - -RETURN VALUE - 0 - -SIDE EFFECTS - N/A - -===========================================================================*/ -int loc_ulp_send_network_position(UlpNetworkPositionReport *position_report) -{ - ENTRY_LOG(); - int ret_val = -1; - ret_val = loc_eng_ulp_send_network_position(loc_afw_data, position_report); - EXIT_LOG(%d, ret_val); - return ret_val; -} - -/*=========================================================================== -FUNCTION loc_ulp_engine_init - -DESCRIPTION - Initialize the ULP Engine interface. - -DEPENDENCIES - NONE - -RETURN VALUE - 0 - -SIDE EFFECTS - N/A - -===========================================================================*/ -static int loc_ulp_engine_init(UlpEngineCallbacks* callbacks) -{ - int retVal = -1; - ENTRY_LOG(); - if(callbacks == NULL) { - LOC_LOGE("loc_ulp_engine_init failed. cb = NULL\n"); - EXIT_LOG(%d, retVal); - return retVal; - } - //Intilize the ulp call back cache at this point - memset(&ulp_cb_data, 0, sizeof(UlpCallbacks)); - ulp_loc_cb = callbacks->location_cb; - retVal = 0; - EXIT_LOG(%d, retVal); - return retVal; -} - -static int loc_ulp_engine_start() -{ - ENTRY_LOG(); - int ret_val = loc_eng_start(loc_afw_data); - - EXIT_LOG(%d, ret_val); - return ret_val; -} - -static int loc_ulp_engine_stop() -{ - ENTRY_LOG(); - int ret_val = loc_eng_stop(loc_afw_data); - - EXIT_LOG(%d, ret_val); - return ret_val; -} - - /*=========================================================================== FUNCTION loc_init diff --git a/loc_api/libloc_api_50001/loc.h b/loc_api/libloc_api_50001/loc.h index 08392179..9b1195b6 100644 --- a/loc_api/libloc_api_50001/loc.h +++ b/loc_api/libloc_api_50001/loc.h @@ -78,11 +78,6 @@ typedef struct { gps_request_utc_time request_utc_time_cb; } LocCallbacks; -typedef struct { - UlpNetworkLocationCallbacks* network_location_cb; - UlpPhoneContextCallbacks* phone_context_cb; -} UlpCallbacks; - enum loc_sess_status { LOC_SESS_SUCCESS, LOC_SESS_INTERMEDIATE, diff --git a/loc_api/libloc_api_50001/loc_eng.cpp b/loc_api/libloc_api_50001/loc_eng.cpp index 9391b5e8..91367ca0 100644 --- a/loc_api/libloc_api_50001/loc_eng.cpp +++ b/loc_api/libloc_api_50001/loc_eng.cpp @@ -523,19 +523,13 @@ int loc_eng_start(loc_eng_data_s_type &loc_eng_data) ENTRY_LOG_CALLFLOW(); INIT_CHECK(loc_eng_data.context, return -1); - if(loc_eng_data.ulp_initialized == true) - { - //Pass the start messgage to ULP if present & activated - loc_eng_msg *msg(new loc_eng_msg(&loc_eng_data, ULP_MSG_START_FIX)); - msg_q_snd( (void*)((LocEngContext*)(loc_eng_data.context))->ulp_q, - msg, loc_eng_free_msg); - } - else - { - 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, - msg, loc_eng_free_msg); - } + void* target_q = loc_eng_data.ulp_initialized? + (void*)((LocEngContext*)(loc_eng_data.context))->ulp_q: + (void*)((LocEngContext*)(loc_eng_data.context))->deferred_q; + + //Pass the start messgage to ULP if present & activated + loc_eng_msg *msg(new loc_eng_msg(&loc_eng_data, LOC_ENG_MSG_START_FIX)); + msg_q_snd( target_q, msg, loc_eng_free_msg); EXIT_LOG(%d, 0); return 0; } @@ -581,19 +575,13 @@ int loc_eng_stop(loc_eng_data_s_type &loc_eng_data) ENTRY_LOG_CALLFLOW(); INIT_CHECK(loc_eng_data.context, return -1); - if(loc_eng_data.ulp_initialized == true) - { - //Pass the start messgage to ULP if present & activated - loc_eng_msg *msg(new loc_eng_msg(&loc_eng_data, ULP_MSG_STOP_FIX)); - msg_q_snd( (void*)((LocEngContext*)(loc_eng_data.context))->ulp_q, - msg, loc_eng_free_msg); - } - else - { - 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, - msg, loc_eng_free_msg); - } + void* target_q = loc_eng_data.ulp_initialized? + (void*)((LocEngContext*)(loc_eng_data.context))->ulp_q: + (void*)((LocEngContext*)(loc_eng_data.context))->deferred_q; + + //Pass the start messgage to ULP if present & activated + loc_eng_msg *msg(new loc_eng_msg(&loc_eng_data, LOC_ENG_MSG_STOP_FIX)); + msg_q_snd( target_q, msg, loc_eng_free_msg); EXIT_LOG(%d, 0); return 0; @@ -665,9 +653,13 @@ int loc_eng_set_position_mode(loc_eng_data_s_type &loc_eng_data, INIT_CHECK(loc_eng_data.context, return -1); loc_eng_msg_position_mode *msg( new loc_eng_msg_position_mode(&loc_eng_data, params)); - msg_q_snd((void*)((LocEngContext*)(loc_eng_data.context))->deferred_q, - msg, loc_eng_free_msg); + void* target_q = loc_eng_data.ulp_initialized? + (void*)((LocEngContext*)(loc_eng_data.context))->ulp_q: + (void*)((LocEngContext*)(loc_eng_data.context))->deferred_q; + + //Pass the start messgage to ULP if present & activated + msg_q_snd(target_q, msg, loc_eng_free_msg); EXIT_LOG(%d, 0); return 0; } @@ -1515,20 +1507,16 @@ static void loc_eng_deferred_action_thread(void* arg) } // what's in the else if is... (line by line) // 1. this is a good fix; or - // 1.1 there is source info; or - // 1.1.1 this is from hybrid provider; - // 1.2 it is a Satellite fix; or - // 1.2.1 it is a sensor fix + // 1.1 it is a Satellite fix; or + // 1.1.1 it is a sensor fix // 2. (must be intermediate fix... implicit) // 2.1 we accepte intermediate; and // 2.2 it is NOT the case that // 2.2.1 there is inaccuracy; and // 2.2.2 we care about inaccuracy; and // 2.2.3 the inaccuracy exceeds our tolerance - else if ((LOC_SESS_SUCCESS == rpMsg->status && ( - ((LOCATION_HAS_SOURCE_INFO & rpMsg->location.gpsLocation.flags) && - ULP_LOCATION_IS_FROM_HYBRID == rpMsg->location.position_source) || - ((LOC_POS_TECH_MASK_SATELLITE & rpMsg->technology_mask) || + else if ((LOC_SESS_SUCCESS == rpMsg->status && + (((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.gpsLocation.flags & GPS_LOCATION_HAS_ACCURACY) && @@ -1832,36 +1820,6 @@ static void loc_eng_deferred_action_thread(void* arg) loc_eng_handle_engine_up(*loc_eng_data_p); break; - case LOC_ENG_MSG_REQUEST_NETWORK_POSIITON: - { - loc_eng_msg_request_network_position *nlprequestmsg = (loc_eng_msg_request_network_position*)msg; - //loc_eng_handle_request_network_position(nlprequestmsg ); - LOC_LOGD("Received n/w position request from ULP.Request type %d Periodicity: %d\n", - nlprequestmsg->networkPosRequest.request_type, - nlprequestmsg->networkPosRequest.interval_ms); - if(loc_eng_data_p->ulp_network_callback != NULL) - { - loc_eng_data_p->ulp_network_callback((UlpNetworkRequestPos*)&(nlprequestmsg->networkPosRequest)); - } - else - LOC_LOGE("Ulp Network call back not initialized"); - } - break; - - case LOC_ENG_MSG_REQUEST_PHONE_CONTEXT: - { - loc_eng_msg_request_phone_context *contextReqMsg = (loc_eng_msg_request_phone_context*)msg; - LOC_LOGD("Received phone context request from ULP.context_type 0x%x,request_type 0x%x ", - contextReqMsg->contextRequest.context_type,contextReqMsg->contextRequest.request_type) - if(loc_eng_data_p->ulp_phone_context_req_cb != NULL) - { - loc_eng_data_p->ulp_phone_context_req_cb((UlpPhoneContextRequest*)&(contextReqMsg->contextRequest)); - } - else - LOC_LOGE("Ulp Phone context request call back not initialized"); - } - break; - case LOC_ENG_MSG_LOC_INIT: { loc_eng_reinit(*loc_eng_data_p); @@ -1933,235 +1891,6 @@ int loc_eng_ulp_init(loc_eng_data_s_type &loc_eng_data, const ulpInterface * loc return ret_val; } -/*=========================================================================== -FUNCTION loc_eng_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 - -===========================================================================*/ -bool loc_eng_inject_raw_command(loc_eng_data_s_type &loc_eng_data, - char* command, int length) -{ - ENTRY_LOG_CALLFLOW(); - INIT_CHECK(loc_eng_data.context, return -1); - boolean ret_val; - LOC_LOGD("loc_eng_send_extra_command: %s\n", command); - ret_val = TRUE; - - if(loc_eng_data.ulp_initialized == true) - { - ulp_msg_inject_raw_command *msg( - new ulp_msg_inject_raw_command(&loc_eng_data,command, length)); - msg_q_snd( (void*)((LocEngContext*)(loc_eng_data.context))->ulp_q - , msg, loc_eng_free_msg); - ret_val = 0; - }else - { - ret_val = -1; - } - - - EXIT_LOG(%s, loc_logger_boolStr[ret_val!=0]); - return ret_val; -} -/*=========================================================================== -FUNCTION loc_eng_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 - -===========================================================================*/ -int loc_eng_update_criteria(loc_eng_data_s_type &loc_eng_data, - UlpLocationCriteria criteria) -{ - ENTRY_LOG_CALLFLOW(); - INIT_CHECK(loc_eng_data.context, return -1); - int ret_val; - - if(loc_eng_data.ulp_initialized == true) - { - LOC_LOGD("SJ:loc_eng_update_criteria: valid 0x%x action:%d, minTime:%ld, minDistance:%f, singleShot:%d, horizontalAccuracy:%d, powerRequirement:%d \n", - criteria.valid_mask, criteria.action, criteria.min_interval, criteria.min_distance, criteria.recurrence_type, criteria.preferred_horizontal_accuracy, - criteria.preferred_power_consumption ); - ulp_msg_update_criteria *msg( - new ulp_msg_update_criteria(&loc_eng_data,criteria)); - msg_q_snd( (void*)((LocEngContext*)(loc_eng_data.context))->ulp_q - , msg, loc_eng_free_msg); - ret_val = 0; - }else - { - ret_val = -1; - } - EXIT_LOG(%d, ret_val); - return ret_val; -} - -/*=========================================================================== -FUNCTION loc_eng_ulp_phone_context_settings_update - -DESCRIPTION - This is used to inform the ULP module of phone settings changes carried out - by the users -DEPENDENCIES - N/A - -RETURN VALUE - 0: success - -SIDE EFFECTS - N/A - -===========================================================================*/ - -int loc_eng_ulp_phone_context_settings_update(loc_eng_data_s_type &loc_eng_data, - UlpPhoneContextSettings *settings) -{ - ENTRY_LOG(); - int ret_val = -1; - - LOC_LOGD("loc_eng_ulp_phone_context_settings: context_type - 0x%x is_agps_enabled - %d " - "is_battery_charging %d ,is_gps_enabled %d, is_network_position_available %d," - "is_wifi_setting_enabled %d, is_agps_setting_enabled %d, is_enh_location_services_enabled %d\n", - settings->context_type ,settings->is_agps_enabled,settings->is_battery_charging, - settings->is_gps_enabled, settings->is_network_position_available, - settings->is_wifi_setting_enabled, settings->is_agps_enabled, - settings->is_enh_location_services_enabled ); - - if(loc_eng_data.ulp_initialized == true) - { - ulp_msg_inject_phone_context_settings *msg - (new ulp_msg_inject_phone_context_settings(&loc_eng_data, *settings)); - msg_q_snd( (void*)((LocEngContext*)(loc_eng_data.context))->ulp_q, msg, loc_eng_free_msg); - ret_val = 0; - } - - // Send battery information to modem for processing. - if(settings->context_type & ULP_PHONE_CONTEXT_BATTERY_CHARGING_STATE) - { - loc_eng_msg_ext_power_config *msg(new loc_eng_msg_ext_power_config(&loc_eng_data, settings->is_battery_charging)); - msg_q_snd( (void*)((LocEngContext*)(loc_eng_data.context))->deferred_q, msg, loc_eng_free_msg); - } - - EXIT_LOG(%d, ret_val); - return ret_val; -} -/*=========================================================================== -FUNCTION loc_eng_ulp_network_init - -DESCRIPTION - Initialize the ULP network interface. - -DEPENDENCIES - NONE - -RETURN VALUE - 0 - -SIDE EFFECTS - N/A - -===========================================================================*/ -int loc_eng_ulp_phone_context_init(loc_eng_data_s_type &loc_eng_data,UlpPhoneContextCallbacks *callback) -{ - int ret_val = -1; - ENTRY_LOG(); - if(callback != NULL) { - loc_eng_data.ulp_phone_context_req_cb = callback->ulp_request_phone_context_cb ; - ret_val = 0; - } - else - LOC_LOGE("loc_eng_ulp_phone_context_init: bad parameters cb %p", callback); - EXIT_LOG(%d, ret_val); - return ret_val; -} - -/*=========================================================================== -FUNCTION loc_eng_ulp_network_init - -DESCRIPTION - Initialize the ULP network interface. - -DEPENDENCIES - NONE - -RETURN VALUE - 0 - -SIDE EFFECTS - N/A - -===========================================================================*/ -int loc_eng_ulp_network_init(loc_eng_data_s_type &loc_eng_data, - UlpNetworkLocationCallbacks *callbacks) -{ - int ret_val = -1; - ENTRY_LOG_CALLFLOW(); - if(callbacks != NULL) { - loc_eng_data.ulp_network_callback = callbacks->ulp_network_location_request_cb; - ret_val = 0; - } - else - LOC_LOGE("loc_eng_ulp_network_init: bad parameters cb %p", callbacks); - EXIT_LOG(%d, ret_val); - return ret_val; -} - - -/*=========================================================================== -FUNCTION loc_eng_ulp_send_network_position - -DESCRIPTION - Ulp send data - -DEPENDENCIES - NONE - -RETURN VALUE - 0 - -SIDE EFFECTS - N/A - -===========================================================================*/ -int loc_eng_ulp_send_network_position(loc_eng_data_s_type &loc_eng_data, - UlpNetworkPositionReport *position_report) -{ - ENTRY_LOG(); - int ret_val = 0; - if(loc_eng_data.ulp_initialized == true) - { - ulp_msg_inject_network_position *msg - (new ulp_msg_inject_network_position(&loc_eng_data, *position_report)); - msg_q_snd( (void*)((LocEngContext*)(loc_eng_data.context))->ulp_q - , msg, loc_eng_free_msg); - ret_val = 0; - }else - { - ret_val = -1; - } - EXIT_LOG(%d, ret_val); - return ret_val; -} - /*=========================================================================== 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 db69befa..52a1d77c 100644 --- a/loc_api/libloc_api_50001/loc_eng.h +++ b/loc_api/libloc_api_50001/loc_eng.h @@ -95,7 +95,7 @@ private: }; // Module data -typedef struct +typedef struct loc_eng_data_s { LocApiAdapter *client_handle; loc_location_cb_ext location_cb; @@ -107,8 +107,6 @@ typedef struct gps_acquire_wakelock acquire_wakelock_cb; gps_release_wakelock release_wakelock_cb; gps_request_utc_time request_utc_time_cb; - ulp_network_location_request ulp_network_callback; - ulp_request_phone_context ulp_phone_context_req_cb; boolean intermediateFix; AGpsStatusValue agps_status; // used to defer stopping the GPS engine until AGPS data calls are done @@ -152,8 +150,6 @@ typedef struct char mpc_host_buf[101]; int mpc_port_buf; bool ulp_initialized; - uint32_t min_interval_cached; - UlpRecurrenceCriteria recurrence_type_cached; } loc_eng_data_s_type; #include "ulp.h" @@ -220,9 +216,6 @@ 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); -int loc_eng_update_criteria(loc_eng_data_s_type &loc_eng_data, - UlpLocationCriteria criteria); - void loc_eng_agps_init(loc_eng_data_s_type &loc_eng_data, AGpsExtCallbacks* callbacks); int loc_eng_agps_open(loc_eng_data_s_type &loc_eng_data, AGpsExtType agpsType, @@ -260,14 +253,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); -int loc_eng_ulp_network_init(loc_eng_data_s_type &loc_eng_data, UlpNetworkLocationCallbacks *callbacks); - -int loc_eng_ulp_phone_context_settings_update(loc_eng_data_s_type &loc_eng_data, - UlpPhoneContextSettings *settings); -int loc_eng_ulp_phone_context_init(loc_eng_data_s_type &loc_eng_data, - UlpPhoneContextCallbacks *callback); -int loc_eng_ulp_send_network_position(loc_eng_data_s_type &loc_eng_data, - UlpNetworkPositionReport *position_report); int loc_eng_read_config(void); #ifdef __cplusplus } diff --git a/loc_api/libloc_api_50001/loc_eng_log.cpp b/loc_api/libloc_api_50001/loc_eng_log.cpp index b0d64c68..6667ecbf 100644 --- a/loc_api/libloc_api_50001/loc_eng_log.cpp +++ b/loc_api/libloc_api_50001/loc_eng_log.cpp @@ -95,18 +95,7 @@ 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 ), - NAME_VAL( LOC_ENG_MSG_REQUEST_PHONE_CONTEXT ), - NAME_VAL( LOC_ENG_MSG_REQUEST_NETWORK_POSIITON ), - NAME_VAL( ULP_MSG_UPDATE_CRITERIA ), - NAME_VAL( ULP_MSG_START_FIX ), - NAME_VAL( ULP_MSG_STOP_FIX ), - NAME_VAL( ULP_MSG_INJECT_PHONE_CONTEXT_SETTINGS ), - NAME_VAL( ULP_MSG_INJECT_NETWORK_POSITION ), - NAME_VAL( ULP_MSG_REPORT_QUIPC_POSITION ), - NAME_VAL( ULP_MSG_REQUEST_COARSE_POSITION ), - NAME_VAL( ULP_MSG_MONITOR ), NAME_VAL( LOC_ENG_MSG_LPP_CONFIG ), - NAME_VAL( ULP_MSG_INJECT_RAW_COMMAND ), NAME_VAL( LOC_ENG_MSG_A_GLONASS_PROTOCOL ), NAME_VAL( LOC_ENG_MSG_LOC_INIT ) }; diff --git a/loc_api/libloc_api_50001/loc_eng_msg.h b/loc_api/libloc_api_50001/loc_eng_msg.h index 9d9c1581..22286777 100644 --- a/loc_api/libloc_api_50001/loc_eng_msg.h +++ b/loc_api/libloc_api_50001/loc_eng_msg.h @@ -35,7 +35,6 @@ #include #include #include "log_util.h" -#include "loc.h" #include #include "loc_eng_msg_id.h" @@ -825,118 +824,6 @@ struct loc_eng_msg_set_data_enable : public loc_eng_msg { } }; -struct loc_eng_msg_request_network_position : public loc_eng_msg { - const UlpNetworkRequestPos networkPosRequest; - inline loc_eng_msg_request_network_position (void* instance, UlpNetworkRequestPos networkPosReq) : - loc_eng_msg(instance, LOC_ENG_MSG_REQUEST_NETWORK_POSIITON), - networkPosRequest(networkPosReq) - { - LOC_LOGV("network position request: desired pos source %d\n request type: %d\n interval ms: %d ", - networkPosReq.desired_position_source, - networkPosReq.request_type, - networkPosReq.interval_ms); - } -}; - -struct loc_eng_msg_request_phone_context : public loc_eng_msg { - const UlpPhoneContextRequest contextRequest; - inline loc_eng_msg_request_phone_context (void* instance, UlpPhoneContextRequest contextReq) : - loc_eng_msg(instance, LOC_ENG_MSG_REQUEST_PHONE_CONTEXT), - contextRequest(contextReq) - { - LOC_LOGV("phone context request: request type 0x%x context type: 0x%x ", - contextRequest.request_type, - contextRequest.context_type); - } -}; - -struct ulp_msg_update_criteria : public loc_eng_msg { - const UlpLocationCriteria locationCriteria; - inline ulp_msg_update_criteria (void* instance, UlpLocationCriteria criteria) : - loc_eng_msg(instance, ULP_MSG_UPDATE_CRITERIA), - locationCriteria(criteria) - { - LOC_LOGV("location criteria: aciton %d\n valid mask: %d\n provider source: %d\n accuracy %d\n recurrence type %d\n min interval %d\n power consumption %d\n intermediate pos %d ", - locationCriteria.action, - locationCriteria.valid_mask, - locationCriteria.provider_source, - locationCriteria.preferred_horizontal_accuracy, - locationCriteria.recurrence_type, - locationCriteria.min_interval, - locationCriteria.preferred_power_consumption, - locationCriteria.intermediate_pos_report_enabled); - } -}; - -struct ulp_msg_inject_raw_command : public loc_eng_msg { - const char* rawCommand; - const int rawCommandLength; - inline ulp_msg_inject_raw_command (void* instance, char* command, int length) : - loc_eng_msg(instance, ULP_MSG_INJECT_RAW_COMMAND), - rawCommand(new char[length]), - rawCommandLength(length) - { - memcpy((void*)rawCommand, (void*)command, length); - LOC_LOGV("inject raw command: command %s\n command length: %d\n ", - rawCommand, - rawCommandLength); - } - - inline ~ulp_msg_inject_raw_command() - { - delete[] rawCommand; - } -}; - -struct ulp_msg_inject_phone_context_settings : public loc_eng_msg { - const UlpPhoneContextSettings phoneSetting; - inline ulp_msg_inject_phone_context_settings(void* instance, UlpPhoneContextSettings setting) : - loc_eng_msg(instance, ULP_MSG_INJECT_PHONE_CONTEXT_SETTINGS), - phoneSetting(setting) - { - LOC_LOGV("context type: %d\n gps enabled: %d\n network position available %d\n wifi setting enabled %d\n battery charging %d" - "is_agps_setting_enabled %d, is_enh_location_services_enabled %d\n", - phoneSetting.context_type, - phoneSetting.is_gps_enabled, - phoneSetting.is_network_position_available, - phoneSetting.is_wifi_setting_enabled, - phoneSetting.is_battery_charging, - phoneSetting.is_agps_enabled, - phoneSetting.is_enh_location_services_enabled); - } -}; - -struct ulp_msg_inject_network_position : public loc_eng_msg { - const UlpNetworkPositionReport networkPosition; - inline ulp_msg_inject_network_position(void* instance, UlpNetworkPositionReport networkPos) : - loc_eng_msg(instance, ULP_MSG_INJECT_NETWORK_POSITION), - networkPosition(networkPos) - { - LOC_LOGV("flags: %d\n source: %d\n latitude: %f\n longitude: %f\n accuracy %f", - networkPosition.valid_flag, - networkPosition.position.pos_source, - networkPosition.position.latitude, - networkPosition.position.longitude, - networkPosition.position.HEPE); - } -}; - -struct ulp_msg_report_quipc_position : public loc_eng_msg { - const UlpLocation location; - const int quipc_error_code; - inline ulp_msg_report_quipc_position(void* instance, UlpLocation &loc, - int quipc_err) : - loc_eng_msg(instance, ULP_MSG_REPORT_QUIPC_POSITION), - location(loc), quipc_error_code(quipc_err) - { - LOC_LOGV("flags: %d\n source: %d\n latitude: %f\n longitude: %f\n altitude: %f\n speed: %f\n bearing: %f\n accuracy: %f\n timestamp: %lld\n rawDataSize: %d\n rawData: %p\n Quipc error: %d", - location.gpsLocation.flags, location.position_source, location.gpsLocation.latitude, location.gpsLocation.longitude, - location.gpsLocation.altitude, location.gpsLocation.speed, location.gpsLocation.bearing, location.gpsLocation.accuracy, - location.gpsLocation.timestamp, location.rawDataSize, location.rawData, - quipc_error_code); - } -}; - void loc_eng_msg_sender(void* loc_eng_data_p, void* msg); int loc_eng_msgget(int * p_req_msgq); int loc_eng_msgremove(int req_msgq); 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 6d011240..6e35312c 100644 --- a/loc_api/libloc_api_50001/loc_eng_msg_id.h +++ b/loc_api/libloc_api_50001/loc_eng_msg_id.h @@ -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 @@ -42,13 +42,18 @@ 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, + /*******************OEMs PLEASE NOTE***************************/ + /* The next five messages are shared with libulp. They are should + not be altered if libulp cannot be recompiled */ + LOC_ENG_MSG_START_FIX, + LOC_ENG_MSG_STOP_FIX, + LOC_ENG_MSG_SET_POSITION_MODE, + LOC_ENG_MSG_REPORT_POSITION, + LOC_ENG_MSG_REPORT_SV, 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_REQUEST_XTRA_SERVER, @@ -69,8 +74,6 @@ enum loc_eng_msg_ids_t { 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_REPORT_XTRA_SERVER, @@ -87,50 +90,10 @@ enum loc_eng_msg_ids_t { LOC_ENG_MSG_REQUEST_POSITION, LOC_ENG_MSG_EXT_POWER_CONFIG, - // The following messages are added for ulp - LOC_ENG_MSG_REQUEST_PHONE_CONTEXT, - LOC_ENG_MSG_REQUEST_NETWORK_POSIITON, - - /* Following messages are for ulp, start at index 0x600 */ - - // Message is sent by GPS HAL layer to add/remove unique request criteria - ULP_MSG_UPDATE_CRITERIA = 0x600, - - // Message is sent by GPS HAL layer to request ULP to start producing position fixes - - ULP_MSG_START_FIX, - - // Message is sent by Android framework(GpsLocationProvider) - // to request ULP to stop producing position fixes - ULP_MSG_STOP_FIX, - - // Message is sent by Android framework(GpsLocationProvider) - // to inject phone context setting include initial phone context setting and subsequent changes - ULP_MSG_INJECT_PHONE_CONTEXT_SETTINGS, - - // Message is sent by network provider to INJECT the position in UlpNetworkPositionReport format - ULP_MSG_INJECT_NETWORK_POSITION, - - // Message is sent by QUIPC provider in order to report the position in GpsPosition format with QUIPC status - ULP_MSG_REPORT_QUIPC_POSITION, - - // Message is sent by QUIPC module in order to request some info from ULP - ULP_MSG_REQUEST_COARSE_POSITION, - - // Message is sent to ULP module to re-evaluate its subsystems - ULP_MSG_MONITOR, - - // Last ULP MSG - ULP_MSG_LAST = 0x700, - /* Message is sent by HAL to LOC API to configure LTE Positioning Profile in modem */ LOC_ENG_MSG_LPP_CONFIG, - // Message is sent by Android framework (GpsLocationProvider) - // to inject the raw command - ULP_MSG_INJECT_RAW_COMMAND, - /* Message is sent by HAL to LOC API to select A-GLONASS protocol */ LOC_ENG_MSG_A_GLONASS_PROTOCOL, diff --git a/loc_api/libloc_api_50001/loc_ulp.h b/loc_api/libloc_api_50001/loc_ulp.h index 5822b7ca..f4b1d0ed 100644 --- a/loc_api/libloc_api_50001/loc_ulp.h +++ b/loc_api/libloc_api_50001/loc_ulp.h @@ -38,11 +38,6 @@ extern "C" { #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 */ @@ -65,69 +60,6 @@ extern "C" { #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) */ @@ -144,269 +76,6 @@ typedef struct { unsigned char map_index[GPS_LOCATION_MAP_INDEX_SIZE]; } UlpLocation; -/** Callback with location information. - */ -typedef void (* ulp_location_callback)(UlpLocation* location); - -/** ULP Engine callback structure. */ -typedef struct { - /** set to sizeof(UlpCallbacks) */ - size_t size; - ulp_location_callback location_cb; -} UlpEngineCallbacks; - -typedef struct { - - uint32_t valid_mask; - /* delete or add. This is a mandatory field */ - int action; - /*via gps or hybrid provider*/ - int provider_source; - /** PERIODIC or SINGLE */ - UlpRecurrenceCriteria recurrence_type; - /** obtain position within the specified response time */ - uint32_t preferred_response_time; - /** Send updates after the specified interval */ - uint32_t min_interval; - /** Send updates after device moved a specified distance */ - float min_distance; - uint32_t min_dist_sample_interval; - /** Fields specfied in the mask should be reported in the - * position report (altitude, bearing and speed) */ - uint32_t desired_output_parameter; - /** Desired accuracy for latitude, longitude */ - UlpHorzAccuracyCriteria preferred_horizontal_accuracy; - /** Desired power consumption level */ - UlpPowerCriteria preferred_power_consumption; - /** Desired accuracy for altitude */ - UlpAccuracyCriteria preferred_altitude_accuracy; - /** Desired accuracy for bearing */ - UlpAccuracyCriteria preferred_bearing_accuracy; - UlpDataUsageCriteria preferred_data_usage; - bool intermediate_pos_report_enabled; -} UlpLocationCriteria; - -/** Represents the Ulp Egine interface. */ -typedef struct { - /** set to sizeof(UlpEngineInterface) */ - size_t size; - /** - * Opens the interface and provides the callback routines - * to the implemenation of this interface. - */ - int (*init)( UlpEngineCallbacks* callbacks ); - - /* set criterias of location requests */ - int (*update_criteria) (UlpLocationCriteria criteria ); - - /** Starts navigating. */ - int (*start)( void ); - - /** Stops navigating. */ - int (*stop)( void ); -} UlpEngineInterface; - - -/** Extended interface for raw GPS command support. */ -typedef struct { - /** set to sizeof(ExtraCmdInterface) */ - size_t size; - /** Injects Android extra cmd into the ulp. Clarify if they are blocking calls */ - bool (*inject_raw_cmd)(char* bundle, int bundle_length ); - -} InjectRawCmdInterface; - -/** ULP Network Interface */ -/** Request for network position status */ -#define ULP_NETWORK_POS_STATUS_REQUEST (0x01) -/** Request for periodic network positions */ -#define ULP_NETWORK_POS_START_PERIODIC_REQUEST (0x02) -/** Request last known location */ -#define ULP_NETWORK_POS_GET_LAST_KNOWN_LOCATION_REQUEST (0x03) -/** Cancel request */ -#define ULP_NETWORK_POS_STOP_REQUEST (0x04) - -/** Position was obtained using Wifi Network */ -#define ULP_NETWORK_POSITION_SRC_WIFI (0x01) -/** Position was obtained using Cell Network */ -#define ULP_NETWORK_POSITION_SRC_CELL (0x02) -/** Position was obtained using an Unknown Network */ -#define ULP_NETWORK_POSITION_SRC_UNKNOWN (0x00) - -/** Represents the ULP network request */ -typedef struct { - /** type of request */ - uint16_t request_type; - /** Desired time between network positions/measurements in ms. - * Shall be set to 0 if only one position is requested */ - int interval_ms; - /** network position source to be used */ - uint16_t desired_position_source; -}UlpNetworkRequestPos; - -/** Callback with network position request. */ -typedef void (*ulp_network_location_request)(UlpNetworkRequestPos *req); - -/** ULP Network callback structure. */ -typedef struct { - ulp_network_location_request ulp_network_location_request_cb; -} UlpNetworkLocationCallbacks; - -/** represent a network position */ -typedef struct { - /** source of the position (Wifi, Cell) */ - uint16_t pos_source; - /** latitude in degrees */ - double latitude; - /** longitude in degrees */ - double longitude; - /** Horzizontal error estimate in meters */ - float HEPE; -} UlpNetworkPosition; - -/** Represents access point information */ -typedef struct { - /** Mac adderess */ - char mac_addr[6]; - /** signal strength in dbM */ - int32_t rssi; - /** Beacon channel for access point */ - uint16_t channel; - - /** Bit 0 = AP is used by WiFi positioning system - * Bit 1 = AP doesn't broadcast SSID Bit 2 = AP has encrption - * turned on Bit 3 = AP is in infrastructure mode and not in - * ad-hoc/unknown mode */ - uint8_t ap_qualifier; -} UlpNetworkAccessPointInfo; - -/** Represents Wifi information */ -typedef struct { - /** Number of APs in the calculated position (-1 means - * unknown) */ - uint8_t num_aps_in_pos; - /** Information of the scanned ap's used in the position estimation*/ - UlpNetworkAccessPointInfo *ap_info; -} UlpNetworkWifiInfo; - - -/** Represent network landscape information */ -typedef struct { - /** network type Cell/Wifi */ - uint8_t network_type; - /** network information */ - union { - UlpNetworkWifiInfo wifi_info; - uint32_t cell_info; - } u; -} UlpNetworkLandscape; - -/** network report valid flags */ -/** fix time is valid */ -#define ULP_NETWORK_POSITION_REPORT_HAS_FIX_TIME (0x01) -/** position is valid */ -#define ULP_NETWORK_POSITION_REPORT_HAS_POSITION (0x02) -/** landscape is valid */ -#define ULP_NETWORK_POSITION_REPORT_HAS_LANDSCAPE (0x04) - -/** Represents the network position report */ -typedef struct -{ - /** validity flags */ - uint16_t valid_flag; - /** time fo network fix */ - GpsUtcTime fix_time; - /** network position */ - UlpNetworkPosition position; - /** network landscape */ - UlpNetworkLandscape landscape_info; -}UlpNetworkPositionReport; - -/** represents ULP network interface extension */ -typedef struct -{ - /** set to sizeof(UlpNetworkInterface) */ - size_t size; - /** initialize network interface */ - int ( *init)(UlpNetworkLocationCallbacks *callback); - /** send network position */ - int ( *ulp_send_network_position)(UlpNetworkPositionReport *position_report); -}UlpNetworkInterface; - -/** Information for the ULP Phone context interface */ - -/** the Location settings context supports only ON_CHANGE - * request type */ -#define ULP_PHONE_CONTEXT_GPS_SETTING (0x01) -#define ULP_PHONE_CONTEXT_NETWORK_POSITION_SETTING (0x02) -#define ULP_PHONE_CONTEXT_WIFI_SETTING (0x04) -/** The battery charging state context supports only - * ON_CHANGE request type */ -#define ULP_PHONE_CONTEXT_BATTERY_CHARGING_STATE (0x08) -#define ULP_PHONE_CONTEXT_AGPS_SETTING (0x010) -#define ULP_PHONE_CONTEXT_ENH_LOCATION_SERVICES_SETTING (0x020) - -/** return phone context only once */ -#define ULP_PHONE_CONTEXT_REQUEST_TYPE_SINGLE (0x01) -/** return phone context periodcially */ -#define ULP_PHONE_CONTEXT_REQUEST_TYPE_PERIODIC (0x02) -/** return phone context when it changes */ -#define ULP_PHONE_CONTEXT_REQUEST_TYPE_ON_CHANGE (0x03) - - -/** Represents ULP phone context request */ -typedef struct { - /** context type requested */ - uint16_t context_type; - /** request type */ - uint16_t request_type; - /** interval in ms if request type is periodic */ - int interval_ms; -}UlpPhoneContextRequest; - -/** Callback for phone context request. */ -typedef void (*ulp_request_phone_context)(UlpPhoneContextRequest *req); - -/** ULP Phone Context callback structure. */ -typedef struct { - ulp_request_phone_context ulp_request_phone_context_cb; -}UlpPhoneContextCallbacks; - -/** Represents the phone context settings */ -typedef struct { - /** Phone context information type */ - uint16_t context_type; - - /** network information */ - /** gps setting */ - bool is_gps_enabled; - /** is network positioning enabled */ - bool is_network_position_available; - /** is wifi turned on */ - bool is_wifi_setting_enabled; - /** is battery being currently charged */ - bool is_battery_charging; - /* is agps enabled for single shot */ - bool is_agps_enabled; - /* is Enhanced Location Services enabled by user*/ - bool is_enh_location_services_enabled; -} UlpPhoneContextSettings; - -/** Represent the phone contxt interface */ -typedef struct -{ - /** set to sizeof(UlpPhoneContextInterface) */ - size_t size; - /** Initialize, register callback */ - int (*init)(UlpPhoneContextCallbacks *callback); - /** send the phone context settings */ - int (*ulp_phone_context_settings_update) (UlpPhoneContextSettings *settings ); -}UlpPhoneContextInterface; - - -//int loc_update_criteria(UlpLocationCriteria criteria); -//const void* loc_get_extension(const char* name); - #ifdef __cplusplus } diff --git a/loc_api/ulp/inc/ulp.h b/loc_api/ulp/inc/ulp.h index 94f2ebd8..3a2e8e32 100644 --- a/loc_api/ulp/inc/ulp.h +++ b/loc_api/ulp/inc/ulp.h @@ -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 @@ -36,7 +36,7 @@ extern "C" #endif #include -#include "loc_eng.h" +struct loc_eng_data_s; /** Represents the standard ulp module interface. */ typedef struct { @@ -46,7 +46,9 @@ typedef struct { /** * Starts the libulp module. 0: success */ - int (*init)(loc_eng_data_s_type &loc_eng_data); + int (*init)(struct loc_eng_data_s &loc_eng_data); + /** Get a pointer to extension information. */ + const void* (*get_extension)(const char* name); }ulpInterface;