Commit 26febfcb authored by Philippe De Swert's avatar Philippe De Swert

Add Android gadget manufacturer and vendor id support

Signed-off-by: default avatarPhilippe De Swert <philippe.deswert@jollamobile.com>
parent af3a30b0
......@@ -32,7 +32,9 @@ usb_moded_SOURCES = \
usb_moded-mac.h \
usb_moded-dyn-config.c \
usb_moded-dyn-config.h \
usb_moded-modules.c
usb_moded-modules.c \
usb_moded-android.h \
usb_moded-android.c
if GCONF
usb_moded_SOURCES += \
......
/**
@file usb_moded-android.c
Copyright (C) 2013 Jolla. All rights reserved.
@author: Philippe De Swert <philippe.deswert@jollamobile.com>
This program is free software; you can redistribute it and/or
modify it under the terms of the Lesser GNU General Public License
version 2 as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the Lesser GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
02110-1301 USA
*/
#include <stdio.h>
#include <glib.h>
#include "usb_moded-android.h"
#include "usb_moded-log.h"
#include "usb_moded-modesetting.h"
#include "usb_moded-config.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;
}
/** initialize the basic android values
*/
void android_init_values(void)
{
const char *text;
text = get_android_manufacturer();
if(text)
{
write_to_file("/sys/class/android_usb/android0/iManufacturer", text);
g_free((char *)text);
}
text = get_android_vendor();
if(text)
{
write_to_file("/sys/class/android_usb/android0/idVendor", text);
g_free((char *)text);
}
}
/**
@file usb_moded-android.h
Copyright (C) 2013 Jolla. All rights reserved.
@author: Philippe De Swert <philippe.deswert@jollamobile.com>
This program is free software; you can redistribute it and/or
modify it under the terms of the Lesser GNU General Public License
version 2 as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the Lesser GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
02110-1301 USA
*/
int android_settings(void);
void android_init_values(void);
......@@ -196,6 +196,7 @@ static int get_conf_int(const gchar *entry, const gchar *key)
}
keys++;
}
g_strfreev(keys);
g_key_file_free(settingsfile);
return(ret);
......@@ -229,6 +230,7 @@ static const char * get_conf_string(const gchar *entry, const gchar *key)
}
keys++;
}
g_strfreev(keys);
g_key_file_free(settingsfile);
return(g_strdup(tmp_char));
......@@ -304,7 +306,6 @@ static const char * get_kcmdline_string(const char *entry)
return(ret);
}
#ifndef GCONF
const char * get_mode_setting(void)
{
const char * mode = get_kcmdline_string(MODE_SETTING_KEY);
......@@ -380,8 +381,6 @@ int set_network_setting(const char *config, const char *setting)
return(!ret);
}
#endif
int conf_file_merge(void)
{
GDir *confdir;
......@@ -493,3 +492,35 @@ end:
g_dir_close(confdir);
return(ret);
}
const char * get_android_manufacturer(void)
{
return(get_conf_string(ANDROID_ENTRY, ANDROID_MANUFACTURER_KEY));
}
const char * get_android_vendor(void)
{
return(get_conf_string(ANDROID_ENTRY, ANDROID_VENDOR_KEY));
}
int check_android_section(void)
{
GKeyFile *settingsfile;
gboolean test = FALSE;
gchar **keys;
settingsfile = g_key_file_new();
test = g_key_file_load_from_file(settingsfile, FS_MOUNT_CONFIG_FILE, G_KEY_FILE_NONE, NULL);
if(!test)
return 0;
keys = g_key_file_get_keys (settingsfile, ANDROID_ENTRY, NULL, NULL);
if(keys == NULL)
{
g_key_file_free(settingsfile);
return 0;
}
g_strfreev(keys);
g_key_file_free(settingsfile);
return 1;
}
......@@ -50,6 +50,9 @@
#define NETWORK_GATEWAY_KEY "gateway"
#define SOFT_CONNECT_ENTRY "soft_connect"
#define SOFT_CONNECT_PATH_KEY "soft_connect_path"
#define ANDROID_ENTRY "android"
#define ANDROID_MANUFACTURER_KEY "manufacturer"
#define ANDROID_VENDOR_KEY "vendor"
const char * find_mounts(void);
int find_sync(void);
......@@ -78,5 +81,10 @@ const char * get_network_interface(void);
const char * get_network_gateway(void);
const char * get_soft_connect_path(void);
const char * get_android_manufacturer(void);
const char * get_android_vendor(void);
int check_android_section(void);
int conf_file_merge(void);
int set_config_setting(const char *entry, const char *key, const char *value);
......@@ -51,6 +51,7 @@
#include "usb_moded-config-private.h"
#include "usb_moded-network.h"
#include "usb_moded-mac.h"
#include "usb_moded-android.h"
/* global definitions */
......@@ -469,6 +470,9 @@ static void usb_moded_init(void)
ctx = kmod_new(NULL, NULL);
kmod_load_resources(ctx);
/* Android specific stuff */
if(android_settings())
android_init_values();
/* TODO: add more start-up clean-up and init here if needed */
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment