Fix System issues
[platform/framework/native/appfw.git] / src / system / FSys_SystemInfoImpl.cpp
1 //
2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 //     http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17
18 /**
19  * @file                FSys_SystemInfoImpl.cpp
20  * @brief               This is the implementation file for _SystemInfoImpl class.
21  */
22 #include <unique_ptr.h>
23
24 #include <FBaseBoolean.h>
25 #include <FBaseInteger.h>
26 #include <FBaseColHashMap.h>
27
28 #include <FBase_NativeError.h>
29 #include <FIo_RegistryImpl.h>
30 #include <FSys_SystemInfoImpl.h>
31 #include <FIo_AppServiceIpcMessages.h>
32 #include <FIo_IpcClient.h>
33 #include <FSys_Types.h>
34
35 using namespace std;
36
37 using namespace Tizen::Base;
38 using namespace Tizen::Base::Collection;
39 using namespace Tizen::Io;
40
41 namespace Tizen { namespace System
42 {
43
44 static const wchar_t* _REGISTRY_PATH = L"/tmp/osp/system_info_cache.ini";
45 static const wchar_t* _SYSTEM_INFO_SESSION = L"SystemInformation";
46
47 //Bluetooth
48 static const wchar_t* _BLUETOOTH = L"http://tizen.org/feature/network.bluetooth";
49 static const wchar_t* _BLUETOOTH_SUPPORTED = L"BluetoothSupported";
50
51 //Camera
52
53 static const wchar_t* _CAMERA_FRONT = L"http://tizen.org/feature/camera.front";
54
55 static const wchar_t* _CAMERA_BACK = L"http://tizen.org/feature/camera.back";
56
57 static const wchar_t* _CAMERA_COUNT = L"CameraCount";
58
59 //DUID
60 static const wchar_t* _DUID = L"http://tizen.org/system/duid";
61 static const wchar_t* _DEVICE_ID = L"DUID";
62
63 //FM Radio
64 static const wchar_t* _FMRADIO = L"http://tizen.org/feature/fmradio";
65 static const wchar_t* _FM_RADIO_SUPPORTED = L"FmRadioSupported";
66
67 //Keyboard
68 static const wchar_t* _KEYBOARD_TYPE = L"KeyboardType";
69 static const wchar_t* _INPUT_KEYBOARD_LAYOUT = L"http://tizen.org/feature/input.keyboard.layout";
70
71 //Location
72 static const wchar_t* _GPS_SUPPORTED = L"GPSSupported";
73 static const wchar_t* _LOCATION_GPS = L"http://tizen.org/feature/location.gps";
74 static const wchar_t* _WPS_SUPPORTED = L"WPSSupported";
75 static const wchar_t* _LOCATION_WPS = L"http://tizen.org/feature/location.wps";
76
77 //Model name
78 static const wchar_t* _MODELNAME = L"http://tizen.org/system/model_name";
79 static const wchar_t* _MODEL_NAME = L"ModelName";
80
81 //Multi point
82 static const wchar_t* _MULTIPOINTTOUCH_POINTCOUNT = L"http://tizen.org/feature/multi_point_touch.point_count";
83 static const wchar_t* _MULTIPOINT_TOUCH_COUNT = L"MultiPointTouchCount";
84
85 //NFC
86 static const wchar_t* _NETWORK_NFC = L"http://tizen.org/feature/network.nfc";
87 static const wchar_t* _NFC_SUPPORTED = L"NFCSupported";
88
89 //Opengles
90 static const wchar_t* _OPENGLES_VERSION_1_1 = L"http://tizen.org/feature/opengles.version.1_1";
91 static const wchar_t* _OPENGLES_VERSION_2_0 = L"http://tizen.org/feature/opengles.version.2_0";
92 static const wchar_t* _OPENGL_ES_VERSION = L"OpenGLESVersion";
93
94 // Screen
95 static const wchar_t* _SCREEN_BPP = L"http://tizen.org/feature/screen.bpp";
96 static const wchar_t* _SCREEN_BITS_PER_PIXEL = L"ScreenBitsPerPixel";
97 static const wchar_t* _SCREEN_DPI = L"http://tizen.org/feature/screen.dpi";
98 static const wchar_t* _SCREEN_HEIGHT = L"http://tizen.org/feature/screen.height";
99 static const wchar_t* _SCREENHEIGHT = L"ScreenHeight";
100 static const wchar_t* _SCREEN_WIDTH = L"http://tizen.org/feature/screen.width";
101 static const wchar_t* _SCREENWIDTH = L"ScreenWidth";
102 static const wchar_t* _SCREENDPI = L"ScreenDPI";
103
104 //HDMI RCA
105 static const wchar_t* _SCREEN_OUTPUT_RCA = L"http://tizen.org/feature/screen.output.rca";
106 static const wchar_t* _TV_OUT_SUPPORTED = L"TvOutSupported";
107
108 //Sound
109 static const wchar_t* _SOUND_MEDIA_VOLUME_MAX = L"http://tizen.org/system/sound.media.volume.resolution.max";
110 static const wchar_t* _MAX_MEDIA_SOUND_VOLUME = L"MaxMediaSoundVolume";
111 static const wchar_t* _SOUND_NOTIFICATION_VOLUME_MAX = L"http://tizen.org/system/sound.notification.volume.resolution.max";
112 static const wchar_t* _MAX_NOTIFICATION_SOUND_VOLUME = L"MaxNotificationSoundVolume";
113 static const wchar_t* _SOUND_RINGTONE_VOLUME_MAX = L"http://tizen.org/system/sound.ringtone.volume.resolution.max";
114 static const wchar_t* _MAX_RINGTONE_SOUND_VOLUME = L"MaxRingtoneSoundVolume";
115 static const wchar_t* _SOUND_SYSTEM_VOLUME_MAX = L"http://tizen.org/system/sound.system.volume.resolution.max";
116 static const wchar_t* _MAX_SYSTEM_SOUND_VOLUME = L"MaxSystemSoundVolume";
117
118 //Telephony
119 static const wchar_t* _TELEPHONY = L"http://tizen.org/feature/network.telephony";
120 static const wchar_t* _TELEPHONY_SERVICE_GSM = L"http://tizen.org/feature/network.telephony.service.gsm";
121 static const wchar_t* _TELEPHONY_SERVICE_GPRS = L"http://tizen.org/feature/network.telephony.service.gprs";
122 static const wchar_t* _TELEPHONY_SERVICE_EDGE = L"http://tizen.org/feature/network.telephony.service.edge";
123 static const wchar_t* _TELEPHONY_SERVICE_UMTS = L"http://tizen.org/feature/network.telephony.service.umts";
124 static const wchar_t* _TELEPHONY_SERVICE_HSDPA = L"http://tizen.org/feature/network.telephony.service.hsdpa";
125 static const wchar_t* _TELEPHONY_SERVICE_HSUPA = L"http://tizen.org/feature/network.telephony.service.hsupa";
126 static const wchar_t* _TELEPHONY_SERVICE_HSPA = L"http://tizen.org/feature/network.telephony.service.hspa";
127 static const wchar_t* _TELEPHONY_SERVICE_LTE = L"http://tizen.org/feature/network.telephony.service.lte";
128 static const wchar_t* _TELEPHONY_SERVICE_CDMA = L"http://tizen.org/feature/network.telephony.service.cdma";
129 static const wchar_t* _NETWORK_TYPE = L"NetworkType";
130 static const wchar_t* _NETWORK_EMERGENCY = L"Emergency";
131 static const wchar_t* _NETWORK_NO_SERVICE = L"NoService";
132
133
134 //WIFI
135 static const wchar_t* _WIFI = L"http://tizen.org/feature/network.wifi";
136 static const wchar_t* _WIFI_SUPPORTED = L"WiFiSupported";
137 static const wchar_t* _WIFI_DIRECT = L"http://tizen.org/feature/network.wifi.direct";
138 static const wchar_t* _WIFI_DIRECT_SUPPORTED = L"WiFiDirectSupported";
139
140 //Version
141 static const wchar_t* _PLATFORM_VERSION = L"http://tizen.org/feature/platform.version";
142 static const wchar_t* _PLATFORM_NATIVE_API_VERSION = L"http://tizen.org/feature/platform.native.api.version";
143 static const wchar_t* _PLATFORM_WEB_API_VERSION = L"http://tizen.org/feature/platform.web.api.version";
144 static const wchar_t* _BUILD_STRING = L"http://tizen.org/system/build.string";
145
146 static const wchar_t* _WAC_VERSION = L"WACVersion";
147 static const wchar_t* _SUPPORTED = L"Supported";
148 static const wchar_t* _UNSUPPORTED = L"Unsupported";
149
150 static bool firstRequest = false;
151 static HashMap integerList;
152 static HashMap boolList;
153 static HashMap stringList;
154
155 void
156 PrepareCache(void)
157 {
158         if(firstRequest == false)
159         {
160                 integerList.Construct();
161                 boolList.Construct();
162                 stringList.Construct();
163                 firstRequest = true;
164         }
165 }
166
167 String
168 _SystemInfoImpl::ConvertToTizen(const String& key)
169 {
170         String code(key);
171
172         if(code == _DEVICE_ID)
173         {
174                 code = _DUID;
175         }
176         else if(code == _MODEL_NAME)
177         {
178                 code = _MODELNAME;
179         }
180         else if(code == _KEYBOARD_TYPE)
181         {
182                 code == _INPUT_KEYBOARD_LAYOUT;
183         }
184         else if(code == _SCREEN_BITS_PER_PIXEL)
185         {
186                 code = _SCREEN_BPP;
187         }
188         else if(code == _SCREENHEIGHT)
189         {
190                 code = _SCREEN_HEIGHT;
191         }
192         else if(code == _SCREENWIDTH)
193         {
194                 code = _SCREEN_WIDTH;
195         }
196         else if(code == _SCREENDPI)
197         {
198                 code = _SCREEN_DPI;
199         }
200         else if(code == _MAX_SYSTEM_SOUND_VOLUME)
201         {
202                 code = _SOUND_SYSTEM_VOLUME_MAX;
203         }
204         else if(code == _MAX_MEDIA_SOUND_VOLUME)
205         {
206                 code = _SOUND_MEDIA_VOLUME_MAX;
207         }
208         else if(code == _MAX_RINGTONE_SOUND_VOLUME)
209         {
210                 code = _SOUND_RINGTONE_VOLUME_MAX;
211         }
212         else if(code == _MAX_NOTIFICATION_SOUND_VOLUME)
213         {
214                 code = _SOUND_NOTIFICATION_VOLUME_MAX;
215         }
216         else if(code == _MULTIPOINT_TOUCH_COUNT)
217         {
218                 code = _MULTIPOINTTOUCH_POINTCOUNT;
219         }
220         else if(code == _BLUETOOTH_SUPPORTED)
221         {
222                 code = _BLUETOOTH;
223         }
224         else if(code == _GPS_SUPPORTED)
225         {
226                 code = _LOCATION_GPS;
227         }
228         else if(code == _WPS_SUPPORTED)
229         {
230                 code = _LOCATION_WPS;
231         }
232         else if(code == _WIFI_SUPPORTED)
233         {
234                 code = _WIFI;
235         }
236         else if(code == _WIFI_DIRECT_SUPPORTED)
237         {
238                 code = _WIFI_DIRECT;
239         }
240         else if(code == _FM_RADIO_SUPPORTED)
241         {
242                 code = _FMRADIO;
243         }
244         else if(code == _TV_OUT_SUPPORTED)
245         {
246                 code = _SCREEN_OUTPUT_RCA;
247         }
248         else if(code == _NFC_SUPPORTED)
249         {
250                 code = _NETWORK_NFC;
251         }
252         return code;
253 }
254
255 result
256 _SystemInfoImpl::GetSysInfo(const String& key, String& value)
257 {
258         result r = E_OBJ_NOT_FOUND;
259         String tizenKey = ConvertToTizen(key);
260
261         if (firstRequest == false)
262         {
263                 PrepareCache();
264         }
265
266         String* pValue = (String*)stringList.GetValue(key);
267
268         if(pValue != null)
269         {
270                 value = *pValue;
271         }
272
273         if (key == _NETWORK_TYPE) //Compatibility
274         {
275                 bool supported = false;
276                 GetSysInfo(_TELEPHONY, supported);
277                 if(supported == false)
278                 {
279                         value = _NETWORK_EMERGENCY;
280                 }
281
282                 bool supportedGsm = false;
283                 bool supportedGprs = false;
284                 bool supportedEdge = false;
285                 bool supportedUmts = false;
286                 bool supportedHsdpa = false;
287                 bool supportedHsupa = false;
288                 bool supportedHspa = false;
289                 bool supportedLte = false;
290                 bool supportedCdma = false;
291
292                 GetSysInfo(_TELEPHONY_SERVICE_GSM, supportedGsm);
293                 GetSysInfo(_TELEPHONY_SERVICE_GPRS, supportedGprs);
294                 GetSysInfo(_TELEPHONY_SERVICE_EDGE, supportedEdge);
295                 GetSysInfo(_TELEPHONY_SERVICE_UMTS, supportedUmts);
296                 GetSysInfo(_TELEPHONY_SERVICE_HSDPA, supportedHsdpa);
297                 GetSysInfo(_TELEPHONY_SERVICE_HSUPA, supportedHsupa);
298                 GetSysInfo(_TELEPHONY_SERVICE_HSPA, supportedHspa);
299                 GetSysInfo(_TELEPHONY_SERVICE_LTE, supportedLte);
300                 GetSysInfo(_TELEPHONY_SERVICE_CDMA, supportedCdma);
301
302                 value.Clear();
303                 if(supportedGsm == false && supportedGprs == false
304                         && supportedEdge == false && supportedUmts == false
305                         && supportedHsdpa == false && supportedHsupa == false
306                         && supportedHspa == false && supportedLte == false
307                         && supportedCdma == false)
308                 {
309                         value = _NETWORK_NO_SERVICE;
310                 }
311                 else if(supportedGsm == true)
312                 {
313                         value.Append(L"GSM");
314                 }
315                 else if(supportedGprs == true)
316                 {
317                         if(value.GetLength() > 0)
318                                 value.Append(L" | ");
319
320                         value.Append(L"GPRS");
321                 }
322                 else if(supportedEdge == true)
323                 {
324                         if(value.GetLength() > 0)
325                                 value.Append(L" | ");
326
327                         value.Append(L"EDGE");
328                 }
329                 else if(supportedUmts == true)
330                 {
331                         if(value.GetLength() > 0)
332                                 value.Append(L" | ");
333
334                         value.Append(L"UMTS");
335                 }
336                 else if(supportedHsdpa == true)
337                 {
338                         if(value.GetLength() > 0)
339                                 value.Append(L" | ");
340
341                         value.Append(L"HSDPA");
342                 }
343                 else if(supportedHsupa == true)
344                 {
345                         if(value.GetLength() > 0)
346                                 value.Append(L" | ");
347
348                         value.Append(L"HSUPA");
349                 }
350                 else if(supportedHspa == true)
351                 {
352                         if(value.GetLength() > 0)
353                                 value.Append(L" | ");
354
355                         value.Append(L"HSPA");
356                 }
357                 else if(supportedLte == true)
358                 {
359                         if(value.GetLength() > 0)
360                                 value.Append(L" | ");
361
362                         value.Append(L"LTE");
363                 }
364                 else if(supportedCdma == true)
365                 {
366                         if(value.GetLength() > 0)
367                                 value.Append(L" | ");
368
369                         value.Append(L"CDMA");
370                 }
371
372         }
373         else if (key == _OPENGL_ES_VERSION)
374         {
375                 bool opengles_11 = false;
376                 bool opengles_20 = false;
377
378                 GetSysInfo(_OPENGLES_VERSION_1_1, opengles_11);
379                 GetSysInfo(_OPENGLES_VERSION_2_0, opengles_20);
380
381                 if(opengles_11 == true)
382                 {
383                         value.Append(L"1.1");
384                 }
385                 else if(opengles_20 == true)
386                 {
387                         if(value.GetLength() > 0)
388                                 value.Append(L" | ");
389
390                         value.Append(L"2.0");
391                 }
392         }
393         else if(key == _BLUETOOTH_SUPPORTED)
394         {
395                 bool supported = false;
396                 GetSysInfo(_BLUETOOTH, supported);
397                 if(supported == false)
398                         value = _SUPPORTED;
399                 else
400                         value = _UNSUPPORTED;
401         }
402         else if (key == _GPS_SUPPORTED)
403         {
404                 bool supported = false;
405                 GetSysInfo(_LOCATION_GPS, supported);
406                 if(supported == false)
407                         value = _SUPPORTED;
408                 else
409                         value = _UNSUPPORTED;
410         }
411         else if (key == _WIFI_SUPPORTED)
412         {
413                 bool supported = false;
414                 GetSysInfo(_WIFI, supported);
415                 if(supported == false)
416                         value = _SUPPORTED;
417                 else
418                         value = _UNSUPPORTED;
419         }
420         else if (key == _WAC_VERSION)
421         {
422                 value.Clear();
423                 r = E_SUCCESS;
424         }
425         else if (key == _PLATFORM_NATIVE_API_VERSION || key == _PLATFORM_WEB_API_VERSION || key == _PLATFORM_VERSION || key == _BUILD_STRING)
426         {
427                 r = E_OBJ_NOT_FOUND;
428         }
429         else
430         {
431                 r = GetFromRegistry(tizenKey, value);
432                 SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_OBJ_NOT_FOUND, "It is failed to get the key[%ls]", tizenKey.GetPointer());
433                 r = E_SUCCESS;
434         }
435         if( r == E_SUCCESS)
436         {
437                 stringList.Add(new String(key), new String(value));
438         }
439         return r;
440 }
441
442
443 result
444 _SystemInfoImpl::GetSysInfo(const String& key, int& value)
445 {
446         result r = E_SUCCESS;
447         String tizenKey = ConvertToTizen(key);
448
449         if (firstRequest == false)
450         {
451                 PrepareCache();
452         }
453
454         Integer* pValue = (Integer*)integerList.GetValue(key);
455
456         if(pValue != null)
457         {
458                 value = pValue->value;
459         }
460
461         if (key == _CAMERA_COUNT)
462         {
463                 bool supported = false;
464                 int cameraCount = 0;
465
466                 GetSysInfo(_CAMERA_FRONT, supported);
467                 if(supported == true)
468                         cameraCount++;
469
470                 GetSysInfo(_CAMERA_BACK, supported);
471                 if(supported == true)
472                         cameraCount++;
473
474                 value = cameraCount;
475         }       
476         else
477         {
478                 r = GetFromRegistry(tizenKey, value);
479                 SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_OBJ_NOT_FOUND, "It is failed to get the key[%ls]", tizenKey.GetPointer());
480         }
481
482         if(r == E_SUCCESS)
483         {
484                 integerList.Add(new String(key), new Integer(value));
485         }
486         
487         return r;
488 }
489
490
491 result
492 _SystemInfoImpl::GetSysInfo(const String& key, long long& value)
493 {
494         return E_OBJ_NOT_FOUND;
495 }
496
497
498 result
499 _SystemInfoImpl::GetSysInfo(const String& key, double& value)
500 {
501         return E_OBJ_NOT_FOUND;
502 }
503
504
505 result
506 _SystemInfoImpl::GetSysInfo(const String& key, bool& value)
507 {
508         result r = E_SUCCESS;
509         String tizenKey = ConvertToTizen(key);
510
511         if (firstRequest == false)
512         {
513                 PrepareCache();
514         }
515
516         Boolean* pValue = (Boolean*)boolList.GetValue(key);
517
518         if(pValue != null)
519         {
520                 value = pValue->value;
521         }
522
523
524         r = GetFromRegistry(tizenKey, value);
525         SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_OBJ_NOT_FOUND, "It is failed to get the key[%ls]", tizenKey.GetPointer());
526
527         if(r == E_SUCCESS)
528         {
529                 boolList.Add(new String(key), new Boolean(value));
530         }
531
532         return r;
533 }
534
535
536 result
537 _SystemInfoImpl::GetSysInfo(const String& key, UuId& value)
538 {
539         return E_OBJ_NOT_FOUND;
540 }
541
542
543 Collection::IList*
544 _SystemInfoImpl::GetSysInfoValuesN(const String& key, SystemInfoValueType type)
545 {       
546         SetLastResult(E_OBJ_NOT_FOUND);
547         return null;
548 }
549
550 result
551 _SystemInfoImpl::GetPlatformVersion(String& platformVersion)
552 {
553         result r = E_SUCCESS;
554         String tizenKey(_PLATFORM_VERSION);
555
556         r = GetFromRegistry(tizenKey, platformVersion);
557         SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to get the key[%ls]", tizenKey.GetPointer());
558         return r;
559 }
560
561 result
562 _SystemInfoImpl::GetBuildInfo(String& buildInfo)
563 {
564         result r = E_SUCCESS;
565         String tizenKey(_BUILD_STRING);
566
567         r = GetFromRegistry(tizenKey, buildInfo);
568         SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to get the key[%ls]", tizenKey.GetPointer());
569         return r;
570 }
571
572 result
573 _SystemInfoImpl::GetNativeApiVersion(String& nativeApiVersion)
574 {
575         result r = E_SUCCESS;
576         String tizenKey(_PLATFORM_NATIVE_API_VERSION);
577
578         r = GetFromRegistry(tizenKey, nativeApiVersion);
579         SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to get the key[%ls]", tizenKey.GetPointer());
580         return r;
581 }
582
583 result
584 _SystemInfoImpl::GetWebApiVersion(String& webApiVersion)
585 {
586         result r = E_SUCCESS;
587         String tizenKey(_PLATFORM_WEB_API_VERSION);
588
589         r = GetFromRegistry(tizenKey, webApiVersion);
590         SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to get the key[%ls]", tizenKey.GetPointer());
591         return r;
592 }
593
594 result
595 _SystemInfoImpl::GetImei(String& imei)
596 {
597         result r = E_SUCCESS;
598
599         ArrayList requestMessage;
600         ArrayList responseMessage;
601
602         unique_ptr<_IpcClient> pIpcClient (new (std::nothrow) _IpcClient());
603         SysTryReturn(NID_SYS, pIpcClient != null, E_OUT_OF_MEMORY, r, "It is failed to create IPC instance.");
604
605         r = pIpcClient->Construct(_COMMUNICATION_DISPATCHER_IPC_ID);
606         SysTryReturn(NID_SYS, r == E_SUCCESS, E_SYSTEM, r, "It is failed to create IpcClient. [%s]", GetErrorMessage(r));
607
608         requestMessage.Construct();
609         responseMessage.Construct();
610
611         String serviceId(_SYSTEM_SERVICE_ID);
612         String commandId(L"osp.system.command.get.imei.internal");
613
614         requestMessage.Add(serviceId);
615         requestMessage.Add(commandId);
616
617         unique_ptr<IoService_Request> pMsg(new (std::nothrow) IoService_Request(requestMessage, &responseMessage));
618         SysTryReturnResult(NID_SYS, pMsg != null, E_OUT_OF_MEMORY, "It is failed to create Ipc message");
619
620         r = pIpcClient->SendRequest(pMsg.get());
621         SysTryReturn(NID_SYS, r == E_SUCCESS, E_SYSTEM, r, "It is failed to send ipc message. [%s]", GetErrorMessage(r));
622
623         unique_ptr<String> pResult((String*)responseMessage.GetAt(_SYSTEM_RESPONSE_DATA));
624         unique_ptr<String> pImei((String*)responseMessage.GetAt(_SYSTEM_RESPONSE_DATA+1));
625
626         SysTryReturnResult(NID_SYS, pResult != null, E_SYSTEM, "It is failed to receive result on IPC response message.");
627         SysTryReturnResult(NID_SYS, pImei != null, E_SYSTEM, "It is failed to receive IMEI value on IPC response message.");
628
629         SysTryReturnResult(NID_SYS, *pResult != _SYSTEM_RESULT_PRIVILEGED, E_PRIVILEGE_DENIED, "It is failed to get privilege.");
630         SysTryReturnResult(NID_SYS, *pResult == _SYSTEM_RESULT_OK, E_SYSTEM, "It is failed to get IMEI value.");
631
632         imei = *pImei;
633         return r;
634 }
635
636 result
637 _SystemInfoImpl::GetFromRegistry(const String& key, String& value)
638 {
639         result r = E_SUCCESS;
640         _RegistryImpl _reg;
641         String valStr;
642
643         r = _reg.Construct(_REGISTRY_PATH, REG_OPEN_READ_ONLY, null);
644         SysTryReturnResult(NID_SYS, r == E_SUCCESS , r, " RegistryImpl construct It is failed");
645
646         r = _reg.GetValue(_SYSTEM_INFO_SESSION, key, valStr);
647         SysTryReturnResult(NID_SYS, r == E_SUCCESS , r, " Registry GetValue  It is failed");
648
649         if(valStr == L"true" || valStr == L"false")
650         {
651                 return E_OBJ_NOT_FOUND;
652         }
653         else
654         {
655                 value = valStr;
656         }
657
658         return E_SUCCESS;
659 }
660
661 result
662 _SystemInfoImpl::GetFromRegistry(const String& key, int& value)
663 {
664         result r = E_SUCCESS;
665         _RegistryImpl _reg;
666         String valStr;
667         r = _reg.Construct(_REGISTRY_PATH, REG_OPEN_READ_ONLY, null);
668         SysTryReturnResult(NID_SYS, r == E_SUCCESS, r, " RegistryImpl construct It is failed");
669
670         r = _reg.GetValue(_SYSTEM_INFO_SESSION, key, valStr);
671         SysTryReturnResult(NID_SYS, r == E_SUCCESS, r, " Registry GetValue  It is failed");
672         SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, " Registry GetValue  It is failed");
673         r = Integer::Parse(valStr, value);
674         SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_OBJ_NOT_FOUND, " Integer::Parse()  It is failed");
675         return E_SUCCESS;
676 }
677
678 result
679 _SystemInfoImpl::GetFromRegistry(const String& key, bool& value)
680 {
681         result r = E_SUCCESS;
682         _RegistryImpl _reg;
683         String valStr;
684         r = _reg.Construct(_REGISTRY_PATH, REG_OPEN_READ_ONLY, null);
685         SysTryReturnResult(NID_SYS, r == E_SUCCESS, r, " RegistryImpl construct It is failed");
686
687         r = _reg.GetValue(_SYSTEM_INFO_SESSION, key, valStr);
688         SysTryReturnResult(NID_SYS, r == E_SUCCESS, r, " Registry GetValue It is failed");
689         SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, " Registry GetValue  It is failed");
690         if(valStr == L"true")
691         {
692                 value = true;
693         }
694         else if(valStr == L"false")
695         {
696                 value = false;
697         }
698         else
699         {
700                 return E_OBJ_NOT_FOUND;
701         }
702         return E_SUCCESS;
703 }
704 _SystemInfoImpl*
705 _SystemInfoImpl::GetInstance(SystemInfo& systeminfo)
706 {
707         return systeminfo.__pSystemInfoImpl;
708 }
709 const _SystemInfoImpl*
710 _SystemInfoImpl::GetInstance(const SystemInfo& systeminfo)
711 {
712         return systeminfo.__pSystemInfoImpl;
713 }
714 } } // Tizen::System