Adds a code when statsd sends intent to getData.
If the data receiver is experiencing delays, there may be a queue of
multiple intents to collect the same data. This timestamp makes it
easy in the receiver to de-dupe these requests to call getData.
Also, we update how StatsCompanionService gets the snapshot by
requesting data for all known apps. I notice that Keep seems to have
a uid active even when it appears uninstalled.
Bug: 77981668
Test: Flashed marlin-eng and manually verified.
Change-Id: I509e19383ec4a5da8746dd0c76ac71a948c6877d
diff --git a/cmds/statsd/src/StatsLogProcessor.cpp b/cmds/statsd/src/StatsLogProcessor.cpp
index f2443e8..d3aefed 100644
--- a/cmds/statsd/src/StatsLogProcessor.cpp
+++ b/cmds/statsd/src/StatsLogProcessor.cpp
@@ -485,6 +485,15 @@
mStatsPullerManager.OnAlarmFired(timestampNs);
}
+int64_t StatsLogProcessor::getLastReportTimeNs(const ConfigKey& key) {
+ auto it = mMetricsManagers.find(key);
+ if (it == mMetricsManagers.end()) {
+ return 0;
+ } else {
+ return it->second->getLastReportTimeNs();
+ }
+}
+
} // namespace statsd
} // namespace os
} // namespace android
diff --git a/cmds/statsd/src/StatsLogProcessor.h b/cmds/statsd/src/StatsLogProcessor.h
index 6efdf8c..b91b01d 100644
--- a/cmds/statsd/src/StatsLogProcessor.h
+++ b/cmds/statsd/src/StatsLogProcessor.h
@@ -75,6 +75,8 @@
void informPullAlarmFired(const int64_t timestampNs);
+ int64_t getLastReportTimeNs(const ConfigKey& key);
+
private:
// For testing only.
inline sp<AlarmMonitor> getAnomalyAlarmMonitor() const {
diff --git a/cmds/statsd/src/StatsService.cpp b/cmds/statsd/src/StatsService.cpp
index f7cc00c..e26806b 100644
--- a/cmds/statsd/src/StatsService.cpp
+++ b/cmds/statsd/src/StatsService.cpp
@@ -90,7 +90,7 @@
VLOG("Statscompanion could not find a broadcast receiver for %s",
key.ToString().c_str());
} else {
- sc->sendDataBroadcast(receiver);
+ sc->sendDataBroadcast(receiver, mProcessor->getLastReportTimeNs(key));
}
}
);
@@ -377,14 +377,15 @@
print_cmd_help(out);
return UNKNOWN_ERROR;
}
- auto receiver = mConfigManager->GetConfigReceiver(ConfigKey(uid, StrToInt64(name)));
+ ConfigKey key(uid, StrToInt64(name));
+ auto receiver = mConfigManager->GetConfigReceiver(key);
sp<IStatsCompanionService> sc = getStatsCompanionService();
if (sc == nullptr) {
VLOG("Could not access statsCompanion");
} else if (receiver == nullptr) {
VLOG("Could not find receiver for %s, %s", args[1].c_str(), args[2].c_str())
} else {
- sc->sendDataBroadcast(receiver);
+ sc->sendDataBroadcast(receiver, mProcessor->getLastReportTimeNs(key));
VLOG("StatsService::trigger broadcast succeeded to %s, %s", args[1].c_str(),
args[2].c_str());
}