Update SystemStatus with battery info in HealthHAL

Change-Id: Ibc2157f1834eb65da48f9375e497628411a185c9
CRs-fixed: 2433570
This commit is contained in:
Yingjie Wang 2019-04-11 08:33:46 +08:00
parent 052afd6e47
commit 2e7c04a82d
7 changed files with 45 additions and 5 deletions

View file

@ -37,6 +37,7 @@ namespace gnss {
namespace V1_0 { namespace V1_0 {
namespace implementation { namespace implementation {
static sp<Gnss> sGnss;
void Gnss::GnssDeathRecipient::serviceDied(uint64_t cookie, const wp<IBase>& who) { void Gnss::GnssDeathRecipient::serviceDied(uint64_t cookie, const wp<IBase>& who) {
LOC_LOGE("%s] service died. cookie: %llu, who: %p", LOC_LOGE("%s] service died. cookie: %llu, who: %p",
__FUNCTION__, static_cast<unsigned long long>(cookie), &who); __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) { 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() { Gnss::Gnss() {
ENTRY_LOG_CALLFLOW(); ENTRY_LOG_CALLFLOW();
sGnss = this;
// register health client to listen on battery change // register health client to listen on battery change
loc_extn_battery_properties_listener_init(location_on_battery_status_changed); loc_extn_battery_properties_listener_init(location_on_battery_status_changed);
// clear pending GnssConfig // clear pending GnssConfig
@ -65,6 +70,7 @@ Gnss::~Gnss() {
delete mApi; delete mApi;
mApi = nullptr; mApi = nullptr;
} }
sGnss = nullptr;
} }
GnssAPIClient* Gnss::getApi() { GnssAPIClient* Gnss::getApi() {

View file

@ -41,6 +41,7 @@ namespace gnss {
namespace V1_1 { namespace V1_1 {
namespace implementation { namespace implementation {
static sp<Gnss> sGnss;
static std::string getVersionString() { static std::string getVersionString() {
static std::string version; static std::string version;
if (!version.empty()) 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) { 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() { Gnss::Gnss() {
ENTRY_LOG_CALLFLOW(); ENTRY_LOG_CALLFLOW();
sGnss = this;
// register health client to listen on battery change // register health client to listen on battery change
loc_extn_battery_properties_listener_init(location_on_battery_status_changed); loc_extn_battery_properties_listener_init(location_on_battery_status_changed);
// clear pending GnssConfig // clear pending GnssConfig
@ -106,6 +111,7 @@ Gnss::~Gnss() {
delete mApi; delete mApi;
mApi = nullptr; mApi = nullptr;
} }
sGnss = nullptr;
} }
GnssAPIClient* Gnss::getApi() { GnssAPIClient* Gnss::getApi() {

View file

@ -41,7 +41,7 @@ namespace V2_0 {
namespace implementation { namespace implementation {
using ::android::hardware::gnss::visibility_control::V1_0::implementation::GnssVisibilityControl; using ::android::hardware::gnss::visibility_control::V1_0::implementation::GnssVisibilityControl;
static sp<Gnss> sGnss;
static std::string getVersionString() { static std::string getVersionString() {
static std::string version; static std::string version;
if (!version.empty()) 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) { 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() { Gnss::Gnss() {
ENTRY_LOG_CALLFLOW(); ENTRY_LOG_CALLFLOW();
sGnss = this;
// register health client to listen on battery change // register health client to listen on battery change
loc_extn_battery_properties_listener_init(location_on_battery_status_changed); loc_extn_battery_properties_listener_init(location_on_battery_status_changed);
// clear pending GnssConfig // clear pending GnssConfig
@ -105,6 +109,7 @@ Gnss::~Gnss() {
delete mApi; delete mApi;
mApi = nullptr; mApi = nullptr;
} }
sGnss = nullptr;
} }
GnssAPIClient* Gnss::getApi() { GnssAPIClient* Gnss::getApi() {

View file

@ -1723,5 +1723,18 @@ bool SystemStatus::eventConnectionStatus(bool connected, int8_t type,
return true; 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 } // namespace loc_core

View file

@ -858,6 +858,7 @@ public:
bool setDefaultGnssEngineStates(void); bool setDefaultGnssEngineStates(void);
bool eventConnectionStatus(bool connected, int8_t type, bool eventConnectionStatus(bool connected, int8_t type,
bool roaming, NetworkHandle networkHandle); bool roaming, NetworkHandle networkHandle);
bool updatePowerConnectState(bool charging);
}; };
} // namespace loc_core } // namespace loc_core

View file

@ -78,6 +78,7 @@ static void odcpiInject(const Location& location);
static void blockCPI(double latitude, double longitude, float accuracy, static void blockCPI(double latitude, double longitude, float accuracy,
int blockDurationMsec, double latLonDiffThreshold); int blockDurationMsec, double latLonDiffThreshold);
static void updateBatteryStatus(bool charging);
static const GnssInterface gGnssInterface = { static const GnssInterface gGnssInterface = {
sizeof(GnssInterface), sizeof(GnssInterface),
@ -115,7 +116,8 @@ static const GnssInterface gGnssInterface = {
enableNfwLocationAccess, enableNfwLocationAccess,
nfwInit, nfwInit,
getPowerStateChanges, getPowerStateChanges,
injectLocationExt injectLocationExt,
updateBatteryStatus
}; };
#ifndef DEBUG_X86 #ifndef DEBUG_X86
@ -382,3 +384,9 @@ static void injectLocationExt(const GnssLocationInfoNotification &locationInfo)
gGnssAdapter->injectLocationExtCommand(locationInfo); gGnssAdapter->injectLocationExtCommand(locationInfo);
} }
} }
static void updateBatteryStatus(bool charging) {
if (NULL != gGnssAdapter) {
gGnssAdapter->getSystemStatus()->updatePowerConnectState(charging);
}
}

View file

@ -87,6 +87,7 @@ struct GnssInterface {
void (*nfwInit)(const NfwCbInfo& cbInfo); void (*nfwInit)(const NfwCbInfo& cbInfo);
void (*getPowerStateChanges)(void* powerStateCb); void (*getPowerStateChanges)(void* powerStateCb);
void (*injectLocationExt)(const GnssLocationInfoNotification &locationInfo); void (*injectLocationExt)(const GnssLocationInfoNotification &locationInfo);
void (*updateBatteryStatus)(bool charging);
}; };
struct BatchingInterface { struct BatchingInterface {