From fec5b2a24e622aae92a9876703e5fa9c362ed39a Mon Sep 17 00:00:00 2001 From: "pr.jung" Date: Mon, 18 Sep 2017 20:19:56 +0900 Subject: [PATCH 01/16] block: Only for primary mmc, vconf key value should be valid Change-Id: I1b3362978d9e649cd8801d7494743bbcb8ff3350 Signed-off-by: pr.jung (cherry picked from commit 4af347bc7a99dcceaa6e8953946756786e81b53b) --- src/block/block.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/block/block.c b/src/block/block.c index 113b15d..da7443f 100644 --- a/src/block/block.c +++ b/src/block/block.c @@ -259,6 +259,9 @@ static void broadcast_block_info(enum block_dev_operation op, if (data->primary != true) return; + if (data->primary != true) + return; + DD_LIST_FOREACH(block_ops_list, elem, ops) { if (ops->block_type != data->block_type) continue; -- 2.7.4 From e736d71f927d0604ea8ed2b97ad1505050aa4fd6 Mon Sep 17 00:00:00 2001 From: "pr.jung" Date: Mon, 18 Sep 2017 20:22:34 +0900 Subject: [PATCH 02/16] app: Call FormatwithType asynchronously Change-Id: I10d779bbd64d1dd6f856d650df2a42ffea9fc33e Signed-off-by: pr.jung (cherry picked from commit 0e6ed6b68508fd5fb438377cd99c443712f2b057) --- apps/extended-sd/include/dbus-call.h | 12 +++- apps/extended-sd/src/dbus-call.c | 79 +++++++++++++++++++++ apps/extended-sd/src/es-internal-storage-page.c | 92 ++++++++++++++++--------- apps/extended-sd/src/es-portable-storage-page.c | 92 +++++++++++++++++-------- 4 files changed, 211 insertions(+), 64 deletions(-) diff --git a/apps/extended-sd/include/dbus-call.h b/apps/extended-sd/include/dbus-call.h index 2cd3a16..7250ae0 100644 --- a/apps/extended-sd/include/dbus-call.h +++ b/apps/extended-sd/include/dbus-call.h @@ -39,9 +39,6 @@ struct dbus_int { int size; }; -int register_signal_handler(appdata_s *); -int unregister_signal_handler(void); - int dbus_method_sync(const char *dest, const char *path, const char *interface, const char *method, const char *sig, char *param[]); @@ -50,6 +47,15 @@ int dbus_method_sync_with_reply(const char *dest, const char *method, const char *sig, char *param[], GVariant **info); +typedef void (*dbus_pending_cb)(void *data, GVariant *result, GError *err); + +int dbus_method_async_with_reply(const char *dest, const char *path, + const char *interface, const char *method, + const char *sig, char *param[], dbus_pending_cb cb, int timeout, void *data); + +int register_signal_handler(appdata_s *); +int unregister_signal_handler(void); + /** * If result is NULL, err is set. * Do not invoke g_variant_unref() with result. diff --git a/apps/extended-sd/src/dbus-call.c b/apps/extended-sd/src/dbus-call.c index 1c4123c..e1ddfff 100644 --- a/apps/extended-sd/src/dbus-call.c +++ b/apps/extended-sd/src/dbus-call.c @@ -29,6 +29,11 @@ #define DBUS_REPLY_TIMEOUT (-1) #define DBUS_MAXIMUM_NAME_LENGTH 255 +struct pending_call_data { + dbus_pending_cb func; + void *data; +}; + struct proxy_node { GDBusProxy *proxy; char *dest; @@ -332,6 +337,80 @@ int dbus_method_sync_with_reply(const char *dest, return 0; } +static void cb_pending(GDBusProxy *proxy, + GAsyncResult *res, + gpointer user_data) +{ + struct pending_call_data *data = user_data; + GError *err = NULL; + GVariant *output; + + output = g_dbus_proxy_call_finish(proxy, + res, /* GAsyncResult */ + &err); + if (!output) + DMSG_ERR("g_dbus_proxy_call_finish error : %d-%s", + err->code, err->message); + + if (data && data->func) + data->func(data->data, output, err); + free(data); + + if (err) + g_clear_error(&err); + if (output) + g_variant_unref(output); +} + +int dbus_method_async_with_reply(const char *dest, const char *path, + const char *interface, const char *method, + const char *sig, char *param[], + dbus_pending_cb cb, int timeout, void *data) +{ + GDBusProxy *proxy; + GError *err = NULL; + struct pending_call_data *pdata; + int result; + +#if !GLIB_CHECK_VERSION(2, 35, 0) + g_type_init(); +#endif + + pthread_mutex_lock(&dmutex); + proxy = get_proxy_from_proxy_pool(dest, path, interface, &err); + if (!proxy) { + pthread_mutex_unlock(&dmutex); + DMSG_ERR("fail to get proxy from proxy pool : %s-%s (%d-%s)", + interface, method, err->code, err->message); + result = g_dbus_error_to_errno(err->code); + g_clear_error(&err); + return result; + } + + pdata = malloc(sizeof(struct pending_call_data)); + if (!pdata) { + pthread_mutex_unlock(&dmutex); + DMSG_ERR("malloc error : %s-%s", + interface, method); + return -ENOMEM; + } + + pdata->func = cb; + pdata->data = data; + + g_dbus_proxy_call(proxy, + method, /* method name */ + append_g_variant(sig, param), /* parameters */ + G_DBUS_CALL_FLAGS_NONE, + DBUS_REPLY_TIMEOUT, /* timeout */ + NULL, /* GCancellable */ + (GAsyncReadyCallback)cb_pending, /* GAsyncReadyCallback */ + pdata); /* user data */ + pthread_mutex_unlock(&dmutex); + + return 0; +} + static GDBusConnection *get_dbus_connection(void) { GError *err = NULL; diff --git a/apps/extended-sd/src/es-internal-storage-page.c b/apps/extended-sd/src/es-internal-storage-page.c index ddf4867..00834c5 100644 --- a/apps/extended-sd/src/es-internal-storage-page.c +++ b/apps/extended-sd/src/es-internal-storage-page.c @@ -58,11 +58,55 @@ _format_click_cb(void *data, Evas_Object* obj, void *event_info) } static void +format_done(void *data, GVariant *result, GError *err) +{ + appdata_s* ad = (appdata_s*)data; + char str_id[32]; + char *arr[2]; + int ret; + + FUNC_BEGIN(); + ret_if(ad == NULL); + ret_if(result == NULL); + + g_variant_get(result, "(i)", &ret); + if (ret < 0) { + DMSG("Failed to format sd card as portable storage: %d", ret); + return; + } + + snprintf(str_id, sizeof(str_id), "%d", ad->storage_id); + arr[0] = str_id; + arr[1] = "ExtendedInternalSD"; + + ret = dbus_method_sync(STORAGED_BUS_NAME, + STORAGED_PATH_BLOCK_MANAGER, STORAGED_INTERFACE_BLOCK_MANAGER, "Mount", "is", arr); + if (ret < 0) { + DMSG("Failed to mount sd card as extended internal storage: %d", ret); + return; + } + + Evas_Object* page_content = elm_object_part_content_unset(ad->internal_storage_page_data->internal_storage_page_base_layout, "elm.swallow.content"); + EVAS_OBJECT_DEL(page_content); + page_content = create_page_5(ad); + elm_object_part_content_set(ad->internal_storage_page_data->internal_storage_page_base_layout, "elm.swallow.content", page_content); + + + g_variant_unref(result); + FUNC_END(); +} + +static void _continue_click_cb(void *data, Evas_Object* obj, void *event_info) { FUNC_BEGIN(); appdata_s* ad = (appdata_s*)data; + char str_id[32]; + char str_option[32]; + char *arr[3]; + int ret; + ret_if(ad == NULL); Evas_Object* page_content = elm_object_part_content_unset(ad->internal_storage_page_data->internal_storage_page_base_layout, "elm.swallow.content"); @@ -70,6 +114,23 @@ _continue_click_cb(void *data, Evas_Object* obj, void *event_info) page_content = create_page_4(ad); elm_object_part_content_set(ad->internal_storage_page_data->internal_storage_page_base_layout, "elm.swallow.content", page_content); + snprintf(str_id, sizeof(str_id), "%d", ad->storage_id); + arr[0] = str_id; + snprintf(str_option, sizeof(str_option), "%d", UNMOUNT_FORCE); + arr[1] = str_option; + arr[2] = "ext4"; + ret = dbus_method_async_with_reply(STORAGED_BUS_NAME, + STORAGED_PATH_BLOCK_MANAGER, + STORAGED_INTERFACE_BLOCK_MANAGER, + "FormatwithType", + "iis", + arr, + format_done, + -1, + ad); + if (ret < 0) + DMSG("Failed to format", ret); + FUNC_END(); } @@ -513,13 +574,7 @@ static Evas_Object* create_page_4(appdata_s* ad) FUNC_BEGIN(); Elm_Genlist_Item_Class *extended_multiline_genlist_itc; - Evas_Object *page_content; genlist_item_s *item; - char str_id[32]; - char str_option[32]; - char *arr[3]; - char *arr2[2]; - int ret; extended_multiline_genlist_itc = elm_genlist_item_class_new(); extended_multiline_genlist_itc->item_style = "extended-multiline"; @@ -563,31 +618,6 @@ static Evas_Object* create_page_4(appdata_s* ad) elm_genlist_item_class_free(extended_multiline_genlist_itc); - snprintf(str_id, sizeof(str_id), "%d", ad->storage_id); - arr[0] = str_id; - arr2[0] = str_id; - snprintf(str_option, sizeof(str_option), "%d", UNMOUNT_FORCE); - arr[1] = str_option; - arr[2] = "ext4"; - ret = dbus_method_sync(STORAGED_BUS_NAME, - STORAGED_PATH_BLOCK_MANAGER, STORAGED_INTERFACE_BLOCK_MANAGER, "FormatwithType", "iis", arr); - if (ret < 0) - DMSG("Failed to format sd card as extended internal storage: %d", ret); - - arr2[1] = "ExtendedInternalSD"; - ret = dbus_method_sync(STORAGED_BUS_NAME, - STORAGED_PATH_BLOCK_MANAGER, STORAGED_INTERFACE_BLOCK_MANAGER, "Mount", "is", arr2); - if (ret < 0) - DMSG("Failed to mount sd card as extended internal storage: %d", ret); - - page_content = elm_object_part_content_unset(ad->internal_storage_page_data->internal_storage_page_base_layout, "elm.swallow.content"); - EVAS_OBJECT_DEL(page_content); - page_content = create_page_5(ad); - elm_object_part_content_set(ad->internal_storage_page_data->internal_storage_page_base_layout, "elm.swallow.content", page_content); - - FUNC_END(); - return page_content; - out: FUNC_END(); return genlist; diff --git a/apps/extended-sd/src/es-portable-storage-page.c b/apps/extended-sd/src/es-portable-storage-page.c index 5699031..01077f6 100644 --- a/apps/extended-sd/src/es-portable-storage-page.c +++ b/apps/extended-sd/src/es-portable-storage-page.c @@ -30,9 +30,52 @@ static Evas_Object* create_page_2(appdata_s* ad); static Evas_Object* create_page_3(appdata_s* ad); static void +format_done(void *data, GVariant *result, GError *err) +{ + appdata_s* ad = (appdata_s*)data; + char str_id[32]; + char *arr[2]; + int ret; + + FUNC_BEGIN(); + ret_if(ad == NULL); + ret_if(result == NULL); + + g_variant_get(result, "(i)", &ret); + if (ret < 0) { + DMSG("Failed to format sd card as portable storage: %d", ret); + return; + } + + snprintf(str_id, sizeof(str_id), "%d", ad->storage_id); + arr[0] = str_id; + arr[1] = ""; + + ret = dbus_method_sync(STORAGED_BUS_NAME, + STORAGED_PATH_BLOCK_MANAGER, STORAGED_INTERFACE_BLOCK_MANAGER, "Mount", "is", arr); + if (ret < 0) { + DMSG("Failed to mount sd card as portable storage: %d", ret); + return; + } + + Evas_Object* page_content = elm_object_part_content_unset(ad->portable_storage_page_data->portable_storage_page_base_layout, "elm.swallow.content"); + EVAS_OBJECT_DEL(page_content); + page_content = create_page_3(ad); + elm_object_part_content_set(ad->portable_storage_page_data->portable_storage_page_base_layout, "elm.swallow.content", page_content); + + g_variant_unref(result); + FUNC_END(); +} + +static void _format_click_cb(void *data, Evas_Object* obj, void *event_info) { FUNC_BEGIN(); + char str_id[32]; + char str_option[32]; + char *arr[3]; + int ret; + appdata_s* ad = (appdata_s*)data; ret_if(ad == NULL); @@ -42,7 +85,26 @@ _format_click_cb(void *data, Evas_Object* obj, void *event_info) page_content = create_page_2(ad); elm_object_part_content_set(ad->portable_storage_page_data->portable_storage_page_base_layout, "elm.swallow.content", page_content); + + snprintf(str_id, sizeof(str_id), "%d", ad->storage_id); + arr[0] = str_id; + snprintf(str_option, sizeof(str_option), "%d", UNMOUNT_FORCE); + arr[1] = str_option; + arr[2] = "vfat"; + ret = dbus_method_async_with_reply(STORAGED_BUS_NAME, + STORAGED_PATH_BLOCK_MANAGER, + STORAGED_INTERFACE_BLOCK_MANAGER, + "FormatwithType", + "iis", + arr, + format_done, + -1, + ad); + if (ret < 0) + DMSG("Failed to format", ret); + FUNC_END(); + } static void @@ -367,13 +429,7 @@ static Evas_Object* create_page_2(appdata_s* ad) FUNC_BEGIN(); Elm_Genlist_Item_Class *extended_multiline_genlist_itc; - Evas_Object *page_content; genlist_item_s *item; - char str_id[32]; - char str_option[32]; - char *arr[3]; - char *arr2[2]; - int ret; extended_multiline_genlist_itc = elm_genlist_item_class_new(); extended_multiline_genlist_itc->item_style = "extended-multiline"; @@ -417,30 +473,6 @@ static Evas_Object* create_page_2(appdata_s* ad) elm_genlist_item_class_free(extended_multiline_genlist_itc); - snprintf(str_id, sizeof(str_id), "%d", ad->storage_id); - arr[0] = str_id; - arr2[0] = str_id; - snprintf(str_option, sizeof(str_option), "%d", UNMOUNT_FORCE); - arr[1] = str_option; - arr[2] = "vfat"; - ret = dbus_method_sync(STORAGED_BUS_NAME, - STORAGED_PATH_BLOCK_MANAGER, STORAGED_INTERFACE_BLOCK_MANAGER, "FormatwithType", "iis", arr); - if (ret < 0) - _D("Failed to format sd card as portable storage: %d", ret); - - arr2[1] = ""; - ret = dbus_method_sync(STORAGED_BUS_NAME, - STORAGED_PATH_BLOCK_MANAGER, STORAGED_INTERFACE_BLOCK_MANAGER, "Mount", "is", arr2); - if (ret < 0) - _D("Failed to mount sd card as portable storage: %d", ret); - - page_content = elm_object_part_content_unset(ad->portable_storage_page_data->portable_storage_page_base_layout, "elm.swallow.content"); - EVAS_OBJECT_DEL(page_content); - page_content = create_page_3(ad); - elm_object_part_content_set(ad->portable_storage_page_data->portable_storage_page_base_layout, "elm.swallow.content", page_content); - - FUNC_END(); - return page_content; out: FUNC_END(); return genlist; -- 2.7.4 From 7f6adcb40d48b11d388836d0e8d361d9d4aca89d Mon Sep 17 00:00:00 2001 From: "pr.jung" Date: Tue, 19 Sep 2017 13:46:04 +0900 Subject: [PATCH 03/16] app: Change async call timeout to 120sec. Change-Id: I09f1c634cd09246fb481a7bd4d6a3d32ee629147 Signed-off-by: pr.jung (cherry picked from commit 8b5a310953a56fc7281793ebb63cf79e3634d176) --- apps/extended-sd/src/dbus-call.c | 2 +- apps/extended-sd/src/es-internal-storage-page.c | 2 +- apps/extended-sd/src/es-portable-storage-page.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/extended-sd/src/dbus-call.c b/apps/extended-sd/src/dbus-call.c index e1ddfff..cdc503e 100644 --- a/apps/extended-sd/src/dbus-call.c +++ b/apps/extended-sd/src/dbus-call.c @@ -402,7 +402,7 @@ int dbus_method_async_with_reply(const char *dest, const char *path, method, /* method name */ append_g_variant(sig, param), /* parameters */ G_DBUS_CALL_FLAGS_NONE, - DBUS_REPLY_TIMEOUT, /* timeout */ + timeout, //DBUS_REPLY_TIMEOUT, /* timeout */ NULL, /* GCancellable */ (GAsyncReadyCallback)cb_pending, /* GAsyncReadyCallback */ pdata); /* user data */ diff --git a/apps/extended-sd/src/es-internal-storage-page.c b/apps/extended-sd/src/es-internal-storage-page.c index 00834c5..e5f2d94 100644 --- a/apps/extended-sd/src/es-internal-storage-page.c +++ b/apps/extended-sd/src/es-internal-storage-page.c @@ -126,7 +126,7 @@ _continue_click_cb(void *data, Evas_Object* obj, void *event_info) "iis", arr, format_done, - -1, + 120000, // ms ad); if (ret < 0) DMSG("Failed to format", ret); diff --git a/apps/extended-sd/src/es-portable-storage-page.c b/apps/extended-sd/src/es-portable-storage-page.c index 01077f6..6e9ffdb 100644 --- a/apps/extended-sd/src/es-portable-storage-page.c +++ b/apps/extended-sd/src/es-portable-storage-page.c @@ -98,7 +98,7 @@ _format_click_cb(void *data, Evas_Object* obj, void *event_info) "iis", arr, format_done, - -1, + 120000, ad); if (ret < 0) DMSG("Failed to format", ret); -- 2.7.4 From 95f8b324dd953c54642530c43a9b53a13b73c88e Mon Sep 17 00:00:00 2001 From: "pr.jung" Date: Tue, 19 Sep 2017 14:10:00 +0900 Subject: [PATCH 04/16] block: Launch sdcard setting popup when sdcard is inserted after booting is done Change-Id: Icd62e3be2d58c82d2f4afaf854590a1cf1239fed Signed-off-by: pr.jung (cherry picked from commit 7ac0b06affd5668ee06c1466d44d7a0bf10dc128) --- src/block/block.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/block/block.c b/src/block/block.c index da7443f..c973874 100644 --- a/src/block/block.c +++ b/src/block/block.c @@ -2082,7 +2082,7 @@ out: } // Called by MainThread -static int add_block_device(struct udev_device *dev, const char *devnode) +static int add_block_device(struct udev_device *dev, const char *devnode, bool init) { struct block_data *data; struct block_device *bdev; @@ -2149,18 +2149,13 @@ static int add_block_device(struct udev_device *dev, const char *devnode) bdev->data->primary) { _I("Check whether sdcard will be used as extended internal storage"); - if (!bdev->data->fs_type) { - _D("Storage is unformatted"); + if (!init) { snprintf(id_string, PATH_LEN, "%d", bdev->data->id); ret = launch_system_app(POPUP_DEFAULT, 4, POPUP_KEY_CONTENT, "sdcardsetup", POPUP_SDCARD_ID, id_string); if (ret < 0) _E("Failed to launch popup"); return 0; } - - //TODO Need to check for other phone - if (!strncmp(bdev->data->fs_type, LUKS_NAME, strlen(LUKS_NAME))) - bdev->data->block_type = BLOCK_MMC_EXTENDED_INTERNAL_DEV; } else { if (!bdev->data->fs_type) { _E("Unformatted Storage"); @@ -2417,7 +2412,7 @@ static int block_init_from_udev_enumerate(void) } _I("%s device add", devnode); - add_block_device(dev, devnode); + add_block_device(dev, devnode, true); udev_device_unref(dev); } @@ -2569,7 +2564,7 @@ static void uevent_block_handler(struct udev_device *dev) return; } - add_block_device(dev, devnode); + add_block_device(dev, devnode, false); } else if (!strncmp(action, UDEV_REMOVE, sizeof(UDEV_REMOVE))) remove_block_device(dev, devnode); } -- 2.7.4 From 89e19344e0c241d45a6e5cd8c564cc8c0328298a Mon Sep 17 00:00:00 2001 From: "pr.jung" Date: Tue, 19 Sep 2017 14:28:04 +0900 Subject: [PATCH 05/16] block: Change /opt/extendedsd directory access permission - 770 root priv_externalstorage * -> 755 root root _ Change-Id: I2428d90e7178fd50af822aa1ff7895dc324fce0b Signed-off-by: pr.jung (cherry picked from commit a490b2e4eb125c07771dd5084e324e73a61242a1) --- src/block/block.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/block/block.c b/src/block/block.c index c973874..9829dd5 100644 --- a/src/block/block.c +++ b/src/block/block.c @@ -1150,7 +1150,10 @@ static int block_mount(struct block_data *data) goto out; } - r = fs->mount(smack, data->devnode, data->mount_point); + if (data->block_type == BLOCK_MMC_EXTENDED_INTERNAL_DEV) + r = fs->mount(false, data->devnode, data->mount_point); + else + r = fs->mount(smack, data->devnode, data->mount_point); if (r == -EIO) BLOCK_FLAG_SET(data, FS_BROKEN); -- 2.7.4 From 8196ffe08b2aa9ed825f284e4442d336332657ba Mon Sep 17 00:00:00 2001 From: "pr.jung" Date: Tue, 19 Sep 2017 16:35:04 +0900 Subject: [PATCH 06/16] app: Call myfiles app on Move files button callback Change-Id: I865ba1dc65f0801ea4747aca4375dc61aab09301 Signed-off-by: pr.jung --- apps/extended-sd/CMakeLists.txt | 1 + apps/extended-sd/include/extended-sd-main.h | 2 ++ apps/extended-sd/src/es-internal-storage-page.c | 18 ++++++++++++++++++ apps/extended-sd/src/es-portable-storage-page.c | 19 +++++++++++++++++++ packaging/storaged.spec | 1 + 5 files changed, 41 insertions(+) diff --git a/apps/extended-sd/CMakeLists.txt b/apps/extended-sd/CMakeLists.txt index 183382a..c1b3a7e 100755 --- a/apps/extended-sd/CMakeLists.txt +++ b/apps/extended-sd/CMakeLists.txt @@ -23,6 +23,7 @@ pkg_check_modules(pkgs REQUIRED capi-appfw-application capi-system-system-settings efl-extension + capi-appfw-app-control ) FIND_LIBRARY(LIB_M m) diff --git a/apps/extended-sd/include/extended-sd-main.h b/apps/extended-sd/include/extended-sd-main.h index 470a6be..c4d5441 100644 --- a/apps/extended-sd/include/extended-sd-main.h +++ b/apps/extended-sd/include/extended-sd-main.h @@ -17,6 +17,8 @@ #define UNMOUNT_FORCE 1 +#define MYFILES_APP_ID "org.tizen.myfile" + typedef enum { USE_AS_PORTABLE_STORAGE = 0, USE_AS_INTERNAL_STORAGE diff --git a/apps/extended-sd/src/es-internal-storage-page.c b/apps/extended-sd/src/es-internal-storage-page.c index e5f2d94..3405d50 100644 --- a/apps/extended-sd/src/es-internal-storage-page.c +++ b/apps/extended-sd/src/es-internal-storage-page.c @@ -1,3 +1,5 @@ +#include + #include "extended-sd-main.h" #include "dbus-call.h" #include "log-util.h" @@ -139,6 +141,22 @@ _move_files_button_click_cb(void *data, Evas_Object* obj, void *event_info) { FUNC_BEGIN(); + app_control_h app_control = NULL; + int ret; + + ret = app_control_create(&app_control); + if (ret != APP_CONTROL_ERROR_NONE) + return; + + ret = app_control_set_app_id(app_control, MYFILES_APP_ID); + if (ret != APP_CONTROL_ERROR_NONE) { + app_control_destroy(app_control); + return; + } + + ret = app_control_send_launch_request(app_control, NULL, NULL); + app_control_destroy(app_control); + FUNC_END(); } diff --git a/apps/extended-sd/src/es-portable-storage-page.c b/apps/extended-sd/src/es-portable-storage-page.c index 6e9ffdb..41a3141 100644 --- a/apps/extended-sd/src/es-portable-storage-page.c +++ b/apps/extended-sd/src/es-portable-storage-page.c @@ -1,3 +1,5 @@ +#include + #include "extended-sd-main.h" #include "dbus-call.h" //#include "dbus-macro.h" @@ -112,6 +114,22 @@ _move_button_click_cb(void *data, Evas_Object* obj, void *event_info) { FUNC_BEGIN(); + app_control_h app_control = NULL; + int ret; + + ret = app_control_create(&app_control); + if (ret != APP_CONTROL_ERROR_NONE) + return; + + ret = app_control_set_app_id(app_control, MYFILES_APP_ID); + if (ret != APP_CONTROL_ERROR_NONE) { + app_control_destroy(app_control); + return; + } + + ret = app_control_send_launch_request(app_control, NULL, NULL); + app_control_destroy(app_control); + FUNC_END(); } @@ -391,6 +409,7 @@ static Evas_Object* create_page_3(appdata_s* ad) item->it = elm_genlist_item_append(genlist, extended_multiline_genlist_itc, item, NULL, ELM_GENLIST_ITEM_NONE, NULL, item); elm_genlist_item_select_mode_set(item->it, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY); + item = (genlist_item_s *)malloc(sizeof(genlist_item_s)); if (!item) { DMSG_ERR("malloc failed"); diff --git a/packaging/storaged.spec b/packaging/storaged.spec index b64f8af..8467b30 100644 --- a/packaging/storaged.spec +++ b/packaging/storaged.spec @@ -32,6 +32,7 @@ BuildRequires: pkgconfig(mount) BuildRequires: pkgconfig(capi-ui-efl-util) BuildRequires: pkgconfig(capi-appfw-application) BuildRequires: pkgconfig(capi-appfw-preference) +BuildRequires: pkgconfig(capi-appfw-app-control) BuildRequires: pkgconfig(capi-system-system-settings) BuildRequires: pkgconfig(efl-extension) -- 2.7.4 From 9c65118e4b137444d89a719d31d89de41f229edf Mon Sep 17 00:00:00 2001 From: "pr.jung" Date: Tue, 19 Sep 2017 17:04:33 +0900 Subject: [PATCH 07/16] block: Change mount path of extended internal storage at booting time Change-Id: I862f4cc1a5d92aeb5870154e7d957fb2d9f2b74b Signed-off-by: pr.jung --- src/block/block.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/block/block.c b/src/block/block.c index 9829dd5..be2e5ea 100644 --- a/src/block/block.c +++ b/src/block/block.c @@ -2152,12 +2152,22 @@ static int add_block_device(struct udev_device *dev, const char *devnode, bool i bdev->data->primary) { _I("Check whether sdcard will be used as extended internal storage"); - if (!init) { + if (!init) { // after booting is done snprintf(id_string, PATH_LEN, "%d", bdev->data->id); ret = launch_system_app(POPUP_DEFAULT, 4, POPUP_KEY_CONTENT, "sdcardsetup", POPUP_SDCARD_ID, id_string); if (ret < 0) _E("Failed to launch popup"); return 0; + } else { // at booting time + if (!strncmp(bdev->data->fs_type, LUKS_NAME, strlen(LUKS_NAME))) { + bdev->data->block_type = BLOCK_MMC_EXTENDED_INTERNAL_DEV; + ret = change_mount_point(bdev, EXTENDED_SD_PATH); + if (ret < 0) { + ret = -EPERM; + return ret; + } + + } } } else { if (!bdev->data->fs_type) { -- 2.7.4 From caa883b88a22143153a62d2c27656d8636fdd46a Mon Sep 17 00:00:00 2001 From: Hyotaek Shim Date: Fri, 22 Sep 2017 10:36:48 +0900 Subject: [PATCH 08/16] remove duplicated exception codes Change-Id: I86d3da1d03b2af52115e37e634e1be506842688f Signed-off-by: Hyotaek Shim --- src/block/block.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/block/block.c b/src/block/block.c index be2e5ea..4e5d6f1 100644 --- a/src/block/block.c +++ b/src/block/block.c @@ -259,9 +259,6 @@ static void broadcast_block_info(enum block_dev_operation op, if (data->primary != true) return; - if (data->primary != true) - return; - DD_LIST_FOREACH(block_ops_list, elem, ops) { if (ops->block_type != data->block_type) continue; @@ -3241,13 +3238,13 @@ out: /* Method name Method call format string Reply format string { "ShowDeviceList", NULL, NULL, request_show_device_list }, -{ "GetDeviceList" , "s", "a(issssssisibii)", request_get_device_list }, +{ "GetDeviceList", "s", "a(issssssisibii)", request_get_device_list }, { "GetDeviceList2", "s", "a(issssssisibi)", request_get_device_list_2 }, { "Mount", "is", "i", request_public_mount_block }, { "Unmoun, "ii", "i", request_public_unmount_block }, { "Format", "ii", "i", request_format_block }, { "GetDeviceInfo", "i", "(issssssisibii)", request_get_device_info }, -{ "GetMmcPrimary" , NULL, "(issssssisibii)" , request_get_mmc_primary }, +{ "GetMmcPrimary", NULL, "(issssssisibii)" , request_get_mmc_primary }, { "PrivateMount", "is", "i", request_private_mount_block }, { "PrivateUnmount", "ii", "i", request_private_unmount_block }, */ -- 2.7.4 From c1b82c3608928649639eb324ae3e5c9a58c2bcb7 Mon Sep 17 00:00:00 2001 From: "pr.jung" Date: Mon, 25 Sep 2017 18:59:34 +0900 Subject: [PATCH 09/16] dbus: unref reply message Change-Id: Id47482a765be09f5994fd692e0366ae2c6ba4a7a Signed-off-by: pr.jung --- src/shared/dbus.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/shared/dbus.c b/src/shared/dbus.c index f9eab84..59fafde 100644 --- a/src/shared/dbus.c +++ b/src/shared/dbus.c @@ -208,6 +208,8 @@ void reply_dbus_method_result(dbus_method_reply_handle_h reply_handle, DBusMessa return; dbus_connection_send(reply->handle->conn, reply_msg, NULL); + if (reply->msg) + dbus_message_unref(reply->msg); dbus_message_unref(reply_msg); if (reply) free(reply); -- 2.7.4 From cff22741566f2f308324771a4f1734332b45d2cf Mon Sep 17 00:00:00 2001 From: "pr.jung" Date: Mon, 25 Sep 2017 16:32:20 +0900 Subject: [PATCH 10/16] block: Need to set VCONFKEY_SYSMAN_MMC_EXTENDEDINTERNAL_MOUNTED for extended internal sdcard Change-Id: If4b596e97f0605d52113b185225ffdadda3a3ad6 Signed-off-by: pr.jung (cherry picked from commit 6f9731069c7c99447548293e84fe1802a989399f) --- src/block/block.c | 23 ++++++++++++++++------- src/block/block.h | 6 +++--- src/block/mmc.c | 25 ++++++++++++++++++------- 3 files changed, 37 insertions(+), 17 deletions(-) diff --git a/src/block/block.c b/src/block/block.c index 4e5d6f1..346812a 100644 --- a/src/block/block.c +++ b/src/block/block.c @@ -263,13 +263,22 @@ static void broadcast_block_info(enum block_dev_operation op, if (ops->block_type != data->block_type) continue; // TODO What happend on extended internal storage case? - if (op == BLOCK_DEV_MOUNT) - ops->mounted(data, result); - else if (op == BLOCK_DEV_UNMOUNT) - ops->unmounted(data, result); - else if (op == BLOCK_DEV_FORMAT) - ops->formatted(data, result); - else if (op == BLOCK_DEV_INSERT) + if (op == BLOCK_DEV_MOUNT) { + if (data->block_type == BLOCK_MMC_EXTENDED_INTERNAL_DEV) + ops->mounted(data, result, true); + else + ops->mounted(data, result, false); + } else if (op == BLOCK_DEV_UNMOUNT) { + if (data->block_type == BLOCK_MMC_EXTENDED_INTERNAL_DEV) + ops->unmounted(data, result, true); + else + ops->unmounted(data, result, false); + } else if (op == BLOCK_DEV_FORMAT) { + if (data->block_type == BLOCK_MMC_EXTENDED_INTERNAL_DEV) + ops->formatted(data, result, true); + else + ops->formatted(data, result, false); + } else if (op == BLOCK_DEV_INSERT) ops->inserted(data); else if (op == BLOCK_DEV_REMOVE) ops->removed(data); diff --git a/src/block/block.h b/src/block/block.h index 597204f..57b02b5 100644 --- a/src/block/block.h +++ b/src/block/block.h @@ -87,9 +87,9 @@ struct block_data { struct block_dev_ops { const char *name; enum block_device_type block_type; - void (*mounted) (struct block_data *data, int result); - void (*unmounted) (struct block_data *data, int result); - void (*formatted) (struct block_data *data, int result); + void (*mounted) (struct block_data *data, int result, bool extended); + void (*unmounted) (struct block_data *data, int result, bool extended); + void (*formatted) (struct block_data *data, int result, bool extended); void (*inserted) (struct block_data *data); void (*removed) (struct block_data *data); }; diff --git a/src/block/mmc.c b/src/block/mmc.c index 674cdcc..80ec367 100644 --- a/src/block/mmc.c +++ b/src/block/mmc.c @@ -48,7 +48,7 @@ static void mmc_update_mount_state(int state) old = state; } -static void mmc_mount(struct block_data *data, int result) +static void mmc_mount(struct block_data *data, int result, bool extended) { int r; @@ -68,11 +68,14 @@ static void mmc_mount(struct block_data *data, int result) if (r < 0) _E("setxattr error : %d", errno); - mmc_update_state(VCONFKEY_SYSMAN_MMC_MOUNTED); + if (extended) + mmc_update_state(VCONFKEY_SYSMAN_MMC_EXTENDEDINTERNAL_MOUNTED); + else + mmc_update_state(VCONFKEY_SYSMAN_MMC_MOUNTED); mmc_update_mount_state(VCONFKEY_SYSMAN_MMC_MOUNT_COMPLETED); } -static void mmc_unmount(struct block_data *data, int result) +static void mmc_unmount(struct block_data *data, int result, bool extended) { /* Only the primary partition is valid. */ if (!data || !data->primary) @@ -80,18 +83,26 @@ static void mmc_unmount(struct block_data *data, int result) if (result == 0) mmc_update_state(VCONFKEY_SYSMAN_MMC_INSERTED_NOT_MOUNTED); - else - mmc_update_state(VCONFKEY_SYSMAN_MMC_MOUNTED); + else { + if (extended) + mmc_update_state(VCONFKEY_SYSMAN_MMC_EXTENDEDINTERNAL_MOUNTED); + else + mmc_update_state(VCONFKEY_SYSMAN_MMC_MOUNTED); + } } -static void mmc_format(struct block_data *data, int result) +static void mmc_format(struct block_data *data, int result, bool extended) { /* Only the primary partition is valid. */ if (!data || !data->primary) return; if (data->state == BLOCK_MOUNT) { - mmc_update_state(VCONFKEY_SYSMAN_MMC_MOUNTED); + if (extended) + mmc_update_state(VCONFKEY_SYSMAN_MMC_EXTENDEDINTERNAL_MOUNTED); + else + mmc_update_state(VCONFKEY_SYSMAN_MMC_MOUNTED); + mmc_update_mount_state(VCONFKEY_SYSMAN_MMC_MOUNT_COMPLETED); } } -- 2.7.4 From 106f32f2838a006ea8ae02bb64ef276b72feecf6 Mon Sep 17 00:00:00 2001 From: "pr.jung" Date: Tue, 26 Sep 2017 10:08:02 +0900 Subject: [PATCH 11/16] block: Do not mount unformatted storage at booting time Change-Id: I3c7608c4e76cc0fe4fcb0b21cfcc039e02aee34b Signed-off-by: pr.jung (cherry picked from commit 623c073f0783b615750a6d33f0b7ae2e4851e568) --- src/block/block.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/block/block.c b/src/block/block.c index 346812a..7bce7e1 100644 --- a/src/block/block.c +++ b/src/block/block.c @@ -2165,6 +2165,12 @@ static int add_block_device(struct udev_device *dev, const char *devnode, bool i _E("Failed to launch popup"); return 0; } else { // at booting time + if (!bdev->data->fs_type) { + _E("Unformatted Storage"); + free_block_device(bdev); + return -EPERM; + } + if (!strncmp(bdev->data->fs_type, LUKS_NAME, strlen(LUKS_NAME))) { bdev->data->block_type = BLOCK_MMC_EXTENDED_INTERNAL_DEV; ret = change_mount_point(bdev, EXTENDED_SD_PATH); -- 2.7.4 From cef51346f781169528762244ff6a8a4169b01f60 Mon Sep 17 00:00:00 2001 From: "pr.jung" Date: Tue, 26 Sep 2017 16:41:40 +0900 Subject: [PATCH 12/16] udev: Do not receive G_IO_ERR flag Change-Id: I83ab9c89594c1690c54baf7bf7147add012b41e3 Signed-off-by: pr.jung (cherry picked from commit 49bf0ea30237315f833274e3580797c5ddc6b97d) --- src/shared/fd_handler.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/shared/fd_handler.c b/src/shared/fd_handler.c index c95742e..3c9fc11 100644 --- a/src/shared/fd_handler.c +++ b/src/shared/fd_handler.c @@ -110,7 +110,7 @@ int add_fd_read_handler(int fd, return -ENOMEM; } - id = g_io_add_watch(ch, G_IO_IN | G_IO_ERR, + id = g_io_add_watch(ch, G_IO_IN, channel_changed, h); if (id == 0) { _E("Failed to add watch for GIOChannel"); -- 2.7.4 From c9846ca24d8967583aec35f0d3dfd7395b62df98 Mon Sep 17 00:00:00 2001 From: "pr.jung" Date: Tue, 26 Sep 2017 18:02:37 +0900 Subject: [PATCH 13/16] udev: Increase udev monitor buffer size Change-Id: Ieb3dffe9548530baa89c114c8ab5b9ac8c09cf52 Signed-off-by: pr.jung --- src/shared/fd_handler.c | 10 ++++++++-- src/shared/udev.c | 3 ++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/shared/fd_handler.c b/src/shared/fd_handler.c index 3c9fc11..b96345c 100644 --- a/src/shared/fd_handler.c +++ b/src/shared/fd_handler.c @@ -73,8 +73,14 @@ static gboolean channel_changed(GIOChannel *source, if (h->fd != g_io_channel_unix_get_fd(source)) return TRUE; - if (condition != G_IO_IN) + + if (condition & G_IO_ERR) + _E("udev_monitor_set_receive_buffer_size overflow"); + + if (!(condition & G_IO_IN)) { + _D("udev have a bad behavior"); return TRUE; + } ret = true; if (h->changed) @@ -110,7 +116,7 @@ int add_fd_read_handler(int fd, return -ENOMEM; } - id = g_io_add_watch(ch, G_IO_IN, + id = g_io_add_watch(ch, G_IO_IN | G_IO_ERR, channel_changed, h); if (id == 0) { _E("Failed to add watch for GIOChannel"); diff --git a/src/shared/udev.c b/src/shared/udev.c index de5a927..113c6a6 100644 --- a/src/shared/udev.c +++ b/src/shared/udev.c @@ -32,7 +32,7 @@ #define SIGNAL_POWEROFF_STATE "ChangeState" -#define UDEV_MONITOR_SIZE (10*1024) +#define UDEV_MONITOR_SIZE (100*1024) struct uevent_info { struct udev_monitor *mon; @@ -131,6 +131,7 @@ static int uevent_control_start(const char *type, goto stop; } + _I("Set udev monitor buffer size %d", UDEV_MONITOR_SIZE); ret = udev_monitor_set_receive_buffer_size(info->mon, UDEV_MONITOR_SIZE); if (ret != 0) { -- 2.7.4 From 541e01b6465e0d360ca2d255377db6a8e131a753 Mon Sep 17 00:00:00 2001 From: INSUN PYO Date: Wed, 27 Sep 2017 11:58:06 +0900 Subject: [PATCH 14/16] udev: Increase udev monitor buffer size Signed-off-by: INSUN PYO Change-Id: I17054338f2b600f4a17e0b41502a565539b069a6 --- src/shared/udev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/shared/udev.c b/src/shared/udev.c index 113c6a6..c4a60b6 100644 --- a/src/shared/udev.c +++ b/src/shared/udev.c @@ -32,7 +32,7 @@ #define SIGNAL_POWEROFF_STATE "ChangeState" -#define UDEV_MONITOR_SIZE (100*1024) +#define UDEV_MONITOR_SIZE (128*1024) struct uevent_info { struct udev_monitor *mon; -- 2.7.4 From b6ecf8f1696b7e75031a5c7cf65c1daad530fe37 Mon Sep 17 00:00:00 2001 From: Hyotaek Shim Date: Wed, 27 Sep 2017 19:58:38 +0900 Subject: [PATCH 15/16] include src/shared/dbus_macro.h in apps/* Change-Id: I4c838338226cfada67e7913e6a8694b0e8b282d8 Signed-off-by: Hyotaek Shim --- LICENSE => LICENSE.Apache-2.0 | 0 apps/extended-sd/include/dbus-call.h | 11 +---------- apps/extended-sd/src/extended-sd-main.c | 2 -- packaging/storaged.spec | 8 ++++---- 4 files changed, 5 insertions(+), 16 deletions(-) rename LICENSE => LICENSE.Apache-2.0 (100%) diff --git a/LICENSE b/LICENSE.Apache-2.0 similarity index 100% rename from LICENSE rename to LICENSE.Apache-2.0 diff --git a/apps/extended-sd/include/dbus-call.h b/apps/extended-sd/include/dbus-call.h index 7250ae0..0a3a10c 100644 --- a/apps/extended-sd/include/dbus-call.h +++ b/apps/extended-sd/include/dbus-call.h @@ -22,18 +22,9 @@ #include #include +#include "dbus_macro.h" #include "extended-sd-main.h" -/* Block service: manage block device */ -#define STORAGED_BUS_NAME "org.tizen.system.storage" -#define STORAGED_OBJECT_PATH "/Org/Tizen/System/Storage" -#define STORAGED_INTERFACE_NAME STORAGED_BUS_NAME -#define STORAGED_PATH_BLOCK STORAGED_OBJECT_PATH"/Block" -#define STORAGED_PATH_BLOCK_MANAGER STORAGED_PATH_BLOCK"/Manager" -#define STORAGED_INTERFACE_BLOCK_MANAGER STORAGED_INTERFACE_NAME".BlockManager" - -#define POPUP_SDCARD_ID "_SDCARD_NUM_" - struct dbus_int { int *list; int size; diff --git a/apps/extended-sd/src/extended-sd-main.c b/apps/extended-sd/src/extended-sd-main.c index 2e4c266..8bff947 100644 --- a/apps/extended-sd/src/extended-sd-main.c +++ b/apps/extended-sd/src/extended-sd-main.c @@ -1,8 +1,6 @@ #include "extended-sd-main.h" #include "es-preference-util.h" #include "log-util.h" - -//#include "dbus-macro.h" #include "dbus-call.h" static void diff --git a/packaging/storaged.spec b/packaging/storaged.spec index 8467b30..046d11c 100644 --- a/packaging/storaged.spec +++ b/packaging/storaged.spec @@ -130,7 +130,7 @@ systemctl daemon-reload %files %manifest %{name}.manifest -%license LICENSE +%license LICENSE.Apache-2.0 %config %{_sysconfdir}/dbus-1/system.d/storaged.conf %{_unitdir}/multi-user.target.wants/storaged.service %{_unitdir}/storaged.service @@ -138,20 +138,20 @@ systemctl daemon-reload %files module_block %manifest %{name}.manifest -%license LICENSE +%license LICENSE.Apache-2.0 %{_libdir}/storaged/module_block.so %{_bindir}/mmc-smack-label %config %{_sysconfdir}/storaged/block.conf %files module_storage %manifest %{name}.manifest -%license LICENSE +%license LICENSE.Apache-2.0 %{_libdir}/storaged/module_storage.so %config %{_sysconfdir}/storaged/storage.conf %files org.tizen.extended-sd -f extended-sd.lang %manifest %{name}.manifest -%license LICENSE +%license LICENSE.Apache-2.0 %defattr(-,root,root,-) %{TZ_SYS_RO_APP}/org.tizen.extended-sd/bin/* %{TZ_SYS_RO_APP}/org.tizen.extended-sd/res/* -- 2.7.4 From 71039fa2671892059696decd559f208d1dd30a51 Mon Sep 17 00:00:00 2001 From: "pr.jung" Date: Fri, 29 Sep 2017 15:24:38 +0900 Subject: [PATCH 16/16] block: Add a mutex for pipe - Multithread should not write pipe at the same time Change-Id: Ic95645160e339716bdba8874d42c5aeb516aa520 Signed-off-by: pr.jung --- src/block/block.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/block/block.c b/src/block/block.c index 7bce7e1..10448b6 100644 --- a/src/block/block.c +++ b/src/block/block.c @@ -179,6 +179,7 @@ static int pfds[2]; static fd_handler_h phandler; static bool block_control = false; static bool block_boot = false; +static pthread_mutex_t pipe_mutex = PTHREAD_MUTEX_INITIALIZER; /* Assume there is only one physical internal storage */ static int dev_internal = -1; @@ -931,7 +932,10 @@ static int pipe_trigger(enum block_dev_operation op, get_operation_char(pdata.op, name, sizeof(name)), pdata.bdev, pdata.result); + // Multi thread should not write at the same time + pthread_mutex_lock(&pipe_mutex); n = write(pfds[1], &pdata, sizeof(struct pipe_data)); + pthread_mutex_unlock(&pipe_mutex); return (n != sizeof(struct pipe_data)) ? -EPERM : 0; } -- 2.7.4