Move util and dbus manager to common 05/240105/4
authorJeon Sang-Heon <sh95.jeon@samsung.com>
Mon, 3 Aug 2020 19:17:26 +0000 (19:17 +0000)
committerJeon Sang-Heon <sh95.jeon@samsung.com>
Fri, 7 Aug 2020 17:26:36 +0000 (17:26 +0000)
- Move util and dbus manager to common

Change-Id: Iddfec94e32a8f4cc4de3b89df14828a1a2198878
Signed-off-by: Jeon Sang-Heon <sh95.jeon@samsung.com>
23 files changed:
update-manager/common/common-boot-status-checker.c
update-manager/common/common-client-controller.c
update-manager/common/common-client-info-checker.c
update-manager/common/common-dbus-manager.c [new file with mode: 0644]
update-manager/common/common-storage-checker.c
update-manager/common/common-util.c [new file with mode: 0644]
update-manager/common/common.h [new file with mode: 0644]
update-manager/dbus-manager.c [deleted file]
update-manager/fota/fota-client-controller.c
update-manager/fota/fota-client-info-checker.c
update-manager/fota/fota-delta-verifier.c
update-manager/fota/fota-info-checker.c
update-manager/fota/fota-installer.c
update-manager/fota/fota-manager.h
update-manager/fota/fota-result-sender.c
update-manager/fota/fota-status-checker.c
update-manager/fota/fota-storage-checker.c
update-manager/main.c
update-manager/recovery/recovery-client-controller.c
update-manager/recovery/recovery-client-info-checker.c
update-manager/recovery/recovery-storage-checker.c
update-manager/update-manager.h [deleted file]
update-manager/util.c [deleted file]

index aa604230442794c8b0ec6c2f81c9b4c0b6ee4a9b..5a62ceba10c72575ed248c2073e34f57b62a1f38 100644 (file)
@@ -1,6 +1,6 @@
+#include "common.h"
 #include "../recovery/recovery-manager.h"
 #include "../fota/fota-manager.h"
-#include "../update-manager.h"
 
 static int boot_status = -1;
 
@@ -19,9 +19,9 @@ void common_boot_status_checker_callback(keynode_t *node, void *user_data)
                if (common_boot_status_checker_is_success()) {
                        ret = vconf_ignore_key_changed(VCONFKEY_SYSMAN_BOOTINGSTATUS, common_boot_status_checker_callback);
                        if (ret == VCONF_OK)
-                               _I("Success to remove bootstatus callback");
+                               _CLOGI("Success to remove bootstatus callback");
                        else
-                               _W("vconf_ignore_key_changed for %s failed : %d", VCONFKEY_SYSMAN_BOOTINGSTATUS, ret);
+                               _CLOGW("vconf_ignore_key_changed for %s failed : %d", VCONFKEY_SYSMAN_BOOTINGSTATUS, ret);
 
                        _FLOGI("Success to get bootstatus success, try process fota event");
                        ret = fota_client_controller_process_event();
@@ -34,7 +34,7 @@ void common_boot_status_checker_callback(keynode_t *node, void *user_data)
                                _RLOGE("Failed to process recovery client event : %d", ret);
                }
        } else {
-               _E("Invalid vconf key type : %d", ret);
+               _CLOGE("Invalid vconf key type : %d", ret);
        }
 }
 
@@ -42,22 +42,22 @@ int common_boot_status_checker_init()
 {
        int ret = 0;
 
-       _I("Start process to get boot status");
+       _CLOGI("Start process to get boot status");
        ret = vconf_get_int(VCONFKEY_SYSMAN_BOOTINGSTATUS, &boot_status);
        if (ret != VCONF_OK) {
-               _E("vconf_get_int for %s failed: %d", VCONFKEY_SYSMAN_BOOTINGSTATUS, ret);
+               _CLOGE("vconf_get_int for %s failed: %d", VCONFKEY_SYSMAN_BOOTINGSTATUS, ret);
                return -1;
        }
 
        if (common_boot_status_checker_is_success()) {
-               _I("Success to get boot status : success");
+               _CLOGI("Success to get boot status : success");
        } else {
                ret = vconf_notify_key_changed(VCONFKEY_SYSMAN_BOOTINGSTATUS, common_boot_status_checker_callback, NULL);
                if (ret != VCONF_OK) {
-                       _E("vconf_notify_key_changed for %s failed : %d", VCONFKEY_SYSMAN_BOOTINGSTATUS, ret);
+                       _CLOGE("vconf_notify_key_changed for %s failed : %d", VCONFKEY_SYSMAN_BOOTINGSTATUS, ret);
                        return -1;
                }
-               _I("Success to register boot status callback");
+               _CLOGI("Success to register boot status callback");
        }
 
        return 0;
@@ -70,7 +70,7 @@ int common_boot_status_checker_fini()
        if (!common_boot_status_checker_is_success()) {
                ret = vconf_ignore_key_changed(VCONFKEY_SYSMAN_BOOTINGSTATUS, common_boot_status_checker_callback);
                if (ret != VCONF_OK)
-                       _W("vconf_ignore_key_changed for %s failed : %d", VCONFKEY_SYSMAN_BOOTINGSTATUS, ret);
+                       _CLOGW("vconf_ignore_key_changed for %s failed : %d", VCONFKEY_SYSMAN_BOOTINGSTATUS, ret);
        }
 
        return 0;
index 5d9499b1f83675e79381db5cc4857407e5df6f13..8be288e7ff427419c504aa5ed56f3ba3ef57d311 100644 (file)
@@ -1,4 +1,4 @@
-#include "../update-manager.h"
+#include "common.h"
 
 int common_client_controller_launch(const char* appid, const char *key, const char *value)
 {
@@ -7,28 +7,28 @@ int common_client_controller_launch(const char* appid, const char *key, const ch
 
        bundle_data = bundle_create();
        if (bundle_data == NULL) {
-               _E("bundle_create failed");
+               _CLOGE("bundle_create failed");
                status = -1;
                goto launch_destroy;
        }
 
        ret = aul_svc_set_operation(bundle_data, AUL_SVC_OPERATION_DEFAULT);
        if (ret != AUL_R_OK) {
-               _E("aul_svc_set_operation failed : %d", ret);
+               _CLOGE("aul_svc_set_operation failed : %d", ret);
                status = -1;
                goto launch_destroy;
        }
 
        ret = aul_svc_add_data(bundle_data, key, value);
        if (ret != AUL_R_OK) {
-               _E("aul_svc_add_data failed : %d", ret);
+               _CLOGE("aul_svc_add_data failed : %d", ret);
                status = -1;
                goto launch_destroy;
        }
 
        ret = aul_launch_app_for_uid(appid, bundle_data, OWNER_UID);
        if (ret < AUL_R_OK) {
-               _E("aul_launch_app_for_uid failed : %d", ret);
+               _CLOGE("aul_launch_app_for_uid failed : %d", ret);
                status = -1;
        }
 
@@ -36,7 +36,7 @@ launch_destroy:
        if (bundle_data) {
                ret = bundle_free(bundle_data);
                if (ret != BUNDLE_ERROR_NONE)
-                       _W("bundle_free failed : %d", ret);
+                       _CLOGW("bundle_free failed : %d", ret);
        }
 
        return status;
index ebcf452b8a3050c4262beabe6eb1266f8fcdd61e..f37eba273ea50647afd6c7539dd297dca1caa6aa 100644 (file)
@@ -1,4 +1,4 @@
-#include "../update-manager.h"
+#include "common.h"
 
 int common_client_info_checker_get_appid(pkgmgrinfo_appinfo_h handle, char **app_id)
 {
@@ -6,34 +6,34 @@ int common_client_info_checker_get_appid(pkgmgrinfo_appinfo_h handle, char **app
        pkgmgrinfo_appinfo_h appinfo_h = NULL;
 
        if (app_id == NULL) {
-               _E("invalid params, app_id is should be address");
+               _CLOGE("invalid params, app_id is should be address");
                status = -1;
                goto callback_destroy;
        }
 
        if (*app_id != NULL) {
-               _E("client app id already exists : %s", *app_id);
+               _CLOGE("client app id already exists : %s", *app_id);
                status = -1;
                goto callback_destroy;
        }
 
        ret = pkgmgrinfo_appinfo_clone_appinfo(handle, &appinfo_h);
        if (ret != PMINFO_R_OK) {
-               _E("pkgmgrinfo_appinfo_clone_appinfo failed : %d", ret);
+               _CLOGE("pkgmgrinfo_appinfo_clone_appinfo failed : %d", ret);
                status = -1;
                goto callback_destroy;
        }
 
        ret = pkgmgrinfo_appinfo_get_appid(appinfo_h, app_id);
        if (ret != PMINFO_R_OK) {
-               _E("app_info_get_app_id failed : %d", ret);
+               _CLOGE("app_info_get_app_id failed : %d", ret);
                status = -1;
                goto callback_destroy;
        }
 
        *app_id = strndup(*app_id, strlen(*app_id));
        if (*app_id == NULL) {
-               _E("Failed strndup : %m");
+               _CLOGE("Failed strndup : %m");
                status = -1;
                goto callback_destroy;
        }
@@ -42,7 +42,7 @@ callback_destroy:
        if (appinfo_h) {
                ret = pkgmgrinfo_appinfo_destroy_appinfo(appinfo_h);
                if (ret != PMINFO_R_OK)
-                       _W("pkgmgrinfo_appinfo_destroy_appinfo failed : %d ", ret);
+                       _CLOGW("pkgmgrinfo_appinfo_destroy_appinfo failed : %d ", ret);
        }
 
        return status;
@@ -53,24 +53,23 @@ int common_client_info_checker_filter(const char* key, const char* value, pkgmgr
        int ret = 0, status = 0;
        pkgmgrinfo_appinfo_metadata_filter_h filter_h = NULL;
 
-       _I("Start process to get fota_client app information");
        ret = pkgmgrinfo_appinfo_metadata_filter_create(&filter_h);
        if (ret != PMINFO_R_OK) {
-               _E("pkgmgrinfo_appinfo_metadata_filter_create failed : %d", ret);
+               _CLOGE("pkgmgrinfo_appinfo_metadata_filter_create failed : %d", ret);
                status = -1;
                goto init_destroy;
        }
 
        ret = pkgmgrinfo_appinfo_metadata_filter_add(filter_h, key, value);
        if (ret != PMINFO_R_OK) {
-               _E("pkgmgrinfo_appinfo_metadata_filter_add failed : %d", ret);
+               _CLOGE("pkgmgrinfo_appinfo_metadata_filter_add failed : %d", ret);
                status = -1;
                goto init_destroy;
        }
 
        ret = pkgmgrinfo_appinfo_metadata_filter_foreach(filter_h, cb, NULL);
        if (ret != PMINFO_R_OK) {
-               _E("pkgmgrinfo_appinfo_usr_metadata_filter_foreach failed : %d", ret);
+               _CLOGE("pkgmgrinfo_appinfo_usr_metadata_filter_foreach failed : %d", ret);
                status = -1;
                goto init_destroy;
        }
@@ -79,7 +78,7 @@ init_destroy:
        if (filter_h) {
                ret = pkgmgrinfo_appinfo_metadata_filter_destroy(filter_h);
                if (ret != PMINFO_R_OK)
-                       _W("pkgmgrinfo_appinfo_metadata_filter_destroy failed : %d", ret);
+                       _CLOGW("pkgmgrinfo_appinfo_metadata_filter_destroy failed : %d", ret);
        }
 
        return status;
diff --git a/update-manager/common/common-dbus-manager.c b/update-manager/common/common-dbus-manager.c
new file mode 100644 (file)
index 0000000..abed007
--- /dev/null
@@ -0,0 +1,66 @@
+#include "common.h"
+#include "../fota/fota-manager.h"
+#include "update-manager-dbus.h"
+
+static guint owner_id;
+
+gboolean dbus_manager_result(OrgTizenUpdateManager *skeleton, GDBusMethodInvocation *invocation, gpointer user_data)
+{
+       int ret = 0;
+
+       _FLOGD("Dbus status : result called");
+       ret = fota_result_sender_execute();
+       if (ret < 0)
+               _FLOGW("Failed to fetch result with fota : %d", ret);
+       org_tizen_update_manager_complete_result(skeleton, invocation, ret);
+
+       return TRUE;
+}
+
+gboolean dbus_manager_install(OrgTizenUpdateManager *skeleton, GDBusMethodInvocation *invocation, gpointer user_data)
+{
+       int ret = 0;
+
+       _FLOGD("Dbus status : install called");
+       ret = fota_installer_execute();
+       if (ret < 0)
+               _FLOGW("Failed to install delta with fota : %d", ret);
+       org_tizen_update_manager_complete_install(skeleton, invocation, ret);
+
+       return TRUE;
+}
+
+void dbus_manager_on_name_lost(GDBusConnection *connection, const gchar *name, gpointer user_data)
+{
+       _CLOGD("Dbus status : name lost");
+}
+
+void dbus_manager_on_name_acquired(GDBusConnection *connection, const gchar *name, gpointer user_data)
+{
+       _CLOGD("Dbus status : name acquired");
+
+       OrgTizenUpdateManager *skeleton = org_tizen_update_manager_skeleton_new();
+       g_signal_connect(skeleton, "handle-install", G_CALLBACK(dbus_manager_install), NULL);
+       g_signal_connect(skeleton, "handle-result", G_CALLBACK(dbus_manager_result), NULL);
+       g_dbus_interface_skeleton_export(G_DBUS_INTERFACE_SKELETON(skeleton), connection, DBUS_NODE_NAME, NULL);
+}
+
+void dbus_manager_on_bus_acquired(GDBusConnection *connection, const gchar *name, gpointer user_data)
+{
+       _CLOGD("Dbus status : bus acquired");
+}
+
+int dbus_manager_init()
+{
+       owner_id = g_bus_own_name(G_BUS_TYPE_SYSTEM, DBUS_INTERFACE_NAME, G_BUS_NAME_OWNER_FLAGS_NONE,
+               dbus_manager_on_bus_acquired, dbus_manager_on_name_acquired, dbus_manager_on_name_lost, NULL, NULL);
+
+       return 0;
+}
+
+int dbus_manager_fini()
+{
+       g_bus_unown_name(owner_id);
+
+       return 0;
+}
\ No newline at end of file
index 7e16a799ef2626ffc93a8fa3bf5f729c24765e1a..26d8b14b933c7ae86840beebbc8e1d0063112c5a 100644 (file)
@@ -1,6 +1,6 @@
+#include "common.h"
 #include "../recovery/recovery-manager.h"
 #include "../fota/fota-manager.h"
-#include "../update-manager.h"
 
 void common_storage_checker_callback(int storage_id, storage_dev_e dev, storage_state_e state, const char *fstype,
                                                                   const char *fsuuid, const char *mount_path, bool primary, int flags, void *user_data)
@@ -8,20 +8,20 @@ void common_storage_checker_callback(int storage_id, storage_dev_e dev, storage_
        switch (state) {
        case STORAGE_STATE_UNMOUNTABLE:
        case STORAGE_STATE_MOUNTED_READ_ONLY:
-               _D("Storage %d status : not mounted", storage_id);
+               _CLOGD("Storage %d status : not mounted", storage_id);
                break;
        case STORAGE_STATE_MOUNTED:
-               _I("Storage %d status : mounted", storage_id);
+               _CLOGI("Storage %d status : mounted", storage_id);
                fota_storage_checker_plug(storage_id, mount_path);
                recovery_storage_checker_plug(storage_id, mount_path);
                break;
        case STORAGE_STATE_REMOVED:
-               _I("Storage %d status : removed", storage_id);
+               _CLOGI("Storage %d status : removed", storage_id);
                fota_storage_checker_unplug(storage_id, mount_path);
                recovery_storage_checker_unplug(storage_id, mount_path);
                break;
        default:
-               _E("Unexpected state : %d", state);
+               _CLOGE("Unexpected state : %d", state);
        }
 }
 
@@ -29,13 +29,13 @@ int common_storage_checker_init()
 {
        int ret = 0;
 
-       _I("Start process to get storage status");
+       _CLOGI("Start process to get storage status");
        ret = storage_set_changed_cb(STORAGE_TYPE_EXTERNAL, common_storage_checker_callback, NULL);
        if (ret == STORAGE_ERROR_NOT_SUPPORTED) {
-               _I("External storage is not suppported, so local update will not be supported");
+               _CLOGI("External storage is not suppported, so local update will not be supported");
        }
        else if (ret != STORAGE_ERROR_NONE) {
-               _E("storage_set_changed_cb failed : %d", ret);
+               _CLOGE("storage_set_changed_cb failed : %d", ret);
                return -1;
        }
 
@@ -48,7 +48,7 @@ int common_storage_checker_fini()
 
        ret = storage_unset_changed_cb(STORAGE_TYPE_EXTERNAL, common_storage_checker_callback);
        if (ret != STORAGE_ERROR_NONE) {
-               _W("failed storage_unset_changed_cb : %d", ret);
+               _CLOGW("failed storage_unset_changed_cb : %d", ret);
                return -1;
        }
 
diff --git a/update-manager/common/common-util.c b/update-manager/common/common-util.c
new file mode 100644 (file)
index 0000000..c0ec2f8
--- /dev/null
@@ -0,0 +1,121 @@
+#include "common.h"
+
+int util_file_mkdir(const char *path)
+{
+       int ret = 0;
+       gboolean exist = FALSE;
+
+       exist = g_file_test(path, G_FILE_TEST_IS_DIR);
+       if (!exist) {
+               ret = mkdir(path, 0775);
+               if (ret < 0) {
+                       _CLOGE("Failed to make %s : %m", path);
+                       return -1;
+               }
+       }
+
+       return 0;
+}
+
+int util_file_remove(const char *path)
+{
+       int ret = 0;
+       gboolean exist = FALSE;
+
+       exist = g_file_test(path, G_FILE_TEST_EXISTS);
+       if (exist) {
+               ret = remove(path);
+               if (ret < 0) {
+                       _CLOGE("Failed to remove %s : %m", path);
+                       return -1;
+               }
+       }
+
+       return 0;
+}
+
+int util_file_symlink(const char *target_path, const char *link_path)
+{
+       int ret = 0;
+       gboolean exist = FALSE;
+
+       exist = g_file_test(target_path, G_FILE_TEST_EXISTS);
+       if (!exist) {
+               _CLOGE("Failed to find %s", target_path);
+               return -1;
+       }
+
+       ret = util_file_remove(link_path);
+       if (ret < 0)
+               return -1;
+
+       ret = symlink(target_path, link_path);
+       if (ret < 0) {
+               _CLOGE("Failed to symlink from %s to %s : %m", target_path, link_path);
+               return -1;
+       }
+
+       return 0;
+}
+
+int util_file_read_single_line(const char *path, char buf[])
+{
+       int status = 0;
+       FILE *fp = NULL;
+
+       fp = fopen(path, "r");
+       if (fp != NULL) {
+               if (fgets(buf, MAX_BUFFER_SIZE, fp) == NULL) {
+                       _CLOGE("Failed to read : %s", path);
+                       status = -1;
+               }
+               fclose(fp);
+       } else {
+               _CLOGE("Failed to open : %s", path);
+               status = -1;
+       }
+
+       return status;
+}
+
+int util_file_write_line(const char *path, const char *msg)
+{
+       int ret = 0, status = 0;
+       FILE *fp = NULL;
+
+       fp = fopen(path, "w");
+       if (fp != NULL) {
+               ret = fprintf(fp, "%s", msg);
+               if (ret < 0) {
+                       _CLOGE("Failed to write, path : %s, msg : %s", path, msg);
+                       status = -1;
+               }
+               fclose(fp);
+       } else {
+               _CLOGE("Failed to open : %s", path);
+               status = -1;
+       }
+
+       return status;
+}
+
+int util_file_untar(const char *tar_path, const char *dest_path, const char *extract_file_name)
+{
+       int ret = 0, status = 0;
+       char *command = NULL;
+
+       command = g_strjoin(" ",
+               "tar", "xvfp", tar_path, "-C", dest_path, extract_file_name, NULL);
+
+       ret = system(command);
+       if (ret < 0) {
+               _CLOGE("Failed to execute untar command %s : %m", command);
+               status = -1;
+       } else if (ret > 0) {
+               _CLOGE("Failed to untar : %d", ret);
+               status = -1;
+       }
+       free(command);
+
+       return status;
+}
diff --git a/update-manager/common/common.h b/update-manager/common/common.h
new file mode 100644 (file)
index 0000000..6f36fb7
--- /dev/null
@@ -0,0 +1,59 @@
+#ifndef __COMMON_H__
+#define __COMMON_H__
+
+#include <aul.h>
+#include <aul_svc.h>
+#include <bundle.h>
+#include <dlog.h>
+#include <errno.h>
+#include <gio/gio.h>
+#include <glib.h>
+#include <pkgmgr-info.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <storage.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <vconf.h>
+
+/* Log */
+#define COMMON_LOG_TAG "UPDATE_MANAGER"
+
+#define _CLOGD(fmt, arg...) SLOG(LOG_INFO, COMMON_LOG_TAG, fmt, ##arg)
+#define _CLOGI(fmt, arg...) SLOG(LOG_INFO, COMMON_LOG_TAG, fmt, ##arg)
+#define _CLOGW(fmt, arg...) SLOG(LOG_WARN, COMMON_LOG_TAG, fmt, ##arg)
+#define _CLOGE(fmt, arg...) SLOG(LOG_ERROR, COMMON_LOG_TAG, fmt, ##arg)
+
+/* Constant */
+#define MAX_BUFFER_SIZE 256
+#define OWNER_UID 5001
+
+#define DBUS_INTERFACE_NAME "org.tizen.update.manager"
+#define DBUS_NODE_NAME "/org/tizen/update/manager"
+
+/* Enum */
+
+/* Function */
+int common_boot_status_checker_init(void);
+int common_boot_status_checker_fini(void);
+bool common_boot_status_checker_is_success(void);
+
+int common_client_controller_launch(const char *, const char *, const char *);
+
+int common_client_info_checker_get_appid(pkgmgrinfo_appinfo_h, char **);
+int common_client_info_checker_filter(const char *, const char *, pkgmgrinfo_app_list_cb);
+
+int common_storage_checker_init(void);
+int common_storage_checker_fini(void);
+
+int dbus_manager_init(void);
+int dbus_manager_fini(void);
+
+int util_file_mkdir(const char *);
+int util_file_remove(const char *);
+int util_file_symlink(const char *, const char *);
+int util_file_read_single_line(const char *, char[]);
+int util_file_write_line(const char *, const char *);
+int util_file_untar(const char *, const char *, const char *);
+
+#endif /* __COMMON_H__ */
diff --git a/update-manager/dbus-manager.c b/update-manager/dbus-manager.c
deleted file mode 100644 (file)
index cea865a..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-#include "fota/fota-manager.h"
-#include "update-manager.h"
-#include "update-manager-dbus.h"
-
-static guint owner_id;
-
-gboolean dbus_manager_result(OrgTizenUpdateManager *skeleton, GDBusMethodInvocation *invocation, gpointer user_data)
-{
-       int ret = 0;
-
-       _D("Dbus status : result called");
-       ret = fota_result_sender_execute();
-       if (ret < 0)
-               _W("Failed to fetch result with fota : %d", ret);
-       org_tizen_update_manager_complete_result(skeleton, invocation, ret);
-
-       return TRUE;
-}
-
-gboolean dbus_manager_install(OrgTizenUpdateManager *skeleton, GDBusMethodInvocation *invocation, gpointer user_data)
-{
-       int ret = 0;
-
-       _D("Dbus status : install called");
-       ret = fota_installer_execute();
-       if (ret < 0)
-               _W("Failed to install delta with fota : %d", ret);
-       org_tizen_update_manager_complete_install(skeleton, invocation, ret);
-
-       return TRUE;
-}
-
-void dbus_manager_on_name_lost(GDBusConnection *connection, const gchar *name, gpointer user_data)
-{
-       _D("Dbus status : name lost");
-}
-
-void dbus_manager_on_name_acquired(GDBusConnection *connection, const gchar *name, gpointer user_data)
-{
-       _D("Dbus status : name acquired");
-
-       OrgTizenUpdateManager *skeleton = org_tizen_update_manager_skeleton_new();
-       g_signal_connect(skeleton, "handle-install", G_CALLBACK(dbus_manager_install), NULL);
-       g_signal_connect(skeleton, "handle-result", G_CALLBACK(dbus_manager_result), NULL);
-       g_dbus_interface_skeleton_export(G_DBUS_INTERFACE_SKELETON(skeleton), connection, NODE_NAME, NULL);
-}
-
-void dbus_manager_on_bus_acquired(GDBusConnection *connection, const gchar *name, gpointer user_data)
-{
-       _D("Dbus status : bus acquired");
-}
-
-int dbus_manager_init()
-{
-       owner_id = g_bus_own_name(G_BUS_TYPE_SYSTEM, INTERFACE_NAME, G_BUS_NAME_OWNER_FLAGS_NONE,
-               dbus_manager_on_bus_acquired, dbus_manager_on_name_acquired, dbus_manager_on_name_lost, NULL, NULL);
-
-       return 0;
-}
-
-int dbus_manager_fini()
-{
-       g_bus_unown_name(owner_id);
-
-       return 0;
-}
index 72c86f192435971457b98146eff9d7bea07e7434..8f27f597b6c6a204448ec4a94b315c484c4bd36f 100644 (file)
@@ -1,4 +1,4 @@
-#include "../update-manager.h"
+#include "../common/common.h"
 #include "fota-manager.h"
 
 #define FOTA_CLIENT_APP_CTRL_PLUG_KEY "fota-plug"
index 8c14d71b7d22a1742d460d95fedb213b5a18adbc..9e98cc3c7df97887a78f7b473f23afd76d352c9d 100644 (file)
@@ -1,4 +1,4 @@
-#include "../update-manager.h"
+#include "../common/common.h"
 #include "fota-manager.h"
 
 #define FOTA_CLIENT_METADATA_KEY "tizen-fota-manager"
index 6a7b221d20468ff3bbc4a374e7bd074a819ba6b2..c6d1fe975a956dbe3630b314acabce9f0ed325b5 100644 (file)
@@ -1,5 +1,9 @@
+#include "../common/common.h"
 #include "fota-manager.h"
-#include "../update-manager.h"
+
+#define FOTA_DELTA_BUILD_STRING_DIR "/tmp"
+#define FOTA_DELTA_BUILD_STRING_FILENAME "build_id.txt"
+#define FOTA_DELTA_BUILD_STRING_PATH FOTA_DELTA_BUILD_STRING_DIR "/" FOTA_DELTA_BUILD_STRING_FILENAME
 
 int fota_delta_verify(const char *path, const char *old_build_string, const char *new_build_string)
 {
@@ -20,21 +24,21 @@ int fota_delta_verify(const char *path, const char *old_build_string, const char
        }
 
        _FLOGI("Found delta in %s, start process to verify", path);
-       ret = util_file_untar(path, BUILD_ID_DIR, BUILD_ID_FILE);
+       ret = util_file_untar(path, FOTA_DELTA_BUILD_STRING_DIR, FOTA_DELTA_BUILD_STRING_FILENAME);
        if (ret < 0) {
                status = -1;
                goto verify_destroy;
        }
 
-       fp = fopen(BUILD_ID_PATH, "r");
+       fp = fopen(FOTA_DELTA_BUILD_STRING_PATH, "r");
        if (fp == NULL) {
-               _FLOGE("Failed to open : %s", BUILD_ID_PATH);
+               _FLOGE("Failed to open : %s", FOTA_DELTA_BUILD_STRING_PATH);
                status = -1;
                goto verify_destroy;
        }
 
        if (fgets(buf, MAX_BUFFER_SIZE, fp) == NULL) {
-               _FLOGE("Failed to read : %s", BUILD_ID_PATH);
+               _FLOGE("Failed to read : %s", FOTA_DELTA_BUILD_STRING_PATH);
                status = -1;
                goto verify_destroy;
        }
@@ -47,7 +51,7 @@ int fota_delta_verify(const char *path, const char *old_build_string, const char
 
        if (new_build_string != NULL) {
                if (fgets(buf, MAX_BUFFER_SIZE, fp) == NULL) {
-                       _FLOGE("Failed to read : %s", BUILD_ID_PATH);
+                       _FLOGE("Failed to read : %s", FOTA_DELTA_BUILD_STRING_PATH);
                        status = -1;
                        goto verify_destroy;
                }
@@ -62,9 +66,9 @@ int fota_delta_verify(const char *path, const char *old_build_string, const char
        _FLOGI("Success to verify %s, old : %s, new : %s", path, old_build_string, new_build_string);
 
 verify_destroy:
-       util_file_remove(BUILD_ID_PATH);
+       util_file_remove(FOTA_DELTA_BUILD_STRING_PATH);
 
-       if (!fp)
+       if (fp)
                fclose(fp);
 
        return status;
index da78460e5fe9d32f6c07321b556094c2c30b1f06..1bed2d8eb54d57fd3f350b376460e323872a5bf7 100644 (file)
@@ -1,5 +1,5 @@
+#include "../common/common.h"
 #include "fota-manager.h"
-#include "../update-manager.h"
 
 #define SYSTEM_INFO_BUILD_STRING "tizen.org/system/build.string"
 #define SYSTEM_INFO_PLATFORM_VERSION "tizen.org/feature/platform.version"
index 63f43662921bf07ccd5d40fd419a80886b96d500..4a100cb3cf12f5fa1d928c192c49253ed2699e58 100644 (file)
@@ -1,5 +1,14 @@
+#include "../common/common.h"
 #include "fota-manager.h"
-#include "../update-manager.h"
+
+#define APP_SHARED_DIR "/opt/usr/home/owner/apps_rw"
+#define APP_SHARED_DATA "shared/data"
+
+#define FOTA_DIR "/opt/usr/data/fota"
+#define FOTA_DELTA_PATH FOTA_DIR "/" FOTA_DELTA_FILENAME
+#define FOTA_DELTA_UA_FILE "delta.ua"
+
+#define FOTA_STATUS_DELTA_PATH FOTA_STATUS_DIR "/DELTA.PATH"
 
 int fota_installer_setup_delta()
 {
@@ -23,7 +32,7 @@ int fota_installer_setup_delta()
                return -1;
        }
 
-       shared_path = g_strjoin("/", SHARED_DIR, appid, SHARED_DATA_DIR, FOTA_DELTA_FILE, NULL);
+       shared_path = g_strjoin("/", APP_SHARED_DIR, appid, APP_SHARED_DATA, FOTA_DELTA_FILENAME, NULL);
        ret = fota_delta_verify(shared_path, build_string, NULL);
        if (ret < 0) {
                _FLOGE("Failed to verify delta : %d, path : %s, old_build_string : %s",
@@ -93,15 +102,15 @@ int fota_installer_setup_status()
 {
        int ret = 0;
 
-       ret = util_file_mkdir(STATUS_DIR);
+       ret = util_file_mkdir(FOTA_STATUS_DIR);
        if (ret < 0)
                return -1;
 
-       ret = util_file_write_line(STATUS_FLAG_PATH, NULL);
+       ret = util_file_write_line(FOTA_STATUS_FLAG_PATH, NULL);
        if (ret < 0)
                return -1;
 
-       ret = util_file_write_line(STATUS_FOTA_PATH, FOTA_DIR);
+       ret = util_file_write_line(FOTA_STATUS_DELTA_PATH, FOTA_DIR);
        if (ret < 0)
                return -1;
 
index 374374baf5ef840af02b9837ea15c69ce71e7ecc..4049eb6fa7d4eefd952f937ee4bed87c69cccdf1 100644 (file)
@@ -1,6 +1,7 @@
 #ifndef __FOTA_MANAGER_H__
 #define __FOTA_MANAGER_H__
 
+#include <device/power.h>
 #include <dlog.h>
 #include <system_info.h>
 
 #define _FLOGE(fmt, arg...) SLOG(LOG_ERROR, FOTA_LOG_TAG, fmt, ##arg)
 
 /* Constant */
-
+#define FOTA_DELTA_FILENAME "delta.tar"
 
 #define FOTA_INSTALL_PLATFORM_VERSION_PATH "/opt/etc/version"
 #define FOTA_INSTALL_REBOOT_REASON "fota"
 
+#define FOTA_STATUS_DIR "/opt/data/update"
+#define FOTA_STATUS_FLAG_PATH FOTA_STATUS_DIR "/is-first-boot-after-fota"
+
 #define FOTA_EVENT_SIZE 3
 
 /* Enum */
index 767b57305858a5f801d49eb6306f063d78c134c0..e5b031f7b143679c9290144e3f69ba35fed16a38 100644 (file)
@@ -1,5 +1,5 @@
+#include "../common/common.h"
 #include "fota-manager.h"
-#include "../update-manager.h"
 
 int fota_result_sender_execute()
 {
index 0cc10550b62351ebbf3524a6f577d297a9f9b62d..9608906a334f11978089d36258ada3ab45953dab 100644 (file)
@@ -1,5 +1,7 @@
+#include "../common/common.h"
 #include "fota-manager.h"
-#include "../update-manager.h"
+
+#define FOTA_STATUS_RESULT_PATH FOTA_STATUS_DIR "/result"
 
 static char *fota_result = NULL;
 
@@ -13,12 +15,12 @@ int fota_status_checker_init()
        int ret = 0;
        char buf[MAX_BUFFER_SIZE] = {0, };
 
-       if (!g_file_test(STATUS_RESULT_PATH, G_FILE_TEST_EXISTS)) {
+       if (!g_file_test(FOTA_STATUS_RESULT_PATH, G_FILE_TEST_EXISTS)) {
                _FLOGI("This boot doesn't have fota result");
                return 0;
        }
 
-       ret = util_file_read_single_line(STATUS_RESULT_PATH, buf);
+       ret = util_file_read_single_line(FOTA_STATUS_RESULT_PATH, buf);
        if (ret < 0)
                return -1;
 
@@ -29,7 +31,7 @@ int fota_status_checker_init()
        }
 
        _FLOGI("Success to read fota result : %s", fota_result);
-       if (!g_file_test(STATUS_FLAG_PATH, G_FILE_TEST_EXISTS)) {
+       if (!g_file_test(FOTA_STATUS_FLAG_PATH, G_FILE_TEST_EXISTS)) {
                _FLOGI("This boot isn't triggered with fota");
                return 0;
        }
@@ -41,7 +43,7 @@ int fota_status_checker_init()
                return -1;
        }
 
-       ret = util_file_remove(STATUS_FLAG_PATH);
+       ret = util_file_remove(FOTA_STATUS_FLAG_PATH);
        if (ret < 0)
                return -1;
 
index 3593015f9f3357483dbb7a4f4f5f12ffda4702c0..d1b114b678e15e5b92f164458b03044adaf3be42 100644 (file)
@@ -1,4 +1,4 @@
-#include "../update-manager.h"
+#include "../common/common.h"
 #include "fota-manager.h"
 
 #define FOTA_STORAGE_FOLDER_TOKEN "@"
@@ -29,7 +29,7 @@ int fota_storage_verify_delta(const char* mount_path, const char *folder_name, g
        }
        new_build_string = new_build_string + 1;
 
-       path = g_strjoin("/", mount_path, folder_name, FOTA_DELTA_FILE, NULL);
+       path = g_strjoin("/", mount_path, folder_name, FOTA_DELTA_FILENAME, NULL);
        if (!g_file_test(path, G_FILE_TEST_EXISTS)) {
                _FLOGI("Folder %s doesn't have delta.tar", folder_name);
                status = -1;
index 2543da851d6cb251946adb895ed2f5fef24aad61..67ab23ace9f9a4d062a2fb53e6158bf7911c4526 100644 (file)
@@ -1,6 +1,6 @@
+#include "common/common.h"
 #include "recovery/recovery-manager.h"
 #include "fota/fota-manager.h"
-#include "update-manager.h"
 
 int main(int argc, char *argv[])
 {
@@ -9,53 +9,53 @@ int main(int argc, char *argv[])
 
        mainloop = g_main_loop_new(NULL, FALSE);
        if (!mainloop) {
-               _E("Failed to create mainloop");
+               _CLOGE("Failed to create mainloop");
                return -ENOMEM;
        }
 
        /* Common */
        ret = common_storage_checker_init();
        if (ret < 0) {
-               _E("Failed to initialize common storage checker : %d", ret);
+               _CLOGE("Failed to initialize common storage checker : %d", ret);
                goto main_destroy;
        }
 
        ret = common_boot_status_checker_init();
        if (ret < 0) {
-               _E("Failed to initialize common boot status checker : %d", ret);
+               _CLOGE("Failed to initialize common boot status checker : %d", ret);
                goto main_destroy;
        }
 
        /* Recovery */
        ret = recovery_client_info_checker_init();
        if (ret < 0) {
-               _E("Failed to initialize recovery client info checker : %d", ret);
+               _CLOGE("Failed to initialize recovery client info checker : %d", ret);
                goto main_destroy;
        }
 
        /* Fota */
        ret = fota_client_info_checker_init();
        if (ret < 0) {
-               _E("Failed to initialize fota client info checker : %d", ret);
+               _CLOGE("Failed to initialize fota client info checker : %d", ret);
                goto main_destroy;
        }
 
        ret = fota_info_checker_init();
        if (ret < 0) {
-               _E("Failed to initialize fota info checker : %d", ret);
+               _CLOGE("Failed to initialize fota info checker : %d", ret);
                goto main_destroy;
        }
 
        ret = fota_status_checker_init();
        if (ret < 0) {
-               _E("Failed to initialize fota status checker : %d", ret);
+               _CLOGE("Failed to initialize fota status checker : %d", ret);
                goto main_destroy;
        }
 
        /* Dbus */
        ret = dbus_manager_init();
        if (ret < 0) {
-               _E("Failed to initialize dbus manager : %d", ret);
+               _CLOGE("Failed to initialize dbus manager : %d", ret);
                goto main_destroy;
        }
 
@@ -65,34 +65,34 @@ main_destroy:
        /* Common */
        ret = common_storage_checker_fini();
        if (ret < 0)
-               _W("Failed to finalize common storage checker : %d", ret);
+               _CLOGW("Failed to finalize common storage checker : %d", ret);
 
        ret = common_boot_status_checker_fini();
        if (ret < 0)
-               _W("Failed to finalize common boot status checker : %d", ret);
+               _CLOGW("Failed to finalize common boot status checker : %d", ret);
 
        /* Recovery */
        ret = recovery_client_info_checker_fini();
        if (ret < 0)
-               _W("Failed to finalize recovery client info checker : %d", ret);
+               _CLOGW("Failed to finalize recovery client info checker : %d", ret);
 
        /* Fota */
        ret = fota_client_info_checker_fini();
        if (ret < 0)
-               _W("Failed to finalize fota client info checker : %d", ret);
+               _CLOGW("Failed to finalize fota client info checker : %d", ret);
 
        ret = fota_info_checker_fini();
        if (ret < 0)
-               _W("Failed to finalize fota info checker : %d", ret);
+               _CLOGW("Failed to finalize fota info checker : %d", ret);
 
        ret = fota_status_checker_fini();
        if (ret < 0)
-               _E("Failed to finalize fota status checker : %d", ret);
+               _CLOGW("Failed to finalize fota status checker : %d", ret);
 
        /* Dbus */
        ret = dbus_manager_fini();
        if (ret < 0)
-               _W("Failed to finalize dbus manager : %d", ret);
+               _CLOGW("Failed to finalize dbus manager : %d", ret);
 
        if (mainloop) {
                g_main_loop_quit(mainloop);
index 51e19dc5b2b2700e8950309162dfa6136e7caaba..b2c07a424b8fa85ca2bd2d343493344c752740c6 100644 (file)
@@ -1,5 +1,5 @@
+#include "../common/common.h"
 #include "recovery-manager.h"
-#include "../update-manager.h"
 
 #define RECOVERY_CLIENT_APP_CTRL_PLUG_KEY "recovery-plug"
 #define RECOVERY_CLIENT_APP_CTRL_UNPLUG_KEY "recovery-unplug"
index 8bdfc4dd3f8390846f2e31f77a0d728be1608cca..f6aed75443e78f8801f5657235b68da7a8aa8d5d 100644 (file)
@@ -1,5 +1,5 @@
+#include "../common/common.h"
 #include "recovery-manager.h"
-#include "../update-manager.h"
 
 #define RECOVERY_CLIENT_METADATA_KEY "tizen-recovery-manager"
 #define RECOVERY_CLIENT_METADATA_VALUE "client"
index 95cf95774756fa0debadff45e35a8a73a6bf7527..d2e6c2317c9a12ba0640073bc15f124e436a3d91 100644 (file)
@@ -1,5 +1,5 @@
+#include "../common/common.h"
 #include "recovery-manager.h"
-#include "../update-manager.h"
 
 static int recovery_storage_id = -1;
 
diff --git a/update-manager/update-manager.h b/update-manager/update-manager.h
deleted file mode 100644 (file)
index 23fa4bc..0000000
+++ /dev/null
@@ -1,82 +0,0 @@
-#ifndef __UPDATE_MANAGER_H__
-#define __UPDATE_MANAGER_H__
-
-#include <aul.h>
-#include <aul_svc.h>
-#include <bundle.h>
-#include <device/power.h>
-#include <dlog.h>
-#include <errno.h>
-#include <gio/gio.h>
-#include <glib.h>
-#include <pkgmgr-info.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <storage.h>
-#include <sys/stat.h>
-#include <unistd.h>
-#include <vconf.h>
-
-/* Log */
-#undef LOG_TAG
-#define LOG_TAG "UPDATE_MANAGER"
-
-#define _D(fmt, arg...) SLOGD(fmt, ##arg)
-#define _I(fmt, arg...) SLOGI(fmt, ##arg)
-#define _W(fmt, arg...) SLOGW(fmt, ##arg)
-#define _E(fmt, arg...) SLOGE(fmt, ##arg)
-
-/* Common */
-#define MAX_BUFFER_SIZE             256
-#define OWNER_UID                   5001
-
-/* Dbus */
-#define INTERFACE_NAME              "org.tizen.update.manager"
-#define NODE_NAME                   "/org/tizen/update/manager"
-
-/* Update */
-
-#define BUILD_ID_DIR                "/tmp"
-#define BUILD_ID_FILE               "build_id.txt"
-#define BUILD_ID_PATH               BUILD_ID_DIR "/" BUILD_ID_FILE
-
-#define FOTA_DIR                    "/opt/usr/data/fota"
-#define FOTA_DELTA_FILE             "delta.tar"
-#define FOTA_DELTA_PATH             FOTA_DIR "/" FOTA_DELTA_FILE
-#define FOTA_DELTA_UA_FILE          "delta.ua"
-
-#define STATUS_DIR                  "/opt/data/update"
-#define STATUS_FLAG_FILE            "is-first-boot-after-fota"
-#define STATUS_FLAG_PATH            STATUS_DIR "/" STATUS_FLAG_FILE
-#define STATUS_RESULT_FILE          "result"
-#define STATUS_RESULT_PATH          STATUS_DIR "/" STATUS_RESULT_FILE
-#define STATUS_FOTA_PATH_FILE       "DELTA.PATH"
-#define STATUS_FOTA_PATH            STATUS_DIR "/" STATUS_FOTA_PATH_FILE
-
-#define SHARED_DIR                  "/opt/usr/home/owner/apps_rw"
-#define SHARED_DATA_DIR             "shared/data"
-
-/* Function */
-int common_storage_checker_init(void);
-int common_storage_checker_fini(void);
-
-int common_boot_status_checker_init(void);
-int common_boot_status_checker_fini(void);
-bool common_boot_status_checker_is_success(void);
-
-int common_client_controller_launch(const char*, const char *, const char *);
-
-int common_client_info_checker_get_appid(pkgmgrinfo_appinfo_h, char **);
-int common_client_info_checker_filter(const char*, const char*, pkgmgrinfo_app_list_cb);
-
-int dbus_manager_init(void);
-int dbus_manager_fini(void);
-
-int util_file_mkdir(const char *);
-int util_file_remove(const char *);
-int util_file_symlink(const char *, const char *);
-int util_file_read_single_line(const char *, char []);
-int util_file_write_line(const char *, const char *);
-int util_file_untar(const char *, const char *, const char *);
-
-#endif /* __UPDATE_MANAGER_H__ */
diff --git a/update-manager/util.c b/update-manager/util.c
deleted file mode 100644 (file)
index 30ad998..0000000
+++ /dev/null
@@ -1,121 +0,0 @@
-#include "update-manager.h"
-
-int util_file_mkdir(const char *path)
-{
-       int ret = 0;
-       gboolean exist = FALSE;
-
-       exist = g_file_test(path, G_FILE_TEST_IS_DIR);
-       if (!exist) {
-               ret = mkdir(path, 0775);
-               if (ret < 0) {
-                       _E("Failed to make %s : %m", path);
-                       return -1;
-               }
-       }
-
-       return 0;
-}
-
-int util_file_remove(const char *path)
-{
-       int ret = 0;
-       gboolean exist = FALSE;
-
-       exist = g_file_test(path, G_FILE_TEST_EXISTS);
-       if (exist) {
-               ret = remove(path);
-               if (ret < 0) {
-                       _E("Failed to remove %s : %m", path);
-                       return -1;
-               }
-       }
-
-       return 0;
-}
-
-int util_file_symlink(const char *target_path, const char *link_path)
-{
-       int ret = 0;
-       gboolean exist = FALSE;
-
-       exist = g_file_test(target_path, G_FILE_TEST_EXISTS);
-       if (!exist) {
-               _E("Failed to find %s", target_path);
-               return -1;
-       }
-
-       ret = util_file_remove(link_path);
-       if (ret < 0)
-               return -1;
-
-       ret = symlink(target_path, link_path);
-       if (ret < 0) {
-               _E("Failed to symlink from %s to %s : %m", target_path, link_path);
-               return -1;
-       }
-
-       return 0;
-}
-
-int util_file_read_single_line(const char *path, char buf[])
-{
-       int status = 0;
-       FILE *fp = NULL;
-
-       fp = fopen(path, "r");
-       if (fp != NULL) {
-               if (fgets(buf, MAX_BUFFER_SIZE, fp) == NULL) {
-                       _E("Failed to read : %s", path);
-                       status = -1;
-               }
-               fclose(fp);
-       } else {
-               _E("Failed to open : %s", path);
-               status = -1;
-       }
-
-       return status;
-}
-
-int util_file_write_line(const char *path, const char *msg)
-{
-       int ret = 0, status = 0;
-       FILE *fp = NULL;
-
-       fp = fopen(path, "w");
-       if (fp != NULL) {
-               ret = fprintf(fp, "%s", msg);
-               if (ret < 0) {
-                       _E("Failed to write, path : %s, msg : %s", path, msg);
-                       status = -1;
-               }
-               fclose(fp);
-       } else {
-               _E("Failed to open : %s", path);
-               status = -1;
-       }
-
-       return status;
-}
-
-int util_file_untar(const char *tar_path, const char *dest_path, const char *extract_file_name)
-{
-       int ret = 0, status = 0;
-       char *command = NULL;
-
-       command = g_strjoin(" ",
-               "tar", "xvfp", tar_path, "-C", dest_path, extract_file_name, NULL);
-
-       ret = system(command);
-       if (ret < 0) {
-               _E("Failed to execute untar command %s : %m", command);
-               status = -1;
-       } else if (ret > 0) {
-               _E("Failed to untar : %d", ret);
-               status = -1;
-       }
-       free(command);
-
-       return status;
-}