Skip to content

Commit

Permalink
Merge pull request #5918 from rwarier/sprint/24Q4
Browse files Browse the repository at this point in the history
RDKTV-34551 - Added DeviceInfo brandname API
  • Loading branch information
binuinbaraj authored Dec 6, 2024
2 parents 09e0d2a + d1119b9 commit c821a16
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 3 deletions.
4 changes: 4 additions & 0 deletions DeviceInfo/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions DeviceInfo/DeviceInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions DeviceInfo/DeviceInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
24 changes: 23 additions & 1 deletion DeviceInfo/DeviceInfo.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -867,4 +889,4 @@
]
}
}
}
}
18 changes: 18 additions & 0 deletions DeviceInfo/DeviceInfoJsonRpc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ namespace Plugin {
Property<ModelidData>(_T("modelid"), &DeviceInfo::get_modelid, nullptr, this);
Property<MakeData>(_T("make"), &DeviceInfo::get_make, nullptr, this);
Property<ModelnameData>(_T("modelname"), &DeviceInfo::get_modelname, nullptr, this);
Property<BrandnameData>(_T("brandname"), &DeviceInfo::get_brandname, nullptr, this);
Property<DevicetypeData>(_T("devicetype"), &DeviceInfo::get_devicetype, nullptr, this);
Property<DistributoridData>(_T("distributorid"), &DeviceInfo::get_distributorid, nullptr, this);
Property<SupportedaudioportsData>(_T("supportedaudioports"), &DeviceInfo::get_supportedaudioports, nullptr, this);
Expand All @@ -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"));
Expand Down Expand Up @@ -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
Expand Down
14 changes: 14 additions & 0 deletions DeviceInfo/Implementation/DeviceInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions DeviceInfo/Implementation/DeviceInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
}
}

0 comments on commit c821a16

Please sign in to comment.