Add fota unplugged event 10/239810/3
authorJeon Sang-Heon <sh95.jeon@samsung.com>
Tue, 28 Jul 2020 14:56:36 +0000 (14:56 +0000)
committerJeon Sang-Heon <sh95.jeon@samsung.com>
Fri, 31 Jul 2020 15:16:38 +0000 (15:16 +0000)
- key : fota-unplug, value : (mount path)

Change-Id: I4f2f52deafa7c16dc5bafdf00c2e8e93bd18e521
Signed-off-by: Jeon Sang-Heon <sh95.jeon@samsung.com>
update-manager/client-controller.c
update-manager/common-storage-checker.c
update-manager/fota-storage-checker.c
update-manager/update-manager.h

index 0d5d064d66e543c89628107f85d20aff6284d588..c95200f930d17dd323de3c8030af4d69c3475d0f 100644 (file)
@@ -79,7 +79,7 @@ request_destroy:
        return status;
 }
 
-int client_controller_add_launch_request_with_data(char *key, char *value)
+int client_controller_add_launch_request_with_data(const char *key, const char *value)
 {
        int ret = 0;
        char *mem = NULL;
index ac657a5bda055f2db1b1220971886c8aa9d5ffbd..cd701a8261c8da487809724c45460de43a48a564 100644 (file)
@@ -5,13 +5,16 @@ void common_storage_checker_callback(int storage_id, storage_dev_e dev, storage_
 {
        switch (state) {
        case STORAGE_STATE_UNMOUNTABLE:
-       case STORAGE_STATE_REMOVED:
        case STORAGE_STATE_MOUNTED_READ_ONLY:
                _D("Storage %d status : not mounted", storage_id);
                break;
        case STORAGE_STATE_MOUNTED:
                _I("Storage %d status : mounted", storage_id);
-               fota_storage_checker_process(mount_path);
+               fota_storage_checker_plug(storage_id, mount_path);
+               break;
+       case STORAGE_STATE_REMOVED:
+               _I("Storage %d status : removed", storage_id);
+               fota_storage_checker_unplug(storage_id, mount_path);
                break;
        default:
                _E("Unexpected state : %d", state);
index 95bca75bf24465b972bfb3d41781bb49e5908d83..c6f3539e969b265c8de517fc322b4bc1fde72776 100644 (file)
@@ -1,5 +1,7 @@
 #include "update-manager.h"
 
+static int fota_storage_id = -1;
+
 int fota_storage_search_delta_path(const char *mount_path, gchar **delta_path)
 {
        int status = 0;
@@ -58,7 +60,7 @@ search_destroy:
        return status;
 }
 
-void fota_storage_checker_process(const char *mount_path)
+void fota_storage_checker_plug(int storage_id, const char *mount_path)
 {
        int ret = 0;
        gchar *delta_path = NULL;
@@ -81,7 +83,21 @@ void fota_storage_checker_process(const char *mount_path)
                _E("Failed to add launch request : %d, key : %s, value : %s",
                        ret, CLIENT_APP_CTRL_LOCAL_KEY, delta_path);
        }
+       fota_storage_id = storage_id;
 
 process_destroy:
        g_free(delta_path);
 }
+
+void fota_storage_checker_unplug(int storage_id, const char *mount_path)
+{
+       int ret = 0;
+       if (storage_id == fota_storage_id) {
+               ret = client_controller_add_launch_request_with_data(CLIENT_APP_CTRL_UNPLUG_KEY, mount_path);
+               if (ret < 0) {
+                       _E("Failed to add launch request : %d, key : %s, value : %s",
+                               ret, CLIENT_APP_CTRL_UNPLUG_KEY, mount_path);
+               }
+               fota_storage_id = -1;
+       }
+}
index 3def4217a38256b8b0fa2b1674874e62afff8d31..254f57584ab3ffb667df097c1e2930d1fe953948 100644 (file)
@@ -42,6 +42,7 @@
 #define CLIENT_METADATA_KEY         "tizen-update-manager"
 #define CLIENT_METADATA_VALUE       "client"
 #define CLIENT_APP_CTRL_LOCAL_KEY   "fota-local"
+#define CLIENT_APP_CTRL_UNPLUG_KEY  "fota-unplug"
 #define CLIENT_APP_CTRL_REBOOT_KEY  "fota-reboot"
 
 /* Update */
@@ -82,7 +83,7 @@ int client_status_checker_fini(void);
 bool client_status_checker_is_success(void);
 
 int client_controller_process_launch_request(void);
-int client_controller_add_launch_request_with_data(char *, char *);
+int client_controller_add_launch_request_with_data(const char *, const char *);
 
 int common_storage_checker_init(void);
 int common_storage_checker_fini(void);
@@ -103,7 +104,8 @@ int fota_controller_verify_delta(const char *);
 int fota_controller_install(void);
 int fota_controller_result(void);
 
-void fota_storage_checker_process(const char *);
+void fota_storage_checker_plug(int, const char *);
+void fota_storage_checker_unplug(int, const char *);
 
 int util_file_mkdir(const char *);
 int util_file_read_line(const char *, char []);