Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit be3e76df authored by Mike Yu's avatar Mike Yu
Browse files

Store flags in order

As there are already 16 flags, and we are going to add one more flag,
storing the flags in order would make the output of dumpsys dnsresolver
look nicer.

Bug: 205922706
Test: checked the output of dumpsys dnsresolver
Change-Id: I2905bec795f08f514e1906198d5ca11a65fc458a
parent 1b2e16d6
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -17,10 +17,10 @@
#pragma once

#include <climits>
#include <map>
#include <mutex>
#include <string>
#include <string_view>
#include <unordered_map>

#include <android-base/thread_annotations.h>
#include <netdutils/DumpWriter.h>
@@ -45,7 +45,7 @@ class Experiments {
    Experiments() = delete;
    void updateInternal() EXCLUDES(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.
    // (retry_count, retransmission_time_interval)
    static constexpr const char* const kExperimentFlagKeyList[] = {
+4 −4
Original line number Diff line number Diff line
@@ -14,10 +14,10 @@
 * limitations under the License.
 */

#include <map>
#include <mutex>
#include <string>
#include <string_view>
#include <unordered_map>

#include <android-base/format.h>
#include <android-base/test_utils.h>
@@ -72,7 +72,7 @@ class ExperimentsTest : public ::testing::Test {
    }

    void expectGetDnsExperimentFlagInt() {
        std::unordered_map<std::string_view, int> tempMap;
        std::map<std::string_view, int> tempMap;
        for (const auto& key : Experiments::kExperimentFlagKeyList) {
            tempMap[key] = mExperiments.getFlag(key, 0);
        }
@@ -102,11 +102,11 @@ class ExperimentsTest : public ::testing::Test {
        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;
};

std::unordered_map<std::string_view, int> ExperimentsTest::sFakeFlagsMapInt;
std::map<std::string_view, int> ExperimentsTest::sFakeFlagsMapInt;

TEST_F(ExperimentsTest, update) {
    std::vector<int> testValues = {50, 3, 5, 0};