Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge branch 'jb41303_android_config' into 'master'
Do not require android configuration block

See merge request !32
  • Loading branch information
spiiroin committed Mar 14, 2018
2 parents 70cb7de + ee9b39a commit f2d6ba1
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 44 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
29 changes: 2 additions & 27 deletions src/usb_moded-config.c
Expand Up @@ -42,6 +42,8 @@
#include "usb_moded-log.h"
#include "usb_moded-modes.h"
#include "usb_moded-modesetting.h"
#include "usb_moded-dbus.h"
#include "usb_moded-dbus-private.h"

#ifdef USE_MER_SSU
# include "usb_moded-ssu.h"
Expand Down Expand Up @@ -859,33 +861,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
2 changes: 1 addition & 1 deletion 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();

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

Expand Down

0 comments on commit f2d6ba1

Please sign in to comment.