stub out injectTime API as we should not handle that am: 97eef6b850 am: 6950d3998a
Change-Id: I886538ae5d2e7a6d0bf0c794470319e55a39a3fa
diff --git a/sdm845/core/LocApiBase.cpp b/sdm845/core/LocApiBase.cpp
index d06fddf..a0bf9c4 100644
--- a/sdm845/core/LocApiBase.cpp
+++ b/sdm845/core/LocApiBase.cpp
@@ -31,6 +31,7 @@
#include <dlfcn.h>
#include <inttypes.h>
+#include <gps_extended_c.h>
#include <LocApiBase.h>
#include <LocAdapterBase.h>
#include <log_util.h>
@@ -95,7 +96,10 @@
}
inline virtual void proc() const {
mLocApi->close();
- mLocApi->open(mLocApi->getEvtMask());
+ if (LOC_API_ADAPTER_ERR_SUCCESS == mLocApi->open(mLocApi->getEvtMask())) {
+ // Notify adapters that engine up after SSR
+ mLocApi->handleEngineUpEvent();
+ }
}
inline void locallog() const {
LOC_LOGV("LocSsrMsg");
@@ -107,13 +111,17 @@
struct LocOpenMsg : public LocMsg {
LocApiBase* mLocApi;
- inline LocOpenMsg(LocApiBase* locApi) :
- LocMsg(), mLocApi(locApi)
+ LocAdapterBase* mAdapter;
+ inline LocOpenMsg(LocApiBase* locApi, LocAdapterBase* adapter = nullptr) :
+ LocMsg(), mLocApi(locApi), mAdapter(adapter)
{
locallog();
}
inline virtual void proc() const {
- mLocApi->open(mLocApi->getEvtMask());
+ if (LOC_API_ADAPTER_ERR_SUCCESS == mLocApi->open(mLocApi->getEvtMask()) &&
+ nullptr != mAdapter) {
+ mLocApi->handleEngineUpEvent();
+ }
}
inline void locallog() const {
LOC_LOGv("LocOpen Mask: %" PRIx64 "\n", mLocApi->getEvtMask());
@@ -201,7 +209,7 @@
for (int i = 0; i < MAX_ADAPTERS && mLocAdapters[i] != adapter; i++) {
if (mLocAdapters[i] == NULL) {
mLocAdapters[i] = adapter;
- mMsgTask->sendMsg(new LocOpenMsg(this));
+ mMsgTask->sendMsg(new LocOpenMsg(this, adapter));
break;
}
}
@@ -250,17 +258,15 @@
void LocApiBase::handleEngineUpEvent()
{
- // This will take care of renegotiating the loc handle
- mMsgTask->sendMsg(new LocSsrMsg(this));
-
- LocDualContext::injectFeatureConfig(mContext);
-
// loop through adapters, and deliver to all adapters.
TO_ALL_LOCADAPTERS(mLocAdapters[i]->handleEngineUpEvent());
}
void LocApiBase::handleEngineDownEvent()
{
+ // This will take care of renegotiating the loc handle
+ mMsgTask->sendMsg(new LocSsrMsg(this));
+
// loop through adapters, and deliver to all adapters.
TO_ALL_LOCADAPTERS(mLocAdapters[i]->handleEngineDownEvent());
}
diff --git a/sdm845/core/LocApiBase.h b/sdm845/core/LocApiBase.h
index aec1846..b93b227 100644
--- a/sdm845/core/LocApiBase.h
+++ b/sdm845/core/LocApiBase.h
@@ -80,12 +80,12 @@
friend struct LocOpenMsg;
friend class ContextBase;
const MsgTask* mMsgTask;
- ContextBase *mContext;
LocAdapterBase* mLocAdapters[MAX_ADAPTERS];
uint64_t mSupportedMsg;
uint8_t mFeaturesSupported[MAX_FEATURE_LENGTH];
protected:
+ ContextBase *mContext;
virtual enum loc_api_adapter_err
open(LOC_API_ADAPTER_EVENT_MASK_T mask);
virtual enum loc_api_adapter_err
diff --git a/sdm845/core/LocDualContext.cpp b/sdm845/core/LocDualContext.cpp
index 180d9dc..9851d61 100644
--- a/sdm845/core/LocDualContext.cpp
+++ b/sdm845/core/LocDualContext.cpp
@@ -55,7 +55,6 @@
const MsgTask* LocDualContext::mMsgTask = NULL;
ContextBase* LocDualContext::mFgContext = NULL;
ContextBase* LocDualContext::mBgContext = NULL;
-ContextBase* LocDualContext::mInjectContext = NULL;
// the name must be shorter than 15 chars
const char* LocDualContext::mLocationHalName = "Loc_hal_worker";
#ifndef USE_GLIB
@@ -91,11 +90,6 @@
mFgContext = new LocDualContext(msgTask,
mFgExclMask);
}
- if(NULL == mInjectContext) {
- LOC_LOGD("%s:%d]: mInjectContext is FgContext", __func__, __LINE__);
- mInjectContext = mFgContext;
- injectFeatureConfig(mInjectContext);
- }
pthread_mutex_unlock(&LocDualContext::mGetLocContextMutex);
if (firstMsg) {
@@ -116,11 +110,6 @@
mBgContext = new LocDualContext(msgTask,
mBgExclMask);
}
- if(NULL == mInjectContext) {
- LOC_LOGD("%s:%d]: mInjectContext is BgContext", __func__, __LINE__);
- mInjectContext = mBgContext;
- injectFeatureConfig(mInjectContext);
- }
pthread_mutex_unlock(&LocDualContext::mGetLocContextMutex);
if (firstMsg) {
@@ -132,13 +121,9 @@
void LocDualContext :: injectFeatureConfig(ContextBase *curContext)
{
- LOC_LOGD("%s:%d]: Enter", __func__, __LINE__);
- if(curContext == mInjectContext) {
- LOC_LOGD("%s:%d]: Calling LBSProxy (%p) to inject feature config",
- __func__, __LINE__, ((LocDualContext *)mInjectContext)->mLBSProxy);
- ((LocDualContext *)mInjectContext)->mLBSProxy->injectFeatureConfig(curContext);
- }
- LOC_LOGD("%s:%d]: Exit", __func__, __LINE__);
+ LOC_LOGD("%s:%d]: Calling LBSProxy (%p) to inject feature config",
+ __func__, __LINE__, ((LocDualContext *)curContext)->mLBSProxy);
+ ((LocDualContext *)curContext)->mLBSProxy->injectFeatureConfig(curContext);
}
LocDualContext::LocDualContext(const MsgTask* msgTask,
diff --git a/sdm845/core/LocDualContext.h b/sdm845/core/LocDualContext.h
index 3b3ce2c..edfbfb7 100644
--- a/sdm845/core/LocDualContext.h
+++ b/sdm845/core/LocDualContext.h
@@ -40,7 +40,6 @@
static const MsgTask* mMsgTask;
static ContextBase* mFgContext;
static ContextBase* mBgContext;
- static ContextBase* mInjectContext;
static const MsgTask* getMsgTask(LocThread::tCreate tCreator,
const char* name, bool joinable = true);
static const MsgTask* getMsgTask(const char* name, bool joinable = true);
diff --git a/sdm845/gnss/Agps.cpp b/sdm845/gnss/Agps.cpp
index f2ca8e4..32a4310 100644
--- a/sdm845/gnss/Agps.cpp
+++ b/sdm845/gnss/Agps.cpp
@@ -452,15 +452,14 @@
if (NULL != mAPN) {
delete mAPN;
+ mAPN = NULL;
}
- if (apn == NULL || len <= 0) {
+ if (NULL == apn || len <= 0 || len > MAX_APN_LEN || strlen(apn) != len) {
LOC_LOGD("Invalid apn len (%d) or null apn", len);
mAPN = NULL;
mAPNLen = 0;
- }
-
- if (NULL != apn) {
+ } else {
mAPN = new char[len+1];
if (NULL != mAPN) {
memcpy(mAPN, apn, len);
diff --git a/sdm845/gnss/GnssAdapter.cpp b/sdm845/gnss/GnssAdapter.cpp
index 04750b6..5411de8 100644
--- a/sdm845/gnss/GnssAdapter.cpp
+++ b/sdm845/gnss/GnssAdapter.cpp
@@ -655,14 +655,14 @@
int32_t length = -1;
const char noHost[] = "NONE";
- locErr = LOCATION_ERROR_INVALID_PARAMETER;
-
if ((NULL == server) || (server[0] == 0) ||
(strncasecmp(noHost, server, sizeof(noHost)) == 0)) {
serverUrl[0] = '\0';
length = 0;
} else if (port > 0) {
length = snprintf(serverUrl, sizeof(serverUrl), "%s:%u", server, port);
+ } else {
+ locErr = LOCATION_ERROR_INVALID_PARAMETER;
}
if (length >= 0 && strncasecmp(getServerUrl().c_str(),
@@ -694,7 +694,7 @@
inline virtual void proc() const {
if (ContextBase::mGps_conf.AGPS_CONFIG_INJECT) {
mApi.setSUPLVersion(mAdapter.convertSuplVersion(ContextBase::mGps_conf.SUPL_VER));
- mApi.setLPPConfig(mAdapter.convertLppProfile(ContextBase::mGps_conf.LPP_PROFILE));
+ // mApi.setLPPConfig(mAdapter.convertLppProfile(ContextBase::mGps_conf.LPP_PROFILE));
mApi.setAGLONASSProtocol(ContextBase::mGps_conf.A_GLONASS_POS_PROTOCOL_SELECT);
}
mAdapter.setSuplHostServer(ContextBase::mGps_conf.SUPL_HOST,
@@ -875,6 +875,8 @@
errs[index++] = err;
}
}
+
+ /* Comment out LPP injection as it's configured by MBN.
if (mConfig.flags & GNSS_CONFIG_FLAGS_LPP_PROFILE_VALID_BIT) {
uint32_t newLppProfile = mAdapter.convertLppProfile(mConfig.lppProfile);
if (newLppProfile != ContextBase::mGps_conf.LPP_PROFILE &&
@@ -888,6 +890,8 @@
errs[index++] = err;
}
}
+ */
+
if (mConfig.flags & GNSS_CONFIG_FLAGS_LPPE_CONTROL_PLANE_VALID_BIT) {
uint32_t newLppeControlPlaneMask =
mAdapter.convertLppeCp(mConfig.lppeControlPlaneMask);
@@ -3597,6 +3601,8 @@
LOC_LOGV("AgpsMsgAtlOpenSuccess");
if (mApnName == nullptr) {
LOC_LOGE("%s] new allocation failed, fatal error.", __func__);
+ // Reporting the failure here
+ mAgpsManager->reportAtlClosed(mAgpsType);
return;
}
memcpy(mApnName, apnName, apnLen);
@@ -3613,9 +3619,15 @@
mAgpsManager->reportAtlOpenSuccess(mAgpsType, mApnName, mApnLen, mBearerType);
}
};
-
+ // Added inital length checks for apnlen check to avoid security issues
+ // In case of failure reporting the same
+ if (NULL == apnName || apnLen <= 0 || apnLen > MAX_APN_LEN || (strlen(apnName) != apnLen)) {
+ LOC_LOGe("%s]: incorrect apnlen length or incorrect apnName", __func__);
+ mAgpsManager.reportAtlClosed(agpsType);
+ } else {
sendMsg( new AgpsMsgAtlOpenSuccess(
&mAgpsManager, agpsType, apnName, apnLen, bearerType));
+ }
}
void GnssAdapter::dataConnClosedCommand(AGpsExtType agpsType){