Skip to content

Commit

Permalink
update android modes to use rndis0, fix up networking to accept dyn c…
Browse files Browse the repository at this point in the history
…onfig values

Signed-off-by: Philippe De Swert <philippe.deswert@jollamobile.com>
  • Loading branch information
philippedeswert committed Jun 19, 2013
1 parent c52488a commit 83477c3
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 14 deletions.
2 changes: 1 addition & 1 deletion config/dyn-modes/adb_mode.ini
Expand Up @@ -2,7 +2,7 @@
name = adb_mode
module = none
network = 1
network_interface = usb0
network_interface = rndis0
sysfs_path = /sys/class/android_usb/android0/functions
sysfs_value = rndis,adb
sysfs_reset_value = none
Expand Down
2 changes: 1 addition & 1 deletion config/dyn-modes/developer_mode-android.ini
Expand Up @@ -2,7 +2,7 @@
name = developer_mode
module = none
network = 1
network_interface = usb0
network_interface = rndis0
sysfs_path = /sys/class/android_usb/android0/functions
sysfs_value = rndis
sysfs_reset_value = none
Expand Down
1 change: 0 additions & 1 deletion src/usb_moded-config.c
Expand Up @@ -437,7 +437,6 @@ int conf_file_merge(void)
{
log_debug("%d failed loading config file %s\n", test, filename_full);
g_free(filename_full);
break;
}
g_free(filename_full);
log_debug("file data = %s\n", g_key_file_to_data(settingsfile, NULL, NULL));
Expand Down
12 changes: 7 additions & 5 deletions src/usb_moded-modesetting.c
Expand Up @@ -263,8 +263,8 @@ int set_ovi_suite_mode(void)
#ifdef DEBIAN
system("ifdown usb0 ; ifup usb0");
#else
usb_network_down();
usb_network_up();
usb_network_down(NULL);
usb_network_up(NULL);
#endif /* DEBIAN */

#ifdef NOKIA
Expand Down Expand Up @@ -293,13 +293,14 @@ int set_dynamic_mode(struct mode_list_elem *data)
g_snprintf(command, 256, "ifdown %s ; ifup %s", data->network_interface, data->network_interface);
system(command);
#else
usb_network_down();
usb_network_up();
usb_network_down(data);
usb_network_up(data);
#endif /* DEBIAN */
}
if(data->sysfs_path)
{
write_to_file(data->sysfs_path, data->sysfs_value);
log_debug("writing to file %s, value %s\n", data->sysfs_path, data->sysfs_reset_value);
}
if(data->softconnect)
{
Expand All @@ -322,6 +323,7 @@ void unset_dynamic_mode(void)
if(data->sysfs_path)
{
write_to_file(data->sysfs_path, data->sysfs_reset_value);
log_debug("writing to file %s, value %s\n", data->sysfs_path, data->sysfs_reset_value);
}
if(data->softconnect)
{
Expand Down Expand Up @@ -437,7 +439,7 @@ int usb_moded_mode_cleanup(const char *module)
sync();
/* bring network down immediately */
/*system("ifdown usb0"); */
usb_network_down();
usb_network_down(NULL);
/* do soft disconnect
write_to_file("/sys/devices/platform/musb_hdrc/gadget/softconnect", "0"); */
/* DIRTY WORKAROUND: acm/phonet does not work as it should, remove when it does */
Expand Down
46 changes: 42 additions & 4 deletions src/usb_moded-network.c
Expand Up @@ -28,6 +28,8 @@
#include <stdlib.h>
#include <string.h>

#include <glib.h>

#include "usb_moded-network.h"
#include "usb_moded-config.h"

Expand All @@ -43,7 +45,7 @@
* Activate the network interface
*
*/
int usb_network_up(void)
int usb_network_up(struct mode_list_elem *data)
{
const char *ip, *interface, *gateway;
char command[128];
Expand Down Expand Up @@ -75,8 +77,19 @@ int usb_network_up(void)
return(ret);

#else

if(data)
{
if(data->network_interface)
{
interface = malloc(32*sizeof(char));
strncpy((char *)interface, data->network_interface, 32);
}
}
else
interface = get_network_interface();
ip = get_network_ip();
interface = get_network_interface();
interface = get_network_interface();
gateway = get_network_gateway();
if(ip == NULL)
{
Expand All @@ -103,6 +116,10 @@ int usb_network_up(void)
system(command);
}

free((char *)interface);
free((char *)gateway);
free((char *)ip);

return(0);
#endif /* CONNMAN */
}
Expand All @@ -111,11 +128,32 @@ int usb_network_up(void)
* Deactivate the network interface
*
*/
int usb_network_down(void)
int usb_network_down(struct mode_list_elem *data)
{
#if CONNMAN
#else
system("ifconfig usb0 down");
const char *interface;
char command[128];

if(data)
{
if(data->network_interface)
{
interface = malloc(32*sizeof(char));
strncpy((char *)interface, data->network_interface, 32);
}
}
else
interface = get_network_interface();

if(interface == NULL)
sprintf(command, "ifconfig usb0 down\n");
else
sprintf(command, "ifconfig %s down\n", interface);
system(command);

free((char *)interface);

return(0);
#endif /* CONNMAN */
}
6 changes: 4 additions & 2 deletions src/usb_moded-network.h
Expand Up @@ -22,5 +22,7 @@

/*============================================================================= */

int usb_network_up(void);
int usb_network_down(void);
#include "usb_moded-dyn-config.h"

int usb_network_up(struct mode_list_elem *data);
int usb_network_down(struct mode_list_elem *data);
1 change: 1 addition & 0 deletions src/usb_moded.c
Expand Up @@ -359,6 +359,7 @@ gchar *get_mode_list(void)
{
struct mode_list_elem *data = iter->data;
modelist_str = g_string_append(modelist_str, data->mode_name);
modelist_str = g_string_append(modelist_str, ", ");
}
}
}
Expand Down

0 comments on commit 83477c3

Please sign in to comment.