Merge "Update SystemStatus with battery info in HealthHAL"
This commit is contained in:
commit
9fc8d7444d
7 changed files with 45 additions and 5 deletions
|
@ -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() {
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue