summaryrefslogtreecommitdiffstats
path: root/health
diff options
context:
space:
mode:
authorHridya Valsaraju <hridya@google.com>2018-09-28 10:44:02 -0700
committerHridya Valsaraju <hridya@google.com>2018-09-28 21:30:20 +0000
commitbf0b9faaadaace8fd6b3b72f8cde023a854c333a (patch)
tree4a7e7db00737fe5e5ed9b50116ba274b1d5e78bd /health
parent0d30daba94d703fa05e16e2296688bc510f34a79 (diff)
downloadandroid_hardware_interfaces-bf0b9faaadaace8fd6b3b72f8cde023a854c333a.tar.gz
android_hardware_interfaces-bf0b9faaadaace8fd6b3b72f8cde023a854c333a.tar.bz2
android_hardware_interfaces-bf0b9faaadaace8fd6b3b72f8cde023a854c333a.zip
Initialize healthd_mode_ops in recovery default Health HAL impl.
This is required for correct functioning of getHealthInfo() API in recovery since BatteryMonitor requires healthd_mode_ops to be initialized to update battery properties. Bug: 78793464 Test: fastboot getvar battery-voltage Change-Id: I9ff77664cada22e4aa3668bfb7d28d5f1d45590b
Diffstat (limited to 'health')
-rw-r--r--health/2.0/default/Health.cpp2
-rw-r--r--health/2.0/default/HealthImplDefault.cpp25
2 files changed, 25 insertions, 2 deletions
diff --git a/health/2.0/default/Health.cpp b/health/2.0/default/Health.cpp
index 6d3be9923..e02bfa98d 100644
--- a/health/2.0/default/Health.cpp
+++ b/health/2.0/default/Health.cpp
@@ -142,7 +142,7 @@ Return<void> Health::getChargeStatus(getChargeStatus_cb _hidl_cb) {
Return<Result> Health::update() {
if (!healthd_mode_ops || !healthd_mode_ops->battery_update) {
LOG(WARNING) << "health@2.0: update: not initialized. "
- << "update() should not be called in charger / recovery.";
+ << "update() should not be called in charger";
return Result::UNKNOWN;
}
diff --git a/health/2.0/default/HealthImplDefault.cpp b/health/2.0/default/HealthImplDefault.cpp
index 15346bf6e..e3cbefdbe 100644
--- a/health/2.0/default/HealthImplDefault.cpp
+++ b/health/2.0/default/HealthImplDefault.cpp
@@ -46,9 +46,32 @@ int healthd_board_battery_update(struct android::BatteryProperties*) {
return 0;
}
+void healthd_mode_default_impl_init(struct healthd_config*) {
+ // noop
+}
+
+int healthd_mode_default_impl_preparetowait(void) {
+ return -1;
+}
+
+void healthd_mode_default_impl_heartbeat(void) {
+ // noop
+}
+
+void healthd_mode_default_impl_battery_update(struct android::BatteryProperties*) {
+ // noop
+}
+
+static struct healthd_mode_ops healthd_mode_default_impl_ops = {
+ .init = healthd_mode_default_impl_init,
+ .preparetowait = healthd_mode_default_impl_preparetowait,
+ .heartbeat = healthd_mode_default_impl_heartbeat,
+ .battery_update = healthd_mode_default_impl_battery_update,
+};
+
extern "C" IHealth* HIDL_FETCH_IHealth(const char* name) {
const static std::string providedInstance{"backup"};
-
+ healthd_mode_ops = &healthd_mode_default_impl_ops;
if (providedInstance == name) {
// use defaults
// Health class stores static instance