--- /dev/null
+#include "update-manager.h"
+
+static guint owner_id;
+
+gboolean dbus_manager_result(OrgTizenUpdateManager *skeleton, GDBusMethodInvocation *invocation, gpointer user_data)
+{
+ int ret = 0;
+
+ _D("Dbus status : result called");
+ ret = fota_controller_result();
+ if (ret < 0)
+ _W("Failed to fetch result with fota : %d", ret);
+ org_tizen_update_manager_complete_result(skeleton, invocation, ret);
+
+ return TRUE;
+}
+
+gboolean dbus_manager_install(OrgTizenUpdateManager *skeleton, GDBusMethodInvocation *invocation, gpointer user_data)
+{
+ int ret = 0;
+
+ _D("Dbus status : install called");
+ ret = fota_controller_install();
+ if (ret < 0)
+ _W("Failed to install delta with fota : %d", ret);
+ org_tizen_update_manager_complete_install(skeleton, invocation, ret);
+
+ return TRUE;
+}
+
+void dbus_manager_on_name_lost(GDBusConnection *connection, const gchar *name, gpointer user_data)
+{
+ _D("Dbus status : name lost");
+}
+
+void dbus_manager_on_name_acquired(GDBusConnection *connection, const gchar *name, gpointer user_data)
+{
+ _D("Dbus status : name acquired");
+
+ OrgTizenUpdateManager *skeleton = org_tizen_update_manager_skeleton_new();
+ g_signal_connect(skeleton, "handle-install", G_CALLBACK(dbus_manager_install), NULL);
+ g_signal_connect(skeleton, "handle-result", G_CALLBACK(dbus_manager_result), NULL);
+ g_dbus_interface_skeleton_export(G_DBUS_INTERFACE_SKELETON(skeleton), connection, NODE_NAME, NULL);
+}
+
+void dbus_manager_on_bus_acquired(GDBusConnection *connection, const gchar *name, gpointer user_data)
+{
+ _D("Dbus status : bus acquired");
+}
+
+int dbus_manager_init()
+{
+ owner_id = g_bus_own_name(G_BUS_TYPE_SYSTEM, INTERFACE_NAME, G_BUS_NAME_OWNER_FLAGS_NONE,
+ dbus_manager_on_bus_acquired, dbus_manager_on_name_acquired, dbus_manager_on_name_lost, NULL, NULL);
+
+ return 0;
+}
+
+int dbus_manager_fini()
+{
+ g_bus_unown_name(owner_id);
+
+ return 0;
+}
#include "update-manager.h"
-static guint owner_id;
-
int fota_controller_verify_delta(const char *delta_path)
{
int ret = 0, status = 0;
shared_path = g_strjoin("/", SHARED_DIR, appid, SHARED_DATA_DIR, FOTA_DELTA_FILE, NULL);
ret = fota_controller_verify_delta(shared_path);
- if (ret < 0) {
+ if (ret != 0) {
_E("Failed to verify delta : %d", ret);
status = -1;
goto delta_destroy;
- } else if (ret > 0) {
- _I("Failed to verify delta : %d", ret);
- status = -1;
- goto delta_destroy;
}
ret = symlink(shared_path, FOTA_DELTA_PATH);
return status;
}
-/* dbus-send --system --dest=org.tizen.update.manager --type=method_call /org/tizen/update/manager org.tizen.update.manager.install */
-gboolean fota_controller_install(OrgTizenUpdateManager *skeleton, GDBusMethodInvocation *invocation, gpointer user_data)
+int fota_controller_install()
{
- int ret = 0, status = 0;
+ int ret = 0;
ret = fota_controller_setup_delta();
if (ret < 0) {
- _E("Failed to setup delta.tar");
- status = -1;
- goto install_destroy;
+ _E("Failed to setup delta.tar : %d", ret);
+ return -1;
}
ret = fota_controller_write_platform_version();
if (ret < 0) {
- _E("Failed to write platform version");
- status = -1;
- goto install_destroy;
+ _E("Failed to write platform version : %d", ret);
+ return -1;
}
ret = fota_controller_setup_status();
if (ret < 0) {
- _E("Failed to setup fota update status");
- status = -1;
- goto install_destroy;
+ _E("Failed to setup fota update status : %d", ret);
+ return -1;
}
ret = device_power_reboot(FOTA_REBOOT_REASON);
if (ret != DEVICE_ERROR_NONE) {
_E("Failed to request reboot with reason : %s", FOTA_REBOOT_REASON);
- status = -1;
- goto install_destroy;
+ return -1;
}
_I("Success to request fota, device will reboot");
-
-install_destroy:
- org_tizen_update_manager_complete_install(skeleton, invocation, status);
-
- return TRUE;
-}
-
-void fota_controller_on_name_lost(GDBusConnection *conn, const gchar *name, gpointer user_data)
-{
- _D("Dbus status : name lost");
+ return 0;
}
-void fota_controller_on_name_acquired(GDBusConnection *conn, const gchar *name, gpointer user_data)
+int fota_controller_result()
{
- _D("Dbus status : name acquired");
+ char *fota_result = NULL;
+ int len = 0;
- OrgTizenUpdateManager *skeleton = org_tizen_update_manager_skeleton_new();
- g_signal_connect(skeleton, "handle-install", G_CALLBACK(fota_controller_install), NULL);
- g_dbus_interface_skeleton_export(G_DBUS_INTERFACE_SKELETON(skeleton), conn, NODE_NAME, NULL);
-}
+ fota_result = fota_status_get_result();
+ if (fota_result == NULL) {
+ _I("Fota result : Not exist");
+ return 4;
+ }
-void fota_controller_on_bus_acquired(GDBusConnection *conn, const gchar *name, gpointer user_data)
-{
- _D("Dbus status : bus acquired");
-}
+ len = strlen(fota_result);
+ _I("Fota result length : %d", len);
-int fota_controller_init()
-{
- owner_id = g_bus_own_name(G_BUS_TYPE_SYSTEM, INTERFACE_NAME, G_BUS_NAME_OWNER_FLAGS_NONE,
- fota_controller_on_bus_acquired, fota_controller_on_name_acquired, fota_controller_on_name_lost, NULL, NULL);
+ if (len > 2 && fota_result[0] == 'F') {
+ if (fota_result[1] == 'D') {
+ _I("Fota result : RO failed, %s", fota_result);
+ return 3;
+ }
+ else if (fota_result[1] == 'A') {
+ _I("Fota result : RW failed, %s", fota_result);
+ return 2;
+ }
+ }
- return 0;
-}
+ if (len > 1 && fota_result[1] != '0') {
+ _I("Fota result : RO only success, %s", fota_result);
+ return 1;
+ }
-int fota_controller_fini()
-{
- g_bus_unown_name(owner_id);
+ if (len > 1 && fota_result[0] == '0' && fota_result[1] == '0') {
+ _I("Fota result : RO/RW success, %s", fota_result);
+ return 0;
+ }
- return 0;
+ _E("Unexpected result : %s", fota_result);
+ return -1;
}
free(fota_result);
return 0;
-}
\ No newline at end of file
+}
goto main_destroy;
}
- ret = fota_storage_checker_init();
+ ret = fota_status_checker_init();
if (ret < 0) {
- _E("Failed to initialize fota storage checker : %d", ret);
+ _E("Failed to initialize fota status checker : %d", ret);
goto main_destroy;
}
- ret = fota_status_checker_init();
+ ret = fota_storage_checker_init();
if (ret < 0) {
- _E("Failed to initialize fota status checker : %d", ret);
+ _E("Failed to initialize fota storage checker : %d", ret);
goto main_destroy;
}
- ret = fota_controller_init();
+ /* Dbus */
+ ret = dbus_manager_init();
if (ret < 0) {
- _E("Failed to initialize fota controller : %d", ret);
+ _E("Failed to initialize dbus manager : %d", ret);
goto main_destroy;
}
if (ret < 0)
_W("Failed to finalize fota info checker : %d", ret);
- ret = fota_storage_checker_fini();
- if (ret < 0)
- _W("Failed to finalize fota storage checker : %d", ret);
-
ret = fota_status_checker_fini();
if (ret < 0)
_E("Failed to finalize fota status checker : %d", ret);
- ret = fota_controller_fini();
+ ret = fota_storage_checker_fini();
+ if (ret < 0)
+ _W("Failed to finalize fota storage checker : %d", ret);
+
+ /* Dbus */
+ ret = dbus_manager_fini();
if (ret < 0)
- _W("Failed to finalize fota controller : %d", ret);
+ _W("Failed to finalize dbus manager : %d", ret);
if (mainloop) {
g_main_loop_quit(mainloop);
int client_controller_process_launch_request(void);
int client_controller_add_launch_request_with_data(char *, char *);
+int dbus_manager_init(void);
+int dbus_manager_fini(void);
+
int fota_info_checker_init(void);
int fota_info_checker_fini(void);
char *fota_info_get_release_version(void);
int fota_status_checker_fini(void);
char *fota_status_get_result(void);
-int fota_controller_init(void);
-int fota_controller_fini(void);
int fota_controller_verify_delta(const char *);
+int fota_controller_install(void);
+int fota_controller_result(void);
int util_file_mkdir(const char *);
int util_file_read_line(const char *, char []);