From: dyamy-lee Date: Tue, 13 Sep 2022 01:52:56 +0000 (+0900) Subject: activate input event X-Git-Tag: accepted/tizen/unified/20220927.132357~7 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6f4240fd592bc54b990fcc7a83cf9238e663c1b1;p=platform%2Fcore%2Fuifw%2Fmmi-framework.git activate input event mmi_activate_input_event is called by client, and it check saved input event and callback. If it has matched one, invoke activate input event to stub. Change-Id: I6866edc74f7453d752b679050a44ce4f55193186 --- diff --git a/src/mmi-ipc.c b/src/mmi-ipc.c index c14de7f..651527a 100644 --- a/src/mmi-ipc.c +++ b/src/mmi-ipc.c @@ -180,3 +180,39 @@ int mmi_ipc_register_input_event_result_cb(int input_event_type, rpc_port_proxy_ return MMI_ERROR_NONE; } + +int mmi_ipc_activate_input_event(int input_event_type) +{ + LOGI("Activate about input event type(%d)", input_event_type); + + int ret; + + mmi_handle client = mmi_client_get(); + if (client == NULL) { + LOGE("Fail to get client"); + return MMI_ERROR_INVALID_PARAMETER; + } + + rpc_port_proxy_mmi_h rpc_h = client->rpc_h; + if (rpc_h == NULL) { + LOGE("Fail to get tidl rpc info"); + return MMI_ERROR_INVALID_PARAMETER; + } + + if (mmi_ipc_is_connected() == false) { + LOGE("Try to connect again"); + ret = mmi_ipc_retry_connection(_rpc_h); + if (ret != RPC_PORT_ERROR_NONE) { + LOGE("Fail to retry connection(%d)", ret); + return MMI_ERROR_OPERATION_FAILED; + } + } + + ret = rpc_port_proxy_mmi_invoke_activate_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 b0fadf9..8d15f77 100644 --- a/src/mmi-ipc.h +++ b/src/mmi-ipc.h @@ -28,6 +28,7 @@ extern "C" { 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); 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 08e9796..322381a 100644 --- a/src/mmi.c +++ b/src/mmi.c @@ -18,6 +18,7 @@ #include "mmi.h" #include "mmi-client.h" #include "mmi-dbg.h" +#include "mmi-ipc.h" MMI_API int mmi_initialize(void) { @@ -53,3 +54,43 @@ MMI_API int mmi_set_result_cb(int input_event_type, mmi_result_cb callback, void return MMI_ERROR_NONE; } + +MMI_API int mmi_activate_input_event(int input_event_type) +{ + LOGI("Activate 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 (iter != NULL) { + data = iter->data; + + if (data != NULL) { + int type = data->input_event_type; + + if (type == input_event_type) { + ret = mmi_ipc_activate_input_event(input_event_type); + if(ret != MMI_ERROR_NONE) { + LOGE("Fail to activate input event(%d)", ret); + return ret; + } + + LOGD("Activate input event(%d)", type); + return MMI_ERROR_NONE; + } + } + + iter = g_list_next(iter); + } + } + + LOGE("No match callback about input event type(%d)", input_event_type); + return MMI_ERROR_INVALID_PARAMETER; +} diff --git a/src/mmi.h b/src/mmi.h index 56cf354..8c1da0c 100644 --- a/src/mmi.h +++ b/src/mmi.h @@ -56,6 +56,7 @@ extern "C" { 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); #ifdef __cplusplus } diff --git a/tests/mmi-main-test.cpp b/tests/mmi-main-test.cpp index 64ce80e..4170cbf 100644 --- a/tests/mmi-main-test.cpp +++ b/tests/mmi-main-test.cpp @@ -179,3 +179,69 @@ TEST_F(MMIMainTest, MMISetResultCbFailNoRpcHandle) mmi_deinitialize(); } + +TEST_F(MMIMainTest, MMIActivateInputEventSuccess) +{ + int res = mmi_initialize(); + mmi_input_event_type_e input_event_type = MMI_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_deinitialize(); +} + +TEST_F(MMIMainTest, MMIActivateInputEventFailNoEvent) +{ + int res = mmi_initialize(); + mmi_input_event_type_e input_event_type = MMI_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(MMI_VOICE_RECOGNITION); + EXPECT_EQ(res, MMI_ERROR_INVALID_PARAMETER); + + mmi_deinitialize(); +} + +TEST_F(MMIMainTest, MMIActivateInputEventFailNoCallback) +{ + int res = mmi_initialize(); + mmi_input_event_type_e input_event_type = MMI_VOICE_TOUCH; + + EXPECT_EQ(res, MMI_ERROR_NONE); + + res = mmi_activate_input_event(input_event_type); + EXPECT_EQ(res, MMI_ERROR_INVALID_PARAMETER); + + mmi_deinitialize(); +} + +TEST_F(MMIMainTest, MMIActivateInputEventFailNoRpcHandle) +{ + int res = mmi_initialize(); + mmi_input_event_type_e input_event_type = MMI_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); + + mmi_ipc_deinitialize(); + + mmi_handle mmi_client = mmi_client_get(); + mmi_client->rpc_h = NULL; + + res = mmi_activate_input_event(input_event_type); + EXPECT_EQ(res, MMI_ERROR_INVALID_PARAMETER); + + mmi_deinitialize(); +}