sdcard: send notification to ECP when sdcard state is changed
authorChulHo Song <ch81.song@samsung.com>
Fri, 29 Jan 2016 08:45:14 +0000 (17:45 +0900)
committerChulHo Song <ch81.song@samsung.com>
Wed, 3 Feb 2016 02:24:28 +0000 (11:24 +0900)
Change-Id: Ic8804fc221058cae14bd74509c2ca84b6b45c29c
Signed-off-by: ChulHo Song <ch81.song@samsung.com>
(cherry picked from commit 7e051a5400555016e4656f9635e0fe4b26409405)

tizen/src/ecs/ecs_sdcard.c
tizen/src/util/device_hotplug.c

index f70c406..e249510 100644 (file)
@@ -136,10 +136,10 @@ static void send_sdcard_status(void)
 
     qapi_free_BlockInfoList(block_list);
     LOG_INFO("sdcard data: %s\n", data);
-    if (data[0] == 0) {
-        make_send_device_ntf((char*)MSG_TYPE_SDCARD, GROUP_SDCARD, ACT_SDCARD_DETACH_STATUS, NULL);
-    } else {
+    if (is_sdcard_attached() && data[0] != 0) {
         make_send_device_ntf((char*)MSG_TYPE_SDCARD, GROUP_SDCARD, ACT_SDCARD_ATTACH_STATUS, data);
+    } else {
+        make_send_device_ntf((char*)MSG_TYPE_SDCARD, GROUP_SDCARD, ACT_SDCARD_DETACH_STATUS, NULL);
     }
 }
 
@@ -157,8 +157,6 @@ void handle_sdcard(char* dataBuf, size_t dataLen)
             err_no = remove_sdcard_lock_os(sdcard_full_path);
             if (err_no == 0 && is_sdcard_attached()) {
                 do_hotplug(DETACH_SDCARD, sdcard_full_path, strlen(sdcard_full_path) + 1);
-                make_send_device_ntf((char*)MSG_TYPE_SDCARD, GROUP_SDCARD,
-                        ACT_SDCARD_DETACH, g_path_get_basename(sdcard_full_path));
             } else {
                 LOG_SEVERE("failed to umount: %s, err_no: %d\n", sdcard_full_path, err_no);
                 make_send_device_ntf((char*)MSG_TYPE_SDCARD, GROUP_SDCARD,
@@ -171,8 +169,6 @@ void handle_sdcard(char* dataBuf, size_t dataLen)
             LOG_TRACE("sdcard_full_path: %s\n", sdcard_full_path);
             if (!is_sdcard_attached() && make_sdcard_lock_os(sdcard_full_path)) {
                 do_hotplug(ATTACH_SDCARD, sdcard_full_path, strlen(sdcard_full_path) + 1);
-                make_send_device_ntf((char*)MSG_TYPE_SDCARD, GROUP_SDCARD,
-                        ACT_SDCARD_ATTACH, g_path_get_basename(sdcard_full_path));
             } else {
                 make_send_device_ntf((char*)MSG_TYPE_SDCARD, GROUP_SDCARD,
                         ACT_SDCARD_ATTACH_FAIL, g_path_get_basename(sdcard_full_path));
index 05acabc..2965169 100644 (file)
@@ -130,6 +130,8 @@ static bool do_sdcard_attach(const char * const file)
     g_free(sdcard_device_id);
     g_free(sdcard_drive_id);
     state->sdcard_attached = true;
+    make_send_device_ntf((char*)MSG_TYPE_SDCARD, GROUP_SDCARD,
+                         ACT_SDCARD_ATTACH, g_path_get_basename(file));
     return true;
 }
 
@@ -143,6 +145,9 @@ static bool do_sdcard_detach(const char * const file)
 
     QDECREF(qdict);
     state->sdcard_attached = false;
+    make_send_device_ntf((char*)MSG_TYPE_SDCARD, GROUP_SDCARD,
+                         ACT_SDCARD_DETACH, g_path_get_basename(file));
+
     g_free(sdcard_drive_id);
     return true;
 }