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
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;
+}
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);
#include "mmi.h"
#include "mmi-client.h"
#include "mmi-dbg.h"
+#include "mmi-ipc.h"
MMI_API int mmi_initialize(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;
+}
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
}
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();
+}