klte-common: update GPS HAL

* CAF package version: kk_3.5
* Revert the following patch as it's causing a missing symbol
  error when loading Samsung proprietary GPS libraries:

 "Add a new LocAdapterProxyBase class"

Change-Id: Ib23df3e207048ed32880537a528aa7f85ebcdfe1
This commit is contained in:
Matt Filetto 2014-09-14 10:41:16 -07:00 committed by Ethan Chen
parent 1cd206736f
commit ed22efea40
59 changed files with 836 additions and 646 deletions

View file

@ -52,9 +52,6 @@ BOARD_HAVE_BLUETOOTH_BCM := true
# CMHW
BOARD_HARDWARE_CLASS += hardware/samsung/cmhw
# GPS
TARGET_NO_RPC := true
# Lights
TARGET_PROVIDES_LIBLIGHT := true

View file

@ -29,6 +29,9 @@ INTERMEDIATE_POS=0
# supl version 1.0
SUPL_VER=0x10000
# Emergency SUPL, 1=enable, 0=disable
SUPL_ES=1
# GPS Capabilities bit mask
# SCHEDULING = 0x01
# MSB = 0x02
@ -69,6 +72,9 @@ LPP_PROFILE = 0 # Sensor R&D : This will not be injected to MODEM
# NMEA provider (1=Modem Processor, 0=Application Processor)
NMEA_PROVIDER=1
# Mark if it is a SGLTE target (1=SGLTE, 0=nonSGLTE)
SGLTE_TARGET=0
##################################################
# Select Positioning Protocol on A-GLONASS system
##################################################

View file

@ -1,50 +0,0 @@
# Copyright (C) 2007 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# If you don't need to do a full clean build but would like to touch
# a file or delete some intermediate files, add a clean step to the end
# of the list. These steps will only be run once, if they haven't been
# run before.
#
# E.g.:
# $(call add-clean-step, touch -c external/sqlite/sqlite3.h)
# $(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/STATIC_LIBRARIES/libz_intermediates)
#
# Always use "touch -c" and "rm -f" or "rm -rf" to gracefully deal with
# files that are missing or have been moved.
#
# Use $(PRODUCT_OUT) to get to the "out/target/product/blah/" directory.
# Use $(OUT_DIR) to refer to the "out" directory.
#
# If you need to re-do something that's already mentioned, just copy
# the command and add it to the bottom of the list. E.g., if a change
# that you made last week required touching a file and a change you
# made today requires touching the same file, just copy the old
# touch step and add it to the end of the list.
#
# ************************************************
# NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST
# ************************************************
# For example:
#$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/APPS/AndroidTests_intermediates)
#$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/core_intermediates)
#$(call add-clean-step, find $(OUT_DIR) -type f -name "IGTalkSession*" -print0 | xargs -0 rm -f)
#$(call add-clean-step, rm -rf $(PRODUCT_OUT)/data/*)
# ************************************************
# NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST
# ************************************************
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/SHARED_LIBRARIES/libloc_api*)

View file

@ -66,12 +66,27 @@ LocApiBase* ContextBase::createLocApi(LOC_API_ADAPTER_EVENT_MASK_T exMask)
// first if can not be MPQ
if (TARGET_MPQ != loc_get_target()) {
if (NULL == (locApi = mLBSProxy->getLocApi(mMsgTask, exMask))) {
// only RPC is the option now
void* handle = dlopen("libloc_api-rpc-qc.so", RTLD_NOW);
if (NULL != handle) {
void *handle = NULL;
//try to see if LocApiV02 is present
if((handle = dlopen("libloc_api_v02.so", RTLD_NOW)) != NULL) {
LOC_LOGD("%s:%d]: libloc_api_v02.so is present", __func__, __LINE__);
getLocApi_t* getter = (getLocApi_t*)dlsym(handle, "getLocApi");
if (NULL != getter) {
locApi = (*getter)(mMsgTask, exMask);
if(getter != NULL) {
LOC_LOGD("%s:%d]: getter is not NULL for LocApiV02", __func__, __LINE__);
locApi = (*getter)(mMsgTask,exMask);
}
}
// only RPC is the option now
else {
LOC_LOGD("%s:%d]: libloc_api_v02.so is NOT present. Trying RPC",
__func__, __LINE__);
handle = dlopen("libloc_api-rpc-qc.so", RTLD_NOW);
if (NULL != handle) {
getLocApi_t* getter = (getLocApi_t*)dlsym(handle, "getLocApi");
if (NULL != getter) {
LOC_LOGD("%s:%d]: getter is not NULL in RPC", __func__, __LINE__);
locApi = (*getter)(mMsgTask, exMask);
}
}
}
}

View file

@ -1,4 +1,4 @@
/* Copyright (c) 2011-2013, The Linux Foundation. All rights reserved.
/* Copyright (c) 2011-2014, 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
@ -56,8 +56,8 @@ public:
inline const MsgTask* getMsgTask() { return mMsgTask; }
inline LocApiBase* getLocApi() { return mLocApi; }
inline LocApiProxyBase* getLocApiProxy() { return mLocApiProxy; }
inline bool hasAgpsExt() { return mLBSProxy->hasAgpsExt(); }
inline bool hasCPIExt() { return mLBSProxy->hasCPIExt(); }
inline bool hasAgpsExtendedCapabilities() { return mLBSProxy->hasAgpsExtendedCapabilities(); }
inline bool hasCPIExtendedCapabilities() { return mLBSProxy->hasCPIExtendedCapabilities(); }
inline void requestUlp(LocAdapterBase* adapter,
unsigned long capabilities) {
mLBSProxy->requestUlp(adapter, capabilities);

View file

@ -1,4 +1,4 @@
/* Copyright (c) 2013, The Linux Foundation. All rights reserved.
/* Copyright (c) 2013-2014, 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
@ -49,8 +49,8 @@ public:
inline virtual ~LBSProxyBase() {}
inline virtual void requestUlp(LocAdapterBase* adapter,
unsigned long capabilities) const {}
inline virtual bool hasAgpsExt() const { return false; }
inline virtual bool hasCPIExt() const { return false; }
inline virtual bool hasAgpsExtendedCapabilities() const { return false; }
inline virtual bool hasCPIExtendedCapabilities() const { return false; }
};
typedef LBSProxyBase* (getLBSProxy_t)();

View file

@ -97,6 +97,7 @@ public:
virtual bool requestNiNotify(GpsNiNotification &notify,
const void* data);
inline virtual bool isInSession() { return false; }
ContextBase* getContext() const { return mContext; }
};
} // namespace loc_core

View file

@ -404,7 +404,8 @@ enum loc_api_adapter_err LocApiBase::
DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)
enum loc_api_adapter_err LocApiBase::
setSensorControlConfig(int sensorUsage)
setSensorControlConfig(int sensorUsage,
int sensorProvider)
DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)
enum loc_api_adapter_err LocApiBase::

View file

@ -70,7 +70,6 @@ class LocApiBase {
friend struct LocOpenMsg;
friend class ContextBase;
const MsgTask* mMsgTask;
LocAdapterBase* mLocAdapters[MAX_ADAPTERS];
protected:
@ -87,6 +86,10 @@ protected:
const LOC_API_ADAPTER_EVENT_MASK_T mExcludedMask;
public:
inline void sendMsg(const LocMsg* msg) const {
mMsgTask->sendMsg(msg);
}
void addAdapter(LocAdapterBase* adapter);
void removeAdapter(LocAdapterBase* adapter);
@ -158,7 +161,7 @@ public:
virtual enum loc_api_adapter_err
setLPPConfig(uint32_t profile);
virtual enum loc_api_adapter_err
setSensorControlConfig(int sensorUsage);
setSensorControlConfig(int sensorUsage, int sensorProvider);
virtual enum loc_api_adapter_err
setSensorProperties(bool gyroBiasVarianceRandomWalk_valid,
float gyroBiasVarianceRandomWalk,

View file

@ -74,6 +74,8 @@ const MsgTask* LocDualContext::getMsgTask(MsgTask::tAssociate tAssociate,
{
if (NULL == mMsgTask) {
mMsgTask = new MsgTask(tAssociate, name);
} else if (tAssociate) {
mMsgTask->associate(tAssociate);
}
return mMsgTask;
}

View file

@ -35,7 +35,6 @@
#include <msg_q.h>
#include <log_util.h>
#include <loc_log.h>
#include <android_runtime/AndroidRuntime.h>
namespace loc_core {
@ -69,6 +68,21 @@ MsgTask::~MsgTask() {
msg_q_unblock((void*)mQ);
}
void MsgTask::associate(tAssociate tAssociator) const {
struct LocAssociateMsg : public LocMsg {
tAssociate mAssociator;
inline LocAssociateMsg(tAssociate associator) :
LocMsg(), mAssociator(associator) {}
inline virtual void proc() const {
if (mAssociator) {
LOC_LOGD("MsgTask::associate");
mAssociator();
}
}
};
sendMsg(new LocAssociateMsg(tAssociator));
}
void MsgTask::createPThread(const char* threadName) {
pthread_attr_t attr;
pthread_attr_init(&attr);

View file

@ -52,6 +52,7 @@ public:
MsgTask(tAssociate tAssociator, const char* threadName);
~MsgTask();
void sendMsg(const LocMsg* msg) const;
void associate(tAssociate tAssociator) const;
private:
const void* mQ;

View file

@ -1,4 +1,4 @@
/* Copyright (c) 2013, The Linux Foundation. All rights reserved.
/* Copyright (c) 2013-2014, 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
@ -37,11 +37,19 @@ class LocAdapterBase;
class UlpProxyBase {
public:
inline UlpProxyBase() {}
LocPosMode mPosMode;
bool mFixSet;
inline UlpProxyBase() {
mPosMode.mode = LOC_POSITION_MODE_INVALID;
mFixSet = false;
}
inline virtual ~UlpProxyBase() {}
inline virtual bool sendStartFix() { return false;}
inline virtual bool sendStopFix() { return false;}
inline virtual bool sendFixMode(LocPosMode &params) { return false;}
inline virtual bool sendStartFix() { mFixSet = true; return false; }
inline virtual bool sendStopFix() { mFixSet = false; return false; }
inline virtual bool sendFixMode(LocPosMode &params) {
mPosMode = params;
return false;
}
inline virtual bool reportPosition(UlpLocation &location,
GpsLocationExtended &locationExtended,
void* locationExt,

View file

@ -55,12 +55,16 @@ extern "C" {
/** Position source is ULP */
#define ULP_LOCATION_IS_FROM_HYBRID 0x0001
/** Position source is GNSS only */
#define ULP_LOCATION_IS_FROM_GNSS 0x0002
#define ULP_LOCATION_IS_FROM_GNSS 0x0002
/** Position source is ZPP only */
#define ULP_LOCATION_IS_FROM_ZPP 0x0004
#define ULP_LOCATION_IS_FROM_ZPP 0x0004
/** Position is from a Geofence Breach Event */
#define ULP_LOCATION_IS_FROM_GEOFENCE 0X0008
#define ULP_MIN_INTERVAL_INVALID 0xffffffff
/*Emergency SUPL*/
#define GPS_NI_TYPE_EMERGENCY_SUPL 4
typedef struct {
/** set to sizeof(UlpLocation) */
@ -285,52 +289,54 @@ enum loc_api_adapter_err {
};
enum loc_api_adapter_event_index {
LOC_API_ADAPTER_REPORT_POSITION = 0, // Position report comes in loc_parsed_position_s_type
LOC_API_ADAPTER_REPORT_SATELLITE, // Satellite in view report
LOC_API_ADAPTER_REPORT_NMEA_1HZ, // NMEA report at 1HZ rate
LOC_API_ADAPTER_REPORT_NMEA_POSITION, // NMEA report at position report rate
LOC_API_ADAPTER_REQUEST_NI_NOTIFY_VERIFY, // NI notification/verification request
LOC_API_ADAPTER_REQUEST_ASSISTANCE_DATA, // Assistance data, eg: time, predicted orbits request
LOC_API_ADAPTER_REQUEST_LOCATION_SERVER, // Request for location server
LOC_API_ADAPTER_REPORT_IOCTL, // Callback report for loc_ioctl
LOC_API_ADAPTER_REPORT_STATUS, // Misc status report: eg, engine state
LOC_API_ADAPTER_REQUEST_WIFI, //
LOC_API_ADAPTER_SENSOR_STATUS, //
LOC_API_ADAPTER_REQUEST_TIME_SYNC, //
LOC_API_ADAPTER_REPORT_SPI, //
LOC_API_ADAPTER_REPORT_NI_GEOFENCE, //
LOC_API_ADAPTER_GEOFENCE_GEN_ALERT, //
LOC_API_ADAPTER_REPORT_GENFENCE_BREACH, //
LOC_API_ADAPTER_PEDOMETER_CTRL, //
LOC_API_ADAPTER_MOTION_CTRL, //
LOC_API_ADAPTER_REQUEST_WIFI_AP_DATA, // Wifi ap data
LOC_API_ADAPTER_BATCH_FULL, // Batching on full
LOC_API_ADAPTER_BATCHED_POSITION_REPORT, // Batching on fix
LOC_API_ADAPTER_REPORT_POSITION = 0, // Position report comes in loc_parsed_position_s_type
LOC_API_ADAPTER_REPORT_SATELLITE, // Satellite in view report
LOC_API_ADAPTER_REPORT_NMEA_1HZ, // NMEA report at 1HZ rate
LOC_API_ADAPTER_REPORT_NMEA_POSITION, // NMEA report at position report rate
LOC_API_ADAPTER_REQUEST_NI_NOTIFY_VERIFY, // NI notification/verification request
LOC_API_ADAPTER_REQUEST_ASSISTANCE_DATA, // Assistance data, eg: time, predicted orbits request
LOC_API_ADAPTER_REQUEST_LOCATION_SERVER, // Request for location server
LOC_API_ADAPTER_REPORT_IOCTL, // Callback report for loc_ioctl
LOC_API_ADAPTER_REPORT_STATUS, // Misc status report: eg, engine state
LOC_API_ADAPTER_REQUEST_WIFI, //
LOC_API_ADAPTER_SENSOR_STATUS, //
LOC_API_ADAPTER_REQUEST_TIME_SYNC, //
LOC_API_ADAPTER_REPORT_SPI, //
LOC_API_ADAPTER_REPORT_NI_GEOFENCE, //
LOC_API_ADAPTER_GEOFENCE_GEN_ALERT, //
LOC_API_ADAPTER_REPORT_GENFENCE_BREACH, //
LOC_API_ADAPTER_PEDOMETER_CTRL, //
LOC_API_ADAPTER_MOTION_CTRL, //
LOC_API_ADAPTER_REQUEST_WIFI_AP_DATA, // Wifi ap data
LOC_API_ADAPTER_BATCH_FULL, // Batching on full
LOC_API_ADAPTER_BATCHED_POSITION_REPORT, // Batching on fix
LOC_API_ADAPTER_BATCHED_GENFENCE_BREACH_REPORT, //
LOC_API_ADAPTER_EVENT_MAX
};
#define LOC_API_ADAPTER_BIT_PARSED_POSITION_REPORT (1<<LOC_API_ADAPTER_REPORT_POSITION)
#define LOC_API_ADAPTER_BIT_SATELLITE_REPORT (1<<LOC_API_ADAPTER_REPORT_SATELLITE)
#define LOC_API_ADAPTER_BIT_NMEA_1HZ_REPORT (1<<LOC_API_ADAPTER_REPORT_NMEA_1HZ)
#define LOC_API_ADAPTER_BIT_NMEA_POSITION_REPORT (1<<LOC_API_ADAPTER_REPORT_NMEA_POSITION)
#define LOC_API_ADAPTER_BIT_NI_NOTIFY_VERIFY_REQUEST (1<<LOC_API_ADAPTER_REQUEST_NI_NOTIFY_VERIFY)
#define LOC_API_ADAPTER_BIT_ASSISTANCE_DATA_REQUEST (1<<LOC_API_ADAPTER_REQUEST_ASSISTANCE_DATA)
#define LOC_API_ADAPTER_BIT_LOCATION_SERVER_REQUEST (1<<LOC_API_ADAPTER_REQUEST_LOCATION_SERVER)
#define LOC_API_ADAPTER_BIT_IOCTL_REPORT (1<<LOC_API_ADAPTER_REPORT_IOCTL)
#define LOC_API_ADAPTER_BIT_STATUS_REPORT (1<<LOC_API_ADAPTER_REPORT_STATUS)
#define LOC_API_ADAPTER_BIT_REQUEST_WIFI (1<<LOC_API_ADAPTER_REQUEST_WIFI)
#define LOC_API_ADAPTER_BIT_SENSOR_STATUS (1<<LOC_API_ADAPTER_SENSOR_STATUS)
#define LOC_API_ADAPTER_BIT_REQUEST_TIME_SYNC (1<<LOC_API_ADAPTER_REQUEST_TIME_SYNC)
#define LOC_API_ADAPTER_BIT_REPORT_SPI (1<<LOC_API_ADAPTER_REPORT_SPI)
#define LOC_API_ADAPTER_BIT_REPORT_NI_GEOFENCE (1<<LOC_API_ADAPTER_REPORT_NI_GEOFENCE)
#define LOC_API_ADAPTER_BIT_GEOFENCE_GEN_ALERT (1<<LOC_API_ADAPTER_GEOFENCE_GEN_ALERT)
#define LOC_API_ADAPTER_BIT_REPORT_GENFENCE_BREACH (1<<LOC_API_ADAPTER_REPORT_GENFENCE_BREACH)
#define LOC_API_ADAPTER_BIT_PEDOMETER_CTRL (1<<LOC_API_ADAPTER_PEDOMETER_CTRL)
#define LOC_API_ADAPTER_BIT_MOTION_CTRL (1<<LOC_API_ADAPTER_MOTION_CTRL)
#define LOC_API_ADAPTER_BIT_REQUEST_WIFI_AP_DATA (1<<LOC_API_ADAPTER_REQUEST_WIFI_AP_DATA)
#define LOC_API_ADAPTER_BIT_BATCH_FULL (1<<LOC_API_ADAPTER_BATCH_FULL)
#define LOC_API_ADAPTER_BIT_BATCHED_POSITION_REPORT (1<<LOC_API_ADAPTER_BATCHED_POSITION_REPORT)
#define LOC_API_ADAPTER_BIT_PARSED_POSITION_REPORT (1<<LOC_API_ADAPTER_REPORT_POSITION)
#define LOC_API_ADAPTER_BIT_SATELLITE_REPORT (1<<LOC_API_ADAPTER_REPORT_SATELLITE)
#define LOC_API_ADAPTER_BIT_NMEA_1HZ_REPORT (1<<LOC_API_ADAPTER_REPORT_NMEA_1HZ)
#define LOC_API_ADAPTER_BIT_NMEA_POSITION_REPORT (1<<LOC_API_ADAPTER_REPORT_NMEA_POSITION)
#define LOC_API_ADAPTER_BIT_NI_NOTIFY_VERIFY_REQUEST (1<<LOC_API_ADAPTER_REQUEST_NI_NOTIFY_VERIFY)
#define LOC_API_ADAPTER_BIT_ASSISTANCE_DATA_REQUEST (1<<LOC_API_ADAPTER_REQUEST_ASSISTANCE_DATA)
#define LOC_API_ADAPTER_BIT_LOCATION_SERVER_REQUEST (1<<LOC_API_ADAPTER_REQUEST_LOCATION_SERVER)
#define LOC_API_ADAPTER_BIT_IOCTL_REPORT (1<<LOC_API_ADAPTER_REPORT_IOCTL)
#define LOC_API_ADAPTER_BIT_STATUS_REPORT (1<<LOC_API_ADAPTER_REPORT_STATUS)
#define LOC_API_ADAPTER_BIT_REQUEST_WIFI (1<<LOC_API_ADAPTER_REQUEST_WIFI)
#define LOC_API_ADAPTER_BIT_SENSOR_STATUS (1<<LOC_API_ADAPTER_SENSOR_STATUS)
#define LOC_API_ADAPTER_BIT_REQUEST_TIME_SYNC (1<<LOC_API_ADAPTER_REQUEST_TIME_SYNC)
#define LOC_API_ADAPTER_BIT_REPORT_SPI (1<<LOC_API_ADAPTER_REPORT_SPI)
#define LOC_API_ADAPTER_BIT_REPORT_NI_GEOFENCE (1<<LOC_API_ADAPTER_REPORT_NI_GEOFENCE)
#define LOC_API_ADAPTER_BIT_GEOFENCE_GEN_ALERT (1<<LOC_API_ADAPTER_GEOFENCE_GEN_ALERT)
#define LOC_API_ADAPTER_BIT_REPORT_GENFENCE_BREACH (1<<LOC_API_ADAPTER_REPORT_GENFENCE_BREACH)
#define LOC_API_ADAPTER_BIT_BATCHED_GENFENCE_BREACH_REPORT (1<<LOC_API_ADAPTER_BATCHED_GENFENCE_BREACH_REPORT)
#define LOC_API_ADAPTER_BIT_PEDOMETER_CTRL (1<<LOC_API_ADAPTER_PEDOMETER_CTRL)
#define LOC_API_ADAPTER_BIT_MOTION_CTRL (1<<LOC_API_ADAPTER_MOTION_CTRL)
#define LOC_API_ADAPTER_BIT_REQUEST_WIFI_AP_DATA (1<<LOC_API_ADAPTER_REQUEST_WIFI_AP_DATA)
#define LOC_API_ADAPTER_BIT_BATCH_FULL (1<<LOC_API_ADAPTER_BATCH_FULL)
#define LOC_API_ADAPTER_BIT_BATCHED_POSITION_REPORT (1<<LOC_API_ADAPTER_BATCHED_POSITION_REPORT)
typedef unsigned int LOC_API_ADAPTER_EVENT_MASK_T;

View file

@ -1,4 +1,4 @@
/* Copyright (c) 2011-2013, The Linux Foundation. All rights reserved.
/* Copyright (c) 2011-2014, 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
@ -161,7 +161,8 @@ static loc_name_val_s_type loc_eng_ni_types[] =
{
NAME_VAL( GPS_NI_TYPE_VOICE ),
NAME_VAL( GPS_NI_TYPE_UMTS_SUPL ),
NAME_VAL( GPS_NI_TYPE_UMTS_CTRL_PLANE )
NAME_VAL( GPS_NI_TYPE_UMTS_CTRL_PLANE ),
NAME_VAL( GPS_NI_TYPE_EMERGENCY_SUPL )
};
static int loc_eng_ni_type_num = sizeof(loc_eng_ni_types) / sizeof(loc_name_val_s_type);
@ -204,7 +205,7 @@ static loc_name_val_s_type loc_eng_agps_bears[] =
{
NAME_VAL( AGPS_APN_BEARER_INVALID ),
NAME_VAL( AGPS_APN_BEARER_IPV4 ),
NAME_VAL( AGPS_APN_BEARER_IPV4 ),
NAME_VAL( AGPS_APN_BEARER_IPV6 ),
NAME_VAL( AGPS_APN_BEARER_IPV4V6 )
};
static int loc_eng_agps_bears_num = sizeof(loc_eng_agps_bears) / sizeof(loc_name_val_s_type);

View file

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

View file

@ -1,85 +0,0 @@
#Uncommenting these urls would only enable
#the power up auto injection and force injection(test case).
XTRA_SERVER_1=http://xtra1.gpsonextra.net/xtra2.bin
XTRA_SERVER_2=http://xtra2.gpsonextra.net/xtra2.bin
XTRA_SERVER_3=http://xtra3.gpsonextra.net/xtra2.bin
# Error Estimate
# _SET = 1
# _CLEAR = 0
ERR_ESTIMATE=0
#Test
NTP_SERVER=time.gpsonextra.net
#Asia
# NTP_SERVER=asia.pool.ntp.org
#Europe
# NTP_SERVER=europe.pool.ntp.org
#North America
# NTP_SERVER=north-america.pool.ntp.org
# DEBUG LEVELS: 0 - none, 1 - Error, 2 - Warning, 3 - Info
# 4 - Debug, 5 - Verbose
# If DEBUG_LEVEL is commented, Android's logging levels will be used
DEBUG_LEVEL = 4
# Intermediate position report, 1=enable, 0=disable
INTERMEDIATE_POS=0
# supl version 1.0
SUPL_VER=0x10000
# GPS Capabilities bit mask
# SCHEDULING = 0x01
# MSB = 0x02
# MSA = 0x04
# ON_DEMAND_TIME = 0x10
# GEOFENCE = 0x20
# default = ON_DEMAND_TIME | MSA | MSB | SCHEDULING | GEOFENCE
CAPABILITIES=0x37
# Accuracy threshold for intermediate positions
# less accurate positions are ignored, 0 for passing all positions
# ACCURACY_THRES=5000
################################
##### AGPS server settings #####
################################
# FOR SUPL SUPPORT, set the following
# SUPL_HOST=supl.host.com or IP
# SUPL_PORT=1234
# FOR C2K PDE SUPPORT, set the following
# C2K_HOST=c2k.pde.com or IP
# C2K_PORT=1234
####################################
# LTE Positioning Profile Settings
####################################
# 0: Enable RRLP on LTE(Default)
# 1: Enable LPP_User_Plane on LTE
# 2: Enable LPP_Control_Plane
# 3: Enable both LPP_User_Plane and LPP_Control_Plane
LPP_PROFILE = 0 # Sensor R&D : This will not be injected to MODEM
################################
# EXTRA SETTINGS
################################
# NMEA provider (1=Modem Processor, 0=Application Processor)
NMEA_PROVIDER=1
##################################################
# Select Positioning Protocol on A-GLONASS system
##################################################
# 0x1: RRC CPlane
# 0x2: RRLP UPlane
# 0x4: LLP Uplane
A_GLONASS_POS_PROTOCOL_SELECT = 0x0
##################################################
# Delete only Ephemeris files
##################################################
#0 : off - default
#1 : on - Erase only eph files when we use 'delete aiding data' function.
DEL_EPH_ONLY = 0

View file

@ -1,42 +0,0 @@
################################
# Sensor Settings
################################
# Needs to be set explicitly based on sensor
# There is no default value.
# used in loc_eng_reinit
#GYRO_BIAS_RANDOM_WALK=
#ACCEL_RANDOM_WALK_SPECTRAL_DENSITY=
#ANGLE_RANDOM_WALK_SPECTRAL_DENSITY=
#RATE_RANDOM_WALK_SPECTRAL_DENSITY=
#VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY=
# Sensor Sampling Rate Parameters for Low-Data Rate Filter (should be greater than 0)
# used in loc_eng_reinit
SENSOR_ACCEL_BATCHES_PER_SEC=3
SENSOR_ACCEL_SAMPLES_PER_BATCH=5
SENSOR_GYRO_BATCHES_PER_SEC=3
SENSOR_GYRO_SAMPLES_PER_BATCH=5
# Sensor Sampling Rate Parameters for High-Data Rate Filter (should be greater than 0)
SENSOR_ACCEL_BATCHES_PER_SEC_HIGH=4
SENSOR_ACCEL_SAMPLES_PER_BATCH_HIGH=25
SENSOR_GYRO_BATCHES_PER_SEC_HIGH=4
SENSOR_GYRO_SAMPLES_PER_BATCH_HIGH=25
# Sensor Control Mode (0=AUTO, 1=FORCE_ON)
# used in loc_eng_reinit
SENSOR_CONTROL_MODE=0
# Enable or Disable Sensors for GPS use (0=Enable, 1=Disable)
# used in loc_eng_reinit
SENSOR_USAGE=0
# Choose GSIFF sensor provider (1=Snapdragon Sensors Core, 2=Android NDK)
SENSOR_PROVIDER=2
# Bit mask used to define which sensor algorithms are used.
# Setting each bit has the following definition:
# 0x1 - DISABLE_INS_POSITIONING_FILTER
# 0x0 - ENABLE_INS_POSITIONING_FILTER
SENSOR_ALGORITHM_CONFIG_MASK=0x1

View file

@ -74,8 +74,7 @@ LOCAL_SHARED_LIBRARIES := \
libloc_eng \
libloc_core \
libgps.utils \
libdl \
libandroid_runtime
libdl
LOCAL_SRC_FILES += \
loc.cpp \
@ -85,6 +84,10 @@ LOCAL_CFLAGS += \
-fno-short-enums \
-D_ANDROID_ \
ifeq ($(TARGET_USES_QCOM_BSP), true)
LOCAL_CFLAGS += -DTARGET_USES_QCOM_BSP
endif
## Includes
LOCAL_C_INCLUDES:= \
$(TARGET_OUT_HEADERS)/gps.utils \

View file

@ -1,4 +1,4 @@
/* Copyright (c) 2011-2013, The Linux Foundation. All rights reserved.
/* Copyright (c) 2011-2014, 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
@ -52,6 +52,34 @@ void LocInternalAdapter::stopFixInt() {
void LocInternalAdapter::getZppInt() {
sendMsg(new LocEngGetZpp(mLocEngAdapter));
}
LocEngAdapter::LocEngAdapter(LOC_API_ADAPTER_EVENT_MASK_T mask,
void* owner, ContextBase* context,
MsgTask::tCreate tCreator) :
LocAdapterBase(mask,
//Get the AFW context if VzW context has not already been intialized in
//loc_ext
context == NULL?
LocDualContext::getLocFgContext(tCreator,
LocDualContext::mLocationHalName)
:context),
mOwner(owner), mInternalAdapter(new LocInternalAdapter(this)),
mUlp(new UlpProxyBase()), mNavigating(false),
mSupportsAgpsRequests(false),
mSupportsPositionInjection(false)
{
memset(&mFixCriteria, 0, sizeof(mFixCriteria));
mFixCriteria.mode = LOC_POSITION_MODE_INVALID;
LOC_LOGD("LocEngAdapter created");
}
inline
LocEngAdapter::~LocEngAdapter()
{
delete mInternalAdapter;
LOC_LOGV("LocEngAdapter deleted");
}
void LocInternalAdapter::setUlpProxy(UlpProxyBase* ulp) {
struct LocSetUlpProxy : public LocMsg {
LocAdapterBase* mAdapter;
@ -69,32 +97,6 @@ void LocInternalAdapter::setUlpProxy(UlpProxyBase* ulp) {
sendMsg(new LocSetUlpProxy(mLocEngAdapter, ulp));
}
LocEngAdapter::LocEngAdapter(LOC_API_ADAPTER_EVENT_MASK_T mask,
void* owner, ContextBase* context,
MsgTask::tCreate tCreator) :
LocAdapterBase(mask,
//Get the AFW context if VzW context has not already been intialized in
//loc_ext
context == NULL?
LocDualContext::getLocFgContext(tCreator,
LocDualContext::mLocationHalName)
:context),
mOwner(owner), mInternalAdapter(new LocInternalAdapter(this)),
mUlp(new UlpProxyBase()), mNavigating(false),
mAgpsEnabled(false), mCPIEnabled(false)
{
memset(&mFixCriteria, 0, sizeof(mFixCriteria));
mFixCriteria.mode = LOC_POSITION_MODE_INVALID;
LOC_LOGD("LocEngAdapter created");
}
inline
LocEngAdapter::~LocEngAdapter()
{
delete mInternalAdapter;
LOC_LOGV("LocEngAdapter deleted");
}
void LocEngAdapter::setUlpProxy(UlpProxyBase* ulp)
{
if (ulp == mUlp) {
@ -102,18 +104,24 @@ void LocEngAdapter::setUlpProxy(UlpProxyBase* ulp)
//and we get the same object back for UlpProxyBase . Do nothing
return;
}
delete mUlp;
LOC_LOGV("%s] %p", __func__, ulp);
if (NULL == ulp) {
LOC_LOGE("%s:%d]: ulp pointer is NULL", __func__, __LINE__);
ulp = new UlpProxyBase();
}
mUlp = ulp;
if (LOC_POSITION_MODE_INVALID != mFixCriteria.mode) {
if (LOC_POSITION_MODE_INVALID != mUlp->mPosMode.mode) {
// need to send this mode and start msg to ULP
mUlp->sendFixMode(mFixCriteria);
mUlp->sendStartFix();
ulp->sendFixMode(mUlp->mPosMode);
}
if(mUlp->mFixSet) {
ulp->sendStartFix();
}
delete mUlp;
mUlp = ulp;
}
void LocInternalAdapter::reportPosition(UlpLocation &location,
@ -203,84 +211,84 @@ bool LocEngAdapter::reportXtraServer(const char* url1,
const char* url3,
const int maxlength)
{
if (mAgpsEnabled) {
if (mSupportsAgpsRequests) {
sendMsg(new LocEngReportXtraServer(mOwner, url1,
url2, url3, maxlength));
}
return mAgpsEnabled;
return mSupportsAgpsRequests;
}
inline
bool LocEngAdapter::requestATL(int connHandle, AGpsType agps_type)
{
if (mAgpsEnabled) {
if (mSupportsAgpsRequests) {
sendMsg(new LocEngRequestATL(mOwner,
connHandle, agps_type));
}
return mAgpsEnabled;
return mSupportsAgpsRequests;
}
inline
bool LocEngAdapter::releaseATL(int connHandle)
{
if (mAgpsEnabled) {
if (mSupportsAgpsRequests) {
sendMsg(new LocEngReleaseATL(mOwner, connHandle));
}
return mAgpsEnabled;
return mSupportsAgpsRequests;
}
inline
bool LocEngAdapter::requestXtraData()
{
if (mAgpsEnabled) {
if (mSupportsAgpsRequests) {
sendMsg(new LocEngRequestXtra(mOwner));
}
return mAgpsEnabled;
return mSupportsAgpsRequests;
}
inline
bool LocEngAdapter::requestTime()
{
if (mAgpsEnabled) {
if (mSupportsAgpsRequests) {
sendMsg(new LocEngRequestTime(mOwner));
}
return mAgpsEnabled;
return mSupportsAgpsRequests;
}
inline
bool LocEngAdapter::requestNiNotify(GpsNiNotification &notif, const void* data)
{
if (mAgpsEnabled) {
if (mSupportsAgpsRequests) {
notif.size = sizeof(notif);
notif.timeout = LOC_NI_NO_RESPONSE_TIME;
sendMsg(new LocEngRequestNi(mOwner, notif, data));
}
return mAgpsEnabled;
return mSupportsAgpsRequests;
}
inline
bool LocEngAdapter::requestSuplES(int connHandle)
{
if (mAgpsEnabled)
if (mSupportsAgpsRequests)
sendMsg(new LocEngRequestSuplEs(mOwner, connHandle));
return mAgpsEnabled;
return mSupportsAgpsRequests;
}
inline
bool LocEngAdapter::reportDataCallOpened()
{
if(mAgpsEnabled)
if(mSupportsAgpsRequests)
sendMsg(new LocEngSuplEsOpened(mOwner));
return mAgpsEnabled;
return mSupportsAgpsRequests;
}
inline
bool LocEngAdapter::reportDataCallClosed()
{
if(mAgpsEnabled)
if(mSupportsAgpsRequests)
sendMsg(new LocEngSuplEsClosed(mOwner));
return mAgpsEnabled;
return mSupportsAgpsRequests;
}
inline
@ -294,4 +302,3 @@ void LocEngAdapter::handleEngineUpEvent()
{
sendMsg(new LocEngUp(mOwner));
}

View file

@ -76,8 +76,8 @@ class LocEngAdapter : public LocAdapterBase {
bool mNavigating;
public:
bool mAgpsEnabled;
bool mCPIEnabled;
bool mSupportsAgpsRequests;
bool mSupportsPositionInjection;
LocEngAdapter(LOC_API_ADAPTER_EVENT_MASK_T mask,
void* owner,ContextBase* context,
@ -91,8 +91,12 @@ public:
inline LocInternalAdapter* getInternalAdapter() { return mInternalAdapter; }
inline UlpProxyBase* getUlpProxy() { return mUlp; }
inline void* getOwner() { return mOwner; }
inline bool hasAgpsExt() { return mContext->hasAgpsExt(); }
inline bool hasCPIExt() { return mContext->hasCPIExt(); }
inline bool hasAgpsExtendedCapabilities() {
return mContext->hasAgpsExtendedCapabilities();
}
inline bool hasCPIExtendedCapabilities() {
return mContext->hasCPIExtendedCapabilities();
}
inline const MsgTask* getMsgTask() { return mMsgTask; }
inline enum loc_api_adapter_err
@ -185,9 +189,9 @@ public:
return mLocApi->setLPPConfig(profile);
}
inline enum loc_api_adapter_err
setSensorControlConfig(int sensorUsage)
setSensorControlConfig(int sensorUsage, int sensorProvider)
{
return mLocApi->setSensorControlConfig(sensorUsage);
return mLocApi->setSensorControlConfig(sensorUsage, sensorProvider);
}
inline enum loc_api_adapter_err
setSensorProperties(bool gyroBiasVarianceRandomWalk_valid, float gyroBiasVarianceRandomWalk,

View file

@ -276,8 +276,8 @@ static int loc_init(GpsCallbacks* callbacks)
retVal = loc_eng_init(loc_afw_data, &clientCallbacks, event, NULL);
loc_afw_data.adapter->requestUlp(gps_conf.CAPABILITIES);
loc_afw_data.adapter->mAgpsEnabled = !loc_afw_data.adapter->hasAgpsExt();
loc_afw_data.adapter->mCPIEnabled = !loc_afw_data.adapter->hasCPIExt();
loc_afw_data.adapter->mSupportsAgpsRequests = !loc_afw_data.adapter->hasAgpsExtendedCapabilities();
loc_afw_data.adapter->mSupportsPositionInjection = !loc_afw_data.adapter->hasCPIExtendedCapabilities();
EXIT_LOG(%d, retVal);
return retVal;
@ -461,33 +461,11 @@ SIDE EFFECTS
===========================================================================*/
static int loc_inject_location(double latitude, double longitude, float accuracy)
{
static bool initialized = false;
static bool enable_cpi = true;
accuracy = 1000;
ENTRY_LOG();
if(!initialized)
{
char value[PROPERTY_VALUE_MAX];
memset(value, 0, sizeof(value));
(void)property_get("persist.gps.qc_nlp_in_use", value, "0");
if(0 == strcmp(value, "1"))
{
enable_cpi = false;
LOC_LOGI("GPS HAL coarse position injection disabled");
}
else
{
LOC_LOGI("GPS HAL coarse position injection enabled");
}
initialized = true;
}
int ret_val = 0;
if(enable_cpi)
{
ret_val = loc_eng_inject_location(loc_afw_data, latitude, longitude, accuracy);
}
ret_val = loc_eng_inject_location(loc_afw_data, latitude, longitude, accuracy);
EXIT_LOG(%d, ret_val);
return ret_val;
}
@ -800,8 +778,12 @@ SIDE EFFECTS
static int loc_xtra_inject_data(char* data, int length)
{
ENTRY_LOG();
int ret_val = loc_eng_xtra_inject_data(loc_afw_data, data, length);
int ret_val = -1;
if( (data != NULL) && ((unsigned int)length <= XTRA_DATA_MAX_SIZE))
ret_val = loc_eng_xtra_inject_data(loc_afw_data, data, length);
else
LOC_LOGE("%s, Could not inject XTRA data. Buffer address: %p, length: %d",
__func__, data, length);
EXIT_LOG(%d, ret_val);
return ret_val;
}

View file

@ -39,6 +39,8 @@ extern "C" {
#include "hardware/gps.h"
#include <gps_extended.h>
#define XTRA_DATA_MAX_SIZE 100000 /*bytes*/
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);

View file

@ -1,4 +1,4 @@
/* Copyright (c) 2009-2013, The Linux Foundation. All rights reserved.
/* Copyright (c) 2009-2014, 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
@ -118,6 +118,7 @@ static loc_param_s_type loc_parameter_table[] =
{"QUIPC_ENABLED", &gps_conf.QUIPC_ENABLED, NULL, 'n'},
{"LPP_PROFILE", &gps_conf.LPP_PROFILE, NULL, 'n'},
{"A_GLONASS_POS_PROTOCOL_SELECT", &gps_conf.A_GLONASS_POS_PROTOCOL_SELECT, NULL, 'n'},
{"SENSOR_PROVIDER", &sap_conf.SENSOR_PROVIDER, NULL, 'n'},
};
static void loc_default_parameters(void)
@ -160,6 +161,9 @@ static void loc_default_parameters(void)
/*By default no positioning protocol is selected on A-GLONASS system*/
gps_conf.A_GLONASS_POS_PROTOCOL_SELECT = 0;
/* default provider is SSC */
sap_conf.SENSOR_PROVIDER = 1;
}
// 2nd half of init(), singled out for
@ -497,18 +501,20 @@ struct LocEngLppConfig : public LocMsg {
struct LocEngSensorControlConfig : public LocMsg {
LocEngAdapter* mAdapter;
const int mSensorsDisabled;
const int mSensorProvider;
inline LocEngSensorControlConfig(LocEngAdapter* adapter,
int sensorsDisabled) :
LocMsg(), mAdapter(adapter), mSensorsDisabled(sensorsDisabled)
int sensorsDisabled, int sensorProvider) :
LocMsg(), mAdapter(adapter), mSensorsDisabled(sensorsDisabled),
mSensorProvider(sensorProvider)
{
locallog();
}
inline virtual void proc() const {
mAdapter->setSensorControlConfig(mSensorsDisabled);
mAdapter->setSensorControlConfig(mSensorsDisabled, mSensorProvider);
}
inline void locallog() const {
LOC_LOGV("LocEngSensorControlConfig - Sensors Disabled: %d",
mSensorsDisabled);
LOC_LOGV("LocEngSensorControlConfig - Sensors Disabled: %d, Sensor Provider: %d",
mSensorsDisabled, mSensorProvider);
}
inline virtual void log() const {
locallog();
@ -753,7 +759,10 @@ void LocEngReportPosition::proc() const {
}
if (locEng->generateNmea &&
mLocation.position_source == ULP_LOCATION_IS_FROM_GNSS)
mLocation.position_source == ULP_LOCATION_IS_FROM_GNSS &&
mTechMask & (LOC_POS_TECH_MASK_SATELLITE |
LOC_POS_TECH_MASK_SENSORS |
LOC_POS_TECH_MASK_HYBRID))
{
unsigned char generate_nmea = reported &&
(mStatus != LOC_SESS_FAILURE);
@ -1347,7 +1356,7 @@ struct LocEngAtlOpenSuccess : public LocMsg {
mStateMachine->onRsrcEvent(RSRC_GRANTED);
}
inline void locallog() const {
LOC_LOGV("LocEngAtlClosed agps type: %s\n apn: %s\n"
LOC_LOGV("LocEngAtlOpenSuccess agps type: %s\n apn: %s\n"
" bearer type: %s",
loc_get_agps_type_name(mStateMachine->getType()),
mAPN,
@ -1554,7 +1563,8 @@ static int loc_eng_reinit(loc_eng_data_s_type &loc_eng_data)
LocEngAdapter* adapter = loc_eng_data.adapter;
adapter->sendMsg(new LocEngSuplVer(adapter, gps_conf.SUPL_VER));
adapter->sendMsg(new LocEngLppConfig(adapter, gps_conf.LPP_PROFILE));
adapter->sendMsg(new LocEngSensorControlConfig(adapter, sap_conf.SENSOR_USAGE));
adapter->sendMsg(new LocEngSensorControlConfig(adapter, sap_conf.SENSOR_USAGE,
sap_conf.SENSOR_PROVIDER));
adapter->sendMsg(new LocEngAGlonassProtocol(adapter, gps_conf.A_GLONASS_POS_PROTOCOL_SELECT));
/* Make sure at least one of the sensor property is specified by the user in the gps.conf file. */
@ -1870,7 +1880,7 @@ int loc_eng_inject_location(loc_eng_data_s_type &loc_eng_data, double latitude,
ENTRY_LOG_CALLFLOW();
INIT_CHECK(loc_eng_data.adapter, return -1);
LocEngAdapter* adapter = loc_eng_data.adapter;
if(!adapter->mCPIEnabled)
if(adapter->mSupportsPositionInjection)
{
adapter->sendMsg(new LocEngInjectLocation(adapter, latitude, longitude,
accuracy));
@ -2086,9 +2096,9 @@ void loc_eng_agps_init(loc_eng_data_s_type &loc_eng_data, AGpsExtCallbacks* call
AGPS_TYPE_SUPL,
false);
loc_eng_data.adapter->sendMsg(new LocEngDataClientInit(&loc_eng_data));
if (adapter->mSupportsAgpsRequests) {
loc_eng_data.adapter->sendMsg(new LocEngDataClientInit(&loc_eng_data));
if (adapter->mAgpsEnabled) {
loc_eng_dmn_conn_loc_api_server_launch(callbacks->create_thread_cb,
NULL, NULL, &loc_eng_data);
}

View file

@ -171,6 +171,7 @@ typedef struct
double RATE_RANDOM_WALK_SPECTRAL_DENSITY;
uint8_t VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY_VALID;
double VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY;
unsigned long SENSOR_PROVIDER;
} loc_sap_cfg_s_type;
extern loc_gps_cfg_s_type gps_conf;

View file

@ -137,7 +137,7 @@ static int loc_api_server_proc(void *context)
free(p_cmsgbuf);
LOC_LOGE("%s:%d] fail receiving msg from gpsone_daemon, retry later\n", __func__, __LINE__);
usleep(1000);
return 0;
return -1;
}
LOC_LOGD("%s:%d] received ctrl_type = %d\n", __func__, __LINE__, p_cmsgbuf->ctrl_type);

View file

@ -1,4 +1,4 @@
/* Copyright (c) 2011-2012, The Linux Foundation. All rights reserved.
/* Copyright (c) 2011-2012,2014 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
@ -33,11 +33,11 @@
#ifdef _ANDROID_
#define GPSONE_LOC_API_Q_PATH "/data/misc/gpsone_d/gpsone_loc_api_q"
#define GPSONE_LOC_API_RESP_Q_PATH "/data/misc/gpsone_d/gpsone_loc_api_resp_q"
#define QUIPC_CTRL_Q_PATH "/data/misc/gpsone_d/quipc_ctrl_q"
#define MSAPM_CTRL_Q_PATH "/data/misc/gpsone_d/msapm_ctrl_q"
#define MSAPU_CTRL_Q_PATH "/data/misc/gpsone_d/msapu_ctrl_q"
#define GPSONE_LOC_API_Q_PATH "/data/misc/location/gpsone_d/gpsone_loc_api_q"
#define GPSONE_LOC_API_RESP_Q_PATH "/data/misc/location/gpsone_d/gpsone_loc_api_resp_q"
#define QUIPC_CTRL_Q_PATH "/data/misc/location/gpsone_d/quipc_ctrl_q"
#define MSAPM_CTRL_Q_PATH "/data/misc/location/gpsone_d/msapm_ctrl_q"
#define MSAPU_CTRL_Q_PATH "/data/misc/location/gpsone_d/msapu_ctrl_q"
#else

View file

@ -1,4 +1,4 @@
/* Copyright (c) 2009-2013, The Linux Foundation. All rights reserved.
/* Copyright (c) 2009-2014, 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
@ -116,28 +116,45 @@ void loc_eng_ni_request_handler(loc_eng_data_s_type &loc_eng_data,
ENTRY_LOG();
char lcs_addr[32]; // Decoded LCS address for UMTS CP NI
loc_eng_ni_data_s_type* loc_eng_ni_data_p = &loc_eng_data.loc_eng_ni_data;
loc_eng_ni_session_s_type* pSession = NULL;
if (NULL == loc_eng_data.ni_notify_cb) {
EXIT_LOG(%s, "loc_eng_ni_init hasn't happened yet.");
return;
}
/* If busy, use default or deny */
if (NULL != loc_eng_ni_data_p->rawRequest)
{
/* XXX Consider sending a NO RESPONSE reply or queue the request */
LOC_LOGW("loc_eng_ni_request_handler, notification in progress, new NI request ignored, type: %d",
notif->ni_type);
if (NULL != passThrough) {
free((void*)passThrough);
if (notif->ni_type == GPS_NI_TYPE_EMERGENCY_SUPL) {
if (NULL != loc_eng_ni_data_p->sessionEs.rawRequest) {
LOC_LOGW("loc_eng_ni_request_handler, supl es NI in progress, new supl es NI ignored, type: %d",
notif->ni_type);
if (NULL != passThrough) {
free((void*)passThrough);
}
} else {
pSession = &loc_eng_ni_data_p->sessionEs;
}
} else {
if (NULL != loc_eng_ni_data_p->session.rawRequest ||
NULL != loc_eng_ni_data_p->sessionEs.rawRequest) {
LOC_LOGW("loc_eng_ni_request_handler, supl NI in progress, new supl NI ignored, type: %d",
notif->ni_type);
if (NULL != passThrough) {
free((void*)passThrough);
}
} else {
pSession = &loc_eng_ni_data_p->session;
}
}
else {
if (pSession) {
/* Save request */
loc_eng_ni_data_p->rawRequest = (void*)passThrough;
pSession->rawRequest = (void*)passThrough;
pSession->reqID = ++loc_eng_ni_data_p->reqIDCounter;
pSession->adapter = loc_eng_data.adapter;
/* Fill in notification */
((GpsNiNotification*)notif)->notification_id = loc_eng_ni_data_p->reqID;
((GpsNiNotification*)notif)->notification_id = pSession->reqID;
if (notif->notify_flags == GPS_NI_PRIVACY_OVERRIDE)
{
@ -156,16 +173,16 @@ void loc_eng_ni_request_handler(loc_eng_data_s_type &loc_eng_data,
/* For robustness, spawn a thread at this point to timeout to clear up the notification status, even though
* the OEM layer in java does not do so.
**/
loc_eng_ni_data_p->respTimeLeft = 5 + (notif->timeout != 0 ? notif->timeout : LOC_NI_NO_RESPONSE_TIME);
LOC_LOGI("Automatically sends 'no response' in %d seconds (to clear status)\n", loc_eng_ni_data_p->respTimeLeft);
pSession->respTimeLeft = 5 + (notif->timeout != 0 ? notif->timeout : LOC_NI_NO_RESPONSE_TIME);
LOC_LOGI("Automatically sends 'no response' in %d seconds (to clear status)\n", pSession->respTimeLeft);
int rc = 0;
rc = pthread_create(&loc_eng_ni_data_p->thread, NULL, ni_thread_proc, &loc_eng_data);
rc = pthread_create(&pSession->thread, NULL, ni_thread_proc, pSession);
if (rc)
{
LOC_LOGE("Loc NI thread is not created.\n");
}
rc = pthread_detach(loc_eng_ni_data_p->thread);
rc = pthread_detach(pSession->thread);
if (rc)
{
LOC_LOGE("Loc NI thread is not detached.\n");
@ -186,56 +203,64 @@ static void* ni_thread_proc(void *args)
{
ENTRY_LOG();
loc_eng_data_s_type* loc_eng_data_p = (loc_eng_data_s_type*)args;
loc_eng_ni_data_s_type* loc_eng_ni_data_p = &loc_eng_data_p->loc_eng_ni_data;
loc_eng_ni_session_s_type* pSession = (loc_eng_ni_session_s_type*)args;
int rc = 0; /* return code from pthread calls */
struct timeval present_time;
struct timespec expire_time;
LOC_LOGD("Starting Loc NI thread...\n");
pthread_mutex_lock(&loc_eng_ni_data_p->tLock);
pthread_mutex_lock(&pSession->tLock);
/* Calculate absolute expire time */
gettimeofday(&present_time, NULL);
expire_time.tv_sec = present_time.tv_sec + loc_eng_ni_data_p->respTimeLeft;
expire_time.tv_sec = present_time.tv_sec + pSession->respTimeLeft;
expire_time.tv_nsec = present_time.tv_usec * 1000;
LOC_LOGD("ni_thread_proc-Time out set for abs time %ld with delay %d sec\n",
(long) expire_time.tv_sec, loc_eng_ni_data_p->respTimeLeft );
(long) expire_time.tv_sec, pSession->respTimeLeft );
while (!loc_eng_ni_data_p->respRecvd)
while (!pSession->respRecvd)
{
rc = pthread_cond_timedwait(&loc_eng_ni_data_p->tCond,
&loc_eng_ni_data_p->tLock,
rc = pthread_cond_timedwait(&pSession->tCond,
&pSession->tLock,
&expire_time);
if (rc == ETIMEDOUT)
{
loc_eng_ni_data_p->resp = GPS_NI_RESPONSE_NORESP;
pSession->resp = GPS_NI_RESPONSE_NORESP;
LOC_LOGD("ni_thread_proc-Thread time out after valting for specified time. Ret Val %d\n",rc );
break;
}
}
LOC_LOGD("ni_thread_proc-Java layer has sent us a user response and return value from "
"pthread_cond_timedwait = %d\n",rc );
loc_eng_ni_data_p->respRecvd = FALSE; /* Reset the user response flag for the next session*/
pSession->respRecvd = FALSE; /* Reset the user response flag for the next session*/
LOC_LOGD("pSession->resp is %d\n",pSession->resp);
// adding this check to support modem restart, in which case, we need the thread
// to exit without calling sending data. We made sure that rawRequest is NULL in
// loc_eng_ni_reset_on_engine_restart()
LocEngAdapter* adapter = loc_eng_data_p->adapter;
LocEngAdapter* adapter = pSession->adapter;
LocEngInformNiResponse *msg = NULL;
if (NULL != loc_eng_ni_data_p->rawRequest) {
msg = new LocEngInformNiResponse(adapter,
loc_eng_ni_data_p->resp,
loc_eng_ni_data_p->rawRequest);
loc_eng_ni_data_p->rawRequest = NULL;
if (NULL != pSession->rawRequest) {
if (pSession->resp != GPS_NI_RESPONSE_IGNORE) {
LOC_LOGD("pSession->resp != GPS_NI_RESPONSE_IGNORE \n");
msg = new LocEngInformNiResponse(adapter,
pSession->resp,
pSession->rawRequest);
} else {
LOC_LOGD("this is the ignore reply for SUPL ES\n");
free(pSession->rawRequest);
}
pSession->rawRequest = NULL;
}
pthread_mutex_unlock(&loc_eng_ni_data_p->tLock);
pthread_mutex_unlock(&pSession->tLock);
loc_eng_ni_data_p->respTimeLeft = 0;
loc_eng_ni_data_p->reqID++;
pSession->respTimeLeft = 0;
pSession->reqID = 0;
if (NULL != msg) {
LOC_LOGD("ni_thread_proc: adapter->sendMsg(msg)\n");
adapter->sendMsg(msg);
}
@ -254,16 +279,28 @@ void loc_eng_ni_reset_on_engine_restart(loc_eng_data_s_type &loc_eng_data)
}
// only if modem has requested but then died.
if (NULL != loc_eng_ni_data_p->rawRequest) {
free(loc_eng_ni_data_p->rawRequest);
loc_eng_ni_data_p->rawRequest = NULL;
if (NULL != loc_eng_ni_data_p->sessionEs.rawRequest) {
free(loc_eng_ni_data_p->sessionEs.rawRequest);
loc_eng_ni_data_p->sessionEs.rawRequest = NULL;
pthread_mutex_lock(&loc_eng_ni_data_p->tLock);
pthread_mutex_lock(&loc_eng_ni_data_p->sessionEs.tLock);
// the goal is to wake up ni_thread_proc
// and let it exit.
loc_eng_ni_data_p->respRecvd = TRUE;
pthread_cond_signal(&loc_eng_ni_data_p->tCond);
pthread_mutex_unlock(&loc_eng_ni_data_p->tLock);
loc_eng_ni_data_p->sessionEs.respRecvd = TRUE;
pthread_cond_signal(&loc_eng_ni_data_p->sessionEs.tCond);
pthread_mutex_unlock(&loc_eng_ni_data_p->sessionEs.tLock);
}
if (NULL != loc_eng_ni_data_p->session.rawRequest) {
free(loc_eng_ni_data_p->session.rawRequest);
loc_eng_ni_data_p->session.rawRequest = NULL;
pthread_mutex_lock(&loc_eng_ni_data_p->session.tLock);
// the goal is to wake up ni_thread_proc
// and let it exit.
loc_eng_ni_data_p->session.respRecvd = TRUE;
pthread_cond_signal(&loc_eng_ni_data_p->session.tCond);
pthread_mutex_unlock(&loc_eng_ni_data_p->session.tLock);
}
EXIT_LOG(%s, VOID_RET);
@ -297,12 +334,19 @@ void loc_eng_ni_init(loc_eng_data_s_type &loc_eng_data, GpsNiExtCallbacks *callb
EXIT_LOG(%s, "loc_eng_ni_init: already inited.");
} else {
loc_eng_ni_data_s_type* loc_eng_ni_data_p = &loc_eng_data.loc_eng_ni_data;
loc_eng_ni_data_p->respTimeLeft = 0;
loc_eng_ni_data_p->respRecvd = FALSE;
loc_eng_ni_data_p->rawRequest = NULL;
loc_eng_ni_data_p->reqID = 0;
pthread_cond_init(&loc_eng_ni_data_p->tCond, NULL);
pthread_mutex_init(&loc_eng_ni_data_p->tLock, NULL);
loc_eng_ni_data_p->sessionEs.respTimeLeft = 0;
loc_eng_ni_data_p->sessionEs.respRecvd = FALSE;
loc_eng_ni_data_p->sessionEs.rawRequest = NULL;
loc_eng_ni_data_p->sessionEs.reqID = 0;
pthread_cond_init(&loc_eng_ni_data_p->sessionEs.tCond, NULL);
pthread_mutex_init(&loc_eng_ni_data_p->sessionEs.tLock, NULL);
loc_eng_ni_data_p->session.respTimeLeft = 0;
loc_eng_ni_data_p->session.respRecvd = FALSE;
loc_eng_ni_data_p->session.rawRequest = NULL;
loc_eng_ni_data_p->session.reqID = 0;
pthread_cond_init(&loc_eng_ni_data_p->session.tCond, NULL);
pthread_mutex_init(&loc_eng_ni_data_p->session.tLock, NULL);
loc_eng_data.ni_notify_cb = callbacks->notify_cb;
EXIT_LOG(%s, VOID_RET);
@ -330,25 +374,40 @@ void loc_eng_ni_respond(loc_eng_data_s_type &loc_eng_data,
{
ENTRY_LOG_CALLFLOW();
loc_eng_ni_data_s_type* loc_eng_ni_data_p = &loc_eng_data.loc_eng_ni_data;
loc_eng_ni_session_s_type* pSession = NULL;
if (NULL == loc_eng_data.ni_notify_cb) {
EXIT_LOG(%s, "loc_eng_ni_init hasn't happened yet.");
return;
}
if (notif_id == loc_eng_ni_data_p->reqID &&
NULL != loc_eng_ni_data_p->rawRequest)
{
if (notif_id == loc_eng_ni_data_p->sessionEs.reqID &&
NULL != loc_eng_ni_data_p->sessionEs.rawRequest) {
pSession = &loc_eng_ni_data_p->sessionEs;
// ignore any SUPL NI non-Es session if a SUPL NI ES is accepted
if (user_response == GPS_NI_RESPONSE_ACCEPT &&
NULL != loc_eng_ni_data_p->session.rawRequest) {
pthread_mutex_lock(&loc_eng_ni_data_p->session.tLock);
loc_eng_ni_data_p->session.resp = GPS_NI_RESPONSE_IGNORE;
loc_eng_ni_data_p->session.respRecvd = TRUE;
pthread_cond_signal(&loc_eng_ni_data_p->session.tCond);
pthread_mutex_unlock(&loc_eng_ni_data_p->session.tLock);
}
} else if (notif_id == loc_eng_ni_data_p->session.reqID &&
NULL != loc_eng_ni_data_p->session.rawRequest) {
pSession = &loc_eng_ni_data_p->session;
}
if (pSession) {
LOC_LOGI("loc_eng_ni_respond: send user response %d for notif %d", user_response, notif_id);
pthread_mutex_lock(&loc_eng_ni_data_p->tLock);
loc_eng_ni_data_p->resp = user_response;
loc_eng_ni_data_p->respRecvd = TRUE;
pthread_cond_signal(&loc_eng_ni_data_p->tCond);
pthread_mutex_unlock(&loc_eng_ni_data_p->tLock);
pthread_mutex_lock(&pSession->tLock);
pSession->resp = user_response;
pSession->respRecvd = TRUE;
pthread_cond_signal(&pSession->tCond);
pthread_mutex_unlock(&pSession->tLock);
}
else {
LOC_LOGE("loc_eng_ni_respond: reqID %d and notif_id %d mismatch or rawRequest %p, response: %d",
loc_eng_ni_data_p->reqID, notif_id, loc_eng_ni_data_p->rawRequest, user_response);
LOC_LOGE("loc_eng_ni_respond: notif_id %d not an active session", notif_id);
}
EXIT_LOG(%s, VOID_RET);

View file

@ -1,4 +1,4 @@
/* Copyright (c) 2009,2011 The Linux Foundation. All rights reserved.
/* Copyright (c) 2009,2011,2014 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,9 +31,11 @@
#define LOC_ENG_NI_H
#include <stdbool.h>
#include <LocEngAdapter.h>
#define LOC_NI_NO_RESPONSE_TIME 20 /* secs */
#define LOC_NI_NOTIF_KEY_ADDRESS "Address"
#define GPS_NI_RESPONSE_IGNORE 4
typedef struct {
pthread_t thread; /* NI thread */
@ -44,6 +46,13 @@ typedef struct {
GpsUserResponseType resp;
pthread_cond_t tCond;
pthread_mutex_t tLock;
LocEngAdapter* adapter;
} loc_eng_ni_session_s_type;
typedef struct {
loc_eng_ni_session_s_type session; /* SUPL NI Session */
loc_eng_ni_session_s_type sessionEs; /* Emergency SUPL NI Session */
int reqIDCounter;
} loc_eng_ni_data_s_type;

View file

@ -1,13 +0,0 @@
LOCAL_PATH := $(call my-dir)
# add RPC dirs if RPC is available
ifneq ($(TARGET_NO_RPC),true)
GPS_DIR_LIST += $(LOCAL_PATH)/libloc_api-rpc-50001/
endif #TARGET_NO_RPC
GPS_DIR_LIST += $(LOCAL_PATH)/libloc_api_50001/
#call the subfolders
include $(addsuffix Android.mk, $(GPS_DIR_LIST))

View file

@ -1,13 +0,0 @@
Copyright (c) 2009, QUALCOMM USA, INC.
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
· Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
· Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
· Neither the name of the QUALCOMM USA, INC. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

View file

@ -19,7 +19,8 @@ LOCAL_SRC_FILES += \
linked_list.c \
loc_target.cpp \
loc_timer.c \
../platform_lib_abstractions/elapsed_millis_since_boot.cpp
../platform_lib_abstractions/elapsed_millis_since_boot.cpp \
loc_misc_utils.cpp
LOCAL_CFLAGS += \
@ -43,7 +44,8 @@ LOCAL_COPY_HEADERS:= \
loc_timer.h \
../platform_lib_abstractions/platform_lib_includes.h \
../platform_lib_abstractions/platform_lib_time.h \
../platform_lib_abstractions/platform_lib_macros.h
../platform_lib_abstractions/platform_lib_macros.h \
loc_misc_utils.h
LOCAL_MODULE := libgps.utils

View file

@ -1,4 +1,4 @@
/* Copyright (c) 2011-2013, The Linux Foundation. All rights reserved.
/* Copyright (c) 2011-2014, 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
@ -39,6 +39,7 @@
#include <time.h>
#include <loc_cfg.h>
#include <log_util.h>
#include <loc_misc_utils.h>
#ifdef USE_GLIB
#include <glib.h>
#endif
@ -57,62 +58,17 @@ static uint8_t TIMESTAMP = 0;
/* Parameter spec table */
static loc_param_s_type loc_parameter_table[] =
{
{"DEBUG_LEVEL", &DEBUG_LEVEL, NULL, 'n'},
{"TIMESTAMP", &TIMESTAMP, NULL, 'n'},
{"DEBUG_LEVEL", &DEBUG_LEVEL, NULL, 'n'},
{"TIMESTAMP", &TIMESTAMP, NULL, 'n'},
};
int loc_param_num = sizeof(loc_parameter_table) / sizeof(loc_param_s_type);
/*===========================================================================
FUNCTION trim_space
DESCRIPTION
Removes leading and trailing spaces of the string
DEPENDENCIES
N/A
RETURN VALUE
None
SIDE EFFECTS
N/A
===========================================================================*/
void trim_space(char *org_string)
{
char *scan_ptr, *write_ptr;
char *first_nonspace = NULL, *last_nonspace = NULL;
scan_ptr = write_ptr = org_string;
while (*scan_ptr)
{
if ( !isspace(*scan_ptr) && first_nonspace == NULL)
{
first_nonspace = scan_ptr;
}
if (first_nonspace != NULL)
{
*(write_ptr++) = *scan_ptr;
if ( !isspace(*scan_ptr))
{
last_nonspace = write_ptr;
}
}
scan_ptr++;
}
if (last_nonspace) { *last_nonspace = '\0'; }
}
typedef struct loc_param_v_type
{
char* param_name;
char* param_str_value;
int param_int_value;
double param_double_value;
char* param_name;
char* param_str_value;
int param_int_value;
double param_double_value;
}loc_param_v_type;
/*===========================================================================
@ -136,61 +92,166 @@ RETURN VALUE
SIDE EFFECTS
N/A
===========================================================================*/
void loc_set_config_entry(loc_param_s_type* config_entry, loc_param_v_type* config_value)
int loc_set_config_entry(loc_param_s_type* config_entry, loc_param_v_type* config_value)
{
if(NULL == config_entry || NULL == config_value)
{
LOC_LOGE("%s: INVALID config entry or parameter", __FUNCTION__);
return;
}
int ret=-1;
if(NULL == config_entry || NULL == config_value)
{
LOC_LOGE("%s: INVALID config entry or parameter", __FUNCTION__);
return ret;
}
if (strcmp(config_entry->param_name, config_value->param_name) == 0 &&
config_entry->param_ptr)
{
switch (config_entry->param_type)
{
case 's':
if (strcmp(config_value->param_str_value, "NULL") == 0)
{
*((char*)config_entry->param_ptr) = '\0';
}
else {
strlcpy((char*) config_entry->param_ptr,
config_value->param_str_value,
LOC_MAX_PARAM_STRING + 1);
}
/* Log INI values */
LOC_LOGD("%s: PARAM %s = %s", __FUNCTION__, config_entry->param_name, (char*)config_entry->param_ptr);
if (strcmp(config_entry->param_name, config_value->param_name) == 0 &&
config_entry->param_ptr)
{
switch (config_entry->param_type)
{
case 's':
if (strcmp(config_value->param_str_value, "NULL") == 0)
{
*((char*)config_entry->param_ptr) = '\0';
}
else {
strlcpy((char*) config_entry->param_ptr,
config_value->param_str_value,
LOC_MAX_PARAM_STRING + 1);
}
/* Log INI values */
LOC_LOGD("%s: PARAM %s = %s", __FUNCTION__, config_entry->param_name, (char*)config_entry->param_ptr);
if(NULL != config_entry->param_set)
{
*(config_entry->param_set) = 1;
}
break;
case 'n':
*((int *)config_entry->param_ptr) = config_value->param_int_value;
/* Log INI values */
LOC_LOGD("%s: PARAM %s = %d", __FUNCTION__, config_entry->param_name, config_value->param_int_value);
if(NULL != config_entry->param_set)
{
*(config_entry->param_set) = 1;
}
ret = 0;
break;
case 'n':
*((int *)config_entry->param_ptr) = config_value->param_int_value;
/* Log INI values */
LOC_LOGD("%s: PARAM %s = %d", __FUNCTION__, config_entry->param_name, config_value->param_int_value);
if(NULL != config_entry->param_set)
{
*(config_entry->param_set) = 1;
}
break;
case 'f':
*((double *)config_entry->param_ptr) = config_value->param_double_value;
/* Log INI values */
LOC_LOGD("%s: PARAM %s = %f", __FUNCTION__, config_entry->param_name, config_value->param_double_value);
if(NULL != config_entry->param_set)
{
*(config_entry->param_set) = 1;
}
ret = 0;
break;
case 'f':
*((double *)config_entry->param_ptr) = config_value->param_double_value;
/* Log INI values */
LOC_LOGD("%s: PARAM %s = %f", __FUNCTION__, config_entry->param_name, config_value->param_double_value);
if(NULL != config_entry->param_set)
{
*(config_entry->param_set) = 1;
}
break;
default:
LOC_LOGE("%s: PARAM %s parameter type must be n, f, or s", __FUNCTION__, config_entry->param_name);
}
}
if(NULL != config_entry->param_set)
{
*(config_entry->param_set) = 1;
}
ret = 0;
break;
default:
LOC_LOGE("%s: PARAM %s parameter type must be n, f, or s", __FUNCTION__, config_entry->param_name);
}
}
return ret;
}
/*===========================================================================
FUNCTION loc_read_conf_r (repetitive)
DESCRIPTION
Reads the specified configuration file and sets defined values based on
the passed in configuration table. This table maps strings to values to
set along with the type of each of these values.
The difference between this and loc_read_conf is that this function returns
the file pointer position at the end of filling a config table. Also, it
reads a fixed number of parameters at a time which is equal to the length
of the configuration table. This functionality enables the caller to
repeatedly call the function to read data from the same file.
PARAMETERS:
conf_fp : file pointer
config_table: table definition of strings to places to store information
table_length: length of the configuration table
DEPENDENCIES
N/A
RETURN VALUE
0: Table filled successfully
1: No more parameters to read
-1: Error filling table
SIDE EFFECTS
N/A
===========================================================================*/
int loc_read_conf_r(FILE *conf_fp, loc_param_s_type* config_table, uint32_t table_length)
{
char input_buf[LOC_MAX_PARAM_LINE]; /* declare a char array */
char *lasts;
loc_param_v_type config_value;
uint32_t i;
int ret=0;
unsigned int num_params=table_length;
if(conf_fp == NULL) {
LOC_LOGE("%s:%d]: ERROR: File pointer is NULL\n", __func__, __LINE__);
ret = -1;
goto err;
}
/* Clear all validity bits */
for(i = 0; NULL != config_table && i < table_length; i++)
{
if(NULL != config_table[i].param_set)
{
*(config_table[i].param_set) = 0;
}
}
LOC_LOGD("%s:%d]: num_params: %d\n", __func__, __LINE__, num_params);
while(num_params)
{
if(!fgets(input_buf, LOC_MAX_PARAM_LINE, conf_fp)) {
LOC_LOGD("%s:%d]: fgets returned NULL\n", __func__, __LINE__);
break;
}
memset(&config_value, 0, sizeof(config_value));
/* Separate variable and value */
config_value.param_name = strtok_r(input_buf, "=", &lasts);
/* skip lines that do not contain "=" */
if (config_value.param_name == NULL) continue;
config_value.param_str_value = strtok_r(NULL, "=", &lasts);
/* skip lines that do not contain two operands */
if (config_value.param_str_value == NULL) continue;
/* Trim leading and trailing spaces */
loc_util_trim_space(config_value.param_name);
loc_util_trim_space(config_value.param_str_value);
/* Parse numerical value */
if ((strlen(config_value.param_str_value) >=3) &&
(config_value.param_str_value[0] == '0') &&
(tolower(config_value.param_str_value[1]) == 'x'))
{
/* hex */
config_value.param_int_value = (int) strtol(&config_value.param_str_value[2],
(char**) NULL, 16);
}
else {
config_value.param_double_value = (double) atof(config_value.param_str_value); /* float */
config_value.param_int_value = atoi(config_value.param_str_value); /* dec */
}
for(i = 0; NULL != config_table && i < table_length; i++)
{
if(!loc_set_config_entry(&config_table[i], &config_value)) {
num_params--;
}
}
}
err:
return ret;
}
/*===========================================================================
@ -215,72 +276,25 @@ RETURN VALUE
SIDE EFFECTS
N/A
===========================================================================*/
void loc_read_conf(const char* conf_file_name, loc_param_s_type* config_table, uint32_t table_length)
void loc_read_conf(const char* conf_file_name, loc_param_s_type* config_table,
uint32_t table_length)
{
FILE *gps_conf_fp = NULL;
char input_buf[LOC_MAX_PARAM_LINE]; /* declare a char array */
char *lasts;
loc_param_v_type config_value;
uint32_t i;
FILE *gps_conf_fp = NULL;
char input_buf[LOC_MAX_PARAM_LINE]; /* declare a char array */
char *lasts;
loc_param_v_type config_value;
uint32_t i;
if((gps_conf_fp = fopen(conf_file_name, "r")) != NULL)
{
LOC_LOGD("%s: using %s", __FUNCTION__, conf_file_name);
}
else
{
LOC_LOGW("%s: no %s file found", __FUNCTION__, conf_file_name);
loc_logger_init(DEBUG_LEVEL, TIMESTAMP);
return; /* no parameter file */
}
/* Clear all validity bits */
for(i = 0; NULL != config_table && i < table_length; i++)
{
if(NULL != config_table[i].param_set)
{
*(config_table[i].param_set) = 0;
}
}
while(fgets(input_buf, LOC_MAX_PARAM_LINE, gps_conf_fp) != NULL)
{
memset(&config_value, 0, sizeof(config_value));
/* Separate variable and value */
config_value.param_name = strtok_r(input_buf, "=", &lasts);
if (config_value.param_name == NULL) continue; /* skip lines that do not contain "=" */
config_value.param_str_value = strtok_r(NULL, "=", &lasts);
if (config_value.param_str_value == NULL) continue; /* skip lines that do not contain two operands */
/* Trim leading and trailing spaces */
trim_space(config_value.param_name);
trim_space(config_value.param_str_value);
/* Parse numerical value */
if (config_value.param_str_value[0] == '0' && tolower(config_value.param_str_value[1]) == 'x')
{
/* hex */
config_value.param_int_value = (int) strtol(&config_value.param_str_value[2], (char**) NULL, 16);
}
else {
config_value.param_double_value = (double) atof(config_value.param_str_value); /* float */
config_value.param_int_value = atoi(config_value.param_str_value); /* dec */
}
for(i = 0; NULL != config_table && i < table_length; i++)
{
loc_set_config_entry(&config_table[i], &config_value);
}
for(i = 0; i < loc_param_num; i++)
{
loc_set_config_entry(&loc_parameter_table[i], &config_value);
}
}
fclose(gps_conf_fp);
/* Initialize logging mechanism with parsed data */
loc_logger_init(DEBUG_LEVEL, TIMESTAMP);
if((gps_conf_fp = fopen(conf_file_name, "r")) != NULL)
{
LOC_LOGD("%s: using %s", __FUNCTION__, conf_file_name);
if(table_length && config_table) {
loc_read_conf_r(gps_conf_fp, config_table, table_length);
rewind(gps_conf_fp);
}
loc_read_conf_r(gps_conf_fp, loc_parameter_table, loc_param_num);
fclose(gps_conf_fp);
}
/* Initialize logging mechanism with parsed data */
loc_logger_init(DEBUG_LEVEL, TIMESTAMP);
}

View file

@ -1,4 +1,4 @@
/* Copyright (c) 2011-2013, The Linux Foundation. All rights reserved.
/* Copyright (c) 2011-2014, 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
@ -30,6 +30,7 @@
#ifndef LOC_CFG_H
#define LOC_CFG_H
#include <stdio.h>
#include <stdint.h>
#define LOC_MAX_PARAM_NAME 48
@ -75,7 +76,7 @@ extern "C" {
extern void loc_read_conf(const char* conf_file_name,
loc_param_s_type* config_table,
uint32_t table_length);
extern int loc_read_conf_r(FILE *conf_fp, loc_param_s_type* config_table, uint32_t table_length);
#ifdef __cplusplus
}
#endif

View file

@ -0,0 +1,114 @@
/* Copyright (c) 2014, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation, nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#include <stdio.h>
#include <string.h>
#include <log_util.h>
#include <loc_misc_utils.h>
#include <ctype.h>
#define LOG_NDDEBUG 0
#define LOG_TAG "LocSvc_misc_utils"
int loc_util_split_string(char *raw_string, char **split_strings_ptr,
int max_num_substrings, char delimiter)
{
int raw_string_index=0;
int num_split_strings=0;
unsigned char end_string=0;
int raw_string_length=0;
if(!raw_string || !split_strings_ptr) {
LOC_LOGE("%s:%d]: NULL parameters", __func__, __LINE__);
num_split_strings = -1;
goto err;
}
LOC_LOGD("%s:%d]: raw string: %s\n", __func__, __LINE__, raw_string);
raw_string_length = strlen(raw_string) + 1;
split_strings_ptr[num_split_strings] = &raw_string[raw_string_index];
for(raw_string_index=0; raw_string_index < raw_string_length; raw_string_index++) {
if(raw_string[raw_string_index] == '\0')
end_string=1;
if((raw_string[raw_string_index] == delimiter) || end_string) {
raw_string[raw_string_index] = '\0';
LOC_LOGD("%s:%d]: split string: %s\n",
__func__, __LINE__, split_strings_ptr[num_split_strings]);
num_split_strings++;
if(((raw_string_index + 1) < raw_string_length) &&
(num_split_strings < max_num_substrings)) {
split_strings_ptr[num_split_strings] = &raw_string[raw_string_index+1];
}
else {
break;
}
}
if(end_string)
break;
}
err:
LOC_LOGD("%s:%d]: num_split_strings: %d\n", __func__, __LINE__, num_split_strings);
return num_split_strings;
}
void loc_util_trim_space(char *org_string)
{
char *scan_ptr, *write_ptr;
char *first_nonspace = NULL, *last_nonspace = NULL;
if(org_string == NULL) {
LOC_LOGE("%s:%d]: NULL parameter", __func__, __LINE__);
goto err;
}
scan_ptr = write_ptr = org_string;
while (*scan_ptr) {
//Find the first non-space character
if ( !isspace(*scan_ptr) && first_nonspace == NULL) {
first_nonspace = scan_ptr;
}
//Once the first non-space character is found in the
//above check, keep shifting the characters to the left
//to replace the spaces
if (first_nonspace != NULL) {
*(write_ptr++) = *scan_ptr;
//Keep track of which was the last non-space character
//encountered
//last_nonspace will not be updated in the case where
//the string ends with spaces
if ( !isspace(*scan_ptr)) {
last_nonspace = write_ptr;
}
}
scan_ptr++;
}
//Add NULL terminator after the last non-space character
if (last_nonspace) { *last_nonspace = '\0'; }
err:
return;
}

View file

@ -0,0 +1,99 @@
/* Copyright (c) 2014, 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_MISC_UTILS_H_
#define _LOC_MISC_UTILS_H_
#ifdef __cplusplus
extern "C" {
#endif
/*===========================================================================
FUNCTION loc_split_string
DESCRIPTION:
This function is used to split a delimiter separated string into
sub-strings. This function does not allocate new memory to store the split
strings. Instead, it places '\0' in places of delimiters and assings the
starting address of the substring within the raw string as the string address
The input raw_string no longer remains to be a collection of sub-strings
after this function is executed.
Please make a copy of the input string before calling this function if
necessary
PARAMETERS:
char *raw_string: is the original string with delimiter separated substrings
char **split_strings_ptr: is the arraw of pointers which will hold the addresses
of individual substrings
int max_num_substrings: is the maximum number of substrings that are expected
by the caller. The array of pointers in the above parameter
is usually this long
char delimiter: is the delimiter that separates the substrings. Examples: ' ', ';'
DEPENDENCIES
N/A
RETURN VALUE
int Number of split strings
SIDE EFFECTS
The input raw_string no longer remains a delimiter separated single string.
EXAMPLE
delimiter = ' ' //space
raw_string = "hello new user" //delimiter is space ' '
addresses = 0123456789abcd
split_strings_ptr[0] = &raw_string[0]; //split_strings_ptr[0] contains "hello"
split_strings_ptr[1] = &raw_string[6]; //split_strings_ptr[1] contains "new"
split_strings_ptr[2] = &raw_string[a]; //split_strings_ptr[2] contains "user"
===========================================================================*/
int loc_util_split_string(char *raw_string, char **split_strings_ptr, int max_num_substrings,
char delimiter);
/*===========================================================================
FUNCTION trim_space
DESCRIPTION
Removes leading and trailing spaces of the string
DEPENDENCIES
N/A
RETURN VALUE
None
SIDE EFFECTS
N/A
===========================================================================*/
void loc_util_trim_space(char *org_string);
#ifdef __cplusplus
}
#endif
#endif //_LOC_MISC_UTILS_H_

View file

@ -141,6 +141,34 @@ static bool is_qca1530(void)
return res;
}
/*The character array passed to this function should have length
of atleast PROPERTY_VALUE_MAX*/
void loc_get_target_baseband(char *baseband, int array_length)
{
if(baseband && (array_length >= PROPERTY_VALUE_MAX)) {
property_get("ro.baseband", baseband, "");
LOC_LOGD("%s:%d]: Baseband: %s\n", __func__, __LINE__, baseband);
}
else {
LOC_LOGE("%s:%d]: NULL parameter or array length less than PROPERTY_VALUE_MAX\n",
__func__, __LINE__);
}
}
/*The character array passed to this function should have length
of atleast PROPERTY_VALUE_MAX*/
void loc_get_platform_name(char *platform_name, int array_length)
{
if(platform_name && (array_length >= PROPERTY_VALUE_MAX)) {
property_get("ro.board.platform", platform_name, "");
LOC_LOGD("%s:%d]: Target name: %s\n", __func__, __LINE__, platform_name);
}
else {
LOC_LOGE("%s:%d]: Null parameter or array length less than PROPERTY_VALUE_MAX\n",
__func__, __LINE__);
}
}
unsigned int loc_get_target(void)
{
if (gTarget != (unsigned int)-1)
@ -163,7 +191,8 @@ unsigned int loc_get_target(void)
goto detected;
}
property_get("ro.baseband", baseband, "");
loc_get_target_baseband(baseband, sizeof(baseband));
if (!access(hw_platform, F_OK)) {
read_a_line(hw_platform, rd_hw_platform, LINE_LEN);
} else {

View file

@ -1,4 +1,4 @@
/* Copyright (c) 2012, The Linux Foundation. All rights reserved.
/* Copyright (c) 2012-2014, 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
@ -45,6 +45,13 @@ extern "C"
unsigned int loc_get_target(void);
/*The character array passed to this function should have length
of atleast PROPERTY_VALUE_MAX*/
void loc_get_target_baseband(char *baseband, int array_length);
/*The character array passed to this function should have length
of atleast PROPERTY_VALUE_MAX*/
void loc_get_platform_name(char *platform_name, int array_length);
/* Please remember to update 'target_name' in loc_log.cpp,
if do any changes to this enum. */
typedef enum {

View file

@ -1,4 +1,4 @@
/* Copyright (c) 2011 The Linux Foundation. All rights reserved.
/* Copyright (c) 2011-2014 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
@ -96,37 +96,47 @@ extern char* get_timestamp(char* str, unsigned long buf_size);
if that value remains unchanged, it means gps.conf did not
provide a value and we default to the initial value to use
Android's logging levels*/
#define IF_LOC_LOGE if((loc_logger.DEBUG_LEVEL >= 1) && (loc_logger.DEBUG_LEVEL <= 5))
#define IF_LOC_LOGW if((loc_logger.DEBUG_LEVEL >= 2) && (loc_logger.DEBUG_LEVEL <= 5))
#define IF_LOC_LOGI if((loc_logger.DEBUG_LEVEL >= 3) && (loc_logger.DEBUG_LEVEL <= 5))
#define IF_LOC_LOGD if((loc_logger.DEBUG_LEVEL >= 4) && (loc_logger.DEBUG_LEVEL <= 5))
#define IF_LOC_LOGV if((loc_logger.DEBUG_LEVEL >= 5) && (loc_logger.DEBUG_LEVEL <= 5))
#define LOC_LOGE(...) \
if ((loc_logger.DEBUG_LEVEL >= 1) && (loc_logger.DEBUG_LEVEL <= 5)) { ALOGE("W/"__VA_ARGS__); } \
else if (loc_logger.DEBUG_LEVEL == 0xff) { ALOGE("W/"__VA_ARGS__); }
IF_LOC_LOGE { ALOGE("E/" __VA_ARGS__); } \
else if (loc_logger.DEBUG_LEVEL == 0xff) { ALOGE("E/" __VA_ARGS__); }
#define LOC_LOGW(...) \
if ((loc_logger.DEBUG_LEVEL >= 2) && (loc_logger.DEBUG_LEVEL <= 5)) { ALOGE("W/"__VA_ARGS__); } \
else if (loc_logger.DEBUG_LEVEL == 0xff) { ALOGW("W/"__VA_ARGS__); }
IF_LOC_LOGW { ALOGE("W/" __VA_ARGS__); } \
else if (loc_logger.DEBUG_LEVEL == 0xff) { ALOGW("W/" __VA_ARGS__); }
#define LOC_LOGI(...) \
if ((loc_logger.DEBUG_LEVEL >= 3) && (loc_logger.DEBUG_LEVEL <= 5)) { ALOGE("I/"__VA_ARGS__); } \
else if (loc_logger.DEBUG_LEVEL == 0xff) { ALOGI("I/"__VA_ARGS__); }
IF_LOC_LOGI { ALOGE("I/" __VA_ARGS__); } \
else if (loc_logger.DEBUG_LEVEL == 0xff) { ALOGI("I/" __VA_ARGS__); }
#define LOC_LOGD(...) \
if ((loc_logger.DEBUG_LEVEL >= 4) && (loc_logger.DEBUG_LEVEL <= 5)) { ALOGE("D/"__VA_ARGS__); } \
else if (loc_logger.DEBUG_LEVEL == 0xff) { ALOGD("D/"__VA_ARGS__); }
IF_LOC_LOGD { ALOGE("D/" __VA_ARGS__); } \
else if (loc_logger.DEBUG_LEVEL == 0xff) { ALOGD("D/" __VA_ARGS__); }
#define LOC_LOGV(...) \
if ((loc_logger.DEBUG_LEVEL >= 5) && (loc_logger.DEBUG_LEVEL <= 5)) { ALOGE("V/"__VA_ARGS__); } \
else if (loc_logger.DEBUG_LEVEL == 0xff) { ALOGV("V/"__VA_ARGS__); }
IF_LOC_LOGV { ALOGE("V/" __VA_ARGS__); } \
else if (loc_logger.DEBUG_LEVEL == 0xff) { ALOGV("V/" __VA_ARGS__); }
#else /* DEBUG_DMN_LOC_API */
#define LOC_LOGE(...) ALOGE("E/"__VA_ARGS__)
#define LOC_LOGE(...) ALOGE("E/" __VA_ARGS__)
#define LOC_LOGW(...) ALOGW("W/"__VA_ARGS__)
#define LOC_LOGW(...) ALOGW("W/" __VA_ARGS__)
#define LOC_LOGI(...) ALOGI("I/"__VA_ARGS__)
#define LOC_LOGI(...) ALOGI("I/" __VA_ARGS__)
#define LOC_LOGD(...) ALOGD("D/"__VA_ARGS__)
#define LOC_LOGD(...) ALOGD("D/" __VA_ARGS__)
#define LOC_LOGV(...) ALOGV("V/"__VA_ARGS__)
#define LOC_LOGV(...) ALOGV("V/" __VA_ARGS__)
#endif /* DEBUG_DMN_LOC_API */

View file

@ -213,15 +213,12 @@ on post-fs-data
#Create the symlink to qcn wpa_supplicant folder for ar6000 wpa_supplicant
mkdir /data/system 0775 system system
#Create directories for gpsone_daemon services
mkdir /data/misc/gpsone_d 0770 system system
#Create directories for QuIPS
mkdir /data/misc/quipc 0770 gps system
#Create directories for Location services
mkdir /data/misc/location 0770 gps gps
mkdir /data/misc/location/gpsone_d 0770 system gps
mkdir /data/misc/location/gsiff 0770 gps gps
mkdir /data/misc/location/mq 0770 gps gps
mkdir /data/misc/location/quipc 0770 system gps
mkdir /data/misc/location/xtwifi 0770 gps gps
#Create directory from IMS services