Skip to content

Commit

Permalink
[network] Refactor network and tethering setup. JB#46940
Browse files Browse the repository at this point in the history
Network sharing via connman does not work in all devices, legacy sharing
config not ivolving connman works in no devices. Part of the problem lies
in connman/kernel end (device type for rndis0 interface is not reported by
udev and/or connman developer mode plugin does not take connection sharing
mode into account), part is due to fragile / broken usb-moded side logic.

Stop usb-moded from making wifi / cellular power cycle requests.

When using legacy sharing config and cellular is not online, make an
attempt to share wlan connection (the connman way already does this).

Rewrite all D-Bus ipc logic and refactor the rest too.

Add error checks in select places so that usb-moded abandons failed
mode setting and falls back to charging only.

Signed-off-by: Simo Piiroinen <simo.piiroinen@jollamobile.com>
  • Loading branch information
spiiroin committed Jan 28, 2020
1 parent ba7ee2b commit 149dd17
Show file tree
Hide file tree
Showing 3 changed files with 914 additions and 974 deletions.
25 changes: 20 additions & 5 deletions src/usb_moded-modesetting.c
Expand Up @@ -723,10 +723,16 @@ bool modesetting_enter_dynamic_mode(void)
goto EXIT;
}

log_debug("data->mode_name = %s", data->mode_name);
log_debug("data->mass_storage = %d", data->mass_storage);
log_debug("data->connman_tethering = %s", data->connman_tethering ?: "n/a");
log_debug("data->appsync = %d", data->appsync);
log_debug("data->network = %d", data->network);
log_debug("data->network_interface = %s", data->network_interface ?: "n/a");
log_debug("data->idProduct = %s", data->idProduct ?: "n/a");
log_debug("data->idVendorOverride = %s", data->idVendorOverride ?: "n/a");
log_debug("data->nat = %d", data->nat);
log_debug("data->dhcp_server = %d", data->dhcp_server);

/* - - - - - - - - - - - - - - - - - - - *
* Is a mass storage dynamic mode?
Expand Down Expand Up @@ -814,15 +820,23 @@ bool modesetting_enter_dynamic_mode(void)
if( !(error = network_up(data)) )
log_warning("Setting up the network succeeded");
}
if( error )
if( error ) {
log_err("Setting up the network failed");
goto EXIT;
}
#endif /* DEBIAN */
}

/* Needs to be called before application post synching so
* that the dhcp server has the right config */
if(data->nat || data->dhcp_server)
network_set_up_dhcpd(data);
if(data->nat || data->dhcp_server) {
/* FIXME: The used condition is a bit questionable as dhcpd
* service is started based on appsync config - i.e. NOT
* based on either nat or setting in modedata ...
*/
if( network_update_udhcpd_config(data) != 0 )
goto EXIT;
}

/* - - - - - - - - - - - - - - - - - - - *
* Start post-enum app sync
Expand All @@ -844,7 +858,8 @@ bool modesetting_enter_dynamic_mode(void)
#ifdef CONNMAN
if( data->connman_tethering ) {
log_debug("Dynamic mode is tethering");
connman_set_tethering(data->connman_tethering, TRUE);
if( !connman_set_tethering(data->connman_tethering, true) )
goto EXIT;
}
#endif

Expand Down Expand Up @@ -894,7 +909,7 @@ void modesetting_leave_dynamic_mode(void)
#ifdef CONNMAN
if( data->connman_tethering ) {
log_debug("Dynamic mode was tethering");
connman_set_tethering(data->connman_tethering, FALSE);
connman_set_tethering(data->connman_tethering, false);
}
#endif

Expand Down

0 comments on commit 149dd17

Please sign in to comment.