summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--android/1.0/Gnss.cpp8
-rw-r--r--android/1.1/Gnss.cpp8
-rw-r--r--android/2.0/Gnss.cpp9
-rw-r--r--core/SystemStatus.cpp13
-rw-r--r--core/SystemStatus.h1
-rw-r--r--gnss/location_gnss.cpp10
-rw-r--r--location/location_interface.h1
7 files changed, 45 insertions, 5 deletions
diff --git a/android/1.0/Gnss.cpp b/android/1.0/Gnss.cpp
index 873cf37..d85e0a4 100644
--- a/android/1.0/Gnss.cpp
+++ b/android/1.0/Gnss.cpp
@@ -37,6 +37,7 @@ namespace gnss {
namespace V1_0 {
namespace implementation {
+static sp<Gnss> sGnss;
void Gnss::GnssDeathRecipient::serviceDied(uint64_t cookie, const wp<IBase>& who) {
LOC_LOGE("%s] service died. cookie: %llu, who: %p",
__FUNCTION__, static_cast<unsigned long long>(cookie), &who);
@@ -47,10 +48,14 @@ void Gnss::GnssDeathRecipient::serviceDied(uint64_t cookie, const wp<IBase>& who
}
void location_on_battery_status_changed(bool charging) {
- LOC_LOGd("%s: battery status changed to %s charging", __func__, charging ? "" : "not ");
+ LOC_LOGd("battery status changed to %s charging", charging ? "" : "not ");
+ if (sGnss != nullptr) {
+ sGnss->getGnssInterface()->updateBatteryStatus(charging);
+ }
}
Gnss::Gnss() {
ENTRY_LOG_CALLFLOW();
+ sGnss = this;
// register health client to listen on battery change
loc_extn_battery_properties_listener_init(location_on_battery_status_changed);
// clear pending GnssConfig
@@ -65,6 +70,7 @@ Gnss::~Gnss() {
delete mApi;
mApi = nullptr;
}
+ sGnss = nullptr;
}
GnssAPIClient* Gnss::getApi() {
diff --git a/android/1.1/Gnss.cpp b/android/1.1/Gnss.cpp
index f0d74da..bea556f 100644
--- a/android/1.1/Gnss.cpp
+++ b/android/1.1/Gnss.cpp
@@ -41,6 +41,7 @@ namespace gnss {
namespace V1_1 {
namespace implementation {
+static sp<Gnss> sGnss;
static std::string getVersionString() {
static std::string version;
if (!version.empty())
@@ -88,10 +89,14 @@ void Gnss::GnssDeathRecipient::serviceDied(uint64_t cookie, const wp<IBase>& who
}
void location_on_battery_status_changed(bool charging) {
- LOC_LOGd("%s: battery status changed to %s charging", __func__, charging ? "" : "not ");
+ LOC_LOGd("battery status changed to %s charging", charging ? "" : "not");
+ if (sGnss != nullptr) {
+ sGnss->getGnssInterface()->updateBatteryStatus(charging);
+ }
}
Gnss::Gnss() {
ENTRY_LOG_CALLFLOW();
+ sGnss = this;
// register health client to listen on battery change
loc_extn_battery_properties_listener_init(location_on_battery_status_changed);
// clear pending GnssConfig
@@ -106,6 +111,7 @@ Gnss::~Gnss() {
delete mApi;
mApi = nullptr;
}
+ sGnss = nullptr;
}
GnssAPIClient* Gnss::getApi() {
diff --git a/android/2.0/Gnss.cpp b/android/2.0/Gnss.cpp
index be4efac..4fa5b63 100644
--- a/android/2.0/Gnss.cpp
+++ b/android/2.0/Gnss.cpp
@@ -41,7 +41,7 @@ namespace V2_0 {
namespace implementation {
using ::android::hardware::gnss::visibility_control::V1_0::implementation::GnssVisibilityControl;
-
+static sp<Gnss> sGnss;
static std::string getVersionString() {
static std::string version;
if (!version.empty())
@@ -88,10 +88,14 @@ void Gnss::GnssDeathRecipient::serviceDied(uint64_t cookie, const wp<IBase>& who
}
void location_on_battery_status_changed(bool charging) {
- LOC_LOGd("%s: battery status changed to %s charging", __func__, charging ? "" : "not ");
+ LOC_LOGd("battery status changed to %s charging", charging ? "" : "not");
+ if (sGnss != nullptr) {
+ sGnss->getGnssInterface()->updateBatteryStatus(charging);
+ }
}
Gnss::Gnss() {
ENTRY_LOG_CALLFLOW();
+ sGnss = this;
// register health client to listen on battery change
loc_extn_battery_properties_listener_init(location_on_battery_status_changed);
// clear pending GnssConfig
@@ -105,6 +109,7 @@ Gnss::~Gnss() {
delete mApi;
mApi = nullptr;
}
+ sGnss = nullptr;
}
GnssAPIClient* Gnss::getApi() {
diff --git a/core/SystemStatus.cpp b/core/SystemStatus.cpp
index 18cb99c..9ca126f 100644
--- a/core/SystemStatus.cpp
+++ b/core/SystemStatus.cpp
@@ -1723,5 +1723,18 @@ bool SystemStatus::eventConnectionStatus(bool connected, int8_t type,
return true;
}
+/******************************************************************************
+@brief API to update power connect state
+
+@param[In] power connect status
+
+@return true when successfully done
+******************************************************************************/
+bool SystemStatus::updatePowerConnectState(bool charging)
+{
+ SystemStatusPowerConnectState s(charging);
+ mSysStatusObsvr.notify({&s});
+ return true;
+}
} // namespace loc_core
diff --git a/core/SystemStatus.h b/core/SystemStatus.h
index f3467e2..94f7f0b 100644
--- a/core/SystemStatus.h
+++ b/core/SystemStatus.h
@@ -858,6 +858,7 @@ public:
bool setDefaultGnssEngineStates(void);
bool eventConnectionStatus(bool connected, int8_t type,
bool roaming, NetworkHandle networkHandle);
+ bool updatePowerConnectState(bool charging);
};
} // namespace loc_core
diff --git a/gnss/location_gnss.cpp b/gnss/location_gnss.cpp
index 88fa15d..76839b6 100644
--- a/gnss/location_gnss.cpp
+++ b/gnss/location_gnss.cpp
@@ -78,6 +78,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 const GnssInterface gGnssInterface = {
sizeof(GnssInterface),
@@ -115,7 +116,8 @@ static const GnssInterface gGnssInterface = {
enableNfwLocationAccess,
nfwInit,
getPowerStateChanges,
- injectLocationExt
+ injectLocationExt,
+ updateBatteryStatus
};
#ifndef DEBUG_X86
@@ -382,3 +384,9 @@ static void injectLocationExt(const GnssLocationInfoNotification &locationInfo)
gGnssAdapter->injectLocationExtCommand(locationInfo);
}
}
+
+static void updateBatteryStatus(bool charging) {
+ if (NULL != gGnssAdapter) {
+ gGnssAdapter->getSystemStatus()->updatePowerConnectState(charging);
+ }
+}
diff --git a/location/location_interface.h b/location/location_interface.h
index 80f37c2..fb15bea 100644
--- a/location/location_interface.h
+++ b/location/location_interface.h
@@ -87,6 +87,7 @@ struct GnssInterface {
void (*nfwInit)(const NfwCbInfo& cbInfo);
void (*getPowerStateChanges)(void* powerStateCb);
void (*injectLocationExt)(const GnssLocationInfoNotification &locationInfo);
+ void (*updateBatteryStatus)(bool charging);
};
struct BatchingInterface {