#include "../recovery/recovery-manager.h"
+#include "../fota/fota-manager.h"
#include "../update-manager.h"
static int boot_status = -1;
#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,
+#include "fota/fota-manager.h"
#include "update-manager.h"
int fota_controller_verify_delta(const char *delta_path)
goto verify_destroy;
}
- build_id = fota_info_get_build_id();
+ build_id = fota_info_get_build_string();
if (build_id == NULL) {
_E("Failed to get current build id");
status = -1;
+++ /dev/null
-#include "update-manager.h"
-
-static char *build_id = NULL;
-static char *platform_version = NULL;
-
-char *fota_info_get_build_id()
-{
- return build_id;
-}
-
-char *fota_info_get_platform_version()
-{
- return platform_version;
-}
-
-int fota_info_checker_init()
-{
- int ret = 0;
-
- _I("Start process to get fota information");
- ret = system_info_get_platform_string(BUILD_ID_KEY, &build_id);
- if (ret != SYSTEM_INFO_ERROR_NONE) {
- _E("system_info_get_platform_string failed : %d", ret);
- return -1;
- }
-
- ret = system_info_get_platform_string(PLATFORM_VERSION_KEY, &platform_version);
- if (ret != SYSTEM_INFO_ERROR_NONE) {
- _E("system_info_get_platform_string failed : %d", ret);
- return -1;
- }
-
- _I("Success to get fota information, platform : %s, build_id : %s",
- platform_version, build_id);
- return 0;
-}
-
-int fota_info_checker_fini()
-{
- if (build_id)
- free(build_id);
-
- if (platform_version)
- free(platform_version);
-
- return 0;
-}
\ No newline at end of file
+++ /dev/null
-#include "update-manager.h"
-
-static char *fota_result = NULL;
-
-char *fota_status_get_result()
-{
- return fota_result;
-}
-
-int fota_status_checker_process()
-{
- int ret = 0;
-
- if (g_file_test(STATUS_FLAG_PATH, G_FILE_TEST_EXISTS)) {
- _I("This boot is triggered with fota, start process to send result to client");
-
- ret = fota_client_controller_add_event(FOTA_EVENT_REBOOT, fota_result);
- if (ret < 0) {
- _E("Failed to add fota client event : %d, idx : %d, value : %s",
- ret, FOTA_EVENT_REBOOT, fota_result);
- return -1;
- }
-
- ret = remove(STATUS_FLAG_PATH);
- if (ret != 0) {
- _E("Failed to remove fota flag : %m");
- return -1;
- }
-
- _I("Success to process boot triggered with fota");
- } else {
- _I("This boot isn't triggered with fota");
- }
-
- return 0;
-}
-
-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)) {
- _I("This boot have fota status, start process to get fota result");
-
- ret = util_file_read_line(STATUS_RESULT_PATH, buf);
- if (ret < 0) {
- _E("Failed to read fota result : %d", ret);
- return -1;
- }
-
- fota_result = strndup(buf, strlen(buf));
- if (fota_result == NULL) {
- _E("Failed to strndup value (%s) : %m", buf);
- return -1;
- }
-
- _I("Success to read fota result : %s", fota_result);
-
- ret = fota_status_checker_process();
- if (ret < 0) {
- _E("Failed to process fota reboot result : %d", ret);
- return -1;
- }
- } else {
- _I("This boot doesn't have fota result");
- }
-
- return 0;
-}
-
-int fota_status_checker_fini()
-{
- if (fota_result)
- free(fota_result);
-
- return 0;
-}
#include "../update-manager.h"
+#include "fota-manager.h"
static const char* fota_event_keys[FOTA_EVENT_SIZE] = {
- CLIENT_APP_CTRL_LOCAL_KEY,
- CLIENT_APP_CTRL_UNPLUG_KEY,
- CLIENT_APP_CTRL_REBOOT_KEY,
+ FOTA_CLIENT_APP_CTRL_PLUG_KEY,
+ FOTA_CLIENT_APP_CTRL_UNPLUG_KEY,
+ FOTA_CLIENT_APP_CTRL_REBOOT_KEY,
};
static char *fota_event_values[FOTA_EVENT_SIZE] = {
NULL,
appid = fota_client_info_get_appid();
if (appid == NULL) {
- _I("Failed to launch fota client, not found");
+ _FLOGI("Failed to launch fota client, not found");
return 1;
}
if (!common_boot_status_checker_is_success()) {
- _I("Failed to launch fota client, user session is unset");
+ _FLOGI("Failed to launch fota client, user session is unset");
return 2;
}
if (fota_event_values[idx] != NULL) {
ret = common_client_controller_launch(appid, fota_event_keys[idx], fota_event_values[idx]);
if (ret < 0) {
- _E("Failed to launch fota client : %d, appid: %s, key : %s, value : %s",
+ _FLOGE("Failed to launch fota client : %d, appid: %s, key : %s, value : %s",
ret, appid, fota_event_keys[idx], fota_event_values[idx]);
status = -1;
continue;
}
- _I("Success to launch fota client, appid: %s, key : %s, value : %s",
+ _FLOGI("Success to launch fota client, appid: %s, key : %s, value : %s",
appid, fota_event_keys[idx], fota_event_values[idx]);
free(fota_event_values[idx]);
int ret = 0;
if (fota_event_values[idx] != NULL) {
- _I("Same fota event has already set, key: %s, value: %s",
+ _FLOGI("Same fota event has already set, key: %s, value: %s",
fota_event_keys[idx], fota_event_values[idx]);
return -1;
}
fota_event_values[idx] = strndup(value, strlen(value));
if (fota_event_values[idx] == NULL) {
- _E("Failed to strndup value (%s) : %m", value);
+ _FLOGE("Failed to strndup value (%s) : %m", value);
return -1;
}
- _I("Success to set fota client event, key: %s, value: %s",
+ _FLOGI("Success to set fota client event, key: %s, value: %s",
fota_event_keys[idx], fota_event_values[idx]);
if (fota_event_values[FOTA_EVENT_PLUG] != NULL &&
fota_event_values[FOTA_EVENT_UNPLUG] != NULL) {
- _I("Find fota plug/unplug event set at the same time, so remove them");
+ _FLOGI("Find fota plug/unplug event set at the same time, so remove them");
free(fota_event_values[FOTA_EVENT_PLUG]);
free(fota_event_values[FOTA_EVENT_UNPLUG]);
ret = fota_client_controller_process_event();
if (ret < 0) {
- _E("Failed to process fota event : %d", ret);
+ _FLOGE("Failed to process fota event : %d", ret);
return -1;
}
#include "../update-manager.h"
+#include "fota-manager.h"
static char *fota_client_app_id = NULL;
ret = common_client_info_checker_get_appid(handle, &fota_client_app_id);
if (ret < 0) {
- _E("Failed to get fota app id from handle : %d", ret);
+ _FLOGE("Failed to get fota app id from handle : %d", ret);
return -1;
}
- _I("Success to find fota client id : %s, try process fota event", fota_client_app_id);
+ _FLOGI("Success to find fota client id : %s, try process fota event", fota_client_app_id);
ret = fota_client_controller_process_event();
if (ret < 0)
- _E("Failed to process fota client event : %d", ret);
+ _FLOGE("Failed to process fota client event : %d", ret);
return 0;
}
ret = common_client_info_checker_filter(FOTA_CLIENT_METADATA_KEY, FOTA_CLIENT_METADATA_VALUE, fota_client_info_checker_callback);
if (ret < 0) {
- _E("Failed to set fota client app filter : %d, key : %s, value : %s",
+ _FLOGE("Failed to set fota client app filter : %d, key : %s, value : %s",
ret, FOTA_CLIENT_METADATA_KEY, FOTA_CLIENT_METADATA_VALUE);
return -1;
}
--- /dev/null
+#include "fota-manager.h"
+#include "../update-manager.h"
+
+static char *build_string = NULL;
+static char *platform_version = NULL;
+
+char *fota_info_get_build_string()
+{
+ return build_string;
+}
+
+char *fota_info_get_platform_version()
+{
+ return platform_version;
+}
+
+int fota_info_checker_init()
+{
+ int ret = 0;
+
+ _FLOGI("Start process to get fota information");
+ ret = system_info_get_platform_string(SYSTEM_INFO_BUILD_STRING, &build_string);
+ if (ret != SYSTEM_INFO_ERROR_NONE) {
+ _FLOGE("system_info_get_platform_string failed : %d", ret);
+ return -1;
+ }
+
+ ret = system_info_get_platform_string(SYSTEM_INFO_PLATFORM_VERSION, &platform_version);
+ if (ret != SYSTEM_INFO_ERROR_NONE) {
+ _FLOGE("system_info_get_platform_string failed : %d", ret);
+ return -1;
+ }
+
+ _FLOGI("Success to get fota information, platform : %s, build_string : %s",
+ platform_version, build_string);
+ return 0;
+}
+
+int fota_info_checker_fini()
+{
+ if (build_string)
+ free(build_string);
+
+ if (platform_version)
+ free(platform_version);
+
+ return 0;
+}
\ No newline at end of file
+#ifndef __FOTA_MANAGER_H__
+#define __FOTA_MANAGER_H__
+
+#include <dlog.h>
+#include <system_info.h>
+
+/* Log */
+#define FOTA_LOG_TAG "FOTA_MANAGER"
+
+#define _FLOGD(fmt, arg...) SLOG(LOG_INFO, FOTA_LOG_TAG, fmt, ##arg)
+#define _FLOGI(fmt, arg...) SLOG(LOG_INFO, FOTA_LOG_TAG, fmt, ##arg)
+#define _FLOGW(fmt, arg...) SLOG(LOG_WARN, FOTA_LOG_TAG, fmt, ##arg)
+#define _FLOGE(fmt, arg...) SLOG(LOG_ERROR, FOTA_LOG_TAG, fmt, ##arg)
+
+/* Constant */
+#define FOTA_CLIENT_METADATA_KEY "tizen-fota-manager"
+#define FOTA_CLIENT_METADATA_VALUE "client"
+#define FOTA_CLIENT_APP_CTRL_PLUG_KEY "fota-plug"
+#define FOTA_CLIENT_APP_CTRL_UNPLUG_KEY "fota-unplug"
+#define FOTA_CLIENT_APP_CTRL_REBOOT_KEY "fota-reboot"
+
+#define SYSTEM_INFO_BUILD_STRING "tizen.org/system/build.string"
+#define SYSTEM_INFO_PLATFORM_VERSION "tizen.org/feature/platform.version"
+
+#define FOTA_EVENT_SIZE 3
+
+/* Enum */
+typedef enum {
+ FOTA_EVENT_PLUG = 0,
+ FOTA_EVENT_UNPLUG = 1,
+ FOTA_EVENT_REBOOT = 2
+} fota_event_idx;
+
+/* Function */
+int fota_client_controller_process_event(void);
+int fota_client_controller_add_event(fota_event_idx, const char *);
+
+int fota_client_info_checker_init(void);
+int fota_client_info_checker_fini(void);
+char *fota_client_info_get_appid(void);
+
+int fota_info_checker_init(void);
+int fota_info_checker_fini(void);
+char *fota_info_get_build_string(void);
+char *fota_info_get_platform_version(void);
+
+int fota_status_checker_init(void);
+int fota_status_checker_fini(void);
+char *fota_status_get_result(void);
+
+void fota_storage_checker_plug(int, const char *);
+void fota_storage_checker_unplug(int, const char *);
+
+#endif /* __FOTA_MANAGER_H__ */
--- /dev/null
+#include "fota-manager.h"
+#include "../update-manager.h"
+
+static char *fota_result = NULL;
+
+char *fota_status_get_result()
+{
+ return fota_result;
+}
+
+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)) {
+ _FLOGI("This boot doesn't have fota result");
+ return 0;
+ }
+
+ ret = util_file_read_line(STATUS_RESULT_PATH, buf);
+ if (ret < 0) {
+ _FLOGE("Failed to read fota result : %d", ret);
+ return -1;
+ }
+
+ fota_result = strndup(buf, strlen(buf));
+ if (fota_result == NULL) {
+ _FLOGE("Failed to strndup value (%s) : %m", buf);
+ return -1;
+ }
+
+ _FLOGI("Success to read fota result : %s", fota_result);
+ if (!g_file_test(STATUS_FLAG_PATH, G_FILE_TEST_EXISTS)) {
+ _FLOGI("This boot isn't triggered with fota");
+ return 0;
+ }
+
+ ret = fota_client_controller_add_event(FOTA_EVENT_REBOOT, fota_result);
+ if (ret < 0) {
+ _FLOGE("Failed to add fota client event : %d, idx : %d, value : %s",
+ ret, FOTA_EVENT_REBOOT, fota_result);
+ return -1;
+ }
+
+ ret = remove(STATUS_FLAG_PATH);
+ if (ret != 0) {
+ _FLOGE("Failed to remove fota flag : %d, %m", ret);
+ return -1;
+ }
+
+ return 0;
+}
+
+int fota_status_checker_fini()
+{
+ if (fota_result)
+ free(fota_result);
+
+ return 0;
+}
#include "../update-manager.h"
+#include "fota-manager.h"
static int fota_storage_id = -1;
mount = g_file_new_for_path(mount_path);
enumerator = g_file_enumerate_children(mount, G_FILE_ATTRIBUTE_STANDARD_NAME, G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS, NULL, &error);
if (enumerator == NULL) {
- _E("Failed to get enumerator : %s", error->message);
+ _FLOGE("Failed to get enumerator : %s", error->message);
g_clear_error(&error);
status = -1;
goto search_destroy;
}
- build_id = fota_info_get_build_id();
+ build_id = fota_info_get_build_string();
if (build_id == NULL) {
- _E("Failed to get build id");
+ _FLOGE("Failed to get build id");
status = -1;
goto search_destroy;
}
}
if (*delta_path != NULL) {
- _I("Success to find delta path : %s", *delta_path);
+ _FLOGI("Success to find delta path : %s", *delta_path);
} else {
- _I("Failed to find delta path with prefix %s", build_id);
+ _FLOGI("Failed to find delta path with prefix %s", build_id);
status = 1;
}
int ret = 0;
gchar *delta_path = NULL;
- _I("Storage mounted with %s, start process to check local delta", mount_path);
+ _FLOGI("Storage mounted with %s, start process to check local delta", mount_path);
ret = fota_storage_search_delta_path(mount_path, &delta_path);
if (ret != 0) {
- _E("Failed to find delta path : %d", ret);
+ _FLOGE("Failed to find delta path : %d", ret);
goto plug_destroy;
}
ret = fota_controller_verify_delta(delta_path);
if (ret != 0) {
- _E("Failed to verify delta : %d", ret);
+ _FLOGE("Failed to verify delta : %d", ret);
goto plug_destroy;
}
ret = fota_client_controller_add_event(FOTA_EVENT_PLUG, delta_path);
if (ret < 0) {
- _E("Failed to add fota client event : %d, idx : %d, value : %s",
+ _FLOGE("Failed to add fota client event : %d, idx : %d, value : %s",
ret, FOTA_EVENT_PLUG, delta_path);
goto plug_destroy;
}
if (storage_id == fota_storage_id) {
ret = fota_client_controller_add_event(FOTA_EVENT_UNPLUG, mount_path);
if (ret < 0) {
- _E("Failed to add fota client event : %d, idx : %d, value : %s",
+ _FLOGE("Failed to add fota client event : %d, idx : %d, value : %s",
ret, FOTA_EVENT_UNPLUG, mount_path);
}
fota_storage_id = -1;
#include "recovery/recovery-manager.h"
+#include "fota/fota-manager.h"
#include "update-manager.h"
int main(int argc, char *argv[])
#include <stdio.h>
#include <stdlib.h>
#include <storage.h>
-#include <system_info.h>
#include <sys/stat.h>
#include <unistd.h>
#include <vconf.h>
/* Common */
#define MAX_BUFFER_SIZE 256
-#define MAX_STACK_SIZE 5
#define OWNER_UID 5001
/* Dbus */
#define INTERFACE_NAME "org.tizen.update.manager"
#define NODE_NAME "/org/tizen/update/manager"
-/* Client */
-#define FOTA_CLIENT_METADATA_KEY "tizen-update-manager"
-#define FOTA_CLIENT_METADATA_VALUE "client"
-#define CLIENT_APP_CTRL_LOCAL_KEY "fota-local"
-#define CLIENT_APP_CTRL_UNPLUG_KEY "fota-unplug"
-#define CLIENT_APP_CTRL_REBOOT_KEY "fota-reboot"
-
/* Update */
-#define PLATFORM_VERSION_KEY "tizen.org/feature/platform.version"
#define PLATFORM_VERSION_DIR "/opt/etc"
#define PLATFORM_VERSION_FILE "version"
#define PLATFORM_VERSION_PATH PLATFORM_VERSION_DIR "/" PLATFORM_VERSION_FILE
-#define BUILD_ID_KEY "tizen.org/system/build.string"
#define BUILD_ID_DIR "/tmp"
#define BUILD_ID_FILE "build_id.txt"
#define BUILD_ID_PATH BUILD_ID_DIR "/" BUILD_ID_FILE
#define FOTA_DELTA_PATH FOTA_DIR "/" FOTA_DELTA_FILE
#define FOTA_DELTA_UA_FILE "delta.ua"
-#define FOTA_EVENT_SIZE 3
-
#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 SHARED_DIR "/opt/usr/home/owner/apps_rw"
#define SHARED_DATA_DIR "shared/data"
-/* Enum */
-typedef enum {
- FOTA_EVENT_PLUG = 0,
- FOTA_EVENT_UNPLUG = 1,
- FOTA_EVENT_REBOOT = 2
-} fota_event_idx;
-
/* Function */
-int fota_client_info_checker_init(void);
-int fota_client_info_checker_fini(void);
-char *fota_client_info_get_appid(void);
-
-int fota_client_controller_process_event(void);
-int fota_client_controller_add_event(fota_event_idx, const char *);
-
int common_storage_checker_init(void);
int common_storage_checker_fini(void);
int dbus_manager_init(void);
int dbus_manager_fini(void);
-int fota_info_checker_init(void);
-int fota_info_checker_fini(void);
-char *fota_info_get_build_id(void);
-char *fota_info_get_platform_version(void);
-
-int fota_status_checker_init(void);
-int fota_status_checker_fini(void);
-char *fota_status_get_result(void);
-
int fota_controller_verify_delta(const char *);
int fota_controller_install(void);
int fota_controller_result(void);
-void fota_storage_checker_plug(int, const char *);
-void fota_storage_checker_unplug(int, const char *);
-
int util_file_mkdir(const char *);
int util_file_read_line(const char *, char []);
int util_file_write_line(const char *, const char *);