diff options
author | Treehugger Robot <treehugger-gerrit@google.com> | 2018-09-01 17:27:23 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2018-09-01 17:27:23 +0000 |
commit | 47096dff0e3a7debea0c704be7acb2045d2c5014 (patch) | |
tree | c21a4460a966a36e958a9607d2bbfc2383b033ae | |
parent | 887e7e9641360d77a0bd591b61e6c17267859402 (diff) | |
parent | b8691ae1686746bba76e57411afc0d9242ba2e56 (diff) | |
download | extras-47096dff0e3a7debea0c704be7acb2045d2c5014.tar.gz |
Merge "perfprofd: use getHealthInfo for get_charging"
-rw-r--r-- | perfprofd/perfprofdcore.cc | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/perfprofd/perfprofdcore.cc b/perfprofd/perfprofdcore.cc index 9afeb203..00ec8a70 100644 --- a/perfprofd/perfprofdcore.cc +++ b/perfprofd/perfprofdcore.cc @@ -295,12 +295,12 @@ bool get_camera_active() bool get_charging() { #ifdef __ANDROID__ + using android::sp; using android::hardware::Return; - using android::hardware::health::V1_0::BatteryStatus; - using android::hardware::health::V2_0::Result; - using android::hardware::health::V2_0::IHealth; using android::hardware::health::V2_0::get_health_service; - using android::sp; + using android::hardware::health::V2_0::HealthInfo; + using android::hardware::health::V2_0::IHealth; + using android::hardware::health::V2_0::Result; sp<IHealth> service = get_health_service(); if (service == nullptr) { @@ -308,21 +308,23 @@ bool get_charging() return false; } Result res = Result::UNKNOWN; - BatteryStatus val = BatteryStatus::UNKNOWN; - Return<void> ret = service->getChargeStatus([&](Result out_res, BatteryStatus out_val) { - res = out_res; - val = out_val; - }); + HealthInfo val; + Return<void> ret = + service->getHealthInfo([&](Result out_res, HealthInfo out_val) { + res = out_res; + val = out_val; + }); if (!ret.isOk()) { LOG(ERROR) << "Failed to call getChargeStatus on health HAL: " << ret.description(); return false; } - if (res != Result::SUCCESS || val == BatteryStatus::UNKNOWN) { - LOG(ERROR) << "Failed to retrieve charge status from health HAL: result = " << toString(res) - << ", status = " << toString(val); + if (res != Result::SUCCESS) { + LOG(ERROR) << "Failed to retrieve charge status from health HAL: result = " + << toString(res); return false; } - return val == BatteryStatus::CHARGING || val == BatteryStatus::FULL; + return val.legacy.chargerAcOnline || val.legacy.chargerUsbOnline || + val.legacy.chargerWirelessOnline; #else return false; #endif |