From 603c54cc63c1e37fcde5a6058a8c05d8a8a28645 Mon Sep 17 00:00:00 2001 From: rpadin319 Date: Wed, 4 Dec 2024 21:02:33 +0000 Subject: [PATCH] RDKTV-34551 - Added DeviceInfo brandname API --- DeviceInfo/CHANGELOG.md | 4 ++++ DeviceInfo/DeviceInfo.cpp | 4 ++-- DeviceInfo/DeviceInfo.h | 1 + DeviceInfo/DeviceInfo.json | 24 +++++++++++++++++++++++- DeviceInfo/DeviceInfoJsonRpc.cpp | 18 ++++++++++++++++++ DeviceInfo/Implementation/DeviceInfo.cpp | 14 ++++++++++++++ DeviceInfo/Implementation/DeviceInfo.h | 1 + 7 files changed, 63 insertions(+), 3 deletions(-) diff --git a/DeviceInfo/CHANGELOG.md b/DeviceInfo/CHANGELOG.md index d5809acb97..e6f8c0b7d7 100644 --- a/DeviceInfo/CHANGELOG.md +++ b/DeviceInfo/CHANGELOG.md @@ -15,6 +15,10 @@ All notable changes to this RDK Service will be documented in this file. * Changes in CHANGELOG should be updated when commits are added to the main or release branches. There should be one CHANGELOG entry per JIRA Ticket. This is not enforced on sprint branches since there could be multiple changes for the same JIRA ticket during development. * For more details, refer to [versioning](https://github.com/rdkcentral/rdkservices#versioning) section under Main README. +## [1.1.0] - 2024-11-26 +### Added +- Added API to get Device brand + ## [1.0.15] - 2024-09-16 ### Changed - DELIA-65827: Return Empty SerialNumber in curl for "method": "DeviceInfo.1.systeminfo" diff --git a/DeviceInfo/DeviceInfo.cpp b/DeviceInfo/DeviceInfo.cpp index 566c3645af..86a0a551a1 100644 --- a/DeviceInfo/DeviceInfo.cpp +++ b/DeviceInfo/DeviceInfo.cpp @@ -20,8 +20,8 @@ #include "DeviceInfo.h" #define API_VERSION_NUMBER_MAJOR 1 -#define API_VERSION_NUMBER_MINOR 0 -#define API_VERSION_NUMBER_PATCH 14 +#define API_VERSION_NUMBER_MINOR 1 +#define API_VERSION_NUMBER_PATCH 0 namespace WPEFramework { namespace { diff --git a/DeviceInfo/DeviceInfo.h b/DeviceInfo/DeviceInfo.h index 4714b6c0aa..191e250b3d 100644 --- a/DeviceInfo/DeviceInfo.h +++ b/DeviceInfo/DeviceInfo.h @@ -117,6 +117,7 @@ namespace Plugin { uint32_t get_modelid(JsonData::DeviceInfo::ModelidData& response) const; uint32_t get_make(JsonData::DeviceInfo::MakeData& response) const; uint32_t get_modelname(JsonData::DeviceInfo::ModelnameData& response) const; + uint32_t get_brandname(JsonData::DeviceInfo::BrandnameData& response) const; uint32_t get_devicetype(JsonData::DeviceInfo::DevicetypeData& response) const; uint32_t get_distributorid(JsonData::DeviceInfo::DistributoridData& response) const; uint32_t get_supportedaudioports(JsonData::DeviceInfo::SupportedaudioportsData& response) const; diff --git a/DeviceInfo/DeviceInfo.json b/DeviceInfo/DeviceInfo.json index 463e051f76..b7918adb44 100644 --- a/DeviceInfo/DeviceInfo.json +++ b/DeviceInfo/DeviceInfo.json @@ -509,6 +509,28 @@ } ] }, + "brandname": { + "summary": "Device brand name", + "readonly": true, + "params": { + "type": "object", + "properties": { + "brandname": { + "type": "string", + "example": "Comcast" + } + }, + "required": [ + "brand" + ] + }, + "errors": [ + { + "description": "General error", + "$ref": "#/common/errors/general" + } + ] + }, "make": { "summary": "Device manufacturer", "readonly": true, @@ -867,4 +889,4 @@ ] } } -} \ No newline at end of file +} diff --git a/DeviceInfo/DeviceInfoJsonRpc.cpp b/DeviceInfo/DeviceInfoJsonRpc.cpp index 166050f286..e777f2138b 100644 --- a/DeviceInfo/DeviceInfoJsonRpc.cpp +++ b/DeviceInfo/DeviceInfoJsonRpc.cpp @@ -39,6 +39,7 @@ namespace Plugin { Property(_T("modelid"), &DeviceInfo::get_modelid, nullptr, this); Property(_T("make"), &DeviceInfo::get_make, nullptr, this); Property(_T("modelname"), &DeviceInfo::get_modelname, nullptr, this); + Property(_T("brandname"), &DeviceInfo::get_brandname, nullptr, this); Property(_T("devicetype"), &DeviceInfo::get_devicetype, nullptr, this); Property(_T("distributorid"), &DeviceInfo::get_distributorid, nullptr, this); Property(_T("supportedaudioports"), &DeviceInfo::get_supportedaudioports, nullptr, this); @@ -62,6 +63,7 @@ namespace Plugin { Unregister(_T("modelid")); Unregister(_T("make")); Unregister(_T("modelname")); + Unregister(_T("brandname")); Unregister(_T("devicetype")); Unregister(_T("distributorid")); Unregister(_T("supportedaudioports")); @@ -221,6 +223,22 @@ namespace Plugin { return result; } + // Property: brandname - device brand name + // Return codes: + // - ERROR_NONE: Success + // - ERROR_GENERAL: General error + uint32_t DeviceInfo::get_brandname(BrandnameData& response) const + { + string brand; + + auto result = _deviceInfo->Brand(brand); + if (result == Core::ERROR_NONE) { + response.Brand = brand; + } + + return result; + } + // Property: devicetype - Device type // Return codes: // - ERROR_NONE: Success diff --git a/DeviceInfo/Implementation/DeviceInfo.cpp b/DeviceInfo/Implementation/DeviceInfo.cpp index 9707f52c7a..53315657c9 100644 --- a/DeviceInfo/Implementation/DeviceInfo.cpp +++ b/DeviceInfo/Implementation/DeviceInfo.cpp @@ -116,6 +116,20 @@ namespace Plugin { std::regex("^FRIENDLY_ID(?:\\s*)=(?:\\s*)(?:\"{0,1})([^\"\\n]+)(?:\"{0,1})(?:\\s*)$"), model); } + uint32_t DeviceInfoImplementation::Brand(string& brand) const + { + brand = "Unknown"; + return +#ifdef USE_SERIALIZED_MANUFACTURER_NAME + ((Core::ERROR_NONE == GetFileRegex(_T("/tmp/.manufacturer"), std::regex("^([^\\n]+)$"), brand)) || + (GetMFRData(mfrSERIALIZED_TYPE_MANUFACTURER, brand) == Core::ERROR_NONE)) + ? Core::ERROR_NONE + : +#endif + GetFileRegex(_T("/etc/device.properties"), + std::regex("^BRAND_NAME(?:\\s*)=(?:\\s*)(?:\"{0,1})([^\"\\n]+)(?:\"{0,1})(?:\\s*)$"), brand); + } + uint32_t DeviceInfoImplementation::DeviceType(string& deviceType) const { #ifndef ENABLE_COMMUNITY_DEVICE_TYPE diff --git a/DeviceInfo/Implementation/DeviceInfo.h b/DeviceInfo/Implementation/DeviceInfo.h index 66d50dc003..cf321ea3d4 100644 --- a/DeviceInfo/Implementation/DeviceInfo.h +++ b/DeviceInfo/Implementation/DeviceInfo.h @@ -29,6 +29,7 @@ namespace Plugin { uint32_t Model(string& model) const override; uint32_t DeviceType(string& deviceType) const override; uint32_t DistributorId(string& distributorId) const override; + uint32_t Brand(string& brand) const override; }; } }