Merge "Modify IHealthInfoCallback interface to return V2.0 HealthInfo"
This commit is contained in:
commit
6cb4a2ae36
5 changed files with 24 additions and 9 deletions
|
@ -16,8 +16,6 @@
|
|||
|
||||
package android.hardware.health@2.0;
|
||||
|
||||
import @1.0::HealthInfo;
|
||||
|
||||
/**
|
||||
* IHealthInfoCallback is the callback interface to
|
||||
* {@link IHealthInfoBus.registerCallback}.
|
||||
|
@ -28,5 +26,5 @@ interface IHealthInfoCallback {
|
|||
* registered callbacks after health info changes.
|
||||
* @param info the updated HealthInfo
|
||||
*/
|
||||
oneway healthInfoChanged(@1.0::HealthInfo info);
|
||||
oneway healthInfoChanged(HealthInfo info);
|
||||
};
|
||||
|
|
|
@ -155,10 +155,28 @@ Return<Result> Health::update() {
|
|||
return Result::SUCCESS;
|
||||
}
|
||||
|
||||
void Health::notifyListeners(const HealthInfo& info) {
|
||||
void Health::notifyListeners(HealthInfo* healthInfo) {
|
||||
std::vector<StorageInfo> info;
|
||||
get_storage_info(info);
|
||||
|
||||
std::vector<DiskStats> stats;
|
||||
get_disk_stats(stats);
|
||||
|
||||
int32_t currentAvg = 0;
|
||||
|
||||
struct BatteryProperty prop;
|
||||
status_t ret = battery_monitor_->getProperty(BATTERY_PROP_CURRENT_AVG, &prop);
|
||||
if (ret == OK) {
|
||||
currentAvg = static_cast<int32_t>(prop.valueInt64);
|
||||
}
|
||||
|
||||
healthInfo->batteryCurrentAverage = currentAvg;
|
||||
healthInfo->diskStats = stats;
|
||||
healthInfo->storageInfos = info;
|
||||
|
||||
std::lock_guard<std::mutex> _lock(callbacks_lock_);
|
||||
for (auto it = callbacks_.begin(); it != callbacks_.end();) {
|
||||
auto ret = (*it)->healthInfoChanged(info);
|
||||
auto ret = (*it)->healthInfoChanged(*healthInfo);
|
||||
if (!ret.isOk() && ret.isDeadObject()) {
|
||||
it = callbacks_.erase(it);
|
||||
} else {
|
||||
|
|
|
@ -22,7 +22,6 @@ namespace V2_0 {
|
|||
namespace implementation {
|
||||
|
||||
using V1_0::BatteryStatus;
|
||||
using V1_0::HealthInfo;
|
||||
|
||||
using ::android::hidl::base::V1_0::IBase;
|
||||
|
||||
|
@ -38,7 +37,7 @@ struct Health : public IHealth, hidl_death_recipient {
|
|||
Health(struct healthd_config* c);
|
||||
|
||||
// TODO(b/62229583): clean up and hide these functions after update() logic is simplified.
|
||||
void notifyListeners(const HealthInfo& info);
|
||||
void notifyListeners(HealthInfo* info);
|
||||
|
||||
// Methods from IHealth follow.
|
||||
Return<Result> registerCallback(const sp<IHealthInfoCallback>& callback) override;
|
||||
|
|
|
@ -141,7 +141,7 @@ struct HealthInfo {
|
|||
/**
|
||||
* Average battery current in uA. Will be 0 if unsupported.
|
||||
*/
|
||||
int64_t batteryCurrentAverage;
|
||||
int32_t batteryCurrentAverage;
|
||||
/**
|
||||
* Disk Statistics. Will be an empty vector if unsupported.
|
||||
*/
|
||||
|
|
|
@ -68,7 +68,7 @@ class HealthHidlTest : public ::testing::VtsHalHidlTargetTestBase {
|
|||
|
||||
class Callback : public IHealthInfoCallback {
|
||||
public:
|
||||
Return<void> healthInfoChanged(const V1_0::HealthInfo&) override {
|
||||
Return<void> healthInfoChanged(const HealthInfo&) override {
|
||||
std::lock_guard<std::mutex> lock(mMutex);
|
||||
mInvoked = true;
|
||||
mInvokedNotify.notify_all();
|
||||
|
|
Loading…
Reference in a new issue