Skip to content

Commit c0fe64c

Browse files
authored
Merge pull request rdkcentral#5910 from agampa263/sprint/24Q4
SERXIONE-6196: DeviceIdentification activation fail
2 parents 19a898b + affa9d5 commit c0fe64c

File tree

3 files changed

+58
-0
lines changed

3 files changed

+58
-0
lines changed

DeviceIdentification/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,4 +126,5 @@ target_include_directories(${MODULE_NAME}
126126
install(TARGETS ${MODULE_NAME}
127127
DESTINATION lib/${STORAGE_DIRECTORY}/plugins)
128128

129+
target_include_directories(${MODULE_NAME} PRIVATE ../helpers)
129130
write_config(${PLUGIN_NAME})

DeviceIdentification/DeviceIdentification.cpp

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,14 @@
2020
#include "DeviceIdentification.h"
2121
#include "IdentityProvider.h"
2222
#include <interfaces/IConfiguration.h>
23+
#include "tracing/Logging.h"
24+
#include "UtilsJsonRpc.h"
25+
#include "UtilsController.h"
26+
#ifdef USE_THUNDER_R4
27+
#include <interfaces/IDeviceInfo.h>
28+
#else
29+
#include <interfaces/IDeviceInfo2.h>
30+
#endif /* USE_THUNDER_R4 */
2331

2432
#define API_VERSION_NUMBER_MAJOR 1
2533
#define API_VERSION_NUMBER_MINOR 0
@@ -154,6 +162,7 @@ namespace Plugin {
154162
string DeviceIdentification::GetDeviceId() const
155163
{
156164
string result;
165+
string serial;
157166
#ifndef DISABLE_DEVICEID_CONTROL
158167
ASSERT(_identifier != nullptr);
159168

@@ -165,6 +174,24 @@ namespace Plugin {
165174
if (myBuffer[0] != 0) {
166175
result = Core::SystemInfo::Instance().Id(myBuffer, ~0);
167176
}
177+
else
178+
{
179+
serial = RetrieveSerialNumberThroughCOMRPC();
180+
181+
if (!serial.empty()) {
182+
uint8_t ret = serial.length();
183+
184+
if (ret > (sizeof(myBuffer) - 1)){
185+
ret = sizeof(myBuffer) - 1;
186+
}
187+
myBuffer[0] = ret;
188+
::memcpy(&(myBuffer[1]), serial.c_str(), ret);
189+
190+
if(myBuffer[0] != 0){
191+
result = Core::SystemInfo::Instance().Id(myBuffer, ~0);
192+
}
193+
}
194+
}
168195
}
169196
#else
170197
// extract DeviceId set by Thunder
@@ -185,6 +212,35 @@ namespace Plugin {
185212
return result;
186213
}
187214

215+
string DeviceIdentification::RetrieveSerialNumberThroughCOMRPC() const
216+
{
217+
std::string Number;
218+
if (_service)
219+
{
220+
PluginHost::IShell::state state;
221+
222+
if ((Utils::getServiceState(_service, "DeviceInfo", state) == Core::ERROR_NONE) && (state != PluginHost::IShell::state::ACTIVATED))
223+
{
224+
Utils::activatePlugin(_service, "DeviceInfo");
225+
}
226+
if ((Utils::getServiceState(_service, "DeviceInfo", state) == Core::ERROR_NONE) && (state == PluginHost::IShell::state::ACTIVATED))
227+
{
228+
auto _remoteDeviceInfoObject = _service->QueryInterfaceByCallsign<Exchange::IDeviceInfo>("DeviceInfo");
229+
if(_remoteDeviceInfoObject)
230+
{
231+
_remoteDeviceInfoObject->SerialNumber(Number);
232+
_remoteDeviceInfoObject->Release();
233+
}
234+
}
235+
else
236+
{
237+
LOGERR("Failed to create DeviceInfo object\n");
238+
}
239+
}
240+
return Number;
241+
}
242+
243+
188244
void DeviceIdentification::Info(JsonData::DeviceIdentification::DeviceidentificationData& deviceInfo) const
189245
{
190246
deviceInfo.Firmwareversion = _identifier->FirmwareVersion();

DeviceIdentification/DeviceIdentification.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ namespace Plugin {
9494
uint32_t get_deviceidentification(JsonData::DeviceIdentification::DeviceidentificationData& response) const;
9595

9696
string GetDeviceId() const;
97+
string RetrieveSerialNumberThroughCOMRPC() const;
9798
void Info(JsonData::DeviceIdentification::DeviceidentificationData&) const;
9899

99100
void Deactivated(RPC::IRemoteConnection* connection);

0 commit comments

Comments
 (0)