summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/LocApiBase.cpp2
-rw-r--r--core/LocApiBase.h2
-rw-r--r--core/gps_extended_c.h5
-rw-r--r--etc/gps.conf7
-rw-r--r--loc_api/libloc_api-rpc-50001/libloc_api-rpc-glue/rpc_inc/LocApiRpc.h3
-rw-r--r--loc_api/libloc_api-rpc-50001/libloc_api-rpc-glue/src/LocApiRpc.cpp20
-rw-r--r--loc_api/libloc_api_50001/LocEngAdapter.cpp37
-rw-r--r--loc_api/libloc_api_50001/LocEngAdapter.h5
-rw-r--r--loc_api/libloc_api_50001/loc_eng.cpp45
-rw-r--r--loc_api/libloc_api_50001/loc_eng.h2
-rwxr-xr-xmsm8960/etc/gps.conf7
11 files changed, 102 insertions, 33 deletions
diff --git a/core/LocApiBase.cpp b/core/LocApiBase.cpp
index a444fa5..9298a7a 100644
--- a/core/LocApiBase.cpp
+++ b/core/LocApiBase.cpp
@@ -475,7 +475,7 @@ void LocApiBase::
DEFAULT_IMPL()
int LocApiBase::
- setGpsLock(unsigned int lock)
+ setGpsLock(LOC_GPS_LOCK_MASK lock)
DEFAULT_IMPL(-1)
void LocApiBase::
diff --git a/core/LocApiBase.h b/core/LocApiBase.h
index 5218933..2d2b887 100644
--- a/core/LocApiBase.h
+++ b/core/LocApiBase.h
@@ -213,7 +213,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
diff --git a/core/gps_extended_c.h b/core/gps_extended_c.h
index 76a4927..8de0472 100644
--- a/core/gps_extended_c.h
+++ b/core/gps_extended_c.h
@@ -376,6 +376,11 @@ enum loc_api_adapter_event_index {
typedef unsigned int LOC_API_ADAPTER_EVENT_MASK_T;
+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
}
diff --git a/etc/gps.conf b/etc/gps.conf
index 7b882a3..01fee6c 100644
--- a/etc/gps.conf
+++ b/etc/gps.conf
@@ -26,6 +26,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
diff --git a/loc_api/libloc_api-rpc-50001/libloc_api-rpc-glue/rpc_inc/LocApiRpc.h b/loc_api/libloc_api-rpc-50001/libloc_api-rpc-glue/rpc_inc/LocApiRpc.h
index aafec63..01d67f4 100644
--- a/loc_api/libloc_api-rpc-50001/libloc_api-rpc-glue/rpc_inc/LocApiRpc.h
+++ b/loc_api/libloc_api-rpc-50001/libloc_api-rpc-glue/rpc_inc/LocApiRpc.h
@@ -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 &notif,
@@ -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
diff --git a/loc_api/libloc_api-rpc-50001/libloc_api-rpc-glue/src/LocApiRpc.cpp b/loc_api/libloc_api-rpc-50001/libloc_api-rpc-glue/src/LocApiRpc.cpp
index e142292..87d6b7c 100644
--- a/loc_api/libloc_api-rpc-50001/libloc_api-rpc-glue/src/LocApiRpc.cpp
+++ b/loc_api/libloc_api-rpc-50001/libloc_api-rpc-glue/src/LocApiRpc.cpp
@@ -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,
diff --git a/loc_api/libloc_api_50001/LocEngAdapter.cpp b/loc_api/libloc_api_50001/LocEngAdapter.cpp
index 1e6e4e1..184f83d 100644
--- a/loc_api/libloc_api_50001/LocEngAdapter.cpp
+++ b/loc_api/libloc_api_50001/LocEngAdapter.cpp
@@ -128,37 +128,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);
}
}
diff --git a/loc_api/libloc_api_50001/LocEngAdapter.h b/loc_api/libloc_api_50001/LocEngAdapter.h
index 484193c..1a1159d 100644
--- a/loc_api/libloc_api_50001/LocEngAdapter.h
+++ b/loc_api/libloc_api_50001/LocEngAdapter.h
@@ -319,10 +319,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
diff --git a/loc_api/libloc_api_50001/loc_eng.cpp b/loc_api/libloc_api_50001/loc_eng.cpp
index cae6a23..b678802 100644
--- a/loc_api/libloc_api_50001/loc_eng.cpp
+++ b/loc_api/libloc_api_50001/loc_eng.cpp
@@ -92,13 +92,21 @@ 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'},
+};
+
+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'},
@@ -115,10 +123,7 @@ 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'},
- {"AGPS_CERT_WRITABLE_MASK", &gps_conf.AGPS_CERT_WRITABLE_MASK, NULL, 'n'},
};
static void loc_default_parameters(void)
@@ -127,6 +132,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;
@@ -1572,7 +1578,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));
@@ -1585,6 +1592,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;
@@ -1716,6 +1724,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.");
@@ -2379,7 +2389,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));
@@ -2555,7 +2572,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
@@ -2570,7 +2587,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);
@@ -2746,8 +2771,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");
diff --git a/loc_api/libloc_api_50001/loc_eng.h b/loc_api/libloc_api_50001/loc_eng.h
index 0a8569d..834056e 100644
--- a/loc_api/libloc_api_50001/loc_eng.h
+++ b/loc_api/libloc_api_50001/loc_eng.h
@@ -88,6 +88,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;
@@ -145,6 +146,7 @@ typedef struct loc_gps_cfg_s
uint32_t CAPABILITIES;
uint32_t LPP_PROFILE;
uint8_t NMEA_PROVIDER;
+ uint8_t GPS_LOCK;
uint32_t A_GLONASS_POS_PROTOCOL_SELECT;
uint32_t AGPS_CERT_WRITABLE_MASK;
} loc_gps_cfg_s_type;
diff --git a/msm8960/etc/gps.conf b/msm8960/etc/gps.conf
index 60f3123..6aa1901 100755
--- a/msm8960/etc/gps.conf
+++ b/msm8960/etc/gps.conf
@@ -31,6 +31,13 @@ DEBUG_LEVEL = 2
# 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