Evas_Object* create_image(Evas_Object* parent, char* image_path);
void load_font_color_table();
-void mapper_device_cb(int id, storage_dev_e dev, storage_state_e state, const char *fstype, const char *fsuuid, const char *mount_point, bool primary, int flags, void *user_data);
#endif /* __EXTENDED_SD_MAIN_H__ */
static Evas_Object* create_page_4(appdata_s* ad);
static Evas_Object* create_page_5(appdata_s* ad);
-void
+static void
mapper_device_cb(int id, storage_dev_e dev, storage_state_e state,
const char *fstype, const char *fsuuide, const char *mount_point,
bool primary, int flags, void *user_data)
}
// Do not deal with STORAGE_STATE_UNMOUNTABLE. Because of Format operation also emits signals with STORAGE_STATE_UNMOUNTABLE.
- if (state == STORAGE_STATE_REMOVED) {
- DMSG("Storage is removed");
- ui_app_exit();
- return;
- } else if (state == STORAGE_STATE_UNMOUNTABLE)
+ if (state == STORAGE_STATE_UNMOUNTABLE || state == STORAGE_STATE_REMOVED)
return;
Evas_Object* page_content = elm_object_part_content_unset(ad->internal_storage_page_data->internal_storage_page_base_layout, "elm.swallow.content");
FUNC_BEGIN();
Evas_Object *page_content = NULL;
char *str_setup;
+ int ret;
+
+ ret = storage_set_changed_cb(STORAGE_TYPE_EXTENDED_INTERNAL, mapper_device_cb, ad);
+ if (ret != STORAGE_ERROR_NONE)
+ DMSG_ERR("Failed to register signal handler for extended internal storage");
if (ad->internal_storage_page_data) {
ELM_OBJECT_ITEM_DEL(ad->internal_storage_page_data->internal_storage_page_navi_it);
//#include "dbus-macro.h"
#include "log-util.h"
+#define LUKS_NAME "crypto_LUKS"
+
typedef enum {
PORTABLE_STORAGE_ITEM_PAGE_1_HEADING = 0,
PORTABLE_STORAGE_ITEM_PAGE_1_PARA_1,
}
static void
-_format_click_cb(void *data, Evas_Object* obj, void *event_info)
+mapper_device_cb(int mapper_id, storage_dev_e dev, storage_state_e state,
+ const char *fstype, const char *fsuuide, const char *mount_point,
+ bool primary, int flags, void *user_data)
{
FUNC_BEGIN();
+ appdata_s* ad = (appdata_s*)user_data;
+ GVariant *output;
+ GVariantIter *iter;
char str_id[32];
char str_option[32];
char *arr[3];
+ char *new_fstype;
+ bool new_primary;
int ret;
+ int id;
+
+ ret_if(ad == NULL);
+
+ //TODO This supports only one extended internal storage and one sdcard slot.
+ // What if sdcard #1 is setting on extended internal storage,
+ // and another sdcard #2 is inserted and then #1 is removed?
+ if (dev != STORAGE_DEV_EXTENDED_INTERNAL) {
+ DMSG("Not mapper device");
+ return;
+ }
+
+ if (mapper_id != ad->storage_id)
+ return;
+
+ // After mapper node is removed, app need to format sdcard
+ if (state != STORAGE_STATE_REMOVED)
+ return;
+
+ arr[0] = "mmc";
+ ret = dbus_method_sync_with_reply(STORAGED_BUS_NAME,
+ STORAGED_PATH_BLOCK_MANAGER, STORAGED_INTERFACE_BLOCK_MANAGER, "GetDeviceList", "s", arr, &output);
+ if (ret < 0) {
+ DMSG("Failed to get storage information: %d", ret);
+ return;
+ }
+
+ g_variant_get(output, "(a(issssssisibii))", &iter);
+
+ while (g_variant_iter_loop(iter, "(issssssisibii)",
+ NULL, NULL, NULL,
+ NULL, &new_fstype,
+ NULL, NULL,
+ NULL, NULL,
+ NULL, &new_primary,
+ NULL, &id)) {
+ if (!primary)
+ continue;
+ if (strncmp(new_fstype, LUKS_NAME, strlen(LUKS_NAME) + 1))
+ continue;
+
+ DMSG("Get Primary MMC: %d", id);
+ ad->storage_id = id;
+ break;
+ }
+
+ 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,
+ 120000,
+ ad);
+ if (ret < 0)
+ DMSG("Failed to format", ret);
+
+ FUNC_END();
+}
+
+static void
+unmount_done(void *data, GVariant *result, GError *err)
+{
+ appdata_s* ad = (appdata_s*)data;
+ 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;
+ }
+
+ 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[2];
+ int ret;
appdata_s* ad = (appdata_s*)data;
ret_if(ad == NULL);
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",
+ "Unmount",
+ "ii",
arr,
- format_done,
- 120000,
+ unmount_done,
+ DBUS_REPLY_TIMEOUT,
ad);
if (ret < 0)
DMSG("Failed to format", ret);
FUNC_BEGIN();
Evas_Object* page_content = NULL;
char *str_portable;
+ int ret;
+
+ ret = storage_set_changed_cb(STORAGE_TYPE_EXTENDED_INTERNAL, mapper_device_cb, ad);
+ if (ret != STORAGE_ERROR_NONE)
+ DMSG_ERR("Failed to register signal handler for extended internal storage");
if (ad->portable_storage_page_data) {
ELM_OBJECT_ITEM_DEL(ad->portable_storage_page_data->portable_storage_page_navi_it);
}
static void
-storage_removed_cb(int id, storage_state_e state, void *user_data)
+storage_removed_cb(int id, storage_dev_e dev, storage_state_e state,
+ const char *fstype, const char *fsuuide, const char *mount_point,
+ bool primary, int flags, void *user_data)
{
FUNC_BEGIN();
ret_if(ad == NULL);
- if (id == ad->storage_id) {
- DMSG("Storage is removed");
- ui_app_exit();
- }
+ if (dev != STORAGE_DEV_EXT_SDCARD)
+ return;
+
+ if (state != STORAGE_STATE_REMOVED)
+ return;
+
+ /* Only one mmc slot is supported
+ ad->storage_id is mapper node id */
+ DMSG("Storage is removed");
+ ui_app_exit();
FUNC_END();
}
ret_if(ad == NULL);
- ret = storage_set_state_changed_cb(ad->storage_id, storage_removed_cb, ad);
- if (ret != STORAGE_ERROR_NONE) {
- DMSG_ERR("Failed to register signal handler");
- ui_app_exit();
- }
- ret = storage_set_changed_cb(STORAGE_TYPE_EXTENDED_INTERNAL, mapper_device_cb, ad);
+ ret = storage_set_changed_cb(STORAGE_TYPE_EXTERNAL, storage_removed_cb, ad);
+ if (ret != STORAGE_ERROR_NONE)
+ DMSG_ERR("Failed to register signal handler for extended internal storage");
len = strlen(SETUP_EXTENDED) + 1;
app_control_get_extra_data(app_control, SDCARD_SETUP_TYPE, &type);
appdata_s* ad = (appdata_s*)data;
ret_if(ad == NULL);
- storage_unset_state_changed_cb(ad->storage_id, storage_removed_cb);
+ storage_unset_changed_cb(STORAGE_TYPE_EXTERNAL, storage_removed_cb);
FUNC_END();
}
#define PATH_LEN 55
#define EXTENDEDSD_MOUNT_PATH "/opt/extendedsd"
-#define EXTENDEDSD_STRING "ExtendedInternalSD"
#define EXT4_NAME "ext4"
#define LUKS_NAME "crypto_LUKS"
char *name, node[64];
int ret;
- if (!data || !data->devnode || !data->fs_usage || strcmp(data->fs_usage, FILESYSTEM_NAME))
+ if (!data || !data->devnode || !data->fs_usage || (strcmp(data->fs_usage, FILESYSTEM_NAME) && strncmp(data->fs_usage, "crypto", strlen("crypto"))))
return NULL;
name = strrchr(data->devnode, '/');
case BLOCK_DEV_REMOVE:
str = "REMOVE";
break;
+ case BLOCK_LUKS_CLOSE:
+ str = "LUKS CLOSE";
+ break;
default:
_E("invalid operation (%d)", op);
break;
free_block_device(bdev);
return -EPERM;
} else if (!strncmp(bdev->data->fs_type, LUKS_NAME, strlen(LUKS_NAME))) {
- bdev->data->block_type = BLOCK_EXTENDEDSD_DEV;
+// bdev->data->block_type = BLOCK_EXTENDEDSD_DEV;
+ bdev->data->primary = true;
_D("Need to unlock encrypted sdcard");
// ---- ODE UI launch ----
ret = launch_system_app(POPUP_DEFAULT
if (ret < 0)
_E("Failed to launch popup");
+ ret = add_operation(bdev, BLOCK_DEV_INSERT, NULL, (void *)data);
+ if (ret < 0) {
+ _E("Failed to add operation (insert %s)", devnode);
+ free_block_device(bdev);
+ return ret;
+ }
+
return 0;
} else if (mapper && !strncmp(bdev->data->fs_type, EXT4_NAME, strlen(EXT4_NAME))) {
bdev->data->block_type = BLOCK_EXTENDEDSD_DEV;
false);
if (r < 0)
_E("fail to update block data for %s", bdev->data->devnode);
+ if (!strncmp(bdev->data->fs_type, LUKS_NAME, strlen(LUKS_NAME)))
+ _I("filesystem type is updated: crypto_LUKS");
}
}
}
/* if requester want to use a specific mount point */
- if (mount_point &&
- !strncmp(mount_point, EXTENDEDSD_STRING, strlen(EXTENDEDSD_STRING) + 1) != 0) {
- if (!block_conf[bdev->data->block_type].extendedinternal ||
- !bdev->data->primary) {
- _E("Not support extended internal storage");
- ret = -EPERM;
- goto out;
- } else {
- bdev->data->block_type = BLOCK_EXTENDEDSD_DEV;
- ret = change_mount_point(bdev, EXTENDEDSD_MOUNT_PATH);
- if (ret < 0) {
- ret = -EPERM;
- goto out;
- }
-
- create_file(bdev->data->id, bdev->data->mount_point, true);
- }
- } else if (mount_point && strncmp(mount_point, "", 1) != 0) {
+ if (mount_point && strncmp(mount_point, "", 1) != 0) {
ret = change_mount_point(bdev, mount_point);
if (ret < 0) {
ret = -EPERM;
goto out;
}
- if (bdev->data->block_type == BLOCK_EXTENDEDSD_DEV) {
- _I("Impossible to request unmount extended internal sdcard");
- ret = -EPERM;
- goto out;
- }
-
if (onprivate) {
pid = get_dbus_method_sender_pid(reply_handle);
if (bdev->on_private_op == REQ_NORMAL || (bdev->on_private_op != REQ_NORMAL && pid != bdev->private_pid)) {
goto out;
}
+ if (bdev->data->block_type == BLOCK_EXTENDEDSD_DEV) {
+ ret = add_operation(bdev, BLOCK_LUKS_CLOSE, NULL, NULL);
+ if (ret < 0)
+ _E("Failed to add operation (luks_close %s)", bdev->data->devnode);
+ }
+
return NULL;
out:
continue;
if (!data->primary)
continue;
+ // Return mapper node(/dev/mapper/extendedsd) for primary mmc (not /dev/mmcblk1p1(ex))
+ if (!strncmp(data->fs_type, LUKS_NAME, strlen(LUKS_NAME)))
+ continue;
found = true;
break;
}