summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Tang <zhikait@codeaurora.org>2018-07-03 10:45:56 -0700
committerKevin Tang <zhikait@codeaurora.org>2018-07-03 10:45:56 -0700
commit56c4dd442074bad94c2ef1483ecfc328703f8557 (patch)
treea4c49a927f56b593d58c434b0e81015d174efecc
parent271cfd8a00f97f13a937877cc8ef66ef0392a087 (diff)
downloadgps-56c4dd442074bad94c2ef1483ecfc328703f8557.tar.gz
GPS: block CPI injection for those fixes orginate from modem
GNSS adapter to block CPI injection for CPI originates from modem. One source of the fix is QNP fix from modem. Only fixes that comes within time threshold and with latitude and longitude falls within the same proximity will be blocked. Change-Id: If67a164d1e1c75735979f048a9f8dc93f0b0a41f CRs-fixed: 2260721
-rw-r--r--gnss/GnssAdapter.cpp83
-rw-r--r--gnss/GnssAdapter.h18
-rw-r--r--gnss/location_gnss.cpp11
-rw-r--r--location/location_interface.h2
4 files changed, 104 insertions, 10 deletions
diff --git a/gnss/GnssAdapter.cpp b/gnss/GnssAdapter.cpp
index 98a3249..558cf49 100644
--- a/gnss/GnssAdapter.cpp
+++ b/gnss/GnssAdapter.cpp
@@ -84,7 +84,8 @@ GnssAdapter::GnssAdapter() :
mOdcpiInjectedPositionCount(0),
mSystemStatus(SystemStatus::getInstance(mMsgTask)),
mServerUrl(":"),
- mXtraObserver(mSystemStatus->getOsObserver(), mMsgTask)
+ mXtraObserver(mSystemStatus->getOsObserver(), mMsgTask),
+ mBlockCPIInfo{}
{
LOC_LOGD("%s]: Constructor %p", __func__, this);
mLocPositionMode.mode = LOC_POSITION_MODE_INVALID;
@@ -1599,26 +1600,39 @@ GnssAdapter::injectLocationCommand(double latitude, double longitude, float accu
struct MsgInjectLocation : public LocMsg {
LocApiBase& mApi;
ContextBase& mContext;
+ BlockCPIInfo& mBlockCPI;
double mLatitude;
double mLongitude;
float mAccuracy;
inline MsgInjectLocation(LocApiBase& api,
ContextBase& context,
+ BlockCPIInfo& blockCPIInfo,
double latitude,
double longitude,
float accuracy) :
LocMsg(),
mApi(api),
mContext(context),
+ mBlockCPI(blockCPIInfo),
mLatitude(latitude),
mLongitude(longitude),
mAccuracy(accuracy) {}
inline virtual void proc() const {
- mApi.injectPosition(mLatitude, mLongitude, mAccuracy);
+ if ((uptimeMillis() <= mBlockCPI.blockedTillTsMs) &&
+ (fabs(mLatitude-mBlockCPI.latitude) <= mBlockCPI.latLonDiffThreshold) &&
+ (fabs(mLongitude-mBlockCPI.longitude) <= mBlockCPI.latLonDiffThreshold)) {
+
+ LOC_LOGD("%s]: positon injeciton blocked: lat: %f, lon: %f, accuracy: %f",
+ __func__, mLatitude, mLongitude, mAccuracy);
+
+ } else {
+ mApi.injectPosition(mLatitude, mLongitude, mAccuracy);
+ }
}
};
- sendMsg(new MsgInjectLocation(*mLocApi, *mContext, latitude, longitude, accuracy));
+ sendMsg(new MsgInjectLocation(*mLocApi, *mContext, mBlockCPIInfo,
+ latitude, longitude, accuracy));
}
void
@@ -1652,6 +1666,43 @@ GnssAdapter::injectTimeCommand(int64_t time, int64_t timeReference, int32_t unce
sendMsg(new MsgInjectTime(*mLocApi, *mContext, time, timeReference, uncertainty));
}
+// This command is to called to block the position to be injected to the modem.
+// This can happen for network position that comes from modem.
+void
+GnssAdapter::blockCPICommand(double latitude, double longitude,
+ float accuracy, int blockDurationMsec,
+ double latLonDiffThreshold)
+{
+ struct MsgBlockCPI : public LocMsg {
+ BlockCPIInfo& mDstCPIInfo;
+ BlockCPIInfo mSrcCPIInfo;
+
+ inline MsgBlockCPI(BlockCPIInfo& dstCPIInfo,
+ BlockCPIInfo& srcCPIInfo) :
+ mDstCPIInfo(dstCPIInfo),
+ mSrcCPIInfo(srcCPIInfo) {}
+ inline virtual void proc() const {
+ // in the same hal thread, save the cpi to be blocked
+ // the global variable
+ mDstCPIInfo = mSrcCPIInfo;
+ }
+ };
+
+ // construct the new block CPI info and queue on the same thread
+ // for processing
+ BlockCPIInfo blockCPIInfo;
+ blockCPIInfo.latitude = latitude;
+ blockCPIInfo.longitude = longitude;
+ blockCPIInfo.accuracy = accuracy;
+ blockCPIInfo.blockedTillTsMs = uptimeMillis() + blockDurationMsec;
+ blockCPIInfo.latLonDiffThreshold = latLonDiffThreshold;
+
+ LOC_LOGD("%s]: block CPI lat: %f, lon: %f ", __func__, latitude, longitude);
+ // send a message to record down the coarse position
+ // to be blocked from injection in the master copy (mBlockCPIInfo)
+ sendMsg(new MsgBlockCPI(mBlockCPIInfo, blockCPIInfo));
+}
+
void
GnssAdapter::addClientCommand(LocationAPI* client, const LocationCallbacks& callbacks)
{
@@ -3225,13 +3276,25 @@ void GnssAdapter::injectOdcpiCommand(const Location& location)
void GnssAdapter::injectOdcpi(const Location& location)
{
- mLocApi->injectPosition(location, true);
- if (mOdcpiRequestActive) {
- mOdcpiInjectedPositionCount++;
- if (mOdcpiInjectedPositionCount >=
- ODCPI_INJECTED_POSITION_COUNT_PER_REQUEST) {
- mOdcpiRequestActive = false;
- mOdcpiInjectedPositionCount = 0;
+ if (LOCATION_HAS_LAT_LONG_BIT & location.flags) {
+ if ((uptimeMillis() <= mBlockCPIInfo.blockedTillTsMs) &&
+ (fabs(location.latitude-mBlockCPIInfo.latitude) <=
+ mBlockCPIInfo.latLonDiffThreshold) &&
+ (fabs(location.longitude-mBlockCPIInfo.longitude) <=
+ mBlockCPIInfo.latLonDiffThreshold)) {
+
+ LOC_LOGD("%s]: positon injeciton blocked: lat: %f, lon: %f, accuracy: %f",
+ __func__, location.latitude, location.longitude, location.accuracy);
+ } else {
+ mLocApi->injectPosition(location, true);
+ if (mOdcpiRequestActive) {
+ mOdcpiInjectedPositionCount++;
+ if (mOdcpiInjectedPositionCount >=
+ ODCPI_INJECTED_POSITION_COUNT_PER_REQUEST) {
+ mOdcpiRequestActive = false;
+ mOdcpiInjectedPositionCount = 0;
+ }
+ }
}
}
}
diff --git a/gnss/GnssAdapter.h b/gnss/GnssAdapter.h
index 319ea6b..695caf8 100644
--- a/gnss/GnssAdapter.h
+++ b/gnss/GnssAdapter.h
@@ -76,6 +76,19 @@ typedef struct {
uint32_t svIdOffset;
} NmeaSvMeta;
+typedef struct {
+ double latitude;
+ double longitude;
+ float accuracy;
+ // the CPI will be blocked until the boot time
+ // specified in blockedTillTsMs
+ int64_t blockedTillTsMs;
+ // CPIs whose both latitude and longitude differ
+ // no more than latLonThreshold will be blocked
+ // in units of degree
+ double latLonDiffThreshold;
+} BlockCPIInfo;
+
using namespace loc_core;
namespace loc_core {
@@ -124,6 +137,9 @@ class GnssAdapter : public LocAdapterBase {
std::string mServerUrl;
XtraSystemStatusObserver mXtraObserver;
+ /* === Misc ===================================================================== */
+ BlockCPIInfo mBlockCPIInfo;
+
/*==== CONVERSION ===================================================================*/
static void convertOptions(LocPosMode& out, const TrackingOptions& trackingOptions);
static void convertLocation(Location& out, const UlpLocation& ulpLocation,
@@ -336,6 +352,8 @@ public:
void injectLocationCommand(double latitude, double longitude, float accuracy);
void injectTimeCommand(int64_t time, int64_t timeReference, int32_t uncertainty);
+ void blockCPICommand(double latitude, double longitude, float accuracy,
+ int blockDurationMsec, double latLonDiffThreshold);
};
#endif //GNSS_ADAPTER_H
diff --git a/gnss/location_gnss.cpp b/gnss/location_gnss.cpp
index 105145a..800ea1b 100644
--- a/gnss/location_gnss.cpp
+++ b/gnss/location_gnss.cpp
@@ -70,6 +70,9 @@ static void updateConnectionStatus(bool connected, int8_t type);
static void odcpiInit(const OdcpiRequestCallback& callback);
static void odcpiInject(const Location& location);
+static void blockCPI(double latitude, double longitude, float accuracy,
+ int blockDurationMsec, double latLonDiffThreshold);
+
static const GnssInterface gGnssInterface = {
sizeof(GnssInterface),
initialize,
@@ -101,6 +104,7 @@ static const GnssInterface gGnssInterface = {
updateConnectionStatus,
odcpiInit,
odcpiInject,
+ blockCPI,
};
#ifndef DEBUG_X86
@@ -327,3 +331,10 @@ static void odcpiInject(const Location& location)
}
}
+static void blockCPI(double latitude, double longitude, float accuracy,
+ int blockDurationMsec, double latLonDiffThreshold) {
+ if (NULL != gGnssAdapter) {
+ gGnssAdapter->blockCPICommand(latitude, longitude, accuracy,
+ blockDurationMsec, latLonDiffThreshold);
+ }
+} \ No newline at end of file
diff --git a/location/location_interface.h b/location/location_interface.h
index 3c1558e..359cb2b 100644
--- a/location/location_interface.h
+++ b/location/location_interface.h
@@ -63,6 +63,8 @@ struct GnssInterface {
void (*updateConnectionStatus)(bool connected, int8_t type);
void (*odcpiInit)(const OdcpiRequestCallback& callback);
void (*odcpiInject)(const Location& location);
+ void (*blockCPI)(double latitude, double longitude, float accuracy,
+ int blockDurationMsec, double latLonDiffThreshold);
};
struct FlpInterface {