summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Tang <zhikait@codeaurora.org>2014-09-11 12:19:14 -0700
committerGerrit - the friendly Code Review server <code-review@localhost>2014-10-20 15:00:31 -0700
commitaf2762ceca5cf9f99120ab5d1a6971fa1c3b5901 (patch)
tree912c1a4d2b99389483bfb9d4dc01b57214ac4fe4
parent809dec4e92deee31551fae7dc9754daf80d20697 (diff)
downloadgps-af2762ceca5cf9f99120ab5d1a6971fa1c3b5901.tar.gz
GPS_LOCK configuration support
GPS_LOCK is defined as a bit mask in the higher layer defined in gps.conf. GPS HAL reads from gps.conf, yet this can be reconfigured by gps.h defined new API to a different value. The current value will be used at cleanup() time, to optionally lock gps modem to the configured mode. This changs also sets SUPL URL to NULL if hostname comes with set_server() API is a NULL string. Also optimized configuration_update() implementation so that no all items will go through the reconfigu scan. Also added SUPL_MODE as a parameter in gps.conf which can be uncommented to over-write the value from config.xml. This can be used for testing purposes Bug: 16131208 Bug: 17288144 CRs-fixed: 736966 Change-Id: I12a89b12ff82b6efd7b5567d2fcd6a7e79414c71
-rw-r--r--core/LocApiBase.cpp2
-rw-r--r--core/LocApiBase.h2
-rw-r--r--core/gps_extended_c.h6
-rw-r--r--etc/gps.conf14
-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.cpp44
-rw-r--r--loc_api/libloc_api_50001/loc_eng.h2
10 files changed, 103 insertions, 32 deletions
diff --git a/core/LocApiBase.cpp b/core/LocApiBase.cpp
index 141fab6..43332dc 100644
--- a/core/LocApiBase.cpp
+++ b/core/LocApiBase.cpp
@@ -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::
diff --git a/core/LocApiBase.h b/core/LocApiBase.h
index af9d270..f68cf73 100644
--- a/core/LocApiBase.h
+++ b/core/LocApiBase.h
@@ -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
diff --git a/core/gps_extended_c.h b/core/gps_extended_c.h
index 33906b5..a1ffd85 100644
--- a/core/gps_extended_c.h
+++ b/core/gps_extended_c.h
@@ -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 */
diff --git a/etc/gps.conf b/etc/gps.conf
index c57088a..beda6da 100644
--- a/etc/gps.conf
+++ b/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
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 1043fe8..0ac3df4 100644
--- a/loc_api/libloc_api_50001/LocEngAdapter.cpp
+++ b/loc_api/libloc_api_50001/LocEngAdapter.cpp
@@ -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);
}
}
diff --git a/loc_api/libloc_api_50001/LocEngAdapter.h b/loc_api/libloc_api_50001/LocEngAdapter.h
index 806f010..b857d19 100644
--- a/loc_api/libloc_api_50001/LocEngAdapter.h
+++ b/loc_api/libloc_api_50001/LocEngAdapter.h
@@ -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
diff --git a/loc_api/libloc_api_50001/loc_eng.cpp b/loc_api/libloc_api_50001/loc_eng.cpp
index c40a593..e32dbc4 100644
--- a/loc_api/libloc_api_50001/loc_eng.cpp
+++ b/loc_api/libloc_api_50001/loc_eng.cpp
@@ -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");
diff --git a/loc_api/libloc_api_50001/loc_eng.h b/loc_api/libloc_api_50001/loc_eng.h
index 6ef3336..86bdae4 100644
--- a/loc_api/libloc_api_50001/loc_eng.h
+++ b/loc_api/libloc_api_50001/loc_eng.h
@@ -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;