#ifndef ANDROID_HARDWARE_HEALTH_V2_0_HEALTH_H #define ANDROID_HARDWARE_HEALTH_V2_0_HEALTH_H #include #include #include #include #include #include using android::hardware::health::V2_0::StorageInfo; using android::hardware::health::V2_0::DiskStats; void get_storage_info(std::vector& info); void get_disk_stats(std::vector& stats); namespace android { namespace hardware { namespace health { namespace V2_0 { namespace implementation { using V1_0::BatteryStatus; using ::android::hidl::base::V1_0::IBase; struct Health : public IHealth, hidl_death_recipient { public: static sp initInstance(struct healthd_config* c); // Should only be called by implementation itself (-impl, -service). // Clients should not call this function. Instead, initInstance() initializes and returns the // global instance that has fewer functions. static sp getImplementation(); Health(struct healthd_config* c); void notifyListeners(HealthInfo* info); // Methods from IHealth follow. Return registerCallback(const sp& callback) override; Return unregisterCallback(const sp& callback) override; Return update() override; Return getChargeCounter(getChargeCounter_cb _hidl_cb) override; Return getCurrentNow(getCurrentNow_cb _hidl_cb) override; Return getCurrentAverage(getCurrentAverage_cb _hidl_cb) override; Return getCapacity(getCapacity_cb _hidl_cb) override; Return getEnergyCounter(getEnergyCounter_cb _hidl_cb) override; Return getChargeStatus(getChargeStatus_cb _hidl_cb) override; Return getStorageInfo(getStorageInfo_cb _hidl_cb) override; Return getDiskStats(getDiskStats_cb _hidl_cb) override; Return getHealthInfo(getHealthInfo_cb _hidl_cb) override; // Methods from ::android::hidl::base::V1_0::IBase follow. Return debug(const hidl_handle& fd, const hidl_vec& args) override; void serviceDied(uint64_t cookie, const wp& /* who */) override; private: static sp instance_; std::recursive_mutex callbacks_lock_; std::vector> callbacks_; std::unique_ptr battery_monitor_; bool unregisterCallbackInternal(const sp& cb); // update() and only notify the given callback, but none of the other callbacks. // If cb is null, do not notify any callback at all. Return updateAndNotify(const sp& cb); }; } // namespace implementation } // namespace V2_0 } // namespace health } // namespace hardware } // namespace android #endif // ANDROID_HARDWARE_HEALTH_V2_0_HEALTH_H