#include <vconf.h>
#include <bundle.h>
#include <eventsystem.h>
+#include <libsyscommon/dbus-systemd.h>
#include "core/log.h"
#include "core/list.h"
+#include "core/udev.h"
#include "core/common.h"
#include "core/device-notifier.h"
#include "display/poll.h"
return ret;
}
+static void uevent_usb_mode_handler(struct udev_device *dev)
+{
+ const char *state = NULL;
+
+ state = udev_device_get_property_value(dev, "USB_STATE");
+ if (!state)
+ return;
+
+ if (strncmp(state, "CONFIGURED", strlen(state) + 1))
+ return;
+
+ _I("usb_mode udev event happend : CONFIGURED");
+
+ if (usb_state_get_selected_mode() | USB_FUNCTION_ACM)
+ systemd_start_unit_wait_started ("data-router.service", NULL, -1);
+
+ if (usb_state_get_selected_mode() | USB_FUNCTION_SDB)
+ systemd_start_unit_wait_started ("sdbd.service", NULL, -1);
+
+ if (usb_state_get_selected_mode() | USB_FUNCTION_MTP)
+ systemd_start_unit_wait_started ("mtp-responder.service", NULL, -1);
+}
+
+static struct uevent_handler uh = {
+ .subsystem = "usb_mode",
+ .uevent_func = uevent_usb_mode_handler,
+};
+
static void usb_init(void *data)
{
int ret;
ret = usb_config_init();
if (ret < 0)
_E("Failed to initialize usb configuation.");
+
+ ret = register_udev_uevent_control(&uh);
+ if (ret < 0)
+ _E("Failed to register udev event(%d)", ret);
}
ret = usb_dbus_init();
usb_state_update_state(USB_DISCONNECTED, USB_FUNCTION_NONE);
if (!is_emulator()) {
+ unregister_udev_uevent_control(&uh);
usb_config_deinit();
usb_release();
}