Adds client API for interacting with statsd. This API will primarily be used by GmsCore to send updated configs. Also, sending a config will implicitly notify the StatsD that this client wants to know when it should request data for this config. We send a broadcast so that all interested subscribers can know if data needs to be pulled. Test: Manually tested that sending broadcast works via new adb command added in StatsService. Change-Id: I23cdd1df706036e14b32c3d01af30c3d4af819fa
diff --git a/bin/src/config/ConfigManager.cpp b/bin/src/config/ConfigManager.cpp index d86ab57..2a8a741 100644 --- a/bin/src/config/ConfigManager.cpp +++ b/bin/src/config/ConfigManager.cpp
@@ -60,6 +60,14 @@ } } +void ConfigManager::SetConfigReceiver(const ConfigKey& key, const string& pkg, const string& cls) { + mConfigReceivers[key] = pair<string, string>(pkg, cls); +} + +void ConfigManager::RemoveConfigReceiver(const ConfigKey& key) { + mConfigReceivers.erase(key); +} + void ConfigManager::RemoveConfig(const ConfigKey& key) { unordered_map<ConfigKey, StatsdConfig>::iterator it = mConfigs.find(key); if (it != mConfigs.end()) { @@ -85,6 +93,7 @@ if (it->first.GetUid() == uid) { removed.push_back(it->first); it = mConfigs.erase(it); + mConfigReceivers.erase(it->first); } else { it++; }