#include <alloca.h>
#include <linux/limits.h>
#include <stdlib.h>
+
+#include <hal/hal-device-board.h>
+
#include "../common/common.h"
#include "fota-manager.h"
#undef MAX_ARGS
}
+static int set_upgrade_state(char *next_upgrade_state)
+{
+ char current_upgrade_state[128];
+ 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_ro_update_and_finish_update(pid_t sender_pid)
{
int ret = 0, status = 0, exec_status = 0;
goto execute_destroy;
}
+ 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
goto execute_destroy;
}
+ ret = set_upgrade_state("ready");
+ if (ret < 0) {
+ status = ret;
+ goto execute_destroy;
+ }
+
/*
* This is supposed to bo called asynchronously, so we do
* care if and when the script finishes.