Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Implement charging mode for the android gadget. The g_file/mass_stora…
…ge module

might not be available so trick the android gadget into an empty configuration for
charging enumeration.

[usb-moded] Charging mode with android gadget

Signed-off-by: Philippe De Swert <philippe.deswert@jollamobile.com>
  • Loading branch information
philippedeswert committed Aug 14, 2013
1 parent 82c4e2f commit c234d50
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/usb_moded-android.c
Expand Up @@ -81,4 +81,20 @@ void android_init_values(void)
}
}

/* Set a charging mode for the android gadget
*
* @return 0 if successful, 1 on failure
*/
int set_android_charging_mode(void)
{
int ret = 0;

/* disable, set functions to "null", re-enable */
write_to_file("/sys/class/android_usb/android0/enable", "0");
write_to_file("/sys/class/android_usb/android0/functions", "null");
ret = write_to_file("/sys/class/android_usb/android0/enable", "1");
if(ret < 0)
return(1);
else
return(ret);
}
1 change: 1 addition & 0 deletions src/usb_moded-android.h
Expand Up @@ -22,3 +22,4 @@

int android_settings(void);
void android_init_values(void);
int set_android_charging_mode(void);
3 changes: 3 additions & 0 deletions src/usb_moded.c
Expand Up @@ -247,6 +247,9 @@ void set_usb_mode(const char *mode)
set_usb_module(MODULE_MASS_STORAGE);
/* MODULE_CHARGING has all the parameters defined, so it will not match the g_file_storage rule in usb_moded_load_module */
ret = usb_moded_load_module(MODULE_CHARGING);
/* if charging mode setting did not succeed we might be dealing with android */
if(ret)
ret = set_android_charging_mode();
goto end;
}
else if(!strcmp(mode, MODE_ASK) || !strcmp(mode, MODE_CHARGER))
Expand Down

0 comments on commit c234d50

Please sign in to comment.