summaryrefslogtreecommitdiff
path: root/pixelstats/StatsHelper.cpp
diff options
context:
space:
mode:
authorVova Sharaienko <sharaienko@google.com>2021-03-30 20:06:24 +0000
committerVova Sharaienko <sharaienko@google.com>2021-04-01 17:04:44 +0000
commit7774c8809b888c5bd62f76d9f6d91442bd4d7133 (patch)
tree9e0226df1720fbbffcdb81f7bcd79063ee976503 /pixelstats/StatsHelper.cpp
parent01fa4355b0d924914acbb028e29c7d4009c8d77c (diff)
Stats: added isDeclared return value caching
- reduces the amount of logcat messages from AServiceManager_isDeclared() Bug: 184056476 Test: build, flash & boot, grep "VINTF manifest" - should be once per app Change-Id: I13d3671f7b530435ecd6be85d4723607175afafc
Diffstat (limited to 'pixelstats/StatsHelper.cpp')
-rw-r--r--pixelstats/StatsHelper.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/pixelstats/StatsHelper.cpp b/pixelstats/StatsHelper.cpp
index 28304a8..30899ba 100644
--- a/pixelstats/StatsHelper.cpp
+++ b/pixelstats/StatsHelper.cpp
@@ -36,9 +36,14 @@ const int kVendorAtomOffset = 2;
std::shared_ptr<IStats> getStatsService() {
const std::string instance = std::string() + IStats::descriptor + "/default";
- if (!AServiceManager_isDeclared(instance.c_str())) {
- ALOGE("Stats service is not registered.");
- return nullptr;
+ static bool isStatsDeclared = false;
+ if (!isStatsDeclared) {
+ // It is good to cache the result - it would not be changed
+ isStatsDeclared = AServiceManager_isDeclared(instance.c_str());
+ if (!isStatsDeclared) {
+ ALOGE("Stats service is not registered.");
+ return nullptr;
+ }
}
return IStats::fromBinder(ndk::SpAIBinder(AServiceManager_waitForService(instance.c_str())));
}