healthd: move healthd_board_init call to Health::Health() c-tor
The invocation is wrapped so that clients of -impl doesn't
have to call healthd_board_init directly.
Test: health VTS test
Test: charger_test
Bug: 69268160
Change-Id: I61f820b80ce6b03fe51ca05d07ed7e09ca369d2d
diff --git a/healthd/Health.cpp b/healthd/Health.cpp
index d271811..822f664 100644
--- a/healthd/Health.cpp
+++ b/healthd/Health.cpp
@@ -16,6 +16,8 @@
sp<Health> Health::instance_;
Health::Health(struct healthd_config* c) {
+ // TODO(b/69268160): remove when libhealthd is removed.
+ healthd_board_init(c);
battery_monitor_ = std::make_unique<BatteryMonitor>();
battery_monitor_->init(c);
}
diff --git a/healthd/HealthServiceCommon.cpp b/healthd/HealthServiceCommon.cpp
index 68ff526..266ca3a 100644
--- a/healthd/HealthServiceCommon.cpp
+++ b/healthd/HealthServiceCommon.cpp
@@ -53,13 +53,6 @@
LOG(ERROR) << LOG_TAG << ": Register for binder events failed";
}
- // Implementation-defined init logic goes here.
- // 1. config->periodic_chores_interval_* variables
- // 2. config->battery*Path variables
- // 3. config->energyCounter. In this implementation, energyCounter is not defined.
- // TODO(b/68724651): healthd_board_* functions should be removed in health@2.0
- healthd_board_init(config);
-
android::sp<IHealth> service = Health::initInstance(config);
CHECK_EQ(service->registerAsService(HEALTH_INSTANCE_NAME), android::OK)
<< LOG_TAG << ": Failed to register HAL";
@@ -77,9 +70,6 @@
}
void healthd_mode_service_2_0_battery_update(struct android::BatteryProperties* prop) {
- // Implementation-defined update logic goes here. An implementation
- // can make modifications to prop before broadcasting it to all callbacks.
-
HealthInfo info;
convertToHealthInfo(prop, info);
Health::getImplementation()->notifyListeners(info);
diff --git a/healthd/HealthServiceDefault.cpp b/healthd/HealthServiceDefault.cpp
index 42e76d9..dbc480f 100644
--- a/healthd/HealthServiceDefault.cpp
+++ b/healthd/HealthServiceDefault.cpp
@@ -17,10 +17,18 @@
#include <healthd/healthd.h>
void healthd_board_init(struct healthd_config*) {
+ // Implementation-defined init logic goes here.
+ // 1. config->periodic_chores_interval_* variables
+ // 2. config->battery*Path variables
+ // 3. config->energyCounter. In this implementation, energyCounter is not defined.
+
// use defaults
}
int healthd_board_battery_update(struct android::BatteryProperties*) {
+ // Implementation-defined update logic goes here. An implementation
+ // can make modifications to prop before broadcasting it to all callbacks.
+
// return 0 to log periodic polled battery status to kernel log
return 0;
}