+#include "common.h"
#include "../recovery/recovery-manager.h"
#include "../fota/fota-manager.h"
-#include "../update-manager.h"
static int boot_status = -1;
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();
_RLOGE("Failed to process recovery client event : %d", ret);
}
} else {
- _E("Invalid vconf key type : %d", ret);
+ _CLOGE("Invalid vconf key type : %d", ret);
}
}
{
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;
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;
-#include "../update-manager.h"
+#include "common.h"
int common_client_controller_launch(const char* appid, const char *key, const char *value)
{
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;
}
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;
-#include "../update-manager.h"
+#include "common.h"
int common_client_info_checker_get_appid(pkgmgrinfo_appinfo_h handle, char **app_id)
{
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;
}
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;
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;
}
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;
--- /dev/null
+#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
+#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)
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);
}
}
{
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;
}
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;
}
--- /dev/null
+#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;
+}
--- /dev/null
+#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__ */
+++ /dev/null
-#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;
-}
-#include "../update-manager.h"
+#include "../common/common.h"
#include "fota-manager.h"
#define FOTA_CLIENT_APP_CTRL_PLUG_KEY "fota-plug"
-#include "../update-manager.h"
+#include "../common/common.h"
#include "fota-manager.h"
#define FOTA_CLIENT_METADATA_KEY "tizen-fota-manager"
+#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)
{
}
_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;
}
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;
}
_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;
+#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"
+#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()
{
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",
{
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;
#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 */
+#include "../common/common.h"
#include "fota-manager.h"
-#include "../update-manager.h"
int fota_result_sender_execute()
{
+#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;
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;
}
_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;
}
return -1;
}
- ret = util_file_remove(STATUS_FLAG_PATH);
+ ret = util_file_remove(FOTA_STATUS_FLAG_PATH);
if (ret < 0)
return -1;
-#include "../update-manager.h"
+#include "../common/common.h"
#include "fota-manager.h"
#define FOTA_STORAGE_FOLDER_TOKEN "@"
}
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;
+#include "common/common.h"
#include "recovery/recovery-manager.h"
#include "fota/fota-manager.h"
-#include "update-manager.h"
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;
}
/* 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);
+#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"
+#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"
+#include "../common/common.h"
#include "recovery-manager.h"
-#include "../update-manager.h"
static int recovery_storage_id = -1;
+++ /dev/null
-#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__ */
+++ /dev/null
-#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;
-}