From bc24fb2b35717ebc6366ffe425d12c99878b75de Mon Sep 17 00:00:00 2001 From: Jihoon Kim Date: Wed, 15 Jan 2020 16:17:48 +0900 Subject: [PATCH] Add code to check connection between autofill manager and autofill daemon Change-Id: Ie6f37929454158de5f1bcbc2268474f05243c2ea Signed-off-by: Jihoon Kim --- manager/autofill_manager.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/manager/autofill_manager.c b/manager/autofill_manager.c index a8b4574..16484af 100644 --- a/manager/autofill_manager.c +++ b/manager/autofill_manager.c @@ -34,6 +34,7 @@ struct autofill_manager_s { rpc_port_proxy_AutofillManagerPort_h rpc_h; autofill_manager_connection_status_changed_cb connection_callback; + bool connected; void *connection_userdata; }; @@ -42,6 +43,8 @@ static void __on_connected(rpc_port_proxy_AutofillManagerPort_h h, void *user_da autofill_manager_h amh = user_data; LOGI("connected"); + amh->connected = true; + if (amh->connection_callback) amh->connection_callback(amh, AUTOFILL_MANAGER_CONNECTION_STATUS_CONNECTED, amh->connection_userdata); } @@ -56,6 +59,7 @@ static void __on_disconnected(rpc_port_proxy_AutofillManagerPort_h h, void *user amh->connection_callback(amh, AUTOFILL_MANAGER_CONNECTION_STATUS_DISCONNECTED, amh->connection_userdata); amh->rpc_h = NULL; + amh->connected = false; } static void __on_rejected(rpc_port_proxy_AutofillManagerPort_h h, void *user_data) @@ -196,6 +200,11 @@ EXPORT_API int autofill_manager_set_autofill_service(autofill_manager_h amh, con return AUTOFILL_ERROR_OPERATION_FAILED; } + if (!amh->connected) { + LOGW("[ERROR] Not connected"); + return AUTOFILL_ERROR_OPERATION_FAILED; + } + bool ret = rpc_port_proxy_AutofillManagerPort_invoke_set_autofill_service(amh->rpc_h, app_id); if (ret == false) { LOGW("[ERROR] Failed to send rpc port. err = %d", ret); @@ -223,6 +232,11 @@ EXPORT_API int autofill_manager_get_autofill_service(autofill_manager_h amh, cha return AUTOFILL_ERROR_OPERATION_FAILED; } + if (!amh->connected) { + LOGW("[ERROR] Not connected"); + return AUTOFILL_ERROR_OPERATION_FAILED; + } + char *app_id = rpc_port_proxy_AutofillManagerPort_invoke_get_autofill_service(amh->rpc_h); if (app_id) { LOGI("service id : %s", app_id); @@ -230,6 +244,7 @@ EXPORT_API int autofill_manager_get_autofill_service(autofill_manager_h amh, cha free(app_id); return AUTOFILL_ERROR_NONE; } else { + LOGW("[ERROR] Failed to get autofill service app ID"); return AUTOFILL_ERROR_OPERATION_FAILED; } } @@ -253,6 +268,11 @@ EXPORT_API int autofill_manager_foreach_autofill_service(autofill_manager_h amh, return AUTOFILL_ERROR_OPERATION_FAILED; } + if (!amh->connected) { + LOGW("[ERROR] Not connected"); + return AUTOFILL_ERROR_OPERATION_FAILED; + } + rpc_port_list_string_h app_id_list; rpc_port_list_string_create(&app_id_list); ret = rpc_port_proxy_AutofillManagerPort_invoke_get_autofill_service_list(amh->rpc_h, &app_id_list); -- 2.7.4