Loading Android.bp +0 −1 Original line number Original line Diff line number Diff line Loading @@ -83,7 +83,6 @@ aidl_interface { backend: { backend: { java: { java: { apex_available: [ apex_available: [ "com.android.bluetooth.updatable", "com.android.tethering", "com.android.tethering", "com.android.wifi", "com.android.wifi", ], ], Loading DnsStats.cpp +3 −4 Original line number Original line Diff line number Diff line Loading @@ -81,8 +81,7 @@ int StatsData::averageLatencyMs() const { } } std::string StatsData::toString() const { std::string StatsData::toString() const { if (total == 0) if (total == 0) return fmt::format("{} <no data>", sockAddr.toString()); return fmt::format("{}:{} <no data>", sockAddr.ip().toString(), sockAddr.port()); const auto now = std::chrono::steady_clock::now(); const auto now = std::chrono::steady_clock::now(); const int lastUpdateSec = duration_cast<seconds>(now - lastUpdate).count(); const int lastUpdateSec = duration_cast<seconds>(now - lastUpdate).count(); Loading @@ -92,8 +91,8 @@ std::string StatsData::toString() const { buf += fmt::format("{}:{} ", rcodeToName(rcode), counts); buf += fmt::format("{}:{} ", rcodeToName(rcode), counts); } } } } return fmt::format("{}:{} ({}, {}ms, [{}], {}s)", sockAddr.ip().toString(), sockAddr.port(), return fmt::format("{} ({}, {}ms, [{}], {}s)", sockAddr.toString(), total, averageLatencyMs(), total, averageLatencyMs(), buf, lastUpdateSec); buf, lastUpdateSec); } } StatsRecords::StatsRecords(const IPSockAddr& ipSockAddr, size_t size) StatsRecords::StatsRecords(const IPSockAddr& ipSockAddr, size_t size) Loading DnsStatsTest.cpp +2 −3 Original line number Original line Diff line number Diff line Loading @@ -121,7 +121,7 @@ class DnsStatsTest : public ::testing::Test { const std::vector<StatsData>& dohData) { const std::vector<StatsData>& dohData) { // A pattern to capture three matches: // A pattern to capture three matches: // server address (empty allowed), the statistics, and the score. // server address (empty allowed), the statistics, and the score. const std::regex pattern(R"(\s{4,}([0-9a-fA-F:\.]*)[ ]?([<(].*[>)])[ ]?(\S*))"); const std::regex pattern(R"(\s{4,}([0-9a-fA-F:\.\]\[]*)[ ]?([<(].*[>)])[ ]?(\S*))"); std::string dumpString = captureDumpOutput(); std::string dumpString = captureDumpOutput(); const auto check = [&](const std::vector<StatsData>& statsData, const std::string& protocol, const auto check = [&](const std::vector<StatsData>& statsData, const std::string& protocol, Loading @@ -142,8 +142,7 @@ class DnsStatsTest : public ::testing::Test { for (const auto& stats : statsData) { for (const auto& stats : statsData) { ASSERT_TRUE(std::regex_search(*dumpString, sm, pattern)); ASSERT_TRUE(std::regex_search(*dumpString, sm, pattern)); EXPECT_EQ(sm[1], stats.sockAddr.ip().toString() + ":" + EXPECT_EQ(sm[1], stats.sockAddr.toString()); std::to_string(stats.sockAddr.port())); EXPECT_FALSE(sm[2].str().empty()); EXPECT_FALSE(sm[2].str().empty()); EXPECT_FALSE(sm[3].str().empty()); EXPECT_FALSE(sm[3].str().empty()); *dumpString = sm.suffix(); *dumpString = sm.suffix(); Loading Experiments.h +3 −2 Original line number Original line Diff line number Diff line Loading @@ -17,10 +17,10 @@ #pragma once #pragma once #include <climits> #include <climits> #include <map> #include <mutex> #include <mutex> #include <string> #include <string> #include <string_view> #include <string_view> #include <unordered_map> #include <android-base/thread_annotations.h> #include <android-base/thread_annotations.h> #include <netdutils/DumpWriter.h> #include <netdutils/DumpWriter.h> Loading @@ -45,7 +45,7 @@ class Experiments { Experiments() = delete; Experiments() = delete; void updateInternal() EXCLUDES(mMutex); void updateInternal() EXCLUDES(mMutex); mutable std::mutex mMutex; mutable std::mutex mMutex; std::unordered_map<std::string_view, int> mFlagsMapInt GUARDED_BY(mMutex); std::map<std::string_view, int> mFlagsMapInt GUARDED_BY(mMutex); // TODO: Migrate other experiment flags to here. // TODO: Migrate other experiment flags to here. // (retry_count, retransmission_time_interval) // (retry_count, retransmission_time_interval) static constexpr const char* const kExperimentFlagKeyList[] = { static constexpr const char* const kExperimentFlagKeyList[] = { Loading @@ -64,6 +64,7 @@ class Experiments { "doh", "doh", "doh_query_timeout_ms", "doh_query_timeout_ms", "doh_probe_timeout_ms", "doh_probe_timeout_ms", "doh_idle_timeout_ms", "mdns_resolution", "mdns_resolution", }; }; // This value is used in updateInternal as the default value if any flags can't be found. // This value is used in updateInternal as the default value if any flags can't be found. Loading ExperimentsTest.cpp +4 −4 Original line number Original line Diff line number Diff line Loading @@ -14,10 +14,10 @@ * limitations under the License. * limitations under the License. */ */ #include <map> #include <mutex> #include <mutex> #include <string> #include <string> #include <string_view> #include <string_view> #include <unordered_map> #include <android-base/format.h> #include <android-base/format.h> #include <android-base/test_utils.h> #include <android-base/test_utils.h> Loading Loading @@ -72,7 +72,7 @@ class ExperimentsTest : public ::testing::Test { } } void expectGetDnsExperimentFlagInt() { void expectGetDnsExperimentFlagInt() { std::unordered_map<std::string_view, int> tempMap; std::map<std::string_view, int> tempMap; for (const auto& key : Experiments::kExperimentFlagKeyList) { for (const auto& key : Experiments::kExperimentFlagKeyList) { tempMap[key] = mExperiments.getFlag(key, 0); tempMap[key] = mExperiments.getFlag(key, 0); } } Loading Loading @@ -102,11 +102,11 @@ class ExperimentsTest : public ::testing::Test { EXPECT_EQ(dumpString.substr(startPos), "\n"); EXPECT_EQ(dumpString.substr(startPos), "\n"); } } static std::unordered_map<std::string_view, int> sFakeFlagsMapInt; static std::map<std::string_view, int> sFakeFlagsMapInt; Experiments mExperiments; Experiments mExperiments; }; }; std::unordered_map<std::string_view, int> ExperimentsTest::sFakeFlagsMapInt; std::map<std::string_view, int> ExperimentsTest::sFakeFlagsMapInt; TEST_F(ExperimentsTest, update) { TEST_F(ExperimentsTest, update) { std::vector<int> testValues = {50, 3, 5, 0}; std::vector<int> testValues = {50, 3, 5, 0}; Loading Loading
Android.bp +0 −1 Original line number Original line Diff line number Diff line Loading @@ -83,7 +83,6 @@ aidl_interface { backend: { backend: { java: { java: { apex_available: [ apex_available: [ "com.android.bluetooth.updatable", "com.android.tethering", "com.android.tethering", "com.android.wifi", "com.android.wifi", ], ], Loading
DnsStats.cpp +3 −4 Original line number Original line Diff line number Diff line Loading @@ -81,8 +81,7 @@ int StatsData::averageLatencyMs() const { } } std::string StatsData::toString() const { std::string StatsData::toString() const { if (total == 0) if (total == 0) return fmt::format("{} <no data>", sockAddr.toString()); return fmt::format("{}:{} <no data>", sockAddr.ip().toString(), sockAddr.port()); const auto now = std::chrono::steady_clock::now(); const auto now = std::chrono::steady_clock::now(); const int lastUpdateSec = duration_cast<seconds>(now - lastUpdate).count(); const int lastUpdateSec = duration_cast<seconds>(now - lastUpdate).count(); Loading @@ -92,8 +91,8 @@ std::string StatsData::toString() const { buf += fmt::format("{}:{} ", rcodeToName(rcode), counts); buf += fmt::format("{}:{} ", rcodeToName(rcode), counts); } } } } return fmt::format("{}:{} ({}, {}ms, [{}], {}s)", sockAddr.ip().toString(), sockAddr.port(), return fmt::format("{} ({}, {}ms, [{}], {}s)", sockAddr.toString(), total, averageLatencyMs(), total, averageLatencyMs(), buf, lastUpdateSec); buf, lastUpdateSec); } } StatsRecords::StatsRecords(const IPSockAddr& ipSockAddr, size_t size) StatsRecords::StatsRecords(const IPSockAddr& ipSockAddr, size_t size) Loading
DnsStatsTest.cpp +2 −3 Original line number Original line Diff line number Diff line Loading @@ -121,7 +121,7 @@ class DnsStatsTest : public ::testing::Test { const std::vector<StatsData>& dohData) { const std::vector<StatsData>& dohData) { // A pattern to capture three matches: // A pattern to capture three matches: // server address (empty allowed), the statistics, and the score. // server address (empty allowed), the statistics, and the score. const std::regex pattern(R"(\s{4,}([0-9a-fA-F:\.]*)[ ]?([<(].*[>)])[ ]?(\S*))"); const std::regex pattern(R"(\s{4,}([0-9a-fA-F:\.\]\[]*)[ ]?([<(].*[>)])[ ]?(\S*))"); std::string dumpString = captureDumpOutput(); std::string dumpString = captureDumpOutput(); const auto check = [&](const std::vector<StatsData>& statsData, const std::string& protocol, const auto check = [&](const std::vector<StatsData>& statsData, const std::string& protocol, Loading @@ -142,8 +142,7 @@ class DnsStatsTest : public ::testing::Test { for (const auto& stats : statsData) { for (const auto& stats : statsData) { ASSERT_TRUE(std::regex_search(*dumpString, sm, pattern)); ASSERT_TRUE(std::regex_search(*dumpString, sm, pattern)); EXPECT_EQ(sm[1], stats.sockAddr.ip().toString() + ":" + EXPECT_EQ(sm[1], stats.sockAddr.toString()); std::to_string(stats.sockAddr.port())); EXPECT_FALSE(sm[2].str().empty()); EXPECT_FALSE(sm[2].str().empty()); EXPECT_FALSE(sm[3].str().empty()); EXPECT_FALSE(sm[3].str().empty()); *dumpString = sm.suffix(); *dumpString = sm.suffix(); Loading
Experiments.h +3 −2 Original line number Original line Diff line number Diff line Loading @@ -17,10 +17,10 @@ #pragma once #pragma once #include <climits> #include <climits> #include <map> #include <mutex> #include <mutex> #include <string> #include <string> #include <string_view> #include <string_view> #include <unordered_map> #include <android-base/thread_annotations.h> #include <android-base/thread_annotations.h> #include <netdutils/DumpWriter.h> #include <netdutils/DumpWriter.h> Loading @@ -45,7 +45,7 @@ class Experiments { Experiments() = delete; Experiments() = delete; void updateInternal() EXCLUDES(mMutex); void updateInternal() EXCLUDES(mMutex); mutable std::mutex mMutex; mutable std::mutex mMutex; std::unordered_map<std::string_view, int> mFlagsMapInt GUARDED_BY(mMutex); std::map<std::string_view, int> mFlagsMapInt GUARDED_BY(mMutex); // TODO: Migrate other experiment flags to here. // TODO: Migrate other experiment flags to here. // (retry_count, retransmission_time_interval) // (retry_count, retransmission_time_interval) static constexpr const char* const kExperimentFlagKeyList[] = { static constexpr const char* const kExperimentFlagKeyList[] = { Loading @@ -64,6 +64,7 @@ class Experiments { "doh", "doh", "doh_query_timeout_ms", "doh_query_timeout_ms", "doh_probe_timeout_ms", "doh_probe_timeout_ms", "doh_idle_timeout_ms", "mdns_resolution", "mdns_resolution", }; }; // This value is used in updateInternal as the default value if any flags can't be found. // This value is used in updateInternal as the default value if any flags can't be found. Loading
ExperimentsTest.cpp +4 −4 Original line number Original line Diff line number Diff line Loading @@ -14,10 +14,10 @@ * limitations under the License. * limitations under the License. */ */ #include <map> #include <mutex> #include <mutex> #include <string> #include <string> #include <string_view> #include <string_view> #include <unordered_map> #include <android-base/format.h> #include <android-base/format.h> #include <android-base/test_utils.h> #include <android-base/test_utils.h> Loading Loading @@ -72,7 +72,7 @@ class ExperimentsTest : public ::testing::Test { } } void expectGetDnsExperimentFlagInt() { void expectGetDnsExperimentFlagInt() { std::unordered_map<std::string_view, int> tempMap; std::map<std::string_view, int> tempMap; for (const auto& key : Experiments::kExperimentFlagKeyList) { for (const auto& key : Experiments::kExperimentFlagKeyList) { tempMap[key] = mExperiments.getFlag(key, 0); tempMap[key] = mExperiments.getFlag(key, 0); } } Loading Loading @@ -102,11 +102,11 @@ class ExperimentsTest : public ::testing::Test { EXPECT_EQ(dumpString.substr(startPos), "\n"); EXPECT_EQ(dumpString.substr(startPos), "\n"); } } static std::unordered_map<std::string_view, int> sFakeFlagsMapInt; static std::map<std::string_view, int> sFakeFlagsMapInt; Experiments mExperiments; Experiments mExperiments; }; }; std::unordered_map<std::string_view, int> ExperimentsTest::sFakeFlagsMapInt; std::map<std::string_view, int> ExperimentsTest::sFakeFlagsMapInt; TEST_F(ExperimentsTest, update) { TEST_F(ExperimentsTest, update) { std::vector<int> testValues = {50, 3, 5, 0}; std::vector<int> testValues = {50, 3, 5, 0}; Loading