Caleb Connolly | ae389bf | 2021-11-17 22:48:27 +0000 | [diff] [blame] | 1 | #include <memory> |
Caleb Connolly | ae389bf | 2021-11-17 22:48:27 +0000 | [diff] [blame] | 2 | |
| 3 | #include <health/utils.h> |
| 4 | #include <health2impl/Health.h> |
| 5 | #include <hidl/Status.h> |
| 6 | #include <log/log.h> |
Caleb Connolly | c28a5e3 | 2021-11-26 14:13:35 +0000 | [diff] [blame] | 7 | #include <android-base/strings.h> |
| 8 | #include <string> |
Caleb Connolly | c072981 | 2021-11-23 18:39:11 +0000 | [diff] [blame] | 9 | |
Caleb Connolly | ae389bf | 2021-11-17 22:48:27 +0000 | [diff] [blame] | 10 | using ::android::sp; |
| 11 | using ::android::hardware::Return; |
| 12 | using ::android::hardware::Void; |
| 13 | using ::android::hardware::health::InitHealthdConfig; |
| 14 | using ::android::hardware::health::V2_1::IHealth; |
| 15 | using ::android::hidl::base::V1_0::IBase; |
| 16 | |
| 17 | using namespace std::literals; |
| 18 | |
| 19 | namespace android { |
| 20 | namespace hardware { |
| 21 | namespace health { |
| 22 | namespace V2_1 { |
| 23 | namespace implementation { |
| 24 | |
| 25 | // android::hardware::health::V2_1::implementation::Health implements most |
| 26 | // defaults. Uncomment functions that you need to override. |
| 27 | class HealthImpl : public Health { |
| 28 | public: |
| 29 | HealthImpl(std::unique_ptr<healthd_config>&& config) |
| 30 | : Health(std::move(config)) {} |
Caleb Connolly | ae389bf | 2021-11-17 22:48:27 +0000 | [diff] [blame] | 31 | }; |
| 32 | |
| 33 | } // namespace implementation |
| 34 | } // namespace V2_1 |
| 35 | } // namespace health |
| 36 | } // namespace hardware |
| 37 | } // namespace android |
| 38 | |
Caleb Connolly | ae389bf | 2021-11-17 22:48:27 +0000 | [diff] [blame] | 39 | extern "C" IHealth* HIDL_FETCH_IHealth(const char* instance) { |
| 40 | using ::android::hardware::health::V2_1::implementation::HealthImpl; |
Caleb Connolly | c072981 | 2021-11-23 18:39:11 +0000 | [diff] [blame] | 41 | if (instance != "default"sv) { |
Caleb Connolly | c28a5e3 | 2021-11-26 14:13:35 +0000 | [diff] [blame] | 42 | ALOGE("Instance is not supported"); |
Caleb Connolly | ae389bf | 2021-11-17 22:48:27 +0000 | [diff] [blame] | 43 | return nullptr; |
| 44 | } |
| 45 | auto config = std::make_unique<healthd_config>(); |
| 46 | InitHealthdConfig(config.get()); |
Caleb Connolly | 734404a | 2022-04-07 02:29:02 +0100 | [diff] [blame] | 47 | config->batteryStatusPath = "/sys/class/power_supply/pmi8998_charger/status"; |
Caleb Connolly | ae389bf | 2021-11-17 22:48:27 +0000 | [diff] [blame] | 48 | |
| 49 | return new HealthImpl(std::move(config)); |
| 50 | } |