Skip operation when mode is not changed by voice command 24/281824/1
authorSuyeon Hwang <stom.hwang@samsung.com>
Thu, 22 Sep 2022 06:37:00 +0000 (15:37 +0900)
committerTizen AI <ai.tzn.sec@samsung.com>
Thu, 22 Sep 2022 07:24:44 +0000 (16:24 +0900)
Change-Id: I70bdaf533eca6d58da627da305a64906a061f403
Signed-off-by: Suyeon Hwang <stom.hwang@samsung.com>
src/mmimgr/iu/VoiceTouchEngine.cpp
src/mmimgr/iu/VoiceTouchEngine.h

index b2592a2..40e799f 100644 (file)
@@ -208,14 +208,18 @@ bool VoiceTouchEngine::handleVoiceInput(mmi_provider_event_voice *voiceEvent)
                return true;
        }
 
-       bool isModeUpdated = checkVoiceTouchMode(asrResult);
-       if (isModeUpdated) {
-               _I("[VoiceTouchEngine] Voice touch mode is changed. (%d)", static_cast<int>(__currentMode));
+       voice_touch_mode_e mode = getVoiceTouchMode(asrResult);
+       if (mode == VOICE_TOUCH_MODE_INVALID) {
+               _I("[VoiceTouchEngine] This is not mode command. Try to find proper command");
+               __asrResult = asrResult;
+               __findCommandTimer = ecore_timer_add(0.0, findCommandCallback, static_cast<void *>(this));
+       } else if (mode != __currentMode) {
+               _I("[VoiceTouchEngine] Voice touch mode is changed from (%d) to (%d)", static_cast<int>(__currentMode), static_cast<int>(mode));
+               __currentMode = mode;
                resetCurrentGridInfo();
                __makeClickableItemResultTimer = ecore_timer_add(0.0, makeClickableItemResultCallback, static_cast<void *>(this));
        } else {
-               __asrResult = asrResult;
-               __findCommandTimer = ecore_timer_add(0.0, findCommandCallback, static_cast<void *>(this));
+               _I("[VoiceTouchEngine] Voice touch mode is not changed. Skip operation");
        }
 
        return true;
@@ -300,12 +304,10 @@ void VoiceTouchEngine::makeClickedItemResult(ClickableItem* command, int timesta
        }
 }
 
-bool VoiceTouchEngine::checkVoiceTouchMode(const std::string &text)
+voice_touch_mode_e VoiceTouchEngine::getVoiceTouchMode(const std::string &text)
 {
-       _I("[VoiceTouchEngine] Input text(%s)", text.c_str());
-
        string loweredText = StringUtil::makeLowerCase(text);
-       voice_touch_mode_e mode = __currentMode;
+       voice_touch_mode_e mode = VOICE_TOUCH_MODE_INVALID;
        if (__is_exist_in_candidates(loweredText, __SHOW_LABEL_KOKR)) {
                mode = VOICE_TOUCH_MODE_TOOLTIP_TEXT;
        } else if (__is_exist_in_candidates(loweredText, __SHOW_NUMBER_KOKR)) {
@@ -314,14 +316,8 @@ bool VoiceTouchEngine::checkVoiceTouchMode(const std::string &text)
                mode = VOICE_TOUCH_MODE_GRID;
        }
 
-       if (__currentMode != mode) {
-               _I("[VoiceTouchEngine] mode is changed from (%d) to (%d)", __currentMode, mode);
-               __currentMode = mode;
-               return true;
-       }
-
-       _I("[VoiceTouchEngine] Mode is not changed");
-       return false;
+       _I("[VoiceTouchEngine] Mode from text(%s) is (%d)", text.c_str(), static_cast<int>(mode));
+       return mode;
 }
 
 void VoiceTouchEngine::resetCurrentGridInfo()
index e9049bc..55236c3 100644 (file)
@@ -41,7 +41,8 @@ struct grid_info_s {
 enum voice_touch_mode_e {
        VOICE_TOUCH_MODE_TOOLTIP_TEXT,
        VOICE_TOUCH_MODE_TOOLTIP_NUMBER,
-       VOICE_TOUCH_MODE_GRID
+       VOICE_TOUCH_MODE_GRID,
+       VOICE_TOUCH_MODE_INVALID
 };
 
 enum voice_result_type_e {
@@ -78,7 +79,7 @@ private:
        bool handleVoiceInput(mmi_provider_event_voice *voiceEvent);
        bool handleScreenAnalyzerInput(mmi_provider_event_screen_analyzer *screenAnalyzerEvent);
 
-       bool checkVoiceTouchMode(const std::string &text);
+       voice_touch_mode_e getVoiceTouchMode(const std::string &text);
        ClickableItem * findCommand();
 
        void makeClickedItemResult(ClickableItem* command, int timestamp, JsonProvider &provider);