diff --git a/debian/changelog b/debian/changelog index 4777cdd..e192efc 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,8 +1,7 @@ usb-moded (0.34) unstable; urgency=low - * Delay unloading a bit more (8s instead of 3). Fixes: NB#225492 * Fixes for USB autoplay. Fixes: NB#220474 - * Added cdrom emulation support. + * Added cdrom emulation support. Fixes: NB#244861 * Added udev option for cable detection -- Philippe De Swert Fri, 01 Apr 2011 13:22:51 +0300 diff --git a/src/usb_moded-udev.c b/src/usb_moded-udev.c index 947529a..d185f13 100644 --- a/src/usb_moded-udev.c +++ b/src/usb_moded-udev.c @@ -22,6 +22,8 @@ struct udev_device *dev; /* static function definitions */ gpointer monitor_udev(gpointer data) __attribute__ ((noreturn)); +/* TODO: write udev property parsing in seperate function to avoid code duplication */ + gboolean hwal_init(void) { GThread * thread; @@ -66,8 +68,16 @@ gboolean hwal_init(void) } if(!strcmp(tmp, "1")) { - if(!strcmp(udev_device_get_property_value(dev, "POWER_SUPPLY_TYPE"), "USB")|| - !strcmp(udev_device_get_property_value(dev, "POWER_SUPPLY_TYPE"), "USB_CDP")) + /* power supply type might not exist */ + tmp = udev_device_get_property_value(dev, "POWER_SUPPLY_TYPE"); + if(!tmp) + { + /* power supply type might not exist also :( Send connected event but this will not be able + to discriminate between charger/cable */ + log_warning("Fallback since cable detecion cannot be accurate. Will connect on any voltage on usb.\n"); + set_usb_connected(TRUE); + } + if(!strcmp(tmp, "USB")||!strcmp(tmp, "USB_CDP")) { log_debug("UDEV:USB cable connected\n"); set_usb_connected(TRUE); @@ -108,12 +118,20 @@ gpointer monitor_udev(gpointer data) { log_debug("UDEV:power supply present\n"); /* POWER_SUPPLY_TYPE is USB if usb cable is connected, USB_CDP for charging hub or USB_DCP for charger */ - if(!strcmp(udev_device_get_property_value(dev, "POWER_SUPPLY_TYPE"), "USB")|| - !strcmp(udev_device_get_property_value(dev, "POWER_SUPPLY_TYPE"), "USB_CDP")) + tmp = udev_device_get_property_value(dev, "POWER_SUPPLY_TYPE"); + if(!tmp) + { + /* power supply type might not exist also :( Send connected event but this will not be able + to discriminate between charger/cable */ + log_warning("Fallback since cable detecion cannot be accurate. Will connect on any voltage on usb.\n"); + set_usb_connected(TRUE); + } + if(!strcmp(tmp, "USB")||!strcmp(tmp, "USB_CDP")) { log_debug("UDEV:USB cable connected\n"); set_usb_connected(TRUE); } + } else { diff --git a/src/usb_moded.c b/src/usb_moded.c index a5bb657..258add6 100644 --- a/src/usb_moded.c +++ b/src/usb_moded.c @@ -116,7 +116,7 @@ void set_usb_connected(gboolean connected) usb_moded_mode_cleanup(get_usb_module()); usb_moded_send_signal(USB_DISCONNECTED); #ifdef NOKIA - timeout_source = g_timeout_add_seconds(10, usb_module_timeout_cleanup, NULL); + timeout_source = g_timeout_add_seconds(5, usb_module_timeout_cleanup, NULL); #else /* unload modules and general cleanup */ usb_moded_module_cleanup(get_usb_module());