Invoke config changed callback directly 80/291080/1
authorSuyeon Hwang <stom.hwang@samsung.com>
Fri, 7 Apr 2023 09:09:12 +0000 (18:09 +0900)
committerTizen AI <ai.tzn.sec@samsung.com>
Fri, 7 Apr 2023 11:03:42 +0000 (20:03 +0900)
- Issue:
If the app changes the config using setting API, the framework did not
invoke config changed callbacks.

- Solution:
In previous code, vc_config_mgr module could know the changes of the
configuration through checking the difference between the values in the
memory and actual configuration file. However, the values in the memory
and configuration file are the same if the app uses the setting API.
This is beecause the setting API sets the value in both the memory and
file.
So, this patch adds a new logic for invoking the callbacks. Through this
patch, vc_config_mgr module will directly invoke the callbacks related
to changed values when the app changes the configuration using setting
API.

Change-Id: Ic8023395889021501d8528401f9058b743699c72
Signed-off-by: Suyeon Hwang <stom.hwang@samsung.com>
common/vc_config_mgr.cpp

index 3986088..9fb301e 100644 (file)
@@ -89,6 +89,7 @@ static int set_current_language(const char* language);
 
 static Eina_Bool notify_engine_changed_event_by_idler(void *data)
 {
+       SLOG(LOG_INFO, vc_config_tag(), "[INFO] Invoke engine changed callback by idler");
        char *engine_appid = static_cast<char *>(data);
        [&engine_appid]() {
                if (nullptr == engine_appid) {
@@ -101,6 +102,7 @@ static Eina_Bool notify_engine_changed_event_by_idler(void *data)
                        return;
                }
 
+               SLOG(LOG_INFO, vc_config_tag(), "[INFO] Engine ID : %s", engine_appid);
                auto clients = g_VoiceControlClients->getClients();
                for (auto &clientInfo : clients) {
                        if (false == g_VoiceControlClients->isUidValid(clientInfo.getUid())) {
@@ -157,6 +159,7 @@ static inline void release_language_changed_cb_params(language_changed_cb_parame
 
 static Eina_Bool notify_language_changed_event_by_idler(void *data)
 {
+       SLOG(LOG_INFO, vc_config_tag(), "[INFO] Invoke language changed callback by idler");
        language_changed_cb_parameters_s *params = static_cast<language_changed_cb_parameters_s *>(data);
        [&params]() {
                if (nullptr == params) {
@@ -169,6 +172,7 @@ static Eina_Bool notify_language_changed_event_by_idler(void *data)
                        return;
                }
 
+               SLOG(LOG_INFO, vc_config_tag(), "[INFO] Before : %s, Current : %s", params->before_lang, params->current_lang);
                auto clients = g_VoiceControlClients->getClients();
                for (auto &clientInfo : clients) {
                        if (false == g_VoiceControlClients->isUidValid(clientInfo.getUid())) {
@@ -217,6 +221,7 @@ static void notify_language_changed(const char* before_lang, const char* current
 
 static Eina_Bool notify_enabled_changed_event_by_idler(void *data)
 {
+       SLOG(LOG_INFO, vc_config_tag(), "[INFO] Invoke enabled changed callback by idler");
        bool *enable = static_cast<bool *>(data);
        [&enable]() {
                if (nullptr == enable) {
@@ -229,6 +234,7 @@ static Eina_Bool notify_enabled_changed_event_by_idler(void *data)
                        return;
                }
 
+               SLOG(LOG_INFO, vc_config_tag(), "[INFO] Enabled : %s", *enable ? "True" : "False");
                auto clients = g_VoiceControlClients->getClients();
                for (auto &clientInfo : clients) {
                        if (false == g_VoiceControlClients->isUidValid(clientInfo.getUid())) {
@@ -323,6 +329,7 @@ static int check_and_set_default_engine_id(const char* engine_id)
                SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Fail to save config");
                return VC_CONFIG_ERROR_OPERATION_FAILED;
        }
+       notify_engine_changed(engineId.c_str());
        g_VoiceControlConfig->setEngineId(engineId.c_str());
 
        return VC_CONFIG_ERROR_NONE;
@@ -737,6 +744,7 @@ static int set_language_by_automatic_selection()
                        SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Fail to save default language");
                        return VC_CONFIG_ERROR_OPERATION_FAILED;
                }
+               notify_language_changed(before_language.c_str(), candidate_lang);
                g_VoiceControlConfig->setCurrentLanguage(candidate_lang);
 
                SLOG(LOG_DEBUG, vc_config_tag(), "[Config] Default language change : before(%s) current(%s)",
@@ -763,6 +771,7 @@ static int set_language_by_automatic_selection()
                        SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Fail to save config");
                        return VC_CONFIG_ERROR_OPERATION_FAILED;
                }
+               notify_language_changed(before_language.c_str(), tmp_language);
                g_VoiceControlConfig->setCurrentLanguage(tmp_language);
 
                SLOG(LOG_DEBUG, vc_config_tag(), "[Config] Default language change : before(%s) current(%s)",
@@ -1304,6 +1313,7 @@ int vc_config_mgr_set_engine(const char* engine)
                SLOG(LOG_ERROR, vc_config_tag(), " Fail to save config");
                return VC_CONFIG_ERROR_OPERATION_FAILED;
        }
+       notify_engine_changed(engine);
        g_VoiceControlConfig->setEngineId(engine);
 
        /* Engine is valid*/
@@ -1406,6 +1416,7 @@ static int set_current_language(const char* language)
                SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Fail to save engine id");
                return VC_CONFIG_ERROR_OPERATION_FAILED;
        }
+       notify_language_changed(default_language.c_str(), language);
        g_VoiceControlConfig->setCurrentLanguage(language);
 
        return VC_CONFIG_ERROR_NONE;
@@ -1443,7 +1454,7 @@ int vc_config_mgr_set_enabled(bool value)
                SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Fail to set enabled");
                return VC_CONFIG_ERROR_OPERATION_FAILED;
        }
-
+       notify_enabled_changed(value);
        g_VoiceControlConfig->setEnabled(value);
 
        return VC_CONFIG_ERROR_NONE;