Loading cmds/statsd/Android.bp +3 −0 Original line number Diff line number Diff line Loading @@ -40,6 +40,7 @@ cc_defaults { "src/external/StatsPullerManager.cpp", "src/external/TrainInfoPuller.cpp", "src/FieldValue.cpp", "src/flags/flags.cpp", "src/guardrail/StatsdStats.cpp", "src/hash.cpp", "src/HashableDimensionKey.cpp", Loading Loading @@ -92,6 +93,7 @@ cc_defaults { "libstatslog_statsd", "libsysutils", "libutils", "server_configurable_flags", "statsd-aidl-ndk_platform", ], shared_libs: [ Loading Loading @@ -265,6 +267,7 @@ cc_test { "tests/e2e/Anomaly_duration_sum_e2e_test.cpp", "tests/e2e/Attribution_e2e_test.cpp", "tests/e2e/ConfigTtl_e2e_test.cpp", "tests/e2e/ConfigUpdate_e2e_ab_test.cpp", "tests/e2e/ConfigUpdate_e2e_test.cpp", "tests/e2e/CountMetric_e2e_test.cpp", "tests/e2e/DurationMetric_e2e_test.cpp", Loading cmds/statsd/src/StatsLogProcessor.cpp +4 −2 Original line number Diff line number Diff line Loading @@ -24,12 +24,13 @@ #include <frameworks/base/cmds/statsd/src/active_config_list.pb.h> #include <frameworks/base/cmds/statsd/src/experiment_ids.pb.h> #include "StatsService.h" #include "android-base/stringprintf.h" #include "external/StatsPullerManager.h" #include "flags/flags.h" #include "guardrail/StatsdStats.h" #include "logd/LogEvent.h" #include "metrics/CountMetricProducer.h" #include "StatsService.h" #include "state/StateManager.h" #include "stats_log_util.h" #include "stats_util.h" Loading Loading @@ -520,9 +521,10 @@ void StatsLogProcessor::GetActiveConfigsLocked(const int uid, vector<int64_t>& o } void StatsLogProcessor::OnConfigUpdated(const int64_t timestampNs, const ConfigKey& key, const StatsdConfig& config, bool modularUpdate) { const StatsdConfig& config) { std::lock_guard<std::mutex> lock(mMetricsMutex); WriteDataToDiskLocked(key, timestampNs, CONFIG_UPDATED, NO_TIME_CONSTRAINTS); bool modularUpdate = getFlagBool(PARTIAL_CONFIG_UPDATE_FLAG, "false"); OnConfigUpdatedLocked(timestampNs, key, config, modularUpdate); } Loading cmds/statsd/src/StatsLogProcessor.h +4 −4 Original line number Diff line number Diff line Loading @@ -48,7 +48,7 @@ public: void OnLogEvent(LogEvent* event); void OnConfigUpdated(const int64_t timestampNs, const ConfigKey& key, const StatsdConfig& config, bool modularUpdate = false); const StatsdConfig& config); void OnConfigRemoved(const ConfigKey& key); size_t GetMetricsSize(const ConfigKey& key) const; Loading Loading @@ -338,9 +338,9 @@ private: FRIEND_TEST(MetricActivationE2eTest, TestCountMetricWithSameDeactivation); FRIEND_TEST(MetricActivationE2eTest, TestCountMetricWithTwoMetricsTwoDeactivations); FRIEND_TEST(ConfigUpdateE2eTest, TestHashStrings); FRIEND_TEST(ConfigUpdateE2eTest, TestUidMapVersionStringInstaller); FRIEND_TEST(ConfigUpdateE2eTest, TestConfigTtl); FRIEND_TEST(ConfigUpdateE2eAbTest, TestHashStrings); FRIEND_TEST(ConfigUpdateE2eAbTest, TestUidMapVersionStringInstaller); FRIEND_TEST(ConfigUpdateE2eAbTest, TestConfigTtl); FRIEND_TEST(CountMetricE2eTest, TestInitialConditionChanges); FRIEND_TEST(CountMetricE2eTest, TestSlicedState); Loading cmds/statsd/src/config/ConfigListener.h +1 −1 Original line number Diff line number Diff line Loading @@ -39,7 +39,7 @@ public: * A configuration was added or updated. */ virtual void OnConfigUpdated(const int64_t timestampNs, const ConfigKey& key, const StatsdConfig& config, bool modularUpdate = false) = 0; const StatsdConfig& config) = 0; /** * A configuration was removed. Loading cmds/statsd/src/flags/flags.cpp 0 → 100644 +37 −0 Original line number Diff line number Diff line /* * Copyright (C) 2017 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include "flags.h" #include <server_configurable_flags/get_flags.h> using server_configurable_flags::GetServerConfigurableFlag; using std::string; namespace android { namespace os { namespace statsd { string getFlagString(const string& flagName, const string& defaultValue) { return GetServerConfigurableFlag(STATSD_NATIVE_NAMESPACE, flagName, defaultValue); } bool getFlagBool(const string& flagName, const string& defaultValue) { return getFlagString(flagName, defaultValue) == "true"; } } // namespace statsd } // namespace os } // namespace android Loading
cmds/statsd/Android.bp +3 −0 Original line number Diff line number Diff line Loading @@ -40,6 +40,7 @@ cc_defaults { "src/external/StatsPullerManager.cpp", "src/external/TrainInfoPuller.cpp", "src/FieldValue.cpp", "src/flags/flags.cpp", "src/guardrail/StatsdStats.cpp", "src/hash.cpp", "src/HashableDimensionKey.cpp", Loading Loading @@ -92,6 +93,7 @@ cc_defaults { "libstatslog_statsd", "libsysutils", "libutils", "server_configurable_flags", "statsd-aidl-ndk_platform", ], shared_libs: [ Loading Loading @@ -265,6 +267,7 @@ cc_test { "tests/e2e/Anomaly_duration_sum_e2e_test.cpp", "tests/e2e/Attribution_e2e_test.cpp", "tests/e2e/ConfigTtl_e2e_test.cpp", "tests/e2e/ConfigUpdate_e2e_ab_test.cpp", "tests/e2e/ConfigUpdate_e2e_test.cpp", "tests/e2e/CountMetric_e2e_test.cpp", "tests/e2e/DurationMetric_e2e_test.cpp", Loading
cmds/statsd/src/StatsLogProcessor.cpp +4 −2 Original line number Diff line number Diff line Loading @@ -24,12 +24,13 @@ #include <frameworks/base/cmds/statsd/src/active_config_list.pb.h> #include <frameworks/base/cmds/statsd/src/experiment_ids.pb.h> #include "StatsService.h" #include "android-base/stringprintf.h" #include "external/StatsPullerManager.h" #include "flags/flags.h" #include "guardrail/StatsdStats.h" #include "logd/LogEvent.h" #include "metrics/CountMetricProducer.h" #include "StatsService.h" #include "state/StateManager.h" #include "stats_log_util.h" #include "stats_util.h" Loading Loading @@ -520,9 +521,10 @@ void StatsLogProcessor::GetActiveConfigsLocked(const int uid, vector<int64_t>& o } void StatsLogProcessor::OnConfigUpdated(const int64_t timestampNs, const ConfigKey& key, const StatsdConfig& config, bool modularUpdate) { const StatsdConfig& config) { std::lock_guard<std::mutex> lock(mMetricsMutex); WriteDataToDiskLocked(key, timestampNs, CONFIG_UPDATED, NO_TIME_CONSTRAINTS); bool modularUpdate = getFlagBool(PARTIAL_CONFIG_UPDATE_FLAG, "false"); OnConfigUpdatedLocked(timestampNs, key, config, modularUpdate); } Loading
cmds/statsd/src/StatsLogProcessor.h +4 −4 Original line number Diff line number Diff line Loading @@ -48,7 +48,7 @@ public: void OnLogEvent(LogEvent* event); void OnConfigUpdated(const int64_t timestampNs, const ConfigKey& key, const StatsdConfig& config, bool modularUpdate = false); const StatsdConfig& config); void OnConfigRemoved(const ConfigKey& key); size_t GetMetricsSize(const ConfigKey& key) const; Loading Loading @@ -338,9 +338,9 @@ private: FRIEND_TEST(MetricActivationE2eTest, TestCountMetricWithSameDeactivation); FRIEND_TEST(MetricActivationE2eTest, TestCountMetricWithTwoMetricsTwoDeactivations); FRIEND_TEST(ConfigUpdateE2eTest, TestHashStrings); FRIEND_TEST(ConfigUpdateE2eTest, TestUidMapVersionStringInstaller); FRIEND_TEST(ConfigUpdateE2eTest, TestConfigTtl); FRIEND_TEST(ConfigUpdateE2eAbTest, TestHashStrings); FRIEND_TEST(ConfigUpdateE2eAbTest, TestUidMapVersionStringInstaller); FRIEND_TEST(ConfigUpdateE2eAbTest, TestConfigTtl); FRIEND_TEST(CountMetricE2eTest, TestInitialConditionChanges); FRIEND_TEST(CountMetricE2eTest, TestSlicedState); Loading
cmds/statsd/src/config/ConfigListener.h +1 −1 Original line number Diff line number Diff line Loading @@ -39,7 +39,7 @@ public: * A configuration was added or updated. */ virtual void OnConfigUpdated(const int64_t timestampNs, const ConfigKey& key, const StatsdConfig& config, bool modularUpdate = false) = 0; const StatsdConfig& config) = 0; /** * A configuration was removed. Loading
cmds/statsd/src/flags/flags.cpp 0 → 100644 +37 −0 Original line number Diff line number Diff line /* * Copyright (C) 2017 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include "flags.h" #include <server_configurable_flags/get_flags.h> using server_configurable_flags::GetServerConfigurableFlag; using std::string; namespace android { namespace os { namespace statsd { string getFlagString(const string& flagName, const string& defaultValue) { return GetServerConfigurableFlag(STATSD_NATIVE_NAMESPACE, flagName, defaultValue); } bool getFlagBool(const string& flagName, const string& defaultValue) { return getFlagString(flagName, defaultValue) == "true"; } } // namespace statsd } // namespace os } // namespace android