From: dyamy-lee Date: Wed, 7 Sep 2022 01:55:27 +0000 (+0900) Subject: add deactivate input event X-Git-Tag: accepted/tizen/unified/20220927.132357~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a8672e4a7484436841cdc0006132dc697ffeb688;p=platform%2Fcore%2Fuifw%2Fmmi-framework.git add deactivate input event mmi_deactivate_input_event is called by client, and it check saved input event. If it has matched one, invoke deactivate input event to stub. Also, add tests for deactivate. Change-Id: I9b0173cf14485e028892eeac2e8c8cb924d8f7a4 --- diff --git a/src/mmi-ipc.c b/src/mmi-ipc.c index 2da72b6..8f66c5e 100644 --- a/src/mmi-ipc.c +++ b/src/mmi-ipc.c @@ -223,3 +223,30 @@ int mmi_ipc_activate_input_event(int input_event_type) return MMI_ERROR_NONE; } + +int mmi_ipc_deactivate_input_event(int input_event_type) +{ + LOGE("Dectivate about input event type(%d)", input_event_type); + + int ret; + rpc_port_proxy_mmi_h rpc_h = NULL; + + if (input_event_type == MMI_INPUT_EVENT_TYPE_NONE) { + LOGE("Parameter input event type is NULL"); + return MMI_ERROR_INVALID_PARAMETER; + } + + rpc_h = mmi_ipc_get_rpc_h(); + if (rpc_h == NULL) { + LOGE("Fail to get tidl rpc info"); + return MMI_ERROR_OPERATION_FAILED; + } + + ret = rpc_port_proxy_mmi_invoke_deactivate_input_event(rpc_h, input_event_type); + if (ret != RPC_PORT_ERROR_NONE) { + LOGE("Fail to invoke activate input event"); + return MMI_ERROR_OPERATION_FAILED; + } + + return MMI_ERROR_NONE; +} diff --git a/src/mmi-ipc.h b/src/mmi-ipc.h index 8d15f77..8c4367f 100644 --- a/src/mmi-ipc.h +++ b/src/mmi-ipc.h @@ -29,6 +29,7 @@ int mmi_ipc_initialize(void); void mmi_ipc_deinitialize(void); int mmi_ipc_register_input_event_result_cb(int input_event_type, rpc_port_proxy_mmi_result_cb_cb callback); int mmi_ipc_activate_input_event(int input_event_type); +int mmi_ipc_deactivate_input_event(int input_event_type); rpc_port_proxy_mmi_h mmi_ipc_get_rpc_h(void); int mmi_ipc_get_uid(void); diff --git a/src/mmi.c b/src/mmi.c index 322381a..9824c00 100644 --- a/src/mmi.c +++ b/src/mmi.c @@ -94,3 +94,42 @@ MMI_API int mmi_activate_input_event(int input_event_type) LOGE("No match callback about input event type(%d)", input_event_type); return MMI_ERROR_INVALID_PARAMETER; } + +MMI_API int mmi_deactivate_input_event(int input_event_type) +{ + LOGI("Deactivate input event(%d)", input_event_type); + + int ret; + GList* iter = NULL; + mmi_result_cb_s *data = NULL; + mmi_handle client = mmi_client_get(); + + if (g_list_length(client->result_cb_list) > 0) { + LOGD("Check length of callback lists = %d", g_list_length(client->result_cb_list)); + + iter = g_list_first(client->result_cb_list); + + while (NULL != iter) { + data = iter->data; + + if (NULL != data) { + int type = data->input_event_type; + + if (type == input_event_type) { + ret = mmi_ipc_deactivate_input_event(input_event_type); + if(ret != MMI_ERROR_NONE) { + LOGE("Fail to deactivate input event(%d)", ret); + return ret; + } + + return MMI_ERROR_NONE; + } + } + + iter = g_list_next(iter); + } + } + + LOGE("Fail to deactivate input event type(%d)", input_event_type); + return MMI_ERROR_INVALID_PARAMETER; +} diff --git a/src/mmi.h b/src/mmi.h index 3b7e7aa..0a8683b 100644 --- a/src/mmi.h +++ b/src/mmi.h @@ -58,6 +58,7 @@ MMI_API int mmi_initialize(void); MMI_API int mmi_deinitialize(void); MMI_API int mmi_set_result_cb(int input_event_type, mmi_result_cb callback, void* user_data); MMI_API int mmi_activate_input_event(int input_event_type); +MMI_API int mmi_deactivate_input_event(int input_event_type); #ifdef __cplusplus } diff --git a/tests/mmi-ipc-test.cpp b/tests/mmi-ipc-test.cpp index 7232636..21c5514 100644 --- a/tests/mmi-ipc-test.cpp +++ b/tests/mmi-ipc-test.cpp @@ -202,3 +202,65 @@ TEST_F(MMIIpcTest, MMIFWIpcActivateFailAlreadyDone) mmi_deinitialize(); } + +TEST_F(MMIIpcTest, MMIFWIpcDeactivateSuccess) +{ + int res = mmi_initialize(); + mmi_input_event_type_e input_event_type = MMI_INPUT_EVENT_TYPE_VOICE_TOUCH; + + EXPECT_EQ(res, MMI_ERROR_NONE); + + res = mmi_ipc_register_input_event_result_cb(input_event_type, (rpc_port_proxy_mmi_result_cb_cb)voice_touch_callback); + EXPECT_EQ(res, MMI_ERROR_NONE); + + res = mmi_ipc_activate_input_event(input_event_type); + EXPECT_EQ(res, MMI_ERROR_NONE); + + res = mmi_ipc_deactivate_input_event(input_event_type); + EXPECT_EQ(res, MMI_ERROR_NONE); + + mmi_deinitialize(); +} + +TEST_F(MMIIpcTest, MMIFWIpcDeactivateFailNoEvent) +{ + int res = mmi_initialize(); + mmi_input_event_type_e input_event_type = MMI_INPUT_EVENT_TYPE_VOICE_TOUCH; + + EXPECT_EQ(res, MMI_ERROR_NONE); + + res = mmi_ipc_register_input_event_result_cb(input_event_type, (rpc_port_proxy_mmi_result_cb_cb)voice_touch_callback); + EXPECT_EQ(res, MMI_ERROR_NONE); + + res = mmi_ipc_activate_input_event(input_event_type); + EXPECT_EQ(res, MMI_ERROR_NONE); + + res = mmi_ipc_deactivate_input_event(MMI_INPUT_EVENT_TYPE_NONE); + EXPECT_EQ(res, MMI_ERROR_INVALID_PARAMETER); + + mmi_deinitialize(); +} + +TEST_F(MMIIpcTest, MMIFWIpcDeactivateFailNoRpcHandle) +{ + int res = mmi_initialize(); + mmi_input_event_type_e input_event_type = MMI_INPUT_EVENT_TYPE_VOICE_TOUCH; + + EXPECT_EQ(res, MMI_ERROR_NONE); + + res = mmi_ipc_register_input_event_result_cb(input_event_type, (rpc_port_proxy_mmi_result_cb_cb)voice_touch_callback); + EXPECT_EQ(res, MMI_ERROR_NONE); + + res = mmi_ipc_activate_input_event(input_event_type); + EXPECT_EQ(res, MMI_ERROR_NONE); + + mmi_ipc_deinitialize(); + + mmi_handle mmi_client = mmi_client_get(); + mmi_client->rpc_h = NULL; + + res = mmi_ipc_deactivate_input_event(input_event_type); + EXPECT_EQ(res, MMI_ERROR_OPERATION_FAILED); + + mmi_deinitialize(); +} diff --git a/tests/mmi-main-test.cpp b/tests/mmi-main-test.cpp index 6b104ce..a437ddb 100644 --- a/tests/mmi-main-test.cpp +++ b/tests/mmi-main-test.cpp @@ -264,3 +264,65 @@ TEST_F(MMIMainTest, MMIActivateInputEventFailAlreadyDone) mmi_deinitialize(); } + +TEST_F(MMIMainTest, MMIDeactivateInputEventSuccess) +{ + int res = mmi_initialize(); + mmi_input_event_type_e input_event_type = MMI_INPUT_EVENT_TYPE_VOICE_TOUCH; + + EXPECT_EQ(res, MMI_ERROR_NONE); + + res = mmi_set_result_cb(input_event_type, voice_touch_callback, NULL); + EXPECT_EQ(res, MMI_ERROR_NONE); + + res = mmi_activate_input_event(input_event_type); + EXPECT_EQ(res, MMI_ERROR_NONE); + + res = mmi_deactivate_input_event(input_event_type); + EXPECT_EQ(res, MMI_ERROR_NONE); + + mmi_deinitialize(); +} + +TEST_F(MMIMainTest, MMIDeactivateInputEventFailNoEvent) +{ + int res = mmi_initialize(); + mmi_input_event_type_e input_event_type = MMI_INPUT_EVENT_TYPE_VOICE_TOUCH; + + EXPECT_EQ(res, MMI_ERROR_NONE); + + res = mmi_set_result_cb(input_event_type, voice_touch_callback, NULL); + EXPECT_EQ(res, MMI_ERROR_NONE); + + res = mmi_activate_input_event(input_event_type); + EXPECT_EQ(res, MMI_ERROR_NONE); + + res = mmi_deactivate_input_event(MMI_INPUT_EVENT_TYPE_VOICE_RECOGNITION); + EXPECT_EQ(res, MMI_ERROR_INVALID_PARAMETER); + + mmi_deinitialize(); +} + +TEST_F(MMIMainTest, MMIDeactivateInputEventFailNoRpcHandle) +{ + int res = mmi_initialize(); + mmi_input_event_type_e input_event_type = MMI_INPUT_EVENT_TYPE_VOICE_TOUCH; + + EXPECT_EQ(res, MMI_ERROR_NONE); + + res = mmi_set_result_cb(input_event_type, voice_touch_callback, NULL); + EXPECT_EQ(res, MMI_ERROR_NONE); + + res = mmi_activate_input_event(input_event_type); + EXPECT_EQ(res, MMI_ERROR_NONE); + + mmi_ipc_deinitialize(); + + mmi_handle mmi_client = mmi_client_get(); + mmi_client->rpc_h = NULL; + + res = mmi_deactivate_input_event(input_event_type); + EXPECT_EQ(res, MMI_ERROR_OPERATION_FAILED); + + mmi_deinitialize(); +}