Add vconf changed callback for streaming duration 21/300921/1 accepted/tizen/unified/20231106.171646
authorJi-hoon Lee <dalton.lee@samsung.com>
Mon, 6 Nov 2023 05:15:34 +0000 (14:15 +0900)
committerJi-hoon Lee <dalton.lee@samsung.com>
Mon, 6 Nov 2023 05:15:34 +0000 (14:15 +0900)
Change-Id: I8e2aeb57f5cd168fa22e6fb8c492adb102c45145

plugins/wakeup-manager/inc/wakeup_settings.h
plugins/wakeup-manager/src/wakeup_settings.cpp
src/service_main.cpp

index 994a345..ca6a324 100644 (file)
@@ -81,6 +81,7 @@ public:
        float get_wakeup_policy_delay();
        vector<string> get_wakeup_policy_priority();
        float get_streaming_duration_max();
+       void set_streaming_duration_max(float duration);
        string get_current_language(void);
        vector<string> get_wake_word_disabled_assistants();
 private:
index fea630d..602110f 100644 (file)
@@ -50,6 +50,23 @@ static void wakeup_setting_input_language_changed_cb(keynode_t* node, void* data
        }
 }
 
+static void wakeup_setting_streaming_duration_max_changed_cb(keynode_t* node, void* data)
+{
+       MWR_LOGD("[ENTER]");
+       if (nullptr == node) return;
+
+       CWakeupSettings* settings = static_cast<CWakeupSettings*>(data);
+       if (nullptr == settings) return;
+
+       if (VCONF_TYPE_DOUBLE == node->type) {
+               double value = static_cast<double>(node->value.d);
+               settings->set_streaming_duration_max(static_cast<float>(value));
+       } else {
+               LOGE("[Settings ERROR] the value type is not string : %d", node->type);
+       }
+}
+
+
 static void wakeup_setting_enabled_assistants_changed_cb(keynode_t* node, void* data)
 {
        MWR_LOGD("[ENTER]");
@@ -293,6 +310,8 @@ void CWakeupSettings::initialize(map<string, string> custom_keys)
        vconf_notify_key_changed(WAKEUP_SETTINGS_KEY_VOICE_INPUT_LANGUAGE,
                wakeup_setting_input_language_changed_cb, this);
 #endif
+       vconf_notify_key_changed(WAKEUP_SETTINGS_KEY_STREAMING_DURATION_MAX,
+               wakeup_setting_streaming_duration_max_changed_cb, this);
        vconf_notify_key_changed(mCustomVconfKeys[WAKEUP_SETTINGS_KEY_DEFAULT_ASSISTANT_APPID].c_str(),
                wakeup_setting_default_assistant_appid_changed_cb, this);
        if (true == mMultipleMode) {
@@ -311,6 +330,8 @@ void CWakeupSettings::deinitialize()
        vconf_ignore_key_changed(WAKEUP_SETTINGS_KEY_VOICE_INPUT_LANGUAGE,
                wakeup_setting_input_language_changed_cb);
 #endif
+       vconf_ignore_key_changed(WAKEUP_SETTINGS_KEY_STREAMING_DURATION_MAX,
+               wakeup_setting_streaming_duration_max_changed_cb);
        vconf_ignore_key_changed(mCustomVconfKeys[WAKEUP_SETTINGS_KEY_DEFAULT_ASSISTANT_APPID].c_str(),
                wakeup_setting_default_assistant_appid_changed_cb);
        if (true == mMultipleMode) {
@@ -406,6 +427,12 @@ float CWakeupSettings::get_streaming_duration_max()
        return mStreamingDurationMax;
 }
 
+void CWakeupSettings::set_streaming_duration_max(float duration)
+{
+       MWR_LOGE("Setting Streaming Duration Max Value : %f", duration);
+       mStreamingDurationMax = duration;
+}
+
 std::string CWakeupSettings::get_current_language(void)
 {
        std::string result{"en_US"};
index 4886872..8dda168 100644 (file)
@@ -1474,12 +1474,12 @@ void CServiceMain::app_restart()
        const std::chrono::seconds minimum_interval(3);
        auto interval = std::chrono::steady_clock::now() - mStartedTime;
        if (interval < minimum_interval) {
-               MAS_LOGE("sleeping for %lld ms",
-                       std::chrono::duration_cast<std::chrono::milliseconds>(minimum_interval - interval).count());
+               MAS_LOGE("sleeping for %lld ms", static_cast<long long int>(
+                       std::chrono::duration_cast<std::chrono::milliseconds>(minimum_interval - interval).count()));
                std::this_thread::sleep_for(minimum_interval - interval);
        } else {
-               MAS_LOGE("interval is %lld ms, no need to sleep",
-                       std::chrono::duration_cast<std::chrono::milliseconds>(interval).count());
+               MAS_LOGE("interval is %lld ms, no need to sleep", static_cast<long long int>(
+                       std::chrono::duration_cast<std::chrono::milliseconds>(interval).count()));
        }
        mServiceIpc.send_restart_notification();