diff options
author | Steven Laver <lavers@google.com> | 2020-04-07 13:06:39 -0700 |
---|---|---|
committer | Steven Laver <lavers@google.com> | 2020-04-07 13:06:39 -0700 |
commit | df73284a33506ba26aadbd20a1dbd01353820200 (patch) | |
tree | 05663a2e5363806080b72341c1e00e9e3fad6902 /cmds/statsd/src/shell/ShellSubscriber.cpp | |
parent | 194251d18fedf8b9ae6b9e43f3a99f876232663c (diff) | |
parent | e781cc43c6d4aa190d68c5405f36770ba9d6fd0b (diff) |
Merge RP1A.200401.001
Change-Id: I4050f39c7971bf1750afb1c8bc139f5fc41020e3
Diffstat (limited to 'cmds/statsd/src/shell/ShellSubscriber.cpp')
-rw-r--r-- | cmds/statsd/src/shell/ShellSubscriber.cpp | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/cmds/statsd/src/shell/ShellSubscriber.cpp b/cmds/statsd/src/shell/ShellSubscriber.cpp index c677222f31eb..1cee4d9babdc 100644 --- a/cmds/statsd/src/shell/ShellSubscriber.cpp +++ b/cmds/statsd/src/shell/ShellSubscriber.cpp @@ -108,7 +108,21 @@ bool ShellSubscriber::readConfig(shared_ptr<SubscriptionInfo> subscriptionInfo) if (minInterval < 0 || pulled.freq_millis() < minInterval) { minInterval = pulled.freq_millis(); } - subscriptionInfo->mPulledInfo.emplace_back(pulled.matcher(), pulled.freq_millis()); + + vector<string> packages; + vector<int32_t> uids; + for (const string& pkg : pulled.packages()) { + auto it = UidMap::sAidToUidMapping.find(pkg); + if (it != UidMap::sAidToUidMapping.end()) { + uids.push_back(it->second); + } else { + packages.push_back(pkg); + } + } + + subscriptionInfo->mPulledInfo.emplace_back(pulled.matcher(), pulled.freq_millis(), packages, + uids); + VLOG("adding matcher for pulled atom %d", pulled.matcher().atom_id()); } subscriptionInfo->mPullIntervalMin = minInterval; @@ -127,7 +141,15 @@ void ShellSubscriber::startPull(int64_t myToken) { for (auto& pullInfo : mSubscriptionInfo->mPulledInfo) { if (pullInfo.mPrevPullElapsedRealtimeMs + pullInfo.mInterval < nowMillis) { vector<std::shared_ptr<LogEvent>> data; - mPullerMgr->Pull(pullInfo.mPullerMatcher.atom_id(), &data); + vector<int32_t> uids; + uids.insert(uids.end(), pullInfo.mPullUids.begin(), pullInfo.mPullUids.end()); + // This is slow. Consider storing the uids per app and listening to uidmap updates. + for (const string& pkg : pullInfo.mPullPackages) { + set<int32_t> uidsForPkg = mUidMap->getAppUid(pkg); + uids.insert(uids.end(), uidsForPkg.begin(), uidsForPkg.end()); + } + uids.push_back(DEFAULT_PULL_UID); + mPullerMgr->Pull(pullInfo.mPullerMatcher.atom_id(), uids, &data); VLOG("pulled %zu atoms with id %d", data.size(), pullInfo.mPullerMatcher.atom_id()); // TODO(b/150969574): Don't write to a pipe while holding a lock. |