blob: 45bd2f82db8086ef7ee72d1a4749f352f4864c55 [file] [log] [blame]
Caleb Connollyae389bf2021-11-17 22:48:27 +00001#include <memory>
Caleb Connollyae389bf2021-11-17 22:48:27 +00002
3#include <health/utils.h>
4#include <health2impl/Health.h>
5#include <hidl/Status.h>
6#include <log/log.h>
Caleb Connollyc28a5e32021-11-26 14:13:35 +00007#include <android-base/strings.h>
8#include <string>
Caleb Connollyc0729812021-11-23 18:39:11 +00009
Caleb Connollyae389bf2021-11-17 22:48:27 +000010using ::android::sp;
11using ::android::hardware::Return;
12using ::android::hardware::Void;
13using ::android::hardware::health::InitHealthdConfig;
14using ::android::hardware::health::V2_1::IHealth;
15using ::android::hidl::base::V1_0::IBase;
16
17using namespace std::literals;
18
19namespace android {
20namespace hardware {
21namespace health {
22namespace V2_1 {
23namespace implementation {
24
25// android::hardware::health::V2_1::implementation::Health implements most
26// defaults. Uncomment functions that you need to override.
27class HealthImpl : public Health {
28 public:
29 HealthImpl(std::unique_ptr<healthd_config>&& config)
30 : Health(std::move(config)) {}
Caleb Connollyae389bf2021-11-17 22:48:27 +000031};
32
33} // namespace implementation
34} // namespace V2_1
35} // namespace health
36} // namespace hardware
37} // namespace android
38
Caleb Connollyae389bf2021-11-17 22:48:27 +000039extern "C" IHealth* HIDL_FETCH_IHealth(const char* instance) {
40 using ::android::hardware::health::V2_1::implementation::HealthImpl;
Caleb Connollyc0729812021-11-23 18:39:11 +000041 if (instance != "default"sv) {
Caleb Connollyc28a5e32021-11-26 14:13:35 +000042 ALOGE("Instance is not supported");
Caleb Connollyae389bf2021-11-17 22:48:27 +000043 return nullptr;
44 }
45 auto config = std::make_unique<healthd_config>();
46 InitHealthdConfig(config.get());
Caleb Connolly734404a2022-04-07 02:29:02 +010047 config->batteryStatusPath = "/sys/class/power_supply/pmi8998_charger/status";
Caleb Connollyae389bf2021-11-17 22:48:27 +000048
49 return new HealthImpl(std::move(config));
50}