Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[usb_moded] Refactor entering/leaving usb mode. JB#41748
Split mode switching to three layers: Tracking cable connection state,
choosing target mode, and performing required actions to activate
the chosen mode.

Try to minimize places where layer borders are crossed - which should
work also as an enabler for moving blocking actions to separate thread
later on.

Arrange logic in such manner that usb gadget is always configured as
being able to serve some function - fallback being the dummy mass_storage
function used for charging.

Deprecate command line options that serve no useful purpose after the
changes.

Signed-off-by: Simo Piiroinen <simo.piiroinen@jollamobile.com>
  • Loading branch information
spiiroin committed Aug 24, 2018
1 parent 18efbfc commit 6435068
Show file tree
Hide file tree
Showing 11 changed files with 252 additions and 441 deletions.
4 changes: 2 additions & 2 deletions src/usb_moded-appsync.c
Expand Up @@ -62,7 +62,7 @@ static gboolean appsync_enumerate_usb_cb (gpointer data);
static void appsync_start_enumerate_usb_timer (void);
static void appsync_cancel_enumerate_usb_timer(void);
static void appsync_enumerate_usb (void);
static void appsync_stop_apps (int post);
void appsync_stop_apps (int post);
int appsync_stop (gboolean force);

/* ========================================================================= *
Expand Down Expand Up @@ -456,7 +456,7 @@ static void appsync_enumerate_usb(void)
#endif /* APP_SYNC_DBUS */
}

static void appsync_stop_apps(int post)
void appsync_stop_apps(int post)
{
GList *iter = 0;

Expand Down
1 change: 1 addition & 0 deletions src/usb_moded-appsync.h
Expand Up @@ -80,5 +80,6 @@ int appsync_activate_sync (const char *mode);
int appsync_activate_sync_post(const char *mode);
int appsync_mark_active (const gchar *name, int post);
int appsync_stop (gboolean force);
void appsync_stop_apps (int post);

#endif /* USB_MODED_APPSYNC_H_ */
1 change: 0 additions & 1 deletion src/usb_moded-config.c
Expand Up @@ -591,7 +591,6 @@ set_config_result_t config_set_mode_whitelist(const char *whitelist)
else if (strcmp(current_mode, MODE_CHARGING_FALLBACK) && strcmp(current_mode, MODE_ASK) && usbmoded_valid_mode(current_mode)) {
/* Invalid mode that is not MODE_ASK or MODE_CHARGING_FALLBACK
* -> switch to MODE_CHARGING_FALLBACK */
modesetting_cleanup(usbmoded_get_usb_module());
usbmoded_set_usb_mode(MODE_CHARGING_FALLBACK);
}

Expand Down
1 change: 0 additions & 1 deletion src/usb_moded-dbus.c
Expand Up @@ -283,7 +283,6 @@ static DBusHandlerResult umdbus_msg_handler(DBusConnection *const connection, DB
/* do not change mode if the mode requested is the one already set */
if(strcmp(use, usbmoded_get_usb_mode()) != 0)
{
modesetting_cleanup(usbmoded_get_usb_module());
usbmoded_set_usb_mode(use);
}
if((reply = dbus_message_new_method_return(msg)))
Expand Down

0 comments on commit 6435068

Please sign in to comment.