From: SangYoun Kwak Date: Fri, 14 Jun 2024 06:13:05 +0000 (+0900) Subject: Add upgrade state transition to 'ready' state X-Git-Tag: accepted/tizen/8.0/unified/20240618.013448~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ac4a06228f0e1c138bb80557d4514ab4298b04eb;p=platform%2Fcore%2Fsystem%2Fupdate-control.git Add upgrade state transition to 'ready' state The start of upgrade is 'ro upgrade' so when the 'ro upgrade' starts, the 'upgrade state' should be transit to the 'ready' state. Change-Id: Ief9da50884e2db418854ef4da5d4f32bb944001d Signed-off-by: SangYoun Kwak --- diff --git a/update-manager/CMakeLists.txt b/update-manager/CMakeLists.txt index 2d9d750..ecf955d 100644 --- a/update-manager/CMakeLists.txt +++ b/update-manager/CMakeLists.txt @@ -19,6 +19,7 @@ SET(PKG_MODULES storage vconf zlib + hal-api-device ) INCLUDE(FindPkgConfig) pkg_check_modules(${PKG_NAME} REQUIRED ${PKG_MODULES}) diff --git a/update-manager/fota/fota-installer.c b/update-manager/fota/fota-installer.c index b0d7953..1306bb0 100644 --- a/update-manager/fota/fota-installer.c +++ b/update-manager/fota/fota-installer.c @@ -1,5 +1,8 @@ #include #include + +#include + #include "../common/common.h" #include "fota-manager.h" @@ -71,6 +74,33 @@ static char *find_delta_dir(const char *appid) return client_delta_path; } +static int set_upgrade_state_ready(void) +{ + char current_upgrade_state[128]; + char *next_upgrade_state = "ready"; + int ret = 0; + + ret = hal_device_board_get_upgrade_state(current_upgrade_state, + sizeof(current_upgrade_state)); + if (ret < 0) { + _FLOGE("Failed to get upgrade state: %d", ret); + return -1; + } + + ret = hal_device_board_set_upgrade_state(current_upgrade_state, + next_upgrade_state); + if (ret < 0) { + _FLOGE("Failed to set upgrade state %s -> %s: %d", + current_upgrade_state, next_upgrade_state, ret); + return -1; + } + + _FLOGI("Succeed to set upgrade state %s -> %s", current_upgrade_state, + next_upgrade_state); + + return 0; +} + int fota_installer_execute(pid_t sender_pid) { int ret = 0, status = 0, exec_status = 0; @@ -140,6 +170,12 @@ int fota_installer_execute(pid_t sender_pid) } } + ret = set_upgrade_state_ready(); + if (ret < 0) { + status = ret; + goto execute_destroy; + } + /* All basic checks succeeded, following is what happens next: We * double-fork() the process and run actual upgrade script in the child * process. We do this so that we can at least inform API client that