mtp_ctx->device_list->device_num = 0;
mtp_ctx->is_processing = false;
mtp_ctx->is_releasing = false;
+ mtp_ctx->is_device_preparing = false;
_mtp_ctx = mtp_ctx;
if (event == LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED) {
MTP_LOGI("USB device added");
+ mtp_ctx->is_device_preparing = true;
+
LIBMTP_Detect_Raw_Devices(&raw_devices, &num_of_devices);
MTP_LOGI("LIBMTP_Detect_Raw_Devices completed : %d", num_of_devices);
for (slot = 0; slot < num_of_devices; slot++) {
g_thread_pool_push(mtp_ctx->device_list->threads, (gpointer)device, NULL);
g_source_remove(mtp_ctx->quit_timer);
- MTP_LOGI("MTP device added");
+ MTP_LOGI("MTP device added : %s", device_info->model_name);
mtp_daemon_gdbus_emit_event(MTP_INITIATOR_EVENT_DEVICE_ADDED, empty_slot, mtp_ctx);
__print_device_list(mtp_ctx);
}
}
+
+ mtp_ctx->is_device_preparing = false;
+
g_free(raw_devices);
} else if (event == LIBUSB_HOTPLUG_EVENT_DEVICE_LEFT) {
MTP_LOGI("device removed");
{
/* variable definition */
int count = 0;
+ int pending_count = 0;
mtp_param *param = (mtp_param *)user_data;
mtp_error_e result = MTP_ERROR_NONE;
mtpgdbuslibManager *object;
/* do process */
g_variant_builder_init(&b, G_VARIANT_TYPE("aa{sv}"));
+ while (param->mtp_ctx->is_device_preparing && pending_count < 10) {
+ MTP_LOGI("The device is being prepared... wait for 2 seconds (%d/10)", ++pending_count);
+ usleep(200000);
+ }
+
count = param->mtp_ctx->device_list->device_num;
for (slot = 1; slot < MTP_MAX_SLOT; slot++) {