Skip to content

Commit

Permalink
[adb] improve adb starting
Browse files Browse the repository at this point in the history
Signed-off-by: Philippe De Swert <philippe.deswert@jollamobile.com>
  • Loading branch information
philippedeswert committed Sep 24, 2015
1 parent 86c30cf commit c9f3d8d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
1 change: 1 addition & 0 deletions config/run/adb-startserver.ini
Expand Up @@ -2,3 +2,4 @@
name = adbd.service
mode = adb_mode
systemd = 1
post = 1
22 changes: 19 additions & 3 deletions src/usb_moded-modesetting.c
Expand Up @@ -43,6 +43,7 @@
#include "usb_moded-android.h"

static void report_mass_storage_blocker(const char *mountpoint, int try);
guint delayed_network = 0;

int write_to_file(const char *path, const char *text)
{
Expand Down Expand Up @@ -87,6 +88,12 @@ int write_to_file(const char *path, const char *text)
return err;
}

static gboolean network_retry(gpointer data)
{
usb_network_up(data);
return(FALSE);
}

static int set_mass_storage_mode(struct mode_list_elem *data)
{
gchar *command;
Expand Down Expand Up @@ -386,9 +393,8 @@ int set_dynamic_mode(void)
this can happen with functionfs based gadgets (which is why we sleep for a bit */
if(network != 0)
{
log_debug("Retry setting up te network\n");
sleep(1);
usb_network_up(data);
log_debug("Retry setting up the network later\n");
delayed_network = g_timeout_add_seconds(3, network_retry, data);
}

/* Needs to be called before application post synching so
Expand All @@ -398,7 +404,11 @@ int set_dynamic_mode(void)

/* no need to execute the post sync if there was an error setting the mode */
if(data->appsync && !ret)
{
/* let's sleep for a bit (350ms) to allow interfaces to settle before running postsync */
usleep(350000);
activate_sync_post(data->mode_name);
}

#ifdef CONNMAN
if(data->connman_tethering)
Expand All @@ -417,6 +427,12 @@ void unset_dynamic_mode(void)

data = get_usb_mode_data();

if(delayed_network)
{
g_source_remove(delayed_network);
delayed_network = 0;
}

/* the modelist could be empty */
if(!data)
return;
Expand Down

0 comments on commit c9f3d8d

Please sign in to comment.