Add INSTALL status into pkgmgr_client_cb 88/239388/1
authorsooyeon.kim <sooyeon.kim@samsung.com>
Fri, 24 Jul 2020 09:20:12 +0000 (18:20 +0900)
committersooyeon.kim <sooyeon.kim@samsung.com>
Fri, 24 Jul 2020 09:20:12 +0000 (18:20 +0900)
Change-Id: If09373ff73d1e6b6cf17227c6908a1239ebdd27c
Signed-off-by: sooyeon.kim <sooyeon.kim@samsung.com>
client/tts.c

index f3e61db..bfc4eb1 100644 (file)
@@ -51,6 +51,7 @@ static int g_retry_cnt = 0;
 
 /* for checking engine update */
 static pkgmgr_client* g_pkgmgr = NULL;
+static char* g_pkgmgr_status = NULL;
 static char* g_engine_name = NULL;
 static char g_engine_appid[256];
 static int g_engine_update_status = 0;
@@ -277,11 +278,21 @@ static int __pkgmgr_status_cb(uid_t target_uid, int req_id, const char *type, co
                return 0;
        } else {
                if (key && 0 == strncmp(key, "start", strlen(key))) {
-                       if (val && (0 == strncmp(val, "update", strlen(val) || 0 == strncmp(val, "uninstall", strlen(val))))) {
+                       if (NULL != g_pkgmgr_status) {
+                               free(g_pkgmgr_status);
+                               g_pkgmgr_status = NULL;
+                       }
+
+                       if (val) {
+                               g_pkgmgr_status = strdup(val);
+                               SLOG(LOG_INFO, TAG_TTSC, "[INFO] pkgmgr status. key(%s), status(%s)", key, g_pkgmgr_status);
+
+                               if ((0 == strncmp(val, "update", strlen(val) || 0 == strncmp(val, "uninstall", strlen(val))))) {
                                SLOG(LOG_ERROR, TAG_TTSC, "[INFO] start to install.");
                                g_engine_update_status = 1;
                        }
-               } else if (key && 0 == strncmp(key, "end", strlen(key))) {
+                       }
+               } else if (key && 0 == strncmp(g_pkgmgr_status, "install", strlen(g_pkgmgr_status)) && 0 == strncmp(key, "end", strlen(key))) {
                        SLOG(LOG_ERROR, TAG_TTSC, "[INFO] finish to install");
                        g_engine_update_status = 0;
                }
@@ -309,7 +320,7 @@ static void __create_pkgmgr_thread(void* data, Ecore_Thread* thread)
                if (NULL == g_pkgmgr) {
                        SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to create pkgmgr handle");
                } else {
-                       int ret = pkgmgr_client_set_status_type(g_pkgmgr, PKGMGR_CLIENT_STATUS_UNINSTALL | PKGMGR_CLIENT_STATUS_UPGRADE);
+                       int ret = pkgmgr_client_set_status_type(g_pkgmgr, PKGMGR_CLIENT_STATUS_INSTALL | PKGMGR_CLIENT_STATUS_UNINSTALL | PKGMGR_CLIENT_STATUS_UPGRADE);
                        if (0 == ret) {
                                if (pkgmgr_client_listen_status(g_pkgmgr, __pkgmgr_status_cb, NULL) < 0) {
                                        SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to listen pkgmgr status. remove and recreate client");
@@ -628,6 +639,10 @@ int tts_destroy(tts_h tts)
                        pkgmgr_client_free(g_pkgmgr);
                        g_pkgmgr = NULL;
                }
+               if (NULL != g_pkgmgr_status) {
+                       free(g_pkgmgr_status);
+                       g_pkgmgr_status = NULL;
+               }
                pthread_mutex_unlock(&g_pkgmgr_mutex);
        } else {
                SLOG(LOG_ERROR, TAG_TTSC, "[INFO] num_of_client(%d)", num_of_client);