diff --git a/src/usb_moded-android.c b/src/usb_moded-android.c index 1f50ebf..b568c22 100644 --- a/src/usb_moded-android.c +++ b/src/usb_moded-android.c @@ -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 */ @@ -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); @@ -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 diff --git a/src/usb_moded-android.h b/src/usb_moded-android.h index e7f7ac0..3b2f8ed 100644 --- a/src/usb_moded-android.h +++ b/src/usb_moded-android.h @@ -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); diff --git a/src/usb_moded-config.c b/src/usb_moded-config.c index bc5d301..d6c0513 100644 --- a/src/usb_moded-config.c +++ b/src/usb_moded-config.c @@ -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" @@ -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)); diff --git a/src/usb_moded-config.h b/src/usb_moded-config.h index 9f71325..3570bc0 100644 --- a/src/usb_moded-config.h +++ b/src/usb_moded-config.h @@ -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 { diff --git a/src/usb_moded.c b/src/usb_moded.c index 742197b..9d9b96b 100644 --- a/src/usb_moded.c +++ b/src/usb_moded.c @@ -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 */ }