Skip to content

Commit

Permalink
[charging fallback] Keep fallback state internal
Browse files Browse the repository at this point in the history
As other programs might rely on the charging state and it does not make
a difference to them we better do not change the behaviour towards them.
So we do not broadcast the fallback state, just charging state.

(Also clarify some comment)

Signed-off-by: Philippe De Swert <philippe.deswert@jollamobile.com>
  • Loading branch information
philippedeswert committed Aug 26, 2014
1 parent 147dcc5 commit d558918
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
3 changes: 3 additions & 0 deletions src/usb_moded-dbus.c
Expand Up @@ -76,6 +76,9 @@ static DBusHandlerResult msg_handler(DBusConnection *const connection, DBusMessa
{
const char *mode = get_usb_mode();

/* To the outside we want to keep CHARGING and CHARGING_FALLBACK the same */
if(!strcmp(MODE_CHARGING_FALLBACK, mode))
mode = strdup(MODE_CHARGING);
if((reply = dbus_message_new_method_return(msg)))
dbus_message_append_args (reply, DBUS_TYPE_STRING, &mode, DBUS_TYPE_INVALID);
}
Expand Down
11 changes: 8 additions & 3 deletions src/usb_moded.c
Expand Up @@ -384,7 +384,11 @@ void set_usb_mode(const char *mode)
log_debug("Network setting failed!\n");
free(current_mode.mode);
current_mode.mode = strdup(mode);
usb_moded_send_signal(get_usb_mode());
/* CHARGING_FALLBACK is an internal mode not to be broadcasted outside */
if(!strcmp(mode, MODE_CHARGING_FALLBACK))
usb_moded_send_signal(MODE_CHARGING);
else
usb_moded_send_signal(get_usb_mode());
}

/** check if a given usb_mode exists
Expand All @@ -396,8 +400,9 @@ void set_usb_mode(const char *mode)
int valid_mode(const char *mode)
{

/* MODE_ASK and MODE_CHARGER_FALLBACK are not modes that are settable seen their special status */
if(!strcmp(MODE_CHARGING_FALLBACK, mode))
/* MODE_ASK, MODE_CHARGER and MODE_CHARGING_FALLBACK are not modes that are settable seen their special 'internal' status
so we only check the modes that are announed outside. Only exception is the built in MODE_CHARGING */
if(!strcmp(MODE_CHARGING, mode))
return(0);
else
{
Expand Down

0 comments on commit d558918

Please sign in to comment.