From 04cc660f87d34daaf2e0950479f36f3c21a56c75 Mon Sep 17 00:00:00 2001 From: Philippe De Swert Date: Thu, 4 Dec 2014 15:49:56 +0200 Subject: [PATCH] [charger] Debounce charger connection info. Fixes: JB#24913 Stop sending signals the whole time when the charger is connected. As we can get lots of spurious signals from the kernel, just like with the regular cable connection. Signed-off-by: Philippe De Swert --- src/usb_moded.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/usb_moded.c b/src/usb_moded.c index 2863927..c7e8a13 100644 --- a/src/usb_moded.c +++ b/src/usb_moded.c @@ -192,16 +192,23 @@ if(!get_usb_connection_state()) */ void set_charger_connected(gboolean state) { + /* check if charger is already connected + to avoid spamming dbus */ + if(current_mode.connected) + return; + if(state) { usb_moded_send_signal(CHARGER_CONNECTED); set_usb_mode(MODE_CHARGER); + current_mode.connected = TRUE; } else { current_mode.connected = FALSE; usb_moded_send_signal(CHARGER_DISCONNECTED); set_usb_mode(MODE_UNDEFINED); + current_mode.connected = FALSE; } }