summaryrefslogtreecommitdiff
path: root/android/1.0/Gnss.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'android/1.0/Gnss.cpp')
-rw-r--r--android/1.0/Gnss.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/android/1.0/Gnss.cpp b/android/1.0/Gnss.cpp
index 93b320b..d85e0a4 100644
--- a/android/1.0/Gnss.cpp
+++ b/android/1.0/Gnss.cpp
@@ -19,6 +19,7 @@
*/
#define LOG_TAG "LocSvc_GnssInterface"
+#define LOG_NDEBUG 0
#include <fstream>
#include <log_util.h>
@@ -26,6 +27,7 @@
#include <cutils/properties.h>
#include "Gnss.h"
#include <LocationUtil.h>
+#include "battery_listener.h"
typedef const GnssInterface* (getLocationInterface)();
@@ -35,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);
@@ -44,8 +47,17 @@ void Gnss::GnssDeathRecipient::serviceDied(uint64_t cookie, const wp<IBase>& who
}
}
+void location_on_battery_status_changed(bool charging) {
+ 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
memset(&mPendingConfig, 0, sizeof(GnssConfig));
@@ -58,6 +70,7 @@ Gnss::~Gnss() {
delete mApi;
mApi = nullptr;
}
+ sGnss = nullptr;
}
GnssAPIClient* Gnss::getApi() {