diff options
author | Yifan Hong <elsk@google.com> | 2021-11-08 22:12:43 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2021-11-08 22:12:43 +0000 |
commit | b6533047e63a4ac76fda97ad7769f7378f54309e (patch) | |
tree | 69fbd3fbea8e306f354cf9ac4e42789cd128f8e3 /health/aidl/default/main.cpp | |
parent | 0af83e56b5d96d1289deb7f99e7ab421f31ea0f9 (diff) | |
parent | 29af1fe837c2232017849e834fdb4170fc4cb987 (diff) |
Merge "health: handle charger in health HAL" am: 701ff4a1de am: abb62e5e53 am: ae92201c57 am: fe7fca6c9c am: 29af1fe837
Original change: https://android-review.googlesource.com/c/platform/hardware/interfaces/+/1866345
Change-Id: Ibfa5ee50caa763daebf701d04975c37cd16e4e26
Diffstat (limited to 'health/aidl/default/main.cpp')
-rw-r--r-- | health/aidl/default/main.cpp | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/health/aidl/default/main.cpp b/health/aidl/default/main.cpp index 014ae34f69..76c6ba0a8f 100644 --- a/health/aidl/default/main.cpp +++ b/health/aidl/default/main.cpp @@ -19,17 +19,46 @@ #include <health-impl/Health.h> #include <health/utils.h> +#ifndef CHARGER_FORCE_NO_UI +#define CHARGER_FORCE_NO_UI 0 +#endif + +#if !CHARGER_FORCE_NO_UI +#include <health-impl/ChargerUtils.h> +#endif + using aidl::android::hardware::health::HalHealthLoop; using aidl::android::hardware::health::Health; +#if !CHARGER_FORCE_NO_UI +using aidl::android::hardware::health::charger::ChargerCallback; +using aidl::android::hardware::health::charger::ChargerModeMain; +#endif + static constexpr const char* gInstanceName = "default"; +static constexpr std::string_view gChargerArg{"--charger"}; -int main() { - // TODO(b/203246116): handle charger +int main(int argc, char** argv) { // make a default health service auto config = std::make_unique<healthd_config>(); ::android::hardware::health::InitHealthdConfig(config.get()); auto binder = ndk::SharedRefBase::make<Health>(gInstanceName, std::move(config)); + + if (argc >= 2 && argv[1] == gChargerArg) { + android::base::InitLogging(argv, &android::base::KernelLogger); + +#if !CHARGER_FORCE_NO_UI + // If charger shouldn't have UI for your device, simply drop the line below + // for your service implementation. This corresponds to + // ro.charger.no_ui=true + return ChargerModeMain(binder, std::make_shared<ChargerCallback>(binder)); +#endif + + LOG(INFO) << "Starting charger mode without UI."; + } else { + LOG(INFO) << "Starting health HAL."; + } + auto hal_health_loop = std::make_shared<HalHealthLoop>(binder, binder); return hal_health_loop->StartLoop(); } |