summaryrefslogtreecommitdiff
path: root/gnss
diff options
context:
space:
mode:
authorqctecmdr <qctecmdr@localhost>2019-11-13 16:17:56 -0800
committerGerrit - the friendly Code Review server <code-review@localhost>2019-11-13 16:17:56 -0800
commit826c41ec8e18d35e14fa40c3bb7e1d39747e44b8 (patch)
tree9e35537bbf2bbec18acfaac4b580509764c446e6 /gnss
parent381bde3fcbc6d21dd918c305604b61ba57965ffd (diff)
parent52d928e06956bad27f03c78d67cbaadd80cef74d (diff)
downloadgps-826c41ec8e18d35e14fa40c3bb7e1d39747e44b8.tar.gz
Merge "GPS HAL: send platform power state event to modem"
Diffstat (limited to 'gnss')
-rw-r--r--gnss/GnssAdapter.cpp35
-rw-r--r--gnss/GnssAdapter.h6
-rw-r--r--gnss/location_gnss.cpp10
3 files changed, 48 insertions, 3 deletions
diff --git a/gnss/GnssAdapter.cpp b/gnss/GnssAdapter.cpp
index 96447f6..19dcb6d 100644
--- a/gnss/GnssAdapter.cpp
+++ b/gnss/GnssAdapter.cpp
@@ -99,7 +99,8 @@ GnssAdapter::GnssAdapter() :
mIsE911Session(NULL),
mGnssMbSvIdUsedInPosition{},
mGnssMbSvIdUsedInPosAvail(false),
- mSupportNfwControl(true)
+ mSupportNfwControl(true),
+ mSystemPowerState(POWER_STATE_UNKNOWN)
{
LOC_LOGD("%s]: Constructor %p", __func__, this);
mLocPositionMode.mode = LOC_POSITION_MODE_INVALID;
@@ -2023,6 +2024,35 @@ GnssAdapter::blockCPICommand(double latitude, double longitude,
}
void
+GnssAdapter::updateSystemPowerState(PowerStateType systemPowerState) {
+ if (POWER_STATE_UNKNOWN != systemPowerState) {
+ mSystemPowerState = systemPowerState;
+ mLocApi->updateSystemPowerState(mSystemPowerState);
+ }
+}
+
+void
+GnssAdapter::updateSystemPowerStateCommand(PowerStateType systemPowerState) {
+ LOC_LOGd("power event %d", systemPowerState);
+
+ struct MsgUpdatePowerState : public LocMsg {
+ GnssAdapter& mAdapter;
+ PowerStateType mSystemPowerState;
+
+ inline MsgUpdatePowerState(GnssAdapter& adapter,
+ PowerStateType systemPowerState) :
+ LocMsg(),
+ mAdapter(adapter),
+ mSystemPowerState(systemPowerState) {}
+ inline virtual void proc() const {
+ mAdapter.updateSystemPowerState(mSystemPowerState);
+ }
+ };
+
+ sendMsg(new MsgUpdatePowerState(*this, systemPowerState));
+}
+
+void
GnssAdapter::addClientCommand(LocationAPI* client, const LocationCallbacks& callbacks)
{
LOC_LOGD("%s]: client %p", __func__, client);
@@ -2163,9 +2193,10 @@ GnssAdapter::handleEngineUpEvent()
mAdapter.broadcastCapabilities(mAdapter.getCapabilities());
// must be called only after capabilities are known
mAdapter.setConfig();
- mAdapter.restartSessions();
mAdapter.gnssSvIdConfigUpdate();
mAdapter.gnssSvTypeConfigUpdate();
+ mAdapter.updateSystemPowerState(mAdapter.getSystemPowerState());
+ mAdapter.restartSessions();
for (auto msg: mAdapter.mPendingMsgs) {
mAdapter.sendMsg(msg);
}
diff --git a/gnss/GnssAdapter.h b/gnss/GnssAdapter.h
index 1feb985..37a4892 100644
--- a/gnss/GnssAdapter.h
+++ b/gnss/GnssAdapter.h
@@ -189,6 +189,7 @@ class GnssAdapter : public LocAdapterBase {
XtraSystemStatusObserver mXtraObserver;
LocationSystemInfo mLocSystemInfo;
std::vector<GnssSvIdSource> mBlacklistedSvIds;
+ PowerStateType mSystemPowerState;
/* === Misc ===================================================================== */
BlockCPIInfo mBlockCPIInfo;
@@ -416,6 +417,8 @@ public:
return false;
}
+ void updateSystemPowerState(PowerStateType systemPowerState);
+
/*======== GNSSDEBUG ================================================================*/
bool getDebugReport(GnssDebugReport& report);
/* get AGC information from system status and fill it */
@@ -462,11 +465,14 @@ public:
void reportPowerStateIfChanged();
void savePowerStateCallback(powerStateCallback powerStateCb){ mPowerStateCb = powerStateCb; }
bool getPowerState() { return mPowerOn; }
+ inline PowerStateType getSystemPowerState() { return mSystemPowerState; }
+
void setAllowFlpNetworkFixes(uint32_t allow) { mAllowFlpNetworkFixes = allow; }
uint32_t getAllowFlpNetworkFixes() { return mAllowFlpNetworkFixes; }
void setSuplHostServer(const char* server, int port, LocServerType type);
void notifyClientOfCachedLocationSystemInfo(LocationAPI* client,
const LocationCallbacks& callbacks);
+ void updateSystemPowerStateCommand(PowerStateType systemPowerState);
};
#endif //GNSS_ADAPTER_H
diff --git a/gnss/location_gnss.cpp b/gnss/location_gnss.cpp
index 76839b6..5380f05 100644
--- a/gnss/location_gnss.cpp
+++ b/gnss/location_gnss.cpp
@@ -79,6 +79,7 @@ static void odcpiInject(const Location& location);
static void blockCPI(double latitude, double longitude, float accuracy,
int blockDurationMsec, double latLonDiffThreshold);
static void updateBatteryStatus(bool charging);
+static void updateSystemPowerState(PowerStateType systemPowerState);
static const GnssInterface gGnssInterface = {
sizeof(GnssInterface),
@@ -117,7 +118,8 @@ static const GnssInterface gGnssInterface = {
nfwInit,
getPowerStateChanges,
injectLocationExt,
- updateBatteryStatus
+ updateBatteryStatus,
+ updateSystemPowerState
};
#ifndef DEBUG_X86
@@ -390,3 +392,9 @@ static void updateBatteryStatus(bool charging) {
gGnssAdapter->getSystemStatus()->updatePowerConnectState(charging);
}
}
+
+static void updateSystemPowerState(PowerStateType systemPowerState) {
+ if (NULL != gGnssAdapter) {
+ gGnssAdapter->updateSystemPowerStateCommand(systemPowerState);
+ }
+}