#include "update-manager.h"
-int fota_status_checker_init()
+static char *fota_result = NULL;
+
+char *fota_status_get_result()
+{
+ return fota_result;
+}
+
+int fota_status_checker_process()
{
int ret = 0;
- char buf[MAX_BUFFER_SIZE] = {0,};
- bool exist = false;
- exist = g_file_test(STATUS_FLAG_PATH, G_FILE_TEST_EXISTS) && g_file_test(STATUS_RESULT_PATH, G_FILE_TEST_EXISTS);
- if (exist) {
+ if (g_file_test(STATUS_FLAG_PATH, G_FILE_TEST_EXISTS)) {
_I("This boot is triggered with fota, start process to send result to client");
- ret = util_file_read_line(STATUS_RESULT_PATH, buf);
- if (ret < 0) {
- _E("Failed to read fota result : %d", ret);
- return -1;
- }
-
- ret = client_controller_add_launch_request_with_data(CLIENT_APP_CTRL_REBOOT_KEY, buf);
+ ret = client_controller_add_launch_request_with_data(CLIENT_APP_CTRL_REBOOT_KEY, fota_result);
if (ret < 0) {
_E("Failed to add launch request : %d, key : %s, value : %s",
- ret, CLIENT_APP_CTRL_REBOOT_KEY, buf);
+ ret, CLIENT_APP_CTRL_REBOOT_KEY, fota_result);
return -1;
}
return 0;
}
+
+int fota_status_checker_init()
+{
+ int ret = 0;
+ char buf[MAX_BUFFER_SIZE] = {0, };
+
+ if (g_file_test(STATUS_RESULT_PATH, G_FILE_TEST_EXISTS)) {
+ _I("This boot have fota status, start process to get fota result");
+
+ ret = util_file_read_line(STATUS_RESULT_PATH, buf);
+ if (ret < 0) {
+ _E("Failed to read fota result : %d", ret);
+ return -1;
+ }
+
+ fota_result = strndup(buf, strlen(buf));
+ if (fota_result == NULL) {
+ _E("Failed to strndup value (%s) : %m", buf);
+ return -1;
+ }
+
+ _I("Success to read fota result : %s", fota_result);
+
+ ret = fota_status_checker_process();
+ if (ret < 0) {
+ _E("Failed to process fota reboot result : %d", ret);
+ return -1;
+ }
+ } else {
+ _I("This boot doesn't have fota result");
+ }
+
+ return 0;
+}
+
+int fota_status_checker_fini()
+{
+ if (fota_result)
+ free(fota_result);
+
+ return 0;
+}
\ No newline at end of file