Add upgrade state transition to 'ready' state 80/312780/1
authorSangYoun Kwak <sy.kwak@samsung.com>
Fri, 14 Jun 2024 06:13:05 +0000 (15:13 +0900)
committerSangYoun Kwak <sy.kwak@samsung.com>
Fri, 14 Jun 2024 06:13:05 +0000 (15:13 +0900)
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 <sy.kwak@samsung.com>
update-manager/CMakeLists.txt
update-manager/fota/fota-installer.c

index 2d9d750a56d8bcd718b14eb50db5f8123ec3a1fd..ecf955dd484cffd0a4f13635a4e161809b52badb 100644 (file)
@@ -19,6 +19,7 @@ SET(PKG_MODULES
        storage
        vconf
        zlib
+       hal-api-device
 )
 INCLUDE(FindPkgConfig)
 pkg_check_modules(${PKG_NAME} REQUIRED ${PKG_MODULES})
index b0d7953d000cb55301a0683280ad54fc15715920..1306bb09b2523e7d05d9787f0f8db1638e5a32f6 100644 (file)
@@ -1,5 +1,8 @@
 #include <assert.h>
 #include <linux/limits.h>
+
+#include <hal/device/hal-board.h>
+
 #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