powerstats: timeout mechanism for AoC data provider

Reading data from an AoC sysfs node by getline takes 1 second. In total
there are 17 AoC sysfs nodes that must be read. The worst case is taking
17 seconds long that is greater than dumpsys timeout. Therefore, we need
the timeout mechanism to ignore the AoC power stats reporting when AoC
latency exceeds the allowed time.

Bug: 219630658
Test: dumpsys android.hardware.power.stats.IPowerStats/default
Change-Id: I71a9e681780471f31141599c53bb516aef445add
Signed-off-by: Darren Hsu <darrenhsu@google.com>
This commit is contained in:
Darren Hsu 2022-04-19 08:40:05 +08:00
parent f19ccbfa65
commit df08a31b76
2 changed files with 96 additions and 9 deletions

View file

@ -27,7 +27,8 @@ namespace stats {
class AocStateResidencyDataProvider : public PowerStats::IStateResidencyDataProvider {
public:
AocStateResidencyDataProvider(std::vector<std::pair<std::string, std::string>> ids,
std::vector<std::pair<std::string, std::string>> states);
std::vector<std::pair<std::string, std::string>> states,
const uint64_t timeoutMillis);
~AocStateResidencyDataProvider() = default;
bool getStateResidencies(
std::unordered_map<std::string, std::vector<StateResidency>> *residencies) override;
@ -36,10 +37,12 @@ class AocStateResidencyDataProvider : public PowerStats::IStateResidencyDataProv
private:
std::unordered_map<std::string /* entity name */,
std::vector<std::unique_ptr<GenericStateResidencyDataProvider>> /* providers */> mProviders;
int32_t mStateCount;
uint64_t mTimeoutMillis;
};
} // namespace stats
} // namespace power
} // namespace hardware
} // namespace android
} // namespace aidl
} // namespace aidl