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

Commit 7266e82c authored by Howard Ro's avatar Howard Ro Committed by Android (Google) Code Review
Browse files

Merge "Use the configs from disk after reboot and separate out ConfigManager...

Merge "Use the configs from disk after reboot and separate out ConfigManager startup for unit test to avoid reading configs for tests"
parents a070b6a4 469cd808
Loading
Loading
Loading
Loading
+7 −9
Original line number Diff line number Diff line
@@ -49,15 +49,13 @@ ConfigManager::~ConfigManager() {
void ConfigManager::Startup() {
    map<ConfigKey, StatsdConfig> configsFromDisk;
    StorageManager::readConfigFromDisk(configsFromDisk);
    // TODO(b/70667694): Make the configs from disk be used. And remove the fake config,
    // and tests shouldn't call this Startup(), maybe call StartupForTest() so we don't read
    // configs from disk for tests.
    // for (const auto& pair : configsFromDisk) {
    //    UpdateConfig(pair.first, pair.second);
    //}

    // Uncomment the following line and use the hard coded config for development.
    // UpdateConfig(ConfigKey(1000, "fake"), build_fake_config());
    for (const auto& pair : configsFromDisk) {
        UpdateConfig(pair.first, pair.second);
    }
}

void ConfigManager::StartupForTest() {
    // Dummy function to avoid reading configs from disks for tests.
}

void ConfigManager::AddListener(const sp<ConfigListener>& listener) {
+5 −0
Original line number Diff line number Diff line
@@ -48,6 +48,11 @@ public:
     */
    void Startup();

    /*
     * Dummy initializer for tests.
     */
    void StartupForTest();

    /**
     * Someone else wants to know about the configs.
     */
+1 −1
Original line number Diff line number Diff line
@@ -153,7 +153,7 @@ TEST(ConfigManagerTest, TestRemoveUid) {
    EXPECT_CALL(*(listener.get()), OnConfigRemoved(ConfigKeyEq(2, StringToId("yyy"))));
    EXPECT_CALL(*(listener.get()), OnConfigRemoved(ConfigKeyEq(2, StringToId("zzz"))));

    manager->Startup();
    manager->StartupForTest();
    manager->UpdateConfig(ConfigKey(1, StringToId("aaa")), config);
    manager->UpdateConfig(ConfigKey(2, StringToId("xxx")), config);
    manager->UpdateConfig(ConfigKey(2, StringToId("yyy")), config);