Skip to content

Commit

Permalink
[android] Do not require android configuration block. Fixes JB#41303
Browse files Browse the repository at this point in the history
Usb-moded does android usb initialization only if there is a non-empty
configuration block in the ini-files. This does not make sense anymore
as the values defined in the config file are used as fallback solution
if required data can't be obtained by other means.

If android_usb specific sysfs controls are present on the device, try
to initialize them regardless of whether ubs-moded configuration files
contain relevant information or not.

Signed-off-by: Simo Piiroinen <simo.piiroinen@jollamobile.com>
  • Loading branch information
spiiroin committed Mar 8, 2018
1 parent 70cb7de commit 7a2607c
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 45 deletions.
21 changes: 8 additions & 13 deletions src/usb_moded-android.c
Expand Up @@ -29,19 +29,6 @@
#include "usb_moded-config.h"
#include "usb_moded-mac.h"

/** check if android settings are set
*
* @return 1 if settings are available, 0 if not
*
*/
int android_settings(void)
{
int ret = 0;

ret = check_android_section();

return ret;
}

/** Read android serial number from kernel command line
*/
Expand Down Expand Up @@ -97,6 +84,11 @@ void android_init_values(void)
{
gchar *text;

if( access("/sys/class/android_usb/android0", F_OK) != 0 )
{
goto EXIT;
}

if( (text = get_android_serial()) )
{
write_to_file("/sys/class/android_usb/android0/iSerial", text);
Expand Down Expand Up @@ -139,6 +131,9 @@ void android_init_values(void)
/* Make sure android_usb does not stay disabled in case usb moded
* has crashed / been killed in inconvenient time. */
write_to_file("/sys/class/android_usb/android0/enable", "1");

EXIT:
return;
}

/* Set a charging mode for the android gadget
Expand Down
1 change: 0 additions & 1 deletion src/usb_moded-android.h
Expand Up @@ -20,7 +20,6 @@
02110-1301 USA
*/

int android_settings(void);
void android_init_values(void);
int set_android_charging_mode(void);
int set_android_productid(char *id);
Expand Down
27 changes: 0 additions & 27 deletions src/usb_moded-config.c
Expand Up @@ -859,33 +859,6 @@ char * get_mode_whitelist(void)
return(get_conf_string(MODE_SETTING_ENTRY, MODE_WHITELIST_KEY));
}

int check_android_section(void)
{
GKeyFile *settingsfile;
gboolean test = FALSE;
gchar **keys;
int ret = 1;

settingsfile = g_key_file_new();
test = g_key_file_load_from_file(settingsfile, FS_MOUNT_CONFIG_FILE, G_KEY_FILE_NONE, NULL);
if(!test)
{
ret = 0;
goto cleanup;
}
keys = g_key_file_get_keys (settingsfile, ANDROID_ENTRY, NULL, NULL);
if(keys == NULL)
{
ret = 0;
goto cleanup;
}

g_strfreev(keys);
cleanup:
g_key_file_free(settingsfile);
return(ret);
}

int is_roaming_not_allowed(void)
{
return(get_conf_int(NETWORK_ENTRY, NO_ROAMING_KEY));
Expand Down
2 changes: 0 additions & 2 deletions src/usb_moded-config.h
Expand Up @@ -83,8 +83,6 @@ char * get_android_product_id(void);
char * get_hidden_modes(void);
char * get_mode_whitelist(void);

int check_android_section(void);

int is_roaming_not_allowed(void);

typedef enum set_config_result_t {
Expand Down
4 changes: 2 additions & 2 deletions src/usb_moded.c
Expand Up @@ -733,8 +733,8 @@ static void usb_moded_init(void)
usb_moded_module_ctx_init();

/* Android specific stuff */
if(android_settings())
android_init_values();
android_init_values();

/* TODO: add more start-up clean-up and init here if needed */
}

Expand Down

0 comments on commit 7a2607c

Please sign in to comment.