Skip to content

Commit

Permalink
[diag mode] usb-moded : add diag mode for android
Browse files Browse the repository at this point in the history
* Add extra config options (for values that are unique and only need to be set once :( )
* Add diag mode configuration

Signed-off-by: Philippe De Swert <philippe.deswert@jollamobile.com>
  • Loading branch information
philippedeswert committed Jul 19, 2013
1 parent dbedce9 commit 85c1774
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 11 deletions.
14 changes: 14 additions & 0 deletions config/dyn-modes/diag_mode.ini
@@ -0,0 +1,14 @@
[mode]
name = diag_mode
module = none
appsync = 1

[options]
sysfs_path = /sys/class/android_usb/android0/functions
sysfs_value = diag
sysfs_reset_value = none
softconnect_path = /sys/class/android_usb/android0/enable
softconnect = 1
softconnec_disconnect = 0
android_extra_sysfs_path = /sys/class/android_usb/android0/f_diag/clients
android_extra_sysfs_value = diag,diag_mdm
4 changes: 4 additions & 0 deletions config/run/adb-diag.ini
@@ -0,0 +1,4 @@
[info]
name = adbd.service
mode = diag_mode
systemd = 1
2 changes: 2 additions & 0 deletions src/usb_moded-dyn-config.c
Expand Up @@ -90,6 +90,8 @@ static struct mode_list_elem *read_mode_file(const gchar *filename)
list_item->softconnect = g_key_file_get_string(settingsfile, MODE_OPTIONS_ENTRY, MODE_SOFTCONNECT, NULL);
list_item->softconnect_disconnect = g_key_file_get_string(settingsfile, MODE_OPTIONS_ENTRY, MODE_SOFTCONNECT_DISCONNECT, NULL);
list_item->softconnect_path = g_key_file_get_string(settingsfile, MODE_OPTIONS_ENTRY, MODE_SOFTCONNECT_PATH, NULL);
list_item->android_extra_sysfs_path = g_key_file_get_string(settingsfile, MODE_OPTIONS_ENTRY, MODE_ANDROID_EXTRA_SYSFS_PATH, NULL);
list_item->android_extra_sysfs_value = g_key_file_get_string(settingsfile, MODE_OPTIONS_ENTRY, MODE_ANDROID_EXTRA_SYSFS_VALUE, NULL);
g_key_file_free(settingsfile);
if(list_item->mode_name == NULL || list_item->mode_module == NULL)
{
Expand Down
28 changes: 17 additions & 11 deletions src/usb_moded-dyn-config.h
Expand Up @@ -38,24 +38,30 @@
#define MODE_SOFTCONNECT "softconnect"
#define MODE_SOFTCONNECT_DISCONNECT "softconnec_disconnect"
#define MODE_SOFTCONNECT_PATH "softconnect_path"
/* Instead of hard-coding values that never change or have only one option,
android engineers prefered to have sysfs entries... go figure... */
#define MODE_ANDROID_EXTRA_SYSFS_PATH "android_extra_sysfs_path"
#define MODE_ANDROID_EXTRA_SYSFS_VALUE "android_extra_sysfs_value"

/**
* Struct keeping all the data needed for the definition of a dynamic mode
*/
typedef struct mode_list_elem
{
/*@{ */
char *mode_name; /* mode name */
char *mode_module; /* needed module for given mode */
int appsync; /* requires appsync or not */
int network; /* bring up network or not */
char *network_interface; /* Which network interface to bring up if network needs to be enabled */
char *sysfs_path; /* path to set sysfs options */
char *sysfs_value; /* option name/value to write to sysfs */
char *sysfs_reset_value; /* value to reset the the sysfs to default */
char *softconnect; /* value to be written to softconnect interface */
char *softconnect_disconnect; /* value to set on the softconnect interface to disable after disconnect */
char *softconnect_path; /* path for the softconnect */
char *mode_name; /* mode name */
char *mode_module; /* needed module for given mode */
int appsync; /* requires appsync or not */
int network; /* bring up network or not */
char *network_interface; /* Which network interface to bring up if network needs to be enabled */
char *sysfs_path; /* path to set sysfs options */
char *sysfs_value; /* option name/value to write to sysfs */
char *sysfs_reset_value; /* value to reset the the sysfs to default */
char *softconnect; /* value to be written to softconnect interface */
char *softconnect_disconnect; /* value to set on the softconnect interface to disable after disconnect */
char *softconnect_path; /* path for the softconnect */
char *android_extra_sysfs_path; /* path for static value that never changes that needs to be set by sysfs :( */
char *android_extra_sysfs_value; /* static value that never changes that needs to be set by sysfs :( */
/*@} */
}mode_list_elem;

Expand Down
4 changes: 4 additions & 0 deletions src/usb_moded-modesetting.c
Expand Up @@ -373,6 +373,10 @@ int set_dynamic_mode(void)
{
write_to_file(data->softconnect_path, data->softconnect);
}
if(data->android_extra_sysfs_value && data->android_extra_sysfs_path)
{
write_to_file(data->android_extra_sysfs_path, data->android_extra_sysfs_value);
}

/* functionality should be enabled, so we can enable the network now */
if(data->network)
Expand Down

0 comments on commit 85c1774

Please sign in to comment.