static Evas_Object* create_page_5(appdata_s* ad);
static void
-_format_click_cb(void *data, Evas_Object* obj, void *event_info)
-{
- FUNC_BEGIN();
-
- appdata_s* ad = (appdata_s*)data;
- 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");
- EVAS_OBJECT_DEL(page_content);
- page_content = create_page_2(ad);
- elm_object_part_content_set(ad->internal_storage_page_data->internal_storage_page_base_layout, "elm.swallow.content", page_content);
-
- FUNC_END();
-}
-
-static void
format_done(void *data, GVariant *result, GError *err)
{
appdata_s* ad = (appdata_s*)data;
}
static void
-_continue_click_cb(void *data, Evas_Object* obj, void *event_info)
+encryption_format(void *data)
{
FUNC_BEGIN();
}
static void
+check_speed_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("Performance warning", ret);
+ 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_3(ad);
+ elm_object_part_content_set(ad->internal_storage_page_data->internal_storage_page_base_layout, "elm.swallow.content", page_content);
+ goto out;
+ } else
+ encryption_format(ad);
+
+out:
+ g_variant_unref(result);
+ FUNC_END();
+}
+
+static void
+_format_click_cb(void *data, Evas_Object* obj, void *event_info)
+{
+ FUNC_BEGIN();
+
+ appdata_s* ad = (appdata_s*)data;
+ char str_id[32];
+ char *arr[1];
+ 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");
+ EVAS_OBJECT_DEL(page_content);
+ page_content = create_page_2(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;
+ ret = dbus_method_async_with_reply(STORAGED_BUS_NAME,
+ STORAGED_PATH_BLOCK_MANAGER,
+ STORAGED_INTERFACE_BLOCK_MANAGER,
+ "CheckSpeed",
+ "i",
+ arr,
+ check_speed_done,
+ DBUS_REPLY_TIMEOUT, // ms
+ ad);
+ if (ret < 0)
+ DMSG("Failed to check speed", ret);
+
+ FUNC_END();
+}
+
+static void
+_continue_click_cb(void *data, Evas_Object* obj, void *event_info)
+{
+ FUNC_BEGIN();
+
+ appdata_s* ad = (appdata_s*)data;
+
+ encryption_format(ad);
+ FUNC_END();
+}
+
+static void
_move_files_button_click_cb(void *data, Evas_Object* obj, void *event_info)
{
FUNC_BEGIN();
return page_content;
}
-static Eina_Bool _check_timer_cb(void* data)
-{
- FUNC_BEGIN();
-
- appdata_s* ad = (appdata_s*)data;
- retv_if(ad == NULL, ECORE_CALLBACK_CANCEL);
-
- 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_3(ad);
- elm_object_part_content_set(ad->internal_storage_page_data->internal_storage_page_base_layout, "elm.swallow.content", page_content);
-
- ad->check_timer = NULL;
- FUNC_END();
- return ECORE_CALLBACK_CANCEL;
-}
-
static Evas_Object* create_page_2(appdata_s* ad)
{
FUNC_BEGIN();
elm_genlist_item_class_free(extended_multiline_genlist_itc);
- //demo implementation to emulate format process, please remove once formatting implementation in place
- // prprprprprpr TODO
- ECORE_TIMER_DEL(ad->check_timer);
- ad->check_timer = ecore_timer_add(5, _check_timer_cb, ad);
out:
FUNC_END();
/* Maximum number of thread */
#define THREAD_MAX 5
+#define SPEEDCHECK 16
+
#define PKGDIR_BUS_NAME "org.tizen.pkgdir_tool"
#define PKGDIR_PATH "/org/tizen/pkgdir_tool"
#define PKGDIR_INTERFACE "org.tizen.pkgdir_tool"
return reply;
}
+static DBusMessage *request_check_speed(dbus_method_reply_handle_h reply_handle,
+ DBusMessage *msg)
+{
+ struct timespec start_time, end_time;
+ DBusMessageIter iter;
+ DBusMessage *reply;
+ struct block_device *bdev;
+ struct block_data *data;
+ char *buf;
+ int ret = 0;
+ int id;
+ int fd;
+
+ if (!reply_handle || !msg)
+ return NULL;
+
+ ret = dbus_message_get_args(msg, NULL,
+ DBUS_TYPE_INT32, &id,
+ DBUS_TYPE_INVALID);
+ if (!ret) {
+ ret = -1;
+ goto out;
+ }
+
+ bdev = find_block_device_by_id(id);
+ if (!bdev) {
+ ret = -1;
+ goto out;
+ }
+ data = bdev->data;
+ if (!data) {
+ ret = -1;
+ goto out;
+ }
+
+ _D("speed check: %s", data->devnode);
+ fd = open(data->devnode, O_RDWR | O_SYNC);
+ buf = calloc(1, SPEEDCHECK * 1024 * 1024);
+ if (!buf) {
+ _E("calloc() failed");
+ close(fd);
+ ret = -1;
+ goto out;
+ }
+ clock_gettime(CLOCK_REALTIME, &start_time);
+ _I("start time: %lu.%lu", start_time.tv_sec, start_time.tv_nsec);
+ ret = write(fd, buf, SPEEDCHECK * 1024 * 1024);
+ clock_gettime(CLOCK_REALTIME, &end_time);
+ _I("end time %lu.%lu", end_time.tv_sec, end_time.tv_nsec);
+
+ free(buf);
+
+ if (SPEEDCHECK / (end_time.tv_sec - start_time.tv_sec) < 4) {
+ ret = -1;
+ close(fd);
+ goto out;
+ }
+
+ if (ret < 0) {
+ _E("write() failed %d", errno);
+ close(fd);
+ goto out;
+ }
+
+ close(fd);
+out:
+ reply = dbus_message_new_method_return(msg);
+ dbus_message_iter_init_append(reply, &iter);
+ dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &ret);
+ return reply;
+}
+
/*
Method name Method call format string Reply format string
{ "ShowDeviceList", NULL, NULL, request_show_device_list },
{ "GetMmcPrimary" , NULL, request_get_mmc_primary },
{ "PrivateMount", "is", request_private_mount_block },
{ "PrivateUnmount", "ii", request_private_unmount_block },
+ { "CheckSpeed", "i", request_check_speed },
};
static dbus_interface_s block_interface = {