From ff3e2f22ff3b4821bc660f1db99f2e9889e5046e Mon Sep 17 00:00:00 2001 From: InHong Han Date: Wed, 1 Apr 2020 19:29:20 +0900 Subject: [PATCH 01/16] Modified to check the string size is zero Change-Id: I2c49792905831954b08c307463cbfccebe88124e --- client/sticker_data.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/sticker_data.c b/client/sticker_data.c index 555a23a..2a64633 100644 --- a/client/sticker_data.c +++ b/client/sticker_data.c @@ -235,7 +235,7 @@ EXPORT_API int sticker_data_set_uri(sticker_data_h data_handle, sticker_data_uri CHECK_STICKER_FEATURE(); char *file_path = NULL; - if (!data_handle || !type || !uri) + if (!data_handle || !type || !uri || uri[0] == '\0') return STICKER_ERROR_INVALID_PARAMETER; if (type == STICKER_DATA_URI_LOCAL_PATH) { @@ -369,7 +369,7 @@ EXPORT_API int sticker_data_set_thumbnail(sticker_data_h data_handle, const char CHECK_STICKER_FEATURE(); char *file_path = NULL; - if (!data_handle || !thumbnail) + if (!data_handle || !thumbnail || thumbnail[0] == '\0') return STICKER_ERROR_INVALID_PARAMETER; if (access(thumbnail, F_OK) != 0) { -- 2.7.4 From c7f817afabf03b9924e1da296d7a6e97c991fcc7 Mon Sep 17 00:00:00 2001 From: InHong Han Date: Wed, 1 Apr 2020 19:44:25 +0900 Subject: [PATCH 02/16] Fix issue that does not create thumbnail before OOBE Change-Id: Icd2d94dbf8ad1cb2db5511668df2020c57dca048 --- receiver/src/ft.cpp | 44 +++++++++++++++++++++++++------------------- 1 file changed, 25 insertions(+), 19 deletions(-) diff --git a/receiver/src/ft.cpp b/receiver/src/ft.cpp index 2107d32..bd8ae56 100644 --- a/receiver/src/ft.cpp +++ b/receiver/src/ft.cpp @@ -310,6 +310,27 @@ void accept_file() file_on_progress = TRUE; } +static int _create_thumbnail_directory() +{ + char thumb_path[PATH_MAX]; + char *data_path = NULL; + data_path = app_get_shared_data_path(); + sprintf(thumb_path, "%s/thumbnail", data_path); + + if (data_path) + free(data_path); + + if (access(thumb_path, F_OK) == 0) + return 0; + + if (mkdir(thumb_path, 0755) == -1) { + LOGE("directory create error"); + return -1; + } + + return 0; +} + bool request_sticker_data(const char *mode, const char *category, const char *type) { bool result = false; @@ -334,6 +355,9 @@ bool request_sticker_data(const char *mode, const char *category, const char *ty return false; } + if (_create_thumbnail_directory() != 0) + LOGE("Failed to create thumbnail directory"); + json_object_set_string_member(j_object, "msgId", STICKER_SYNC_START_REQ); json_object_set_int_member(j_object, "tID", ++t_id); json_object_set_string_member(j_object, "mode", mode); @@ -358,19 +382,6 @@ bool request_sticker_data(const char *mode, const char *category, const char *ty return result; } -static int _create_directory(const char *path) -{ - if (access(path, F_OK) == 0) - return 0; - - if (mkdir(path, 0755) == -1) { - LOGE("directory create error"); - return -1; - } - - return 0; -} - void request_sticker_feature() { JsonObject *j_object = NULL; @@ -398,12 +409,7 @@ void request_sticker_feature() json_object_unref(j_object); - char thumb_path[PATH_MAX]; - char *data_path = NULL; - data_path = app_get_shared_data_path(); - sprintf(thumb_path, "%s/thumbnail", data_path); - - if (_create_directory(thumb_path) != 0) + if (_create_thumbnail_directory() != 0) LOGE("Failed to create thumbnail directory"); } -- 2.7.4 From ad2fc40b24e573ccad6100eadda380686210b63b Mon Sep 17 00:00:00 2001 From: InHong Han Date: Wed, 1 Apr 2020 20:07:16 +0900 Subject: [PATCH 03/16] Add a new message to notify disconnection Change-Id: Ia65b927b18b0722f74b555039f8eea70b3cc973a --- receiver/inc/ft.h | 1 + receiver/src/ft.cpp | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/receiver/inc/ft.h b/receiver/inc/ft.h index 0a022a6..c20f0af 100644 --- a/receiver/inc/ft.h +++ b/receiver/inc/ft.h @@ -32,5 +32,6 @@ void deinitialize_sap(void); bool request_sticker_data(const char *mode, const char *category, const char *type); void request_sticker_feature(); +void send_disconnect_message(); #endif /* __FT_H__ */ diff --git a/receiver/src/ft.cpp b/receiver/src/ft.cpp index bd8ae56..3e78566 100644 --- a/receiver/src/ft.cpp +++ b/receiver/src/ft.cpp @@ -53,6 +53,7 @@ #define STICKER_SEND_FACE_DATA "sticker-send-face-data" #define STICKER_SEND_STOP_REQ "sticker-send-stop-req" #define STICKER_SEND_STOP_RSP "sticker-send-stop-rsp" +#define STICKER_SEND_DISCONNECT_REQ "sticker-send-disconnect-req" #ifndef VCONFKEY_STICKER_SYNC_COMPLETE_DONE #define VCONFKEY_STICKER_SYNC_COMPLETE_DONE 0x1 @@ -413,6 +414,25 @@ void request_sticker_feature() LOGE("Failed to create thumbnail directory"); } +void send_disconnect_message() +{ + JsonObject *j_object = NULL; + j_object = json_object_new(); + if (j_object == NULL) { + LOGE("json object create error"); + return; + } + + json_object_set_string_member(j_object, "msgId", STICKER_SEND_DISCONNECT_REQ); + json_object_set_int_member(j_object, "tID", t_id); + + if (_send_json_data(j_object) == FALSE) { + LOGE("Failed to send STICKER_SEND_DISCONNECT_REQ"); + } + + json_object_unref(j_object); +} + void reject_file() { int ret = sap_file_transfer_reject(priv_data.file_socket); @@ -556,6 +576,7 @@ on_data_received(sap_socket_h socket, unsigned short int channel_id, unsigned in #endif if (!process_request_queue()) { + send_disconnect_message(); service_app_exit(); } } else if (msg_id == STICKER_SYNC_START_RSP) { @@ -583,6 +604,7 @@ on_data_received(sap_socket_h socket, unsigned short int channel_id, unsigned in if (result_code != SYNC_START_RSP_SUCCESS) { set_sync_progressing(FALSE); if (!process_request_queue()) { + send_disconnect_message(); service_app_exit(); } } @@ -706,6 +728,7 @@ on_data_received(sap_socket_h socket, unsigned short int channel_id, unsigned in sync_success_cnt = 0; + send_disconnect_message(); service_app_exit(); } -- 2.7.4 From 9d81c1b5c72767c6d6f5e5790873e5ac52a8e0ce Mon Sep 17 00:00:00 2001 From: InHong Han Date: Wed, 1 Apr 2020 20:57:23 +0900 Subject: [PATCH 04/16] Update package version to 0.1.28 Change-Id: If9aedf6f19d93d39999e5657be47d564b5c9b5c3 --- packaging/capi-ui-sticker.spec | 2 +- receiver/tizen-manifest.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packaging/capi-ui-sticker.spec b/packaging/capi-ui-sticker.spec index 69d6aab..6ef42ef 100644 --- a/packaging/capi-ui-sticker.spec +++ b/packaging/capi-ui-sticker.spec @@ -1,6 +1,6 @@ Name: capi-ui-sticker Summary: Sticker client library and daemon -Version: 0.1.27 +Version: 0.1.28 Release: 1 Group: Graphics & UI Framework/Input License: Apache-2.0 diff --git a/receiver/tizen-manifest.xml b/receiver/tizen-manifest.xml index ec008e2..681a2d8 100644 --- a/receiver/tizen-manifest.xml +++ b/receiver/tizen-manifest.xml @@ -1,5 +1,5 @@ - + -- 2.7.4 From 3659b65996dd95b449879d61d0421c6e4987d2ca Mon Sep 17 00:00:00 2001 From: InHong Han Date: Thu, 2 Apr 2020 10:24:12 +0900 Subject: [PATCH 05/16] Fix issues detected by static analysis tool Change-Id: Ifcb7aa13ba2158b11687d77c04a3fdea6fe69219 --- sticker-parser/sticker-parser.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/sticker-parser/sticker-parser.c b/sticker-parser/sticker-parser.c index 2c3eb73..21debd2 100644 --- a/sticker-parser/sticker-parser.c +++ b/sticker-parser/sticker-parser.c @@ -543,7 +543,7 @@ static int __get_sticker_info_from_json(const char *appid, const char *file_path char *uri = NULL; char *group = NULL; char *description = NULL; - char *thumbnail = NULL; + char *thumbnail_path = NULL; char *uri_path = NULL; parser = json_parser_new(); @@ -598,10 +598,10 @@ static int __get_sticker_info_from_json(const char *appid, const char *file_path if (!group) goto free_memory; - thumbnail = __get_string_from_object(info_object, "thumbnail"); - if (thumbnail) { - free(thumbnail); - thumbnail = __convert_sticker_uri(thumbnail, appid, app_path); + char *rel_thumbnail = __get_string_from_object(info_object, "thumbnail"); + if (rel_thumbnail) { + thumbnail_path = __convert_sticker_uri(rel_thumbnail, appid, app_path); + free(rel_thumbnail); } description = __get_string_from_object(info_object, "description"); @@ -617,7 +617,7 @@ static int __get_sticker_info_from_json(const char *appid, const char *file_path char *new_uri = __convert_sticker_uri(uri, appid, app_path); if (!new_uri) goto free_memory; - __insert_sticker_info(appid, type, new_uri, group, thumbnail, description, disp_type); + __insert_sticker_info(appid, type, new_uri, group, thumbnail_path, description, disp_type); if (new_uri) { free(new_uri); @@ -643,7 +643,7 @@ static int __get_sticker_info_from_json(const char *appid, const char *file_path uri_path = NULL; goto free_memory; } - __insert_sticker_info(appid, type, new_uri, group, thumbnail, description, disp_type); + __insert_sticker_info(appid, type, new_uri, group, thumbnail_path, description, disp_type); free(new_uri); new_uri = NULL; @@ -658,7 +658,7 @@ static int __get_sticker_info_from_json(const char *appid, const char *file_path } } } else { - __insert_sticker_info(appid, type, uri, group, thumbnail, description, disp_type); + __insert_sticker_info(appid, type, uri, group, thumbnail_path, description, disp_type); } for (int j = 0; j < keyword_arr_len; j++) { @@ -676,9 +676,9 @@ free_memory: group = NULL; } - if (thumbnail) { - free(thumbnail); - thumbnail = NULL; + if (thumbnail_path) { + free(thumbnail_path); + thumbnail_path = NULL; } if (description) { -- 2.7.4 From e4582b9f1c8d1cb3bb0aa388ca5137ec44b1cdf3 Mon Sep 17 00:00:00 2001 From: Jihoon Kim Date: Thu, 2 Apr 2020 10:26:57 +0900 Subject: [PATCH 06/16] Fix issue detected by static analysis tool Dereference null return value (NULL_RETURNS) dereference: Dereferencing a pointer that might be null conv_path when calling snprintf. Change-Id: I47cfa1bded3b313a2fb982c5975a2e7a79f3a83c Signed-off-by: Jihoon Kim --- client/sticker_dbus.c | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/client/sticker_dbus.c b/client/sticker_dbus.c index 318782b..5460c71 100644 --- a/client/sticker_dbus.c +++ b/client/sticker_dbus.c @@ -690,11 +690,12 @@ int sticker_dbus_update_sticker_info(GDBusConnection *gdbus_connection, sticker_ if (sticker_data->type == STICKER_DATA_URI_LOCAL_PATH) { len = strlen(STICKER_DIRECTORY) + strlen(sticker_data->app_id) + strlen(sticker_data->uri) + 2; conv_path = (char *)calloc(len, sizeof(char)); - snprintf(conv_path, len, "%s/%s%s", STICKER_DIRECTORY, sticker_data->app_id, sticker_data->uri); + if (conv_path) + snprintf(conv_path, len, "%s/%s%s", STICKER_DIRECTORY, sticker_data->app_id, sticker_data->uri); } else conv_path = strdup(sticker_data->uri); - if (strcmp(conv_path, origin_data->uri) != 0) { + if (conv_path && (strcmp(conv_path, origin_data->uri) != 0)) { LOGD("origin_uri : %s, new_uri : %s", origin_data->uri, conv_path); int is_exist = 0; ret = _send_sync_message(gdbus_connection, g_variant_new("(s)", sticker_data->uri), &reply, "check_file_exists"); @@ -736,17 +737,21 @@ int sticker_dbus_update_sticker_info(GDBusConnection *gdbus_connection, sticker_ if (sticker_data->thumbnail) { int len = strlen(STICKER_DIRECTORY) + strlen(sticker_data->app_id) + strlen(sticker_data->thumbnail) + 2; char *conv_path = (char *)calloc(len, sizeof(char)); - snprintf(conv_path, len, "%s/%s%s", STICKER_DIRECTORY, sticker_data->app_id, sticker_data->thumbnail); - if (strcmp(conv_path, origin_data->thumbnail) != 0) { - LOGD("origin_thumbnail : %s, new_thumbnail : %s", origin_data->thumbnail, conv_path); - ret = _send_sync_message(gdbus_connection, g_variant_new("(iss)", sticker_data->sticker_info_id, sticker_data->app_id, sticker_data->thumbnail), &reply, "update_sticker_thumbnail"); - if (ret != STICKER_CLIENT_ERROR_NONE) { - LOGE("failed to update sticker thumbnail"); - free(conv_path); - goto cleanup; + if (conv_path) { + snprintf(conv_path, len, "%s/%s%s", STICKER_DIRECTORY, sticker_data->app_id, sticker_data->thumbnail); + if (strcmp(conv_path, origin_data->thumbnail) != 0) + { + LOGD("origin_thumbnail : %s, new_thumbnail : %s", origin_data->thumbnail, conv_path); + ret = _send_sync_message(gdbus_connection, g_variant_new("(iss)", sticker_data->sticker_info_id, sticker_data->app_id, sticker_data->thumbnail), &reply, "update_sticker_thumbnail"); + if (ret != STICKER_CLIENT_ERROR_NONE) + { + LOGE("failed to update sticker thumbnail"); + free(conv_path); + goto cleanup; + } } + free(conv_path); } - free(conv_path); } if (sticker_data->description && strcmp(sticker_data->description, origin_data->description) != 0) { -- 2.7.4 From f039d017f8e39e00463789e74196cb11a074051d Mon Sep 17 00:00:00 2001 From: InHong Han Date: Thu, 2 Apr 2020 10:58:28 +0900 Subject: [PATCH 07/16] Remove unnecessary variable Change-Id: I8e745998dfe86181d30f7ac995081c448dff05f4 --- sticker-parser/sticker-parser.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/sticker-parser/sticker-parser.c b/sticker-parser/sticker-parser.c index 21debd2..86ebd3e 100644 --- a/sticker-parser/sticker-parser.c +++ b/sticker-parser/sticker-parser.c @@ -348,21 +348,17 @@ cleanup: return ret; } -static char* __convert_sticker_uri(const char *uri, const char *appid, const char *app_path) +static char* __convert_sticker_uri(char *uri, const char *appid, const char *app_path) { int ret; - char *rel_path = strdup(uri); - __remove_app_path(rel_path, app_path); - int len = strlen(STICKER_DIRECTORY) + strlen(appid) + strlen(rel_path) + 2; + __remove_app_path(uri, app_path); + int len = strlen(STICKER_DIRECTORY) + strlen(appid) + strlen(uri) + 2; char *new_path = (char *)calloc(len, sizeof(char)); - if (new_path == NULL) { - free(rel_path); - rel_path = NULL; + if (new_path == NULL) return NULL; - } - snprintf(new_path, len, "%s/%s%s",STICKER_DIRECTORY, appid, rel_path); + snprintf(new_path, len, "%s/%s%s",STICKER_DIRECTORY, appid, uri); if (access(new_path, F_OK) == 0) { LOGE("sticker file already exists"); @@ -393,9 +389,6 @@ static char* __convert_sticker_uri(const char *uri, const char *appid, const cha LOGE("failed to change ownership"); cleanup: - free(rel_path); - rel_path = NULL; - if (ret == 0) { return new_path; } else { -- 2.7.4 From 932ccfe230aafd5b4a70b539d1fa9ef05e2b9cc9 Mon Sep 17 00:00:00 2001 From: Jihoon Kim Date: Thu, 2 Apr 2020 19:04:03 +0900 Subject: [PATCH 08/16] Update package version to 0.1.29 Change-Id: I4129f447e8872be19cf71a0dfd96aa445e9e5530 Signed-off-by: Jihoon Kim --- packaging/capi-ui-sticker.spec | 2 +- receiver/tizen-manifest.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packaging/capi-ui-sticker.spec b/packaging/capi-ui-sticker.spec index 6ef42ef..8f3c329 100644 --- a/packaging/capi-ui-sticker.spec +++ b/packaging/capi-ui-sticker.spec @@ -1,6 +1,6 @@ Name: capi-ui-sticker Summary: Sticker client library and daemon -Version: 0.1.28 +Version: 0.1.29 Release: 1 Group: Graphics & UI Framework/Input License: Apache-2.0 diff --git a/receiver/tizen-manifest.xml b/receiver/tizen-manifest.xml index 681a2d8..3467ca4 100644 --- a/receiver/tizen-manifest.xml +++ b/receiver/tizen-manifest.xml @@ -1,5 +1,5 @@ - + -- 2.7.4 From 474e1a94341e3cddf32569807f940a978d0eed4e Mon Sep 17 00:00:00 2001 From: Jihoon Kim Date: Thu, 2 Apr 2020 19:16:57 +0900 Subject: [PATCH 09/16] Rename internal function name Change-Id: I6ab09f08590dd242c1bee3b48d62ae16f73260e3 Signed-off-by: Jihoon Kim --- receiver/src/ft.cpp | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/receiver/src/ft.cpp b/receiver/src/ft.cpp index 3e78566..2541bec 100644 --- a/receiver/src/ft.cpp +++ b/receiver/src/ft.cpp @@ -165,10 +165,10 @@ static void notify_sync_progress(unsigned int file_progress) send_message("sync_progress", NULL); } -static void _on_send_completed(sap_file_transaction_h file_transaction, - sap_ft_transfer_e result, - const char *file_path, - void *user_data) +static void _on_transfer_completed(sap_file_transaction_h file_transaction, + sap_ft_transfer_e result, + const char *file_path, + void *user_data) { if (priv_data.file_socket) { sap_file_transfer_destroy(file_transaction); @@ -265,9 +265,9 @@ static void _on_send_completed(sap_file_transaction_h file_transaction, sticker_data.reset(); } -static void _on_sending_file_in_progress(sap_file_transaction_h file_transaction, - unsigned short int percentage_progress, - void *user_data) +static void _on_transfer_file_in_progress(sap_file_transaction_h file_transaction, + unsigned short int percentage_progress, + void *user_data) { notify_sync_progress(percentage_progress); } @@ -275,9 +275,9 @@ static void _on_sending_file_in_progress(sap_file_transaction_h file_transaction static void __set_file_transfer_cb(sap_file_transaction_h file_socket) { LOGI("# set callbacks"); - sap_file_transfer_set_progress_cb(file_socket, _on_sending_file_in_progress, NULL); + sap_file_transfer_set_progress_cb(file_socket, _on_transfer_file_in_progress, NULL); - sap_file_transfer_set_done_cb(file_socket, _on_send_completed, NULL); + sap_file_transfer_set_done_cb(file_socket, _on_transfer_completed, NULL); } void accept_file() @@ -441,10 +441,10 @@ void reject_file() file_on_progress = FALSE; } -static void _on_receive_file_cb(sap_peer_agent_h peer_agent_h, - sap_file_transaction_h socket, - const char *file_path, - void *user_data) +static void _on_transfer_file_cb(sap_peer_agent_h peer_agent_h, + sap_file_transaction_h socket, + const char *file_path, + void *user_data) { file_on_progress = TRUE; priv_data.file_socket = socket; @@ -927,7 +927,7 @@ static void on_agent_initialized(sap_agent_h agent, priv_data.agent = agent; - sap_file_transfer_set_incoming_file_cb(agent, _on_receive_file_cb, NULL); + sap_file_transfer_set_incoming_file_cb(agent, _on_transfer_file_cb, NULL); sap_agent_set_service_connection_requested_cb(agent, on_conn_req, NULL); break; -- 2.7.4 From 965796b7cb2aa923a11553cf981ac24c564bdc72 Mon Sep 17 00:00:00 2001 From: Jihoon Kim Date: Mon, 6 Apr 2020 18:27:47 +0900 Subject: [PATCH 10/16] Add the way to notify through event publish Change-Id: Ie2c4ee63ddfa278b65fd775d813814934350795d Signed-off-by: Jihoon Kim --- packaging/capi-ui-sticker.spec | 1 + receiver/CMakeLists.txt | 1 + receiver/src/message.cpp | 38 ++++++++++++++++++++++++++++---------- 3 files changed, 30 insertions(+), 10 deletions(-) diff --git a/packaging/capi-ui-sticker.spec b/packaging/capi-ui-sticker.spec index 8f3c329..3ad6b90 100644 --- a/packaging/capi-ui-sticker.spec +++ b/packaging/capi-ui-sticker.spec @@ -11,6 +11,7 @@ Source3: capi-ui-sticker.conf BuildRequires: cmake, coreutils BuildRequires: pkgconfig(capi-appfw-app-common) BuildRequires: pkgconfig(capi-appfw-package-manager) +BuildRequires: pkgconfig(capi-appfw-event) BuildRequires: pkgconfig(capi-system-info) BuildRequires: pkgconfig(cynara-client) BuildRequires: pkgconfig(cynara-session) diff --git a/receiver/CMakeLists.txt b/receiver/CMakeLists.txt index 49b6d42..d415064 100644 --- a/receiver/CMakeLists.txt +++ b/receiver/CMakeLists.txt @@ -18,6 +18,7 @@ pkg_check_modules(pkgs_test REQUIRED capi-message-port capi-appfw-app-common capi-appfw-alarm + capi-appfw-event capi-system-device sap-client-stub-api json-glib-1.0 diff --git a/receiver/src/message.cpp b/receiver/src/message.cpp index 0ca7d32..79b04fd 100644 --- a/receiver/src/message.cpp +++ b/receiver/src/message.cpp @@ -15,11 +15,14 @@ */ #include +#include #include "message.h" #include "log.h" #include "config.h" +#define EVENT_NAME "event.org.tizen.sticker-receiver.user_event" + static int port_id = -1; bool message_sink_init(message_port_message_cb callback, void *user_data) @@ -62,24 +65,39 @@ bool send_message(const char *cmd, const char *data) LOGD("command: %s, data: %s", cmd, data); - message_port_check_remote_port(REMOTE_APP_ID, MESSAGE_PORT_REMOTE_NAME, &found); - if (!found) { - LOGW("Can't find remote port"); - return false; - } - bundle *b = bundle_create(); bundle_add_str(b, "command", cmd); if (data) bundle_add_str(b, "data", data); - ret = message_port_send_message(REMOTE_APP_ID, MESSAGE_PORT_REMOTE_NAME, b); - if (ret != MESSAGE_PORT_ERROR_NONE) { - LOGW("message port send message error. err : %d", ret); + + message_port_check_remote_port(REMOTE_APP_ID, MESSAGE_PORT_REMOTE_NAME, &found); + if (found) { + ret = message_port_send_message(REMOTE_APP_ID, MESSAGE_PORT_REMOTE_NAME, b); + if (ret != MESSAGE_PORT_ERROR_NONE) + { + LOGW("message port send message error. err : %d", ret); + result = false; + } + else + { + LOGI("Succeed to send message."); + result = true; + } + } + else + { + LOGW("Can't find remote port"); + result = false; + } + + ret = event_publish_app_event(EVENT_NAME, b); + if (ret != EVENT_ERROR_NONE) { result = false; + LOGE("Failed to send message by event publish. error : %d", ret); } else { - LOGI("Succeed to send message."); + LOGD("Succeed to send message through event publish"); result = true; } -- 2.7.4 From 808dfe7d2d6a87378e7356f683595c27660cc816 Mon Sep 17 00:00:00 2001 From: Jihoon Kim Date: Mon, 6 Apr 2020 20:16:18 +0900 Subject: [PATCH 11/16] Update package version to 0.1.30 Change-Id: Icbdff6b4da025a510e140519c4243ec194954fd8 Signed-off-by: Jihoon Kim --- packaging/capi-ui-sticker.spec | 2 +- receiver/tizen-manifest.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packaging/capi-ui-sticker.spec b/packaging/capi-ui-sticker.spec index 3ad6b90..377419e 100644 --- a/packaging/capi-ui-sticker.spec +++ b/packaging/capi-ui-sticker.spec @@ -1,6 +1,6 @@ Name: capi-ui-sticker Summary: Sticker client library and daemon -Version: 0.1.29 +Version: 0.1.30 Release: 1 Group: Graphics & UI Framework/Input License: Apache-2.0 diff --git a/receiver/tizen-manifest.xml b/receiver/tizen-manifest.xml index 3467ca4..0765a66 100644 --- a/receiver/tizen-manifest.xml +++ b/receiver/tizen-manifest.xml @@ -1,5 +1,5 @@ - + -- 2.7.4 From 592e29fcfcd0e9d50b47aeb86f474a6b77f3e239 Mon Sep 17 00:00:00 2001 From: Jihoon Kim Date: Tue, 7 Apr 2020 09:25:45 +0900 Subject: [PATCH 12/16] Remove unused functions Change-Id: I71e4ad9659a4eb8a15b9663969397c2690abec43 Signed-off-by: Jihoon Kim --- receiver/inc/message.h | 2 -- receiver/src/message.cpp | 34 ---------------------------------- 2 files changed, 36 deletions(-) diff --git a/receiver/inc/message.h b/receiver/inc/message.h index 791a9aa..597ee7a 100644 --- a/receiver/inc/message.h +++ b/receiver/inc/message.h @@ -20,8 +20,6 @@ #ifndef __MESSAGE_H__ #define __MESSAGE_H__ -bool message_sink_init(message_port_message_cb callback, void *user_data); -void message_sink_shutdown(void); bool send_message(const char *cmd, const char *data); #endif /* __MESSAGE_H__ */ diff --git a/receiver/src/message.cpp b/receiver/src/message.cpp index 79b04fd..e1c4689 100644 --- a/receiver/src/message.cpp +++ b/receiver/src/message.cpp @@ -23,40 +23,6 @@ #define EVENT_NAME "event.org.tizen.sticker-receiver.user_event" -static int port_id = -1; - -bool message_sink_init(message_port_message_cb callback, void *user_data) -{ - port_id = message_port_register_local_port(MESSAGE_PORT_REMOTE_NAME, callback, user_data); - if (port_id < 0) - { - LOGW("Function message_port_register_local_port() failed."); - return false; - } - - return true; -} - -void message_sink_shutdown(void) -{ - int ret; - bool exists = false; - - port_id = -1; - - ret = message_port_check_remote_port(REMOTE_APP_ID, MESSAGE_PORT_REMOTE_NAME, &exists); - if (exists) - { - ret = message_port_unregister_local_port(port_id); - if (ret != MESSAGE_PORT_ERROR_NONE) - LOGE("Function message_port_unregister_local_port() failed."); - } - else if (ret != MESSAGE_PORT_ERROR_NONE) - { - LOGE("Function message_port_check_remote_port() failed."); - } -} - bool send_message(const char *cmd, const char *data) { bool result = false; -- 2.7.4 From fd25e5acd6236e6845379036742c6ad9521befb5 Mon Sep 17 00:00:00 2001 From: Jihoon Kim Date: Fri, 27 Mar 2020 19:38:13 +0900 Subject: [PATCH 13/16] Wake up and send sync request when charging Change-Id: Iedf39ef144311eac828479f2a9d716bf82b7089e Signed-off-by: Jihoon Kim --- packaging/capi-ui-sticker.spec | 3 +- receiver/CMakeLists.txt | 4 +- receiver/inc/config.h | 3 +- receiver/inc/ft.h | 4 + receiver/inc/sync_alarm.h | 27 ------- receiver/src/ft.cpp | 79 ++++++++++++++++--- receiver/src/main.cpp | 171 +++++++++++++++++++++++++++-------------- receiver/src/sync_alarm.cpp | 108 -------------------------- receiver/tizen-manifest.xml | 4 + 9 files changed, 197 insertions(+), 206 deletions(-) delete mode 100644 receiver/inc/sync_alarm.h delete mode 100644 receiver/src/sync_alarm.cpp diff --git a/packaging/capi-ui-sticker.spec b/packaging/capi-ui-sticker.spec index 377419e..7d6cc1d 100644 --- a/packaging/capi-ui-sticker.spec +++ b/packaging/capi-ui-sticker.spec @@ -29,11 +29,12 @@ BuildRequires: pkgconfig(sqlite3) BuildRequires: pkgconfig(capi-base-common) BuildRequires: pkgconfig(capi-appfw-service-application) BuildRequires: pkgconfig(capi-message-port) -BuildRequires: pkgconfig(capi-appfw-alarm) +BuildRequires: pkgconfig(capi-appfw-preference) BuildRequires: pkgconfig(capi-system-device) BuildRequires: pkgconfig(sap-client-stub-api) BuildRequires: pkgconfig(vconf) BuildRequires: pkgconfig(capi-media-thumbnail-util) +BuildRequires: pkgconfig(ecore) BuildRequires: hash-signer Requires(post): signing-client diff --git a/receiver/CMakeLists.txt b/receiver/CMakeLists.txt index d415064..c9f9fc4 100644 --- a/receiver/CMakeLists.txt +++ b/receiver/CMakeLists.txt @@ -7,7 +7,6 @@ SET(SRCS src/ft.cpp src/sticker_info.cpp src/message.cpp - src/sync_alarm.cpp ) INCLUDE(FindPkgConfig) @@ -17,13 +16,14 @@ pkg_check_modules(pkgs_test REQUIRED capi-appfw-service-application capi-message-port capi-appfw-app-common - capi-appfw-alarm capi-appfw-event + capi-appfw-preference capi-system-device sap-client-stub-api json-glib-1.0 vconf capi-media-thumbnail-util + ecore ) INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR}/receiver/inc) diff --git a/receiver/inc/config.h b/receiver/inc/config.h index 454bd5d..10b742f 100644 --- a/receiver/inc/config.h +++ b/receiver/inc/config.h @@ -20,8 +20,7 @@ #define ACCESSORY_SERVICE_PROFILE_ID "/sample/filetransfersender" #define ACCESSORY_SERVICE_CHANNEL_ID 107 -#define SYNC_ALARM_DELAY 0 -#define SYNC_ALARM_INTERVAL 12*60*60 +#define SYNC_INTERVAL 12*60*60 #define REMOTE_APP_ID "com.samsung.w-input-selector" #define MESSAGE_PORT_REMOTE_NAME REMOTE_APP_ID"_msg_port_rcv" diff --git a/receiver/inc/ft.h b/receiver/inc/ft.h index c20f0af..90d506f 100644 --- a/receiver/inc/ft.h +++ b/receiver/inc/ft.h @@ -29,9 +29,13 @@ void reject_file(void); void accept_file(void); gboolean initialize_sap(void); void deinitialize_sap(void); +gboolean is_init_sap(); +void request_all_sticker_data(const char *mode, const char *type); bool request_sticker_data(const char *mode, const char *category, const char *type); void request_sticker_feature(); void send_disconnect_message(); +bool get_job_progress(); + #endif /* __FT_H__ */ diff --git a/receiver/inc/sync_alarm.h b/receiver/inc/sync_alarm.h deleted file mode 100644 index 8f025ca..0000000 --- a/receiver/inc/sync_alarm.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include - -#ifndef __ALARM_H__ -#define __ALARM_H__ - -#define APP_CONTROL_OPERATION_SYNC_ALARM "http://tizen.org/appcontrol/operation/sticker_sync_alarm" - -bool sync_alarm_register(const char *operation, int delay, int period); -bool sync_alarm_exist(); - -#endif /* __ALARM_H__ */ diff --git a/receiver/src/ft.cpp b/receiver/src/ft.cpp index 2541bec..aaef4c3 100644 --- a/receiver/src/ft.cpp +++ b/receiver/src/ft.cpp @@ -33,6 +33,8 @@ #include #include #include +#include +#include #include "ft.h" #include "log.h" @@ -40,8 +42,8 @@ #include "../inc/sticker_data.h" #include "sticker_request.h" #include "message.h" -#include "sync_alarm.h" #include "config.h" +#include "receiver_preference.h" #define STICKER_SYNC_FEATURE_REQ "sticker-sync-feature-req" #define STICKER_SYNC_FEATURE_RSP "sticker-sync-feature-rsp" @@ -84,20 +86,37 @@ static int t_id = 0; static int rec_file_cnt_in_group = 0; static int total_file_count_in_group = 0; static int sync_success_cnt = 0; +static gboolean job_progress = FALSE; -static void set_first_sync_complete() +static void save_last_sync_time() +{ + // save last sync time in preference + double current_time = ecore_time_get(); + if (preference_set_double(LAST_SYNC_TIME, current_time) == PREFERENCE_ERROR_NONE) { + LOGI("Succeed to set last sync time : %f", current_time); + } + else { + LOGW("Failed to set last sync time"); + } +} + +static void set_sync_complete() { int complete_flags = 0; if (vconf_get_int(VCONFKEY_STICKER_SYNC_COMPLETE, &complete_flags) == 0 && complete_flags == 0) { + // first sync if (vconf_set_int(VCONFKEY_STICKER_SYNC_COMPLETE, VCONFKEY_STICKER_SYNC_COMPLETE_DONE) == 0) LOGD("Succeed to set sync complete"); else LOGW("Fail to set sync complete"); } + + save_last_sync_time(); } static void set_sync_progressing(gboolean flag) { + job_progress = flag; #ifdef VCONFKEY_STICKER_SYNC_STATE LOGD("sync progressing : %d", flag); if (vconf_set_int(VCONFKEY_STICKER_SYNC_STATE, flag ? VCONFKEY_STICKER_SYNC_STATE_IN_PROGRESS : VCONFKEY_STICKER_SYNC_STATE_WAITING) == 0) @@ -280,6 +299,11 @@ static void __set_file_transfer_cb(sap_file_transaction_h file_socket) sap_file_transfer_set_done_cb(file_socket, _on_transfer_completed, NULL); } +bool get_job_progress() +{ + return job_progress; +} + void accept_file() { int ret; @@ -338,6 +362,7 @@ bool request_sticker_data(const char *mode, const char *category, const char *ty JsonObject *j_object = NULL; if (!priv_data.socket) { + job_progress = TRUE; StickerRequest pending_request; pending_request.req_type = REQUEST_TYPE_SYNC; pending_request.mode = string(mode ? mode : "manual"); @@ -383,11 +408,32 @@ bool request_sticker_data(const char *mode, const char *category, const char *ty return result; } +void request_all_sticker_data(const char *mode, const char *type) +{ +#ifdef VCONFKEY_STICKER_SUPPORTED_FEATURE + int feature_flag = 0; + if (vconf_get_int(VCONFKEY_STICKER_SUPPORTED_FEATURE, &feature_flag) == 0) + { + if (feature_flag & VCONFKEY_STICKER_FEATURE_AREMOJI) + request_sticker_data(mode, "arsticker", type); + + if (feature_flag & VCONFKEY_STICKER_FEATURE_BITMOJI) + request_sticker_data(mode, "bitmoji", type); + } + else + LOGW("Failed to get value of VCONFKEY_STICKER_SUPPORTED_FEATURE"); +#else + request_sticker_data(mode, "arsticker", type); + request_sticker_data(mode, "bitmoji", type); +#endif +} + void request_sticker_feature() { JsonObject *j_object = NULL; if (!priv_data.socket) { + job_progress = TRUE; StickerRequest pending_request; pending_request.req_type = REQUEST_TYPE_FEATURE_REQ; ReqQueue.push(pending_request); @@ -407,6 +453,9 @@ void request_sticker_feature() if (_send_json_data(j_object) == FALSE) { LOGE("Failed to send STICKER_SYNC_FEATURE_REQ"); } + else { + job_progress = TRUE; + } json_object_unref(j_object); @@ -576,6 +625,7 @@ on_data_received(sap_socket_h socket, unsigned short int channel_id, unsigned in #endif if (!process_request_queue()) { + job_progress = FALSE; send_disconnect_message(); service_app_exit(); } @@ -604,6 +654,10 @@ on_data_received(sap_socket_h socket, unsigned short int channel_id, unsigned in if (result_code != SYNC_START_RSP_SUCCESS) { set_sync_progressing(FALSE); if (!process_request_queue()) { + if (result_code == SYNC_START_RSP_NO_STICKER) + save_last_sync_time(); + + job_progress = FALSE; send_disconnect_message(); service_app_exit(); } @@ -689,7 +743,7 @@ on_data_received(sap_socket_h socket, unsigned short int channel_id, unsigned in { if (current_request.category == string("arsticker")) { - set_first_sync_complete(); + set_sync_complete(); set_sync_progressing(FALSE); } } @@ -697,7 +751,7 @@ on_data_received(sap_socket_h socket, unsigned short int channel_id, unsigned in { if (current_request.category == string("bitmoji")) { - set_first_sync_complete(); + set_sync_complete(); set_sync_progressing(FALSE); } } @@ -721,13 +775,9 @@ on_data_received(sap_socket_h socket, unsigned short int channel_id, unsigned in send_message("sync_stop_result", reason.c_str()); if (!process_request_queue()) { - if (sync_success_cnt > 0 && current_request.mode == string("manual")) { - if (!sync_alarm_exist()) - sync_alarm_register(APP_CONTROL_OPERATION_SYNC_ALARM, SYNC_ALARM_DELAY, SYNC_ALARM_INTERVAL); - } - sync_success_cnt = 0; + job_progress = FALSE; send_disconnect_message(); service_app_exit(); } @@ -1012,6 +1062,11 @@ gboolean initialize_sap(void) { sap_agent_h agent = NULL; + if (priv_data.agent) { + LOGW("duplicate initialize"); + return FALSE; + } + sap_agent_create(&agent); priv_data.agent = agent; @@ -1025,6 +1080,7 @@ gboolean initialize_sap(void) void deinitialize_sap(void) { + LOGD("deinitialize"); if (priv_data.agent) { int ret = sap_agent_deinitialize(priv_data.agent, on_agent_deinitialized, NULL); switch (ret) { @@ -1046,3 +1102,8 @@ void deinitialize_sap(void) priv_data.agent = NULL; } } + +gboolean is_init_sap() +{ + return priv_data.agent ? TRUE : FALSE; +} \ No newline at end of file diff --git a/receiver/src/main.cpp b/receiver/src/main.cpp index aa65584..2006985 100644 --- a/receiver/src/main.cpp +++ b/receiver/src/main.cpp @@ -17,15 +17,20 @@ #include #include #include -#include +#include #include #include +#include +#include +#include #include "main.h" #include "ft.h" #include "log.h" #include "config.h" -#include "sync_alarm.h" +#include "receiver_preference.h" + +using namespace std; static bool app_create(void *data) { @@ -34,11 +39,66 @@ static bool app_create(void *data) If this function returns true, the main loop of application starts If this function returns false, the application is terminated */ - initialize_sap(); + LOGD(""); return true; } +static bool check_battery_condition() +{ + int battery_percentage = 0; + int ret; + + // check battery percentage + ret = device_battery_get_percent(&battery_percentage); + if (ret != DEVICE_ERROR_NONE) + { + LOGW("No sync. Failed to get battery percent. error : %d", ret); + return false; + } + + LOGI("battery percent : %d", battery_percentage); + if (battery_percentage >= MINIMUM_BATTERY) + return true; + else + { + LOGI("No sync due to insufficient battery"); + return false; + } +} + +static bool check_sync_time_condition() +{ + double last_sync_time; + int feature_flag = 0; + bool result = false; + +#ifdef VCONFKEY_STICKER_SUPPORTED_FEATURE + // Check whether oobe has been done + if (vconf_get_int(VCONFKEY_STICKER_SUPPORTED_FEATURE, &feature_flag) == 0 && feature_flag > 0) + { + if (preference_get_double(LAST_SYNC_TIME, &last_sync_time) != PREFERENCE_ERROR_NONE) + { + LOGD("Can't get last sync time."); + return true; + } + + // compare time + LOGD("current time : %f, last_sync_time : %f", ecore_time_get(), last_sync_time); + if (ecore_time_get() - last_sync_time > SYNC_INTERVAL) + result = true; + else + result = false; + } + else + { + result = false; + } +#endif /* VCONFKEY_STICKER_SUPPORTED_FEATURE */ + + return result; +} + static void app_control(app_control_h app_control, void *data) { /* Handle the launch request. */ @@ -46,53 +106,56 @@ static void app_control(app_control_h app_control, void *data) char* mode = NULL; char* type = NULL; char* operation = NULL; - char* alarm_data = NULL; - + char* event_value = NULL; + char* uri = NULL; + const char *event_uri = "event://tizen.system.event.battery_charger_status"; int res; - int battery_percentage = 0; - bool battery_charging = false; // operation int ret = app_control_get_operation(app_control, &operation); if (ret == APP_CONTROL_ERROR_NONE) { LOGD("operation: %s", operation); - if (operation && (strncmp(operation, APP_CONTROL_OPERATION_SYNC_ALARM, strlen(APP_CONTROL_OPERATION_SYNC_ALARM)) == 0)) { - ret = app_control_get_extra_data(app_control, APP_CONTROL_DATA_ALARM_ID, &alarm_data); - if (ret != APP_CONTROL_ERROR_NONE) { - dlog_print(DLOG_ERROR, LOG_TAG, "Function app_control_get_extra_data() failed."); - goto cleanup; - } - - LOGD("alarm data : %s", alarm_data); - - int ret = device_battery_is_charging(&battery_charging); - if (ret != DEVICE_ERROR_NONE) { - LOGW("No sync. Can't get battery charging status"); - goto cleanup; - } - - if (!battery_charging) { - LOGI("No sync due to no battery charging status"); - goto cleanup; - } - - ret = device_battery_get_percent(&battery_percentage); - if (ret != DEVICE_ERROR_NONE) { - LOGW("No sync. Failed to get battery percent. error : %d", ret); - goto cleanup; - } + if (!operation) { + goto cleanup; + } - LOGI("battery percent : %d", battery_percentage); - if (battery_percentage >= MINIMUM_BATTERY) { - request_sticker_data("auto", "arsticker", "input"); - request_sticker_data("auto", "bitmoji", "input"); - } - else { - LOGI("No sync due to insufficient battery"); + if (strcmp(operation, APP_CONTROL_OPERATION_LAUNCH_ON_EVENT) == 0) + { + ret = app_control_get_uri(app_control, &uri); + if (ret == APP_CONTROL_ERROR_NONE && uri) + { + if (strncmp(uri, event_uri, strlen(event_uri) + 1) == 0) + { + ret = app_control_get_extra_data(app_control, "battery_charger_status", &event_value); + if (ret == APP_CONTROL_ERROR_NONE && event_value) + { + if (string(event_value) == "connected") + { + if (!is_init_sap()) { + if (check_sync_time_condition()) { + if (check_battery_condition()) { + initialize_sap(); + request_all_sticker_data("auto", "input"); + } + } + else { + if (!get_job_progress()) + { + LOGD("exit"); + service_app_exit(); + } + } + } + else { + LOGD("continue doing current job"); + } + } + free(event_value); + } + } + free(uri); } - - goto cleanup; } } else { @@ -119,30 +182,23 @@ static void app_control(app_control_h app_control, void *data) goto cleanup; if (mode && type) { -#ifdef VCONFKEY_STICKER_SUPPORTED_FEATURE - int feature_flag = 0; - if (vconf_get_int(VCONFKEY_STICKER_SUPPORTED_FEATURE, &feature_flag) == 0) { - if (feature_flag & VCONFKEY_STICKER_FEATURE_AREMOJI) - request_sticker_data(mode, "arsticker", type); - - if (feature_flag & VCONFKEY_STICKER_FEATURE_BITMOJI) - request_sticker_data(mode, "bitmoji", type); - } else - LOGW("Failed to get value of VCONFKEY_STICKER_SUPPORTED_FEATURE"); -#else - request_sticker_data(mode, "arsticker", type); - request_sticker_data(mode, "bitmoji", type); -#endif + if (!is_init_sap()) { + initialize_sap(); + request_all_sticker_data(mode, type); + } } } else if (strcmp(request, "oobe") == 0) { - LOGI("[OOBE] register sync alarm"); - sync_alarm_register(APP_CONTROL_OPERATION_SYNC_ALARM, SYNC_ALARM_DELAY, SYNC_ALARM_INTERVAL); + initialize_sap(); request_sticker_feature(); } else { LOGW("Unknown command : %s", request); + if (!is_init_sap()) + { + service_app_exit(); + } } } @@ -163,6 +219,7 @@ cleanup: static void app_terminate(void *data) { /* Release all resources. */ + LOGD(""); deinitialize_sap(); } diff --git a/receiver/src/sync_alarm.cpp b/receiver/src/sync_alarm.cpp deleted file mode 100644 index ec7079e..0000000 --- a/receiver/src/sync_alarm.cpp +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include - -#include "log.h" -#include "config.h" - -static int recurring_alarm_id = -1; - -static bool -on_foreach_registered_alarm(int alarm_id, void *user_data) -{ - bool *result = (bool *)user_data; - - LOGD("alarm id : %d", alarm_id); - - *result = *result | 0x1; - - return false; -} - -bool sync_alarm_register(const char *operation, int delay, int period) -{ - int ret; - app_control_h app_control = NULL; - char *app_id = NULL; - bool result = false; - - ret = app_control_create(&app_control); - if (ret != APP_CONTROL_ERROR_NONE) - { - LOGE("Function app_control_create() failed."); - return false; - } - - ret = app_control_set_operation(app_control, operation); - if (ret != APP_CONTROL_ERROR_NONE) - { - LOGE("Function app_control_set_operation() failed."); - goto cleanup; - } - - if (app_get_id(&app_id) != APP_ERROR_NONE) { - goto cleanup; - } - - LOGD("app id : %s", app_id); - if (!app_id) { - goto cleanup; - } - - ret = app_control_set_app_id(app_control, app_id); - if (ret != APP_CONTROL_ERROR_NONE) - { - LOGE("Function app_control_set_app_id() failed."); - goto cleanup; - } - - alarm_cancel_all(); - - ret = alarm_schedule_after_delay(app_control, delay, period, &recurring_alarm_id); - if (ret != ALARM_ERROR_NONE) - LOGE("Function alarm_schedule_after_delay() failed."); - else - LOGD("Function alarm_schedule_after_delay() succeed. delay : %d, interval : %d", delay, period); - - result = true; - -cleanup: - if (app_id) - free(app_id); - - if (app_control) { - ret = app_control_destroy(app_control); - if (ret != APP_CONTROL_ERROR_NONE) - LOGE("Function app_control_destroy() failed."); - else - LOGD("Set recurring alarm with id: %i", recurring_alarm_id); - } - - return result; -} - -bool sync_alarm_exist() -{ - bool result = false; - int ret = alarm_foreach_registered_alarm(on_foreach_registered_alarm, &result); - if (ret != ALARM_ERROR_NONE) - LOGD("Listing error : %d", ret); - - return result; -} \ No newline at end of file diff --git a/receiver/tizen-manifest.xml b/receiver/tizen-manifest.xml index 0765a66..402974f 100644 --- a/receiver/tizen-manifest.xml +++ b/receiver/tizen-manifest.xml @@ -8,6 +8,10 @@ + + + + http://developer.samsung.com/tizen/privilege/accessoryprotocol -- 2.7.4 From 1ab0ed3dae806ec5c08c731d6e7ec99c17d500c7 Mon Sep 17 00:00:00 2001 From: Jihoon Kim Date: Wed, 8 Apr 2020 18:01:06 +0900 Subject: [PATCH 14/16] Add missing header file Change-Id: Idce8ed00100a1da70dbfee22416a22fab5c7cb8f Signed-off-by: Jihoon Kim --- receiver/inc/receiver_preference.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 receiver/inc/receiver_preference.h diff --git a/receiver/inc/receiver_preference.h b/receiver/inc/receiver_preference.h new file mode 100644 index 0000000..140b171 --- /dev/null +++ b/receiver/inc/receiver_preference.h @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2020 Samsung Electronics Co., Ltd. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __RECEIVER_PREFERENCE_H__ +#define __RECEIVER_PREFERENCE_H__ + +#define LAST_SYNC_TIME "LastSyncTime" + +#endif /* __RECEIVER_PREFERENCE_H__ */ -- 2.7.4 From dac20334a76302b59f544e8d683a5135853f4f12 Mon Sep 17 00:00:00 2001 From: InHong Han Date: Wed, 8 Apr 2020 17:56:00 +0900 Subject: [PATCH 15/16] Fix the issue that sticker synchronization is failed when REQUEST_SYNC message is received Change-Id: I059241ca2f9ef5262c02f7b8b14fb6b32c0ae964 --- receiver/src/ft.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/receiver/src/ft.cpp b/receiver/src/ft.cpp index aaef4c3..ef2b771 100644 --- a/receiver/src/ft.cpp +++ b/receiver/src/ft.cpp @@ -415,10 +415,12 @@ void request_all_sticker_data(const char *mode, const char *type) if (vconf_get_int(VCONFKEY_STICKER_SUPPORTED_FEATURE, &feature_flag) == 0) { if (feature_flag & VCONFKEY_STICKER_FEATURE_AREMOJI) - request_sticker_data(mode, "arsticker", type); + if (!request_sticker_data(mode, "arsticker", type)) + LOGW("Failed to request ar_sticker sync"); if (feature_flag & VCONFKEY_STICKER_FEATURE_BITMOJI) - request_sticker_data(mode, "bitmoji", type); + if (!request_sticker_data(mode, "bitmoji", type)) + LOGW("Failed to request bitmoji sync"); } else LOGW("Failed to get value of VCONFKEY_STICKER_SUPPORTED_FEATURE"); @@ -599,8 +601,7 @@ on_data_received(sap_socket_h socket, unsigned short int channel_id, unsigned in json_msgid = json_object_get_string_member(root_obj, "msgId"); msg_id = string(json_msgid ? json_msgid : ""); if (msg_id == STICKER_REQUEST_SYNC_REQ) { - if (!request_sticker_data(current_request.mode.c_str(), current_request.category.c_str(), current_request.type.c_str())) - LOGW("Failed to request sticker sync"); + request_all_sticker_data("auto", "input"); } else if (msg_id == STICKER_SYNC_FEATURE_RSP) { LOGD("msg : %s", msg_id.c_str()); #ifdef VCONFKEY_STICKER_SUPPORTED_FEATURE -- 2.7.4 From 3c5c87061e6c614f1e3eadd07af87cab341c8761 Mon Sep 17 00:00:00 2001 From: InHong Han Date: Wed, 8 Apr 2020 21:56:58 +0900 Subject: [PATCH 16/16] Modified to set VCONFKEY_STICKER_SYNC_STATE when bitmoji sync is finished Change-Id: Ia2c2e65bc0e78fdd7d819f329eb1ff345cf40300 --- receiver/src/ft.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/receiver/src/ft.cpp b/receiver/src/ft.cpp index ef2b771..9288b72 100644 --- a/receiver/src/ft.cpp +++ b/receiver/src/ft.cpp @@ -775,6 +775,10 @@ on_data_received(sap_socket_h socket, unsigned short int channel_id, unsigned in send_message("sync_stop_result", reason.c_str()); + current_request.mode.clear(); + current_request.category.clear(); + current_request.type.clear(); + if (!process_request_queue()) { sync_success_cnt = 0; @@ -782,10 +786,6 @@ on_data_received(sap_socket_h socket, unsigned short int channel_id, unsigned in send_disconnect_message(); service_app_exit(); } - - current_request.mode.clear(); - current_request.category.clear(); - current_request.type.clear(); } else LOGW("unknown msg id : %s", msg_id.c_str()); -- 2.7.4