Skip to content

Commit

Permalink
[usb-moded] Do not pop-up ask dialog if charging mode was chosen befo…
Browse files Browse the repository at this point in the history
…re device locked up. Fixes: JB#13550

Track if charging mode was set explicitly, so we can decide accordingly when
devicelock asks for re-evaluation of the connection state.

Signed-off-by: Philippe De Swert <philippe.deswert@jollamobile.com>
  • Loading branch information
philippedeswert committed Nov 29, 2013
1 parent e1c0179 commit 3d011a0
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/usb_moded.c
Expand Up @@ -67,6 +67,7 @@ extern int log_type;
gboolean rescue_mode = FALSE;
gboolean diag_mode = FALSE;
gboolean hw_fallback = FALSE;
gboolean charging_mode_set = FALSE;

struct usb_mode current_mode;
guint charging_timeout = 0;
Expand Down Expand Up @@ -149,6 +150,7 @@ static gboolean set_disconnected(gpointer data)
usb_moded_module_cleanup(get_usb_module());
set_usb_mode(MODE_UNDEFINED);
#endif /* NOKIA */
charging_mode_set = FALSE;

}
return FALSE;
Expand Down Expand Up @@ -233,6 +235,10 @@ void set_usb_connected_state(void)

if(!strcmp(MODE_ASK, mode_to_set))
{
/* if charging mode was set we do not do anything as we might get here
due to a devicelock state change */
if(charging_mode_set)
return;
/* send signal, mode will be set when the dialog service calls
the set_mode method call.
*/
Expand Down Expand Up @@ -282,6 +288,7 @@ void set_usb_mode(const char *mode)
set_usb_module(MODULE_NONE);
ret = set_android_charging_mode();
}
charging_mode_set = TRUE;
goto end;
}
else if(!strcmp(mode, MODE_ASK) || !strcmp(mode, MODE_CHARGER))
Expand Down Expand Up @@ -527,6 +534,9 @@ static gboolean charging_fallback(gpointer data)
current_mode.mode = strdup(MODE_ASK);
current_mode.data = NULL;
charging_timeout = 0;
/* for extra safety we explicitly set charging_mode_set
to false as the mode was not chosen */
charging_mode_set = FALSE;
log_info("Falling back on charging mode.\n");

return(FALSE);
Expand Down

0 comments on commit 3d011a0

Please sign in to comment.