Merge "GPS_LOCK configuration support"
This commit is contained in:
commit
5d15db9618
10 changed files with 103 additions and 32 deletions
|
@ -486,7 +486,7 @@ void LocApiBase::
|
|||
DEFAULT_IMPL()
|
||||
|
||||
int LocApiBase::
|
||||
setGpsLock(unsigned int lock)
|
||||
setGpsLock(LOC_GPS_LOCK_MASK lock)
|
||||
DEFAULT_IMPL(-1)
|
||||
|
||||
void LocApiBase::
|
||||
|
|
|
@ -230,7 +230,7 @@ public:
|
|||
3 = Lock MT position sessions
|
||||
4 = Lock all position sessions
|
||||
*/
|
||||
virtual int setGpsLock(unsigned int lock);
|
||||
virtual int setGpsLock(LOC_GPS_LOCK_MASK lock);
|
||||
/*
|
||||
Returns
|
||||
Current value of GPS Lock on success
|
||||
|
|
|
@ -380,6 +380,12 @@ typedef enum loc_api_adapter_msg_to_check_supported {
|
|||
LOC_API_ADAPTER_MESSAGE_MAX
|
||||
} LocCheckingMessagesID;
|
||||
|
||||
typedef uint32_t LOC_GPS_LOCK_MASK;
|
||||
#define isGpsLockNone(lock) ((lock) == 0)
|
||||
#define isGpsLockMO(lock) ((lock) & ((LOC_GPS_LOCK_MASK)1))
|
||||
#define isGpsLockMT(lock) ((lock) & ((LOC_GPS_LOCK_MASK)2))
|
||||
#define isGpsLockAll(lock) (((lock) & ((LOC_GPS_LOCK_MASK)3)) == 3)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
|
14
etc/gps.conf
14
etc/gps.conf
|
@ -33,6 +33,13 @@ DEBUG_LEVEL = 3
|
|||
# Intermediate position report, 1=enable, 0=disable
|
||||
INTERMEDIATE_POS=0
|
||||
|
||||
# Below bit mask configures how GPS functionalities
|
||||
# should be locked when user turns off GPS on Settings
|
||||
# Set bit 0x1 if MO GPS functionalities are to be locked
|
||||
# Set bit 0x2 if NI GPS functionalities are to be locked
|
||||
# default - non is locked for backward compatibility
|
||||
#GPS_LOCK = 0
|
||||
|
||||
# supl version 1.0
|
||||
SUPL_VER=0x10000
|
||||
|
||||
|
@ -44,6 +51,13 @@ SUPL_ES=1
|
|||
#0 - Use regular SUPL PDN for Emergency SUPL
|
||||
USE_EMERGENCY_PDN_FOR_EMERGENCY_SUPL=1
|
||||
|
||||
#SUPL_MODE is a bit mask set in config.xml per carrier by default.
|
||||
#If it is uncommented here, this value will over write the value from
|
||||
#config.xml.
|
||||
#MSA=0X1
|
||||
#MSB=0X2
|
||||
#SUPL_MODE=
|
||||
|
||||
# GPS Capabilities bit mask
|
||||
# SCHEDULING = 0x01
|
||||
# MSB = 0x02
|
||||
|
|
|
@ -49,6 +49,7 @@ private:
|
|||
static const LOC_API_ADAPTER_EVENT_MASK_T maskAll;
|
||||
static const rpc_loc_event_mask_type locBits[];
|
||||
static rpc_loc_event_mask_type convertMask(LOC_API_ADAPTER_EVENT_MASK_T mask);
|
||||
static rpc_loc_lock_e_type convertGpsLockMask(LOC_GPS_LOCK_MASK lockMask);
|
||||
static enum loc_api_adapter_err convertErr(int rpcErr);
|
||||
static GpsNiEncodingType convertNiEncodingType(int loc_encoding);
|
||||
static int NIEventFillVerfiyType(GpsNiNotification ¬if,
|
||||
|
@ -123,7 +124,7 @@ public:
|
|||
3 = Lock MT position sessions
|
||||
4 = Lock all position sessions
|
||||
*/
|
||||
virtual int setGpsLock(unsigned int lock);
|
||||
virtual int setGpsLock(LOC_GPS_LOCK_MASK lock);
|
||||
/*
|
||||
Returns
|
||||
Current value of GPS Lock on success
|
||||
|
|
|
@ -164,6 +164,20 @@ LocApiRpc::convertMask(LOC_API_ADAPTER_EVENT_MASK_T mask)
|
|||
return newMask;
|
||||
}
|
||||
|
||||
rpc_loc_lock_e_type
|
||||
LocApiRpc::convertGpsLockMask(LOC_GPS_LOCK_MASK lockMask)
|
||||
{
|
||||
if (isGpsLockAll(lockMask))
|
||||
return RPC_LOC_LOCK_ALL;
|
||||
if (isGpsLockMO(lockMask))
|
||||
return RPC_LOC_LOCK_MI;
|
||||
if (isGpsLockMT(lockMask))
|
||||
return RPC_LOC_LOCK_MT;
|
||||
if (isGpsLockNone(lockMask))
|
||||
return RPC_LOC_LOCK_NONE;
|
||||
return (rpc_loc_lock_e_type)lockMask;
|
||||
}
|
||||
|
||||
enum loc_api_adapter_err
|
||||
LocApiRpc::convertErr(int rpcErr)
|
||||
{
|
||||
|
@ -1400,12 +1414,12 @@ LocApiBase* getLocApi(const MsgTask* msgTask,
|
|||
3 = Lock MT position sessions
|
||||
4 = Lock all position sessions
|
||||
*/
|
||||
int LocApiRpc::setGpsLock(unsigned int lock)
|
||||
int LocApiRpc::setGpsLock(LOC_GPS_LOCK_MASK lockMask)
|
||||
{
|
||||
rpc_loc_ioctl_data_u_type ioctl_data;
|
||||
boolean ret_val;
|
||||
LOC_LOGD("%s:%d]: lock: %d\n", __func__, __LINE__, lock);
|
||||
ioctl_data.rpc_loc_ioctl_data_u_type_u.engine_lock = (rpc_loc_lock_e_type)lock;
|
||||
LOC_LOGD("%s:%d]: lock: %x\n", __func__, __LINE__, lockMask);
|
||||
ioctl_data.rpc_loc_ioctl_data_u_type_u.engine_lock = convertGpsLockMask(lockMask);
|
||||
ioctl_data.disc = RPC_LOC_IOCTL_SET_ENGINE_LOCK;
|
||||
ret_val = loc_eng_ioctl (loc_eng_data.client_handle,
|
||||
RPC_LOC_IOCTL_SET_ENGINE_LOCK,
|
||||
|
|
|
@ -130,37 +130,42 @@ void LocEngAdapter::setUlpProxy(UlpProxyBase* ulp)
|
|||
mUlp = ulp;
|
||||
}
|
||||
|
||||
void LocEngAdapter::requestPowerVote()
|
||||
int LocEngAdapter::setGpsLockMsg(LOC_GPS_LOCK_MASK lockMask)
|
||||
{
|
||||
struct LocEngAdapterVotePower : public LocMsg {
|
||||
struct LocEngAdapterGpsLock : public LocMsg {
|
||||
LocEngAdapter* mAdapter;
|
||||
const bool mPowerUp;
|
||||
inline LocEngAdapterVotePower(LocEngAdapter* adapter, bool powerUp) :
|
||||
LocMsg(), mAdapter(adapter), mPowerUp(powerUp)
|
||||
LOC_GPS_LOCK_MASK mLockMask;
|
||||
inline LocEngAdapterGpsLock(LocEngAdapter* adapter, LOC_GPS_LOCK_MASK lockMask) :
|
||||
LocMsg(), mAdapter(adapter), mLockMask(lockMask)
|
||||
{
|
||||
locallog();
|
||||
}
|
||||
inline virtual void proc() const {
|
||||
/* Power voting without engine lock:
|
||||
* 101: vote down, 102-104 - vote up
|
||||
* These codes are used not to confuse with actual engine lock
|
||||
* functionality, that can't be used in SSR scenario, as it
|
||||
* conflicts with initialization sequence.
|
||||
*/
|
||||
int mode = mPowerUp ? 103 : 101;
|
||||
mAdapter->setGpsLock(mode);
|
||||
mAdapter->setGpsLock(mLockMask);
|
||||
}
|
||||
inline void locallog() const {
|
||||
LOC_LOGV("LocEngAdapterVotePower - Vote Power: %d",
|
||||
(int)mPowerUp);
|
||||
LOC_LOGV("LocEngAdapterGpsLock - mLockMask: %x", mLockMask);
|
||||
}
|
||||
inline virtual void log() const {
|
||||
locallog();
|
||||
}
|
||||
};
|
||||
sendMsg(new LocEngAdapterGpsLock(this, lockMask));
|
||||
return 0;
|
||||
}
|
||||
|
||||
void LocEngAdapter::requestPowerVote()
|
||||
{
|
||||
if (getPowerVoteRight()) {
|
||||
sendMsg(new LocEngAdapterVotePower(this, getPowerVote()));
|
||||
/* Power voting without engine lock:
|
||||
* 101: vote down, 102-104 - vote up
|
||||
* These codes are used not to confuse with actual engine lock
|
||||
* functionality, that can't be used in SSR scenario, as it
|
||||
* conflicts with initialization sequence.
|
||||
*/
|
||||
bool powerUp = getPowerVote();
|
||||
LOC_LOGV("LocEngAdapterVotePower - Vote Power: %d", (int)powerUp);
|
||||
setGpsLock(powerUp ? 103 : 101);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -317,10 +317,13 @@ public:
|
|||
3 = Lock MT position sessions
|
||||
4 = Lock all position sessions
|
||||
*/
|
||||
inline int setGpsLock(unsigned int lock)
|
||||
inline int setGpsLock(LOC_GPS_LOCK_MASK lock)
|
||||
{
|
||||
return mLocApi->setGpsLock(lock);
|
||||
}
|
||||
|
||||
int setGpsLockMsg(LOC_GPS_LOCK_MASK lock);
|
||||
|
||||
/*
|
||||
Returns
|
||||
Current value of GPS lock on success
|
||||
|
|
|
@ -94,14 +94,22 @@ loc_gps_cfg_s_type gps_conf;
|
|||
loc_sap_cfg_s_type sap_conf;
|
||||
|
||||
/* Parameter spec table */
|
||||
static loc_param_s_type loc_parameter_table[] =
|
||||
static loc_param_s_type gps_conf_table[] =
|
||||
{
|
||||
{"GPS_LOCK", &gps_conf.GPS_LOCK, NULL, 'n'},
|
||||
{"SUPL_VER", &gps_conf.SUPL_VER, NULL, 'n'},
|
||||
{"LPP_PROFILE", &gps_conf.LPP_PROFILE, NULL, 'n'},
|
||||
{"A_GLONASS_POS_PROTOCOL_SELECT", &gps_conf.A_GLONASS_POS_PROTOCOL_SELECT, NULL, 'n'},
|
||||
{"AGPS_CERT_WRITABLE_MASK", &gps_conf.AGPS_CERT_WRITABLE_MASK, NULL, 'n'},
|
||||
{"INTERMEDIATE_POS", &gps_conf.INTERMEDIATE_POS, NULL, 'n'},
|
||||
{"ACCURACY_THRES", &gps_conf.ACCURACY_THRES, NULL, 'n'},
|
||||
{"NMEA_PROVIDER", &gps_conf.NMEA_PROVIDER, NULL, 'n'},
|
||||
{"SUPL_VER", &gps_conf.SUPL_VER, NULL, 'n'},
|
||||
{"CAPABILITIES", &gps_conf.CAPABILITIES, NULL, 'n'},
|
||||
{"USE_EMERGENCY_PDN_FOR_EMERGENCY_SUPL", &gps_conf.USE_EMERGENCY_PDN_FOR_EMERGENCY_SUPL, NULL, 'n'},
|
||||
};
|
||||
|
||||
static loc_param_s_type sap_conf_table[] =
|
||||
{
|
||||
{"GYRO_BIAS_RANDOM_WALK", &sap_conf.GYRO_BIAS_RANDOM_WALK, &sap_conf.GYRO_BIAS_RANDOM_WALK_VALID, 'f'},
|
||||
{"ACCEL_RANDOM_WALK_SPECTRAL_DENSITY", &sap_conf.ACCEL_RANDOM_WALK_SPECTRAL_DENSITY, &sap_conf.ACCEL_RANDOM_WALK_SPECTRAL_DENSITY_VALID, 'f'},
|
||||
{"ANGLE_RANDOM_WALK_SPECTRAL_DENSITY", &sap_conf.ANGLE_RANDOM_WALK_SPECTRAL_DENSITY, &sap_conf.ANGLE_RANDOM_WALK_SPECTRAL_DENSITY_VALID, 'f'},
|
||||
|
@ -118,8 +126,6 @@ static loc_param_s_type loc_parameter_table[] =
|
|||
{"SENSOR_CONTROL_MODE", &sap_conf.SENSOR_CONTROL_MODE, NULL, 'n'},
|
||||
{"SENSOR_USAGE", &sap_conf.SENSOR_USAGE, NULL, 'n'},
|
||||
{"SENSOR_ALGORITHM_CONFIG_MASK", &sap_conf.SENSOR_ALGORITHM_CONFIG_MASK, 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'},
|
||||
{"XTRA_VERSION_CHECK", &gps_conf.XTRA_VERSION_CHECK, NULL, 'n'},
|
||||
{"XTRA_SERVER_1", &gps_conf.XTRA_SERVER_1, NULL, 's'},
|
||||
|
@ -134,6 +140,7 @@ static void loc_default_parameters(void)
|
|||
gps_conf.INTERMEDIATE_POS = 0;
|
||||
gps_conf.ACCURACY_THRES = 0;
|
||||
gps_conf.NMEA_PROVIDER = 0;
|
||||
gps_conf.GPS_LOCK = 0;
|
||||
gps_conf.SUPL_VER = 0x10000;
|
||||
gps_conf.CAPABILITIES = 0x7;
|
||||
/* LTE Positioning Profile configuration is disable by default*/
|
||||
|
@ -1611,7 +1618,8 @@ int loc_eng_init(loc_eng_data_s_type &loc_eng_data, LocCallbacks* callbacks,
|
|||
}
|
||||
|
||||
STATE_CHECK((NULL == loc_eng_data.adapter),
|
||||
"instance already initialized", return 0);
|
||||
"instance already initialized",
|
||||
return loc_eng_data.adapter->setGpsLockMsg(0));
|
||||
|
||||
memset(&loc_eng_data, 0, sizeof (loc_eng_data));
|
||||
|
||||
|
@ -1624,6 +1632,7 @@ int loc_eng_init(loc_eng_data_s_type &loc_eng_data, LocCallbacks* callbacks,
|
|||
loc_eng_data.sv_status_cb = callbacks->sv_status_cb;
|
||||
loc_eng_data.status_cb = callbacks->status_cb;
|
||||
loc_eng_data.nmea_cb = callbacks->nmea_cb;
|
||||
loc_eng_data.set_capabilities_cb = callbacks->set_capabilities_cb;
|
||||
loc_eng_data.acquire_wakelock_cb = callbacks->acquire_wakelock_cb;
|
||||
loc_eng_data.release_wakelock_cb = callbacks->release_wakelock_cb;
|
||||
loc_eng_data.request_utc_time_cb = callbacks->request_utc_time_cb;
|
||||
|
@ -1753,6 +1762,8 @@ void loc_eng_cleanup(loc_eng_data_s_type &loc_eng_data)
|
|||
loc_eng_stop(loc_eng_data);
|
||||
}
|
||||
|
||||
loc_eng_data.adapter->setGpsLockMsg(gps_conf.GPS_LOCK);
|
||||
|
||||
#if 0 // can't afford to actually clean up, for many reason.
|
||||
|
||||
LOC_LOGD("loc_eng_init: client opened. close it now.");
|
||||
|
@ -2420,7 +2431,14 @@ static int loc_eng_set_server(loc_eng_data_s_type &loc_eng_data,
|
|||
|
||||
if (LOC_AGPS_SUPL_SERVER == type) {
|
||||
char url[MAX_URL_LEN];
|
||||
unsigned int len = snprintf(url, sizeof(url), "%s:%u", hostname, (unsigned) port);
|
||||
unsigned int len = 0;
|
||||
const char nohost[] = "NONE";
|
||||
if (hostname == NULL ||
|
||||
strncasecmp(nohost, hostname, sizeof(nohost)) == 0) {
|
||||
url[0] = NULL;
|
||||
} else {
|
||||
len = snprintf(url, sizeof(url), "%s:%u", hostname, (unsigned) port);
|
||||
}
|
||||
|
||||
if (sizeof(url) > len) {
|
||||
adapter->sendMsg(new LocEngSetServerUrl(adapter, url, len));
|
||||
|
@ -2596,7 +2614,7 @@ void loc_eng_configuration_update (loc_eng_data_s_type &loc_eng_data,
|
|||
|
||||
if (config_data && length > 0) {
|
||||
loc_gps_cfg_s_type gps_conf_old = gps_conf;
|
||||
UTIL_UPDATE_CONF(config_data, length, loc_parameter_table);
|
||||
UTIL_UPDATE_CONF(config_data, length, gps_conf_table);
|
||||
LocEngAdapter* adapter = loc_eng_data.adapter;
|
||||
|
||||
// it is possible that HAL is not init'ed at this time
|
||||
|
@ -2611,7 +2629,15 @@ void loc_eng_configuration_update (loc_eng_data_s_type &loc_eng_data,
|
|||
adapter->sendMsg(new LocEngAGlonassProtocol(adapter,
|
||||
gps_conf.A_GLONASS_POS_PROTOCOL_SELECT));
|
||||
}
|
||||
if (NULL != loc_eng_data.set_capabilities_cb) {
|
||||
gps_conf.CAPABILITIES &= gps_conf_old.CAPABILITIES;
|
||||
if (gps_conf.CAPABILITIES != gps_conf_old.CAPABILITIES) {
|
||||
loc_eng_data.set_capabilities_cb(gps_conf.CAPABILITIES);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
gps_conf.CAPABILITIES = gps_conf_old.CAPABILITIES;
|
||||
}
|
||||
|
||||
EXIT_LOG(%s, VOID_RET);
|
||||
|
@ -2787,8 +2813,8 @@ int loc_eng_read_config(void)
|
|||
loc_default_parameters();
|
||||
// We only want to parse the conf file once. This is a good place to ensure that.
|
||||
// In fact one day the conf file should go into context.
|
||||
UTIL_READ_CONF(GPS_CONF_FILE, loc_parameter_table);
|
||||
UTIL_READ_CONF(SAP_CONF_FILE, loc_parameter_table);
|
||||
UTIL_READ_CONF(GPS_CONF_FILE, gps_conf_table);
|
||||
UTIL_READ_CONF(SAP_CONF_FILE, sap_conf_table);
|
||||
configAlreadyRead = true;
|
||||
} else {
|
||||
LOC_LOGV("GPS Config file has already been read\n");
|
||||
|
|
|
@ -90,6 +90,7 @@ typedef struct loc_eng_data_s
|
|||
agps_status_extended agps_status_cb;
|
||||
gps_nmea_callback nmea_cb;
|
||||
gps_ni_notify_callback ni_notify_cb;
|
||||
gps_set_capabilities set_capabilities_cb;
|
||||
gps_acquire_wakelock acquire_wakelock_cb;
|
||||
gps_release_wakelock release_wakelock_cb;
|
||||
gps_request_utc_time request_utc_time_cb;
|
||||
|
@ -152,6 +153,7 @@ typedef struct loc_gps_cfg_s
|
|||
char XTRA_SERVER_2[MAX_XTRA_SERVER_URL_LENGTH];
|
||||
char XTRA_SERVER_3[MAX_XTRA_SERVER_URL_LENGTH];
|
||||
uint32_t USE_EMERGENCY_PDN_FOR_EMERGENCY_SUPL;
|
||||
uint8_t GPS_LOCK;
|
||||
uint32_t A_GLONASS_POS_PROTOCOL_SELECT;
|
||||
uint32_t AGPS_CERT_WRITABLE_MASK;
|
||||
} loc_gps_cfg_s_type;
|
||||
|
|
Loading…
Reference in a new issue