20
20
#include " DeviceIdentification.h"
21
21
#include " IdentityProvider.h"
22
22
#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 */
23
31
24
32
#define API_VERSION_NUMBER_MAJOR 1
25
33
#define API_VERSION_NUMBER_MINOR 0
26
- #define API_VERSION_NUMBER_PATCH 6
34
+ #define API_VERSION_NUMBER_PATCH 7
27
35
28
36
namespace WPEFramework {
29
37
namespace {
@@ -154,6 +162,7 @@ namespace Plugin {
154
162
string DeviceIdentification::GetDeviceId () const
155
163
{
156
164
string result;
165
+ string serial;
157
166
#ifndef DISABLE_DEVICEID_CONTROL
158
167
ASSERT (_identifier != nullptr );
159
168
@@ -165,6 +174,25 @@ namespace Plugin {
165
174
if (myBuffer[0 ] != 0 ) {
166
175
result = Core::SystemInfo::Instance ().Id (myBuffer, ~0 );
167
176
}
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
+ }
195
+
168
196
}
169
197
#else
170
198
// extract DeviceId set by Thunder
@@ -184,7 +212,34 @@ namespace Plugin {
184
212
#endif
185
213
return result;
186
214
}
187
-
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
+
230
+ if (_remoteDeviceInfoObject)
231
+ {
232
+ _remoteDeviceInfoObject->SerialNumber (Number);
233
+ _remoteDeviceInfoObject->Release ();
234
+ }
235
+ }
236
+ else
237
+ {
238
+ LOGERR (" Failed to create DeviceInfo object\n " );
239
+ }
240
+ }
241
+ return Number;
242
+ }
188
243
void DeviceIdentification::Info (JsonData::DeviceIdentification::DeviceidentificationData& deviceInfo) const
189
244
{
190
245
deviceInfo.Firmwareversion = _identifier->FirmwareVersion ();
0 commit comments