fota: Modify condition of upgrade state transition 21/314721/4
authorSangYoun Kwak <sy.kwak@samsung.com>
Wed, 17 Jul 2024 09:57:48 +0000 (18:57 +0900)
committerSangYoun Kwak <sy.kwak@samsung.com>
Mon, 22 Jul 2024 03:47:30 +0000 (12:47 +0900)
upgrade-manager service checks if upgrade is completed at the
initialization time and if upgrade is completed, then transition the
upgrade state from "ready" to "completed".

The transition condition is:
 * upgrade status progress is 100
 * boot mode is "normal"

But if upgrade is performed as 'online' mode, the boot mode(which is
parsed from the /proc/cmdline) is "fota".

To make upgrade state be transitioned to "completed", condition is
modified:
 * upgrade status progress is 100
 * (boot mode is "normal")
    or
   (boot mode is "fota" and upgrade type is "online")

Change-Id: I6d284f135df863c991bc8c08f75d6fa6e2b07ab5
Signed-off-by: SangYoun Kwak <sy.kwak@samsung.com>
update-manager/fota/fota-installer.c

index b59693bbe7ffcacfdac0e7699d2370f395701c8b..25cd04deb1605bda1b768e377e637015d6a7e73d 100644 (file)
@@ -465,6 +465,7 @@ int fota_installer_finish_update(void)
 static int get_upgrade_completed(bool *upgrade_completed)
 {
        char boot_mode[128];
+       char upgrade_type[128];
        int upgrde_progress_status = 0;
        int ret = 0;
 
@@ -480,6 +481,12 @@ static int get_upgrade_completed(bool *upgrade_completed)
                return -1;
        }
 
+       ret = hal_device_board_get_upgrade_type(upgrade_type, sizeof(upgrade_type));
+       if (ret < 0) {
+               _FLOGE("Failed to get boot mode: %d", ret);
+               return -1;
+       }
+
        if (upgrde_progress_status != 100) {
                _FLOGI("Upgrade not completed: upgrade progress status is not 100 but %d",
                                upgrde_progress_status);
@@ -488,9 +495,15 @@ static int get_upgrade_completed(bool *upgrade_completed)
        }
 
        if (strncmp(boot_mode, "normal", sizeof(boot_mode)) != 0) {
-               _FLOGI("Boot mode is not normal: %s", boot_mode);
-               *upgrade_completed = false;
-               return 0;
+               if (strncmp(boot_mode, "fota", sizeof(boot_mode)) != 0) {
+                       *upgrade_completed = false;
+                       return 0;
+               }
+
+               if (strncmp(upgrade_type, "online", sizeof(boot_mode)) != 0) {
+                       *upgrade_completed = false;
+                       return 0;
+               }
        }
 
        *upgrade_completed = true;