static void save_result(int result);
static void save_cause(int cause);
-static int get_last_update_status(void);
/*-----------------------------------------------------------------------------
fota_gui_update_progress
}
/*-----------------------------------------------------------------------------
- read_from_file
- ----------------------------------------------------------------------------*/
-int read_from_file(const char *path, char *buf, size_t size)
-{
- int fd;
- ssize_t count;
-
- if (!path)
- return -1;
-
- if (size == 0)
- return 0;
-
- fd = open(path, O_RDONLY, 0);
- LOG("open '%s'\n", path);
- if (fd == -1) {
- LOG("Could not open '%s'", path);
- return -1;
- }
-
- count = read(fd, buf, size);
- if (count > 0) {
- count = (count < (ssize_t)size) ? count : ((ssize_t)size - 1);
- while (count > 0 && buf[count - 1] == '\n')
- count--;
- buf[count] = '\0';
- } else {
- buf[0] = '\0';
- }
- LOG("read '%s'\n", buf);
-
- close(fd);
-
- return (int)count;
-}
-
-
-/*-----------------------------------------------------------------------------
- write_to_file
- ----------------------------------------------------------------------------*/
-/* size is the contents size, not buf size
- buf size should be larger than contents size */
-int write_to_file(const char *path, char *buf, size_t size)
-{
- int fd;
- ssize_t count;
-
- if (!path)
- return -1;
-
- fd = open(path, O_WRONLY | O_CREAT, S_IRWXU);
- LOG("open '%s'\n", path);
-
- if (fd == -1) {
- LOG("Could not open '%s'\n", path);
- return -1;
- }
-
- count = write(fd, buf, size);
- LOG("write '%s'\n", buf);
-
- if (fsync(fd) < 0)
- LOG("fsync failed.\n");
-
- close(fd);
-
- if (size != count) {
- LOG("Could not write to '%s'\n", path);
- return -1;
- }
-
- return 0;
-}
-
-/*-----------------------------------------------------------------------------
- write_num_to_file
- ----------------------------------------------------------------------------*/
-int write_num_to_file(const char *path, int num)
-{
- char num_str[16];
-
- snprintf(num_str, sizeof(num_str), "%d", num);
- return write_to_file(path, num_str, strlen(num_str));
-}
-
-/*-----------------------------------------------------------------------------
- get_last_update_status
- ----------------------------------------------------------------------------*/
-static int get_last_update_status(void)
-{
- /*
- if status file does not exist, status = UP_START_NONE.
- if status file exist, read status from file.
- */
- char buf[256];
- int status = UP_START_NONE;
-
- if (check_existence(fota_status_path) == 0)
- return UP_START_NONE;
-
- if (read_from_file(fota_status_path, buf, sizeof(buf)) < 0)
- return UP_START_NONE;
-
- status = atoi(buf);
- if ((status > UP_START_NONE) && (status < s_part_num))
- return status;
- else
- return UP_START_NONE;
-}
-
-/*-----------------------------------------------------------------------------
- set_last_update_status
- ----------------------------------------------------------------------------*/
-static void set_last_update_status(int status)
-{
- /*
- if status file exist, write status to file.
- if status file does not exist, create file and write status to file.
- */
- write_num_to_file(fota_status_path, status);
-}
-
-/*-----------------------------------------------------------------------------
get_time_stamp
----------------------------------------------------------------------------*/
static char ts[256];
int item_size = 0;
int last_update_status = UP_START_NONE;
int update_status = UP_START_NONE;
+ int del_type = 0; // delta type
int part_idx = UA_PARTI_MAX;
unsigned int update_type = 0;
unsigned long ui32Operation = UI_OP_SCOUT;
s_part_info[i].ua_subject_name);
}
- last_update_status = get_last_update_status();
- LOG("Updatea_all() Last Update status To start with [%d] \n", last_update_status);
+ last_update_status = SS_Get_last_update_status();
+ del_type = SS_Get_last_update_del_type();
+ LOG("last_update_status: [%d], del_type: [%d] \n", last_update_status, del_type);
/* Verify */
if (last_update_status == UP_START_NONE) {
for (part_idx = 0; part_idx < s_part_num; part_idx++) {
get_time_stamp();
LOG("[%s] Verify %s ..............................................................\n", ts,
s_part_info[part_idx].ua_parti_name);
-
update_type = s_update_cfg[part_idx].update_type;
if (update_type == FULL_IMG)
ret = verify_Full_Image(part_idx);
LOG("[%s] Update %s ..............................................................\n", ts,
s_part_info[part_idx].ua_parti_name);
- set_last_update_status(update_status);
+ SS_Set_last_update_status(update_status, del_type);
update_type = s_update_cfg[part_idx].update_type;
if (update_type == FULL_IMG)
goto CleanUp;
}
s_update_data[part_idx].update_check = 1;
+ del_type = 0;
}
}
}
if (part_idx == s_part_num)
- set_last_update_status(s_part_num);
+ SS_Set_last_update_status(s_part_num, 0);
get_time_stamp();
LOG("[%s] Update End ..............................................................\n", ts);