#include <assert.h>
#include <linux/limits.h>
+
+#include <hal/device/hal-board.h>
+
#include "../common/common.h"
#include "fota-manager.h"
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;
}
}
+ 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