Skip to content

Commit c821a16

Browse files
authored
Merge pull request rdkcentral#5918 from rwarier/sprint/24Q4
RDKTV-34551 - Added DeviceInfo brandname API
2 parents 09e0d2a + d1119b9 commit c821a16

File tree

7 files changed

+63
-3
lines changed

7 files changed

+63
-3
lines changed

DeviceInfo/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ All notable changes to this RDK Service will be documented in this file.
1515
* 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.
1616

1717
* For more details, refer to [versioning](https://github.com/rdkcentral/rdkservices#versioning) section under Main README.
18+
## [1.1.0] - 2024-11-26
19+
### Added
20+
- Added API to get Device brand
21+
1822
## [1.0.15] - 2024-09-16
1923
### Changed
2024
- DELIA-65827: Return Empty SerialNumber in curl for "method": "DeviceInfo.1.systeminfo"

DeviceInfo/DeviceInfo.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
#include "DeviceInfo.h"
2121

2222
#define API_VERSION_NUMBER_MAJOR 1
23-
#define API_VERSION_NUMBER_MINOR 0
24-
#define API_VERSION_NUMBER_PATCH 14
23+
#define API_VERSION_NUMBER_MINOR 1
24+
#define API_VERSION_NUMBER_PATCH 0
2525

2626
namespace WPEFramework {
2727
namespace {

DeviceInfo/DeviceInfo.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ namespace Plugin {
117117
uint32_t get_modelid(JsonData::DeviceInfo::ModelidData& response) const;
118118
uint32_t get_make(JsonData::DeviceInfo::MakeData& response) const;
119119
uint32_t get_modelname(JsonData::DeviceInfo::ModelnameData& response) const;
120+
uint32_t get_brandname(JsonData::DeviceInfo::BrandnameData& response) const;
120121
uint32_t get_devicetype(JsonData::DeviceInfo::DevicetypeData& response) const;
121122
uint32_t get_distributorid(JsonData::DeviceInfo::DistributoridData& response) const;
122123
uint32_t get_supportedaudioports(JsonData::DeviceInfo::SupportedaudioportsData& response) const;

DeviceInfo/DeviceInfo.json

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,28 @@
509509
}
510510
]
511511
},
512+
"brandname": {
513+
"summary": "Device brand name",
514+
"readonly": true,
515+
"params": {
516+
"type": "object",
517+
"properties": {
518+
"brandname": {
519+
"type": "string",
520+
"example": "Comcast"
521+
}
522+
},
523+
"required": [
524+
"brand"
525+
]
526+
},
527+
"errors": [
528+
{
529+
"description": "General error",
530+
"$ref": "#/common/errors/general"
531+
}
532+
]
533+
},
512534
"make": {
513535
"summary": "Device manufacturer",
514536
"readonly": true,
@@ -867,4 +889,4 @@
867889
]
868890
}
869891
}
870-
}
892+
}

DeviceInfo/DeviceInfoJsonRpc.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ namespace Plugin {
3939
Property<ModelidData>(_T("modelid"), &DeviceInfo::get_modelid, nullptr, this);
4040
Property<MakeData>(_T("make"), &DeviceInfo::get_make, nullptr, this);
4141
Property<ModelnameData>(_T("modelname"), &DeviceInfo::get_modelname, nullptr, this);
42+
Property<BrandnameData>(_T("brandname"), &DeviceInfo::get_brandname, nullptr, this);
4243
Property<DevicetypeData>(_T("devicetype"), &DeviceInfo::get_devicetype, nullptr, this);
4344
Property<DistributoridData>(_T("distributorid"), &DeviceInfo::get_distributorid, nullptr, this);
4445
Property<SupportedaudioportsData>(_T("supportedaudioports"), &DeviceInfo::get_supportedaudioports, nullptr, this);
@@ -62,6 +63,7 @@ namespace Plugin {
6263
Unregister(_T("modelid"));
6364
Unregister(_T("make"));
6465
Unregister(_T("modelname"));
66+
Unregister(_T("brandname"));
6567
Unregister(_T("devicetype"));
6668
Unregister(_T("distributorid"));
6769
Unregister(_T("supportedaudioports"));
@@ -221,6 +223,22 @@ namespace Plugin {
221223
return result;
222224
}
223225

226+
// Property: brandname - device brand name
227+
// Return codes:
228+
// - ERROR_NONE: Success
229+
// - ERROR_GENERAL: General error
230+
uint32_t DeviceInfo::get_brandname(BrandnameData& response) const
231+
{
232+
string brand;
233+
234+
auto result = _deviceInfo->Brand(brand);
235+
if (result == Core::ERROR_NONE) {
236+
response.Brand = brand;
237+
}
238+
239+
return result;
240+
}
241+
224242
// Property: devicetype - Device type
225243
// Return codes:
226244
// - ERROR_NONE: Success

DeviceInfo/Implementation/DeviceInfo.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,20 @@ namespace Plugin {
116116
std::regex("^FRIENDLY_ID(?:\\s*)=(?:\\s*)(?:\"{0,1})([^\"\\n]+)(?:\"{0,1})(?:\\s*)$"), model);
117117
}
118118

119+
uint32_t DeviceInfoImplementation::Brand(string& brand) const
120+
{
121+
brand = "Unknown";
122+
return
123+
#ifdef USE_SERIALIZED_MANUFACTURER_NAME
124+
((Core::ERROR_NONE == GetFileRegex(_T("/tmp/.manufacturer"), std::regex("^([^\\n]+)$"), brand)) ||
125+
(GetMFRData(mfrSERIALIZED_TYPE_MANUFACTURER, brand) == Core::ERROR_NONE))
126+
? Core::ERROR_NONE
127+
:
128+
#endif
129+
GetFileRegex(_T("/etc/device.properties"),
130+
std::regex("^BRAND_NAME(?:\\s*)=(?:\\s*)(?:\"{0,1})([^\"\\n]+)(?:\"{0,1})(?:\\s*)$"), brand);
131+
}
132+
119133
uint32_t DeviceInfoImplementation::DeviceType(string& deviceType) const
120134
{
121135
#ifndef ENABLE_COMMUNITY_DEVICE_TYPE

DeviceInfo/Implementation/DeviceInfo.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ namespace Plugin {
2929
uint32_t Model(string& model) const override;
3030
uint32_t DeviceType(string& deviceType) const override;
3131
uint32_t DistributorId(string& distributorId) const override;
32+
uint32_t Brand(string& brand) const override;
3233
};
3334
}
3435
}

0 commit comments

Comments
 (0)