Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use /etc/hw-release for manufacturer and device name #1

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions src/usb_moded-config.c
Original file line number Diff line number Diff line change
Expand Up @@ -1061,6 +1061,23 @@ char * config_get_android_manufacturer(void)
{
return ssu_name;
}
#else
/*Trying use /etc/hw-release to get MANUFACTURER_ID*/
GKeyFile *hwReleaseFile;
GError *error = NULL;

// Create a new GKeyFile object and a bitwise list of flags.
char *hw_name = NULL;
hwReleaseFile = g_key_file_new();
neochapay marked this conversation as resolved.
Show resolved Hide resolved
if (g_key_file_load_from_file(hwReleaseFile, "/etc/hw-release", G_KEY_FILE_NONE, &error))
{
hw_name = g_key_file_get_string(hwReleaseFile, NULL, "MANUFACTURER", NULL);
}

if(hw_name)
{
return hw_name;
}
#endif

return config_get_conf_string(ANDROID_ENTRY, ANDROID_MANUFACTURER_KEY);
Expand All @@ -1085,6 +1102,15 @@ char * config_get_android_product(void)
{
return ssu_name;
}
#else
/*Trying use /etc/hw-release to get NAME*/
GKeyFile *hwReleaseFile;
GError *error = NULL;

hwReleaseFile = g_key_file_new();
if (g_key_file_load_from_file(hwReleaseFile, "/etc/hw-release", G_KEY_FILE_NONE, &error)) {
return g_key_file_get_string(hwReleaseFile, NULL, "NAME", NULL);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using a (local) helper function might improve readability vs. verbatim code duplication. Especially if it turns out that g_key_file_xxx() can't be used for this purpose and a custom parser needs to be written.

#endif

return config_get_conf_string(ANDROID_ENTRY, ANDROID_PRODUCT_KEY);
Expand Down