2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 // Licensed under the Apache License, Version 2.0 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
8 // http://www.apache.org/licenses/LICENSE-2.0
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
18 * @file FSys_SystemInfoImpl.cpp
19 * @brief This is the implementation file for _SystemInfoImpl class.
21 #include <unique_ptr.h>
24 #include <system_info.h>
25 #include <ITapiModem.h>
27 #include <FBaseBoolean.h>
28 #include <FBaseInteger.h>
29 #include <FBaseColHashMap.h>
30 #include <FBaseUtilStringUtil.h>
31 #include <FIoRegistry.h>
33 #include <FBase_NativeError.h>
34 #include <FBase_StringConverter.h>
35 #include <FIo_RegistryImpl.h>
36 #include <FSys_SystemInfoImpl.h>
37 #include <FIo_AppServiceIpcMessages.h>
38 #include <FIo_IpcClient.h>
40 #include "FSys_Types.h"
41 #include "FSys_SystemClient.h"
42 #include "FSys_CommunicationDispatcherClient.h"
46 using namespace Tizen::Base;
47 using namespace Tizen::Base::Collection;
48 using namespace Tizen::Io;
49 using namespace Tizen::Base::Utility;
51 namespace Tizen { namespace System
54 static const wchar_t* _REGISTRY_PATH = L"/opt/usr/etc/system_info_cache.ini";
55 static const wchar_t* _SYSTEM_INFO_SESSION = L"SystemInformation";
58 static const wchar_t* _BLUETOOTH = L"http://tizen.org/feature/network.bluetooth";
59 static const wchar_t* _BLUETOOTH_SUPPORTED = L"BluetoothSupported";
63 static const wchar_t* _CAMERA_FRONT = L"http://tizen.org/feature/camera.front";
65 static const wchar_t* _CAMERA_BACK = L"http://tizen.org/feature/camera.back";
67 static const wchar_t* _CAMERA_COUNT = L"CameraCount";
70 static const wchar_t* _DUID = L"http://tizen.org/system/duid";
71 static const wchar_t* _DEVICE_ID = L"DUID";
74 static const wchar_t* _FMRADIO = L"http://tizen.org/feature/fmradio";
75 static const wchar_t* _FM_RADIO_SUPPORTED = L"FmRadioSupported";
78 static const wchar_t* _KEYBOARD_TYPE = L"KeyboardType";
79 static const wchar_t* _INPUT_KEYBOARD_LAYOUT = L"http://tizen.org/feature/input.keyboard.layout";
82 static const wchar_t* _GPS_SUPPORTED = L"GPSSupported";
83 static const wchar_t* _LOCATION_GPS = L"http://tizen.org/feature/location.gps";
84 static const wchar_t* _WPS_SUPPORTED = L"WPSSupported";
85 static const wchar_t* _LOCATION_WPS = L"http://tizen.org/feature/location.wps";
88 static const wchar_t* _MODELNAME = L"http://tizen.org/system/model_name";
89 static const wchar_t* _MODEL_NAME = L"ModelName";
92 static const wchar_t* _MULTIPOINTTOUCH_POINTCOUNT = L"http://tizen.org/feature/multi_point_touch.point_count";
93 static const wchar_t* _MULTIPOINT_TOUCH_COUNT = L"MultiPointTouchCount";
96 static const wchar_t* _NETWORK_NFC = L"http://tizen.org/feature/network.nfc";
97 static const wchar_t* _NFC_SUPPORTED = L"NFCSupported";
100 static const wchar_t* _OPENGLES_VERSION_1_1 = L"http://tizen.org/feature/opengles.version.1_1";
101 static const wchar_t* _OPENGLES_VERSION_2_0 = L"http://tizen.org/feature/opengles.version.2_0";
102 static const wchar_t* _OPENGL_ES_VERSION = L"OpenGLESVersion";
105 static const wchar_t* _SCREEN_BPP = L"http://tizen.org/feature/screen.bpp";
106 static const wchar_t* _SCREEN_BITS_PER_PIXEL = L"ScreenBitsPerPixel";
107 static const wchar_t* _SCREEN_DPI = L"http://tizen.org/feature/screen.dpi";
108 static const wchar_t* _SCREEN_HEIGHT = L"http://tizen.org/feature/screen.height";
109 static const wchar_t* _SCREENHEIGHT = L"ScreenHeight";
110 static const wchar_t* _SCREEN_WIDTH = L"http://tizen.org/feature/screen.width";
111 static const wchar_t* _SCREENWIDTH = L"ScreenWidth";
112 static const wchar_t* _SCREENDPI = L"ScreenDPI";
115 static const wchar_t* _SCREEN_OUTPUT_RCA = L"http://tizen.org/feature/screen.output.rca";
116 static const wchar_t* _TV_OUT_SUPPORTED = L"TvOutSupported";
119 static const wchar_t* _SOUND_MEDIA_VOLUME_MAX = L"http://tizen.org/system/sound.media.volume.resolution.max";
120 static const wchar_t* _MAX_MEDIA_SOUND_VOLUME = L"MaxMediaSoundVolume";
121 static const wchar_t* _SOUND_NOTIFICATION_VOLUME_MAX = L"http://tizen.org/system/sound.notification.volume.resolution.max";
122 static const wchar_t* _MAX_NOTIFICATION_SOUND_VOLUME = L"MaxNotificationSoundVolume";
123 static const wchar_t* _SOUND_RINGTONE_VOLUME_MAX = L"http://tizen.org/system/sound.ringtone.volume.resolution.max";
124 static const wchar_t* _MAX_RINGTONE_SOUND_VOLUME = L"MaxRingtoneSoundVolume";
125 static const wchar_t* _SOUND_SYSTEM_VOLUME_MAX = L"http://tizen.org/system/sound.system.volume.resolution.max";
126 static const wchar_t* _MAX_SYSTEM_SOUND_VOLUME = L"MaxSystemSoundVolume";
129 static const wchar_t* _TELEPHONY = L"http://tizen.org/feature/network.telephony";
130 static const wchar_t* _TELEPHONY_SERVICE_GSM = L"http://tizen.org/feature/network.telephony.service.gsm";
131 static const wchar_t* _TELEPHONY_SERVICE_GPRS = L"http://tizen.org/feature/network.telephony.service.gprs";
132 static const wchar_t* _TELEPHONY_SERVICE_EDGE = L"http://tizen.org/feature/network.telephony.service.edge";
133 static const wchar_t* _TELEPHONY_SERVICE_UMTS = L"http://tizen.org/feature/network.telephony.service.umts";
134 static const wchar_t* _TELEPHONY_SERVICE_HSDPA = L"http://tizen.org/feature/network.telephony.service.hsdpa";
135 static const wchar_t* _TELEPHONY_SERVICE_HSUPA = L"http://tizen.org/feature/network.telephony.service.hsupa";
136 static const wchar_t* _TELEPHONY_SERVICE_HSPA = L"http://tizen.org/feature/network.telephony.service.hspa";
137 static const wchar_t* _TELEPHONY_SERVICE_LTE = L"http://tizen.org/feature/network.telephony.service.lte";
138 static const wchar_t* _TELEPHONY_SERVICE_CDMA = L"http://tizen.org/feature/network.telephony.service.cdma";
139 static const wchar_t* _NETWORK_TYPE = L"NetworkType";
140 static const wchar_t* _NETWORK_EMERGENCY = L"Emergency";
141 static const wchar_t* _NETWORK_NO_SERVICE = L"NoService";
144 static const wchar_t* _WIFI = L"http://tizen.org/feature/network.wifi";
145 static const wchar_t* _WIFI_SUPPORTED = L"WiFiSupported";
146 static const wchar_t* _WIFI_DIRECT = L"http://tizen.org/feature/network.wifi.direct";
147 static const wchar_t* _WIFI_DIRECT_SUPPORTED = L"WiFiDirectSupported";
150 static const wchar_t* _PLATFORM_VERSION = L"http://tizen.org/feature/platform.version";
151 static const wchar_t* _PLATFORM_NATIVE_API_VERSION = L"http://tizen.org/feature/platform.native.api.version";
152 static const wchar_t* _PLATFORM_WEB_API_VERSION = L"http://tizen.org/feature/platform.web.api.version";
153 static const wchar_t* _BUILD_STRING = L"http://tizen.org/system/build.string";
155 static const wchar_t* _WAC_VERSION = L"WACVersion";
156 static const wchar_t* _SUPPORTED = L"Supported";
157 static const wchar_t* _UNSUPPORTED = L"Unsupported";
159 static bool firstRequest = false;
160 static HashMap integerList(SingleObjectDeleter);
161 static HashMap boolList(SingleObjectDeleter);
162 static HashMap stringList(SingleObjectDeleter);
167 if(firstRequest == false)
169 integerList.Construct();
170 boolList.Construct();
171 stringList.Construct();
177 _SystemInfoImpl::ConvertToTizen(const String& key)
181 if(code == _DEVICE_ID)
185 else if(code == _MODEL_NAME)
189 else if(code == _KEYBOARD_TYPE)
191 code = _INPUT_KEYBOARD_LAYOUT;
193 else if(code == _SCREEN_BITS_PER_PIXEL)
197 else if(code == _SCREENHEIGHT)
199 code = _SCREEN_HEIGHT;
201 else if(code == _SCREENWIDTH)
203 code = _SCREEN_WIDTH;
205 else if(code == _SCREENDPI)
209 else if(code == _MAX_SYSTEM_SOUND_VOLUME)
211 code = _SOUND_SYSTEM_VOLUME_MAX;
213 else if(code == _MAX_MEDIA_SOUND_VOLUME)
215 code = _SOUND_MEDIA_VOLUME_MAX;
217 else if(code == _MAX_RINGTONE_SOUND_VOLUME)
219 code = _SOUND_RINGTONE_VOLUME_MAX;
221 else if(code == _MAX_NOTIFICATION_SOUND_VOLUME)
223 code = _SOUND_NOTIFICATION_VOLUME_MAX;
225 else if(code == _MULTIPOINT_TOUCH_COUNT)
227 code = _MULTIPOINTTOUCH_POINTCOUNT;
229 else if(code == _BLUETOOTH_SUPPORTED)
233 else if(code == _GPS_SUPPORTED)
235 code = _LOCATION_GPS;
237 else if(code == _WPS_SUPPORTED)
239 code = _LOCATION_WPS;
241 else if(code == _WIFI_SUPPORTED)
245 else if(code == _WIFI_DIRECT_SUPPORTED)
249 else if(code == _FM_RADIO_SUPPORTED)
253 else if(code == _TV_OUT_SUPPORTED)
255 code = _SCREEN_OUTPUT_RCA;
257 else if(code == _NFC_SUPPORTED)
265 _SystemInfoImpl::GetSysInfo(const String& key, String& value)
267 result r = E_OBJ_NOT_FOUND;
268 String tizenKey = ConvertToTizen(key);
270 SysLog(NID_SYS, "Request Key is %ls.", key.GetPointer());
272 if (firstRequest == false)
277 String* pValue = (String*)stringList.GetValue(tizenKey);
285 if (key == _NETWORK_TYPE) //Compatibility
287 bool supported = false;
288 GetSysInfo(_TELEPHONY, supported);
289 if(supported == false)
291 value = _NETWORK_EMERGENCY;
294 bool supportedGsm = false;
295 bool supportedGprs = false;
296 bool supportedEdge = false;
297 bool supportedUmts = false;
298 bool supportedHsdpa = false;
299 bool supportedHsupa = false;
300 bool supportedHspa = false;
301 bool supportedLte = false;
302 bool supportedCdma = false;
304 GetSysInfo(_TELEPHONY_SERVICE_GSM, supportedGsm);
305 GetSysInfo(_TELEPHONY_SERVICE_GPRS, supportedGprs);
306 GetSysInfo(_TELEPHONY_SERVICE_EDGE, supportedEdge);
307 GetSysInfo(_TELEPHONY_SERVICE_UMTS, supportedUmts);
308 GetSysInfo(_TELEPHONY_SERVICE_HSDPA, supportedHsdpa);
309 GetSysInfo(_TELEPHONY_SERVICE_HSUPA, supportedHsupa);
310 GetSysInfo(_TELEPHONY_SERVICE_HSPA, supportedHspa);
311 GetSysInfo(_TELEPHONY_SERVICE_LTE, supportedLte);
312 GetSysInfo(_TELEPHONY_SERVICE_CDMA, supportedCdma);
315 if(supportedGsm == false && supportedGprs == false
316 && supportedEdge == false && supportedUmts == false
317 && supportedHsdpa == false && supportedHsupa == false
318 && supportedHspa == false && supportedLte == false
319 && supportedCdma == false)
321 value = _NETWORK_NO_SERVICE;
323 else if(supportedGsm == true)
325 value.Append(L"GSM");
327 else if(supportedGprs == true)
329 if(value.GetLength() > 0)
330 value.Append(L" | ");
332 value.Append(L"GPRS");
334 else if(supportedEdge == true)
336 if(value.GetLength() > 0)
337 value.Append(L" | ");
339 value.Append(L"EDGE");
341 else if(supportedUmts == true)
343 if(value.GetLength() > 0)
344 value.Append(L" | ");
346 value.Append(L"UMTS");
348 else if(supportedHsdpa == true)
350 if(value.GetLength() > 0)
351 value.Append(L" | ");
353 value.Append(L"HSDPA");
355 else if(supportedHsupa == true)
357 if(value.GetLength() > 0)
358 value.Append(L" | ");
360 value.Append(L"HSUPA");
362 else if(supportedHspa == true)
364 if(value.GetLength() > 0)
365 value.Append(L" | ");
367 value.Append(L"HSPA");
369 else if(supportedLte == true)
371 if(value.GetLength() > 0)
372 value.Append(L" | ");
374 value.Append(L"LTE");
376 else if(supportedCdma == true)
378 if(value.GetLength() > 0)
379 value.Append(L" | ");
381 value.Append(L"CDMA");
385 else if (key == _OPENGL_ES_VERSION)
387 bool opengles_11 = false;
388 bool opengles_20 = false;
390 GetSysInfo(_OPENGLES_VERSION_1_1, opengles_11);
391 GetSysInfo(_OPENGLES_VERSION_2_0, opengles_20);
393 if(opengles_11 == true)
395 value.Append(L"1.1");
397 else if(opengles_20 == true)
399 if(value.GetLength() > 0)
400 value.Append(L" | ");
402 value.Append(L"2.0");
406 else if(key == _BLUETOOTH_SUPPORTED)
408 bool supported = false;
409 GetSysInfo(_BLUETOOTH, supported);
410 if(supported == false)
413 value = _UNSUPPORTED;
416 else if (key == _GPS_SUPPORTED)
418 bool supported = false;
419 GetSysInfo(_LOCATION_GPS, supported);
420 if(supported == false)
423 value = _UNSUPPORTED;
426 else if (key == _WIFI_SUPPORTED)
428 bool supported = false;
429 GetSysInfo(_WIFI, supported);
430 if(supported == false)
433 value = _UNSUPPORTED;
436 else if (key == _WAC_VERSION)
441 else if (key == _PLATFORM_NATIVE_API_VERSION || key == _PLATFORM_WEB_API_VERSION || key == _PLATFORM_VERSION || key == _BUILD_STRING)
445 else if (tizenKey == _DUID)
447 r = GetFromRegistry(tizenKey, value);
451 ArrayList requestMessage;
452 ArrayList responseMessage;
454 _CommunicationDispatcherClient* pCommunicationDispatcherClient = _CommunicationDispatcherClient::GetInstance();
456 _IpcClient* pIpcClient = pCommunicationDispatcherClient->GetIpcClient();
457 SysTryReturn(NID_SYS, pIpcClient != null, E_OUT_OF_MEMORY, r, "It is failed to create IPC instance.");
459 requestMessage.Construct();
460 responseMessage.Construct();
462 String serviceId(_SYSTEM_SERVICE_ID);
463 String commandId(L"osp.system.command.get.duid.internal");
465 requestMessage.Add(serviceId);
466 requestMessage.Add(commandId);
468 unique_ptr<IoService_Request> pMsg(new (std::nothrow) IoService_Request(requestMessage, &responseMessage));
469 SysTryReturnResult(NID_SYS, pMsg != null, E_OUT_OF_MEMORY, "It is failed to create Ipc message");
471 r = pIpcClient->SendRequest(pMsg.get());
472 SysTryReturn(NID_SYS, r == E_SUCCESS, E_SYSTEM, r, "It is failed to send ipc message. [%s]", GetErrorMessage(r));
474 String* pResult = (String*)responseMessage.GetAt(_SYSTEM_RESPONSE_DATA);
475 String* pDuid = (String*)responseMessage.GetAt(_SYSTEM_RESPONSE_DATA+1);
477 SysTryReturn(NID_SYS, pResult != null, r = E_SYSTEM, r, "It is failed to receive result on IPC response message.");
478 SysTryReturn(NID_SYS, pDuid != null, r = E_SYSTEM, r, "It is failed to receive IMEI value on IPC response message.");
480 SysTryReturn(NID_SYS, *pResult != _SYSTEM_RESULT_PRIVILEGED, r = E_PRIVILEGE_DENIED, r, "It is failed to get privilege.");
481 SysTryReturn(NID_SYS, *pResult == _SYSTEM_RESULT_OK, r = E_SYSTEM, r, "It is failed to get DUID value.");
486 responseMessage.RemoveAll(true);
491 r = GetFromRegistry(tizenKey, value);
495 char* pStringValue = null;
497 tizenKey.SubString(7, tKey);
498 SysTryReturnResult(NID_SYS, tKey.GetLength() > 0, E_OBJ_NOT_FOUND, "Required key should be longer than 0.");
501 unique_ptr< char[] > systemKey(_StringConverter::CopyToCharArrayN(tKey));
503 SysTryReturn(NID_SYS, r == E_SUCCESS, E_SYSTEM, r, "[%s] StringUtil::StringToUtf8N It is failed", GetErrorMessage(r));
504 int ret = system_info_get_platform_string(systemKey.get(), &pStringValue);
506 SysTryReturnResult(NID_SYS, ret == 0, E_OBJ_NOT_FOUND, "It is failed to get system information %ls from configration file.", tizenKey.GetPointer());
508 r = StringUtil::Utf8ToString(pStringValue, value);
515 stringList.Add(new String(tizenKey), new String(value));
521 _SystemInfoImpl::GetSysInfo(const String& key, int& value)
523 result r = E_SUCCESS;
524 String tizenKey = ConvertToTizen(key);
526 SysLog(NID_SYS, "Request Key is %ls.", key.GetPointer());
528 if (firstRequest == false)
533 Integer* pValue = (Integer*)integerList.GetValue(tizenKey);
537 value = pValue->value;
541 if (key == _CAMERA_COUNT)
543 bool supported = false;
546 GetSysInfo(_CAMERA_FRONT, supported);
547 if(supported == true)
550 GetSysInfo(_CAMERA_BACK, supported);
551 if(supported == true)
558 r = GetFromRegistry(tizenKey, value);
564 tizenKey.SubString(7, tKey);
565 SysTryReturnResult(NID_SYS, tKey.GetLength() > 0, E_OBJ_NOT_FOUND, "Required key should be longer than 0.");
568 unique_ptr< char[] > systemKey(_StringConverter::CopyToCharArrayN(tKey));
570 SysTryReturn(NID_SYS, r == E_SUCCESS, E_SYSTEM, r, "[%s] StringUtil::StringToUtf8N It is failed", GetErrorMessage(r));
571 ret = system_info_get_platform_int(systemKey.get(), &value);
573 SysTryReturnResult(NID_SYS, ret == 0, E_OBJ_NOT_FOUND, "It is failed to get system information %ls from configration file.", tizenKey.GetPointer());
580 integerList.Add(new String(tizenKey), new Integer(value));
587 _SystemInfoImpl::GetSysInfo(const String& key, long long& value)
589 return E_OBJ_NOT_FOUND;
593 _SystemInfoImpl::GetSysInfo(const String& key, double& value)
595 return E_OBJ_NOT_FOUND;
599 _SystemInfoImpl::GetSysInfo(const String& key, bool& value)
601 result r = E_SUCCESS;
602 String tizenKey = ConvertToTizen(key);
604 SysLog(NID_SYS, "Request Key is %ls.", key.GetPointer());
606 if (firstRequest == false)
611 Boolean* pValue = (Boolean*)boolList.GetValue(tizenKey);
615 value = pValue->value;
619 r = GetFromRegistry(tizenKey, value);
623 tizenKey.SubString(7, tKey);
624 SysTryReturnResult(NID_SYS, tKey.GetLength() > 0, E_OBJ_NOT_FOUND, "Required key should be longer than 0.");
627 unique_ptr< char[] > systemKey(_StringConverter::CopyToCharArrayN(tKey));
629 SysTryReturn(NID_SYS, r == E_SUCCESS, E_SYSTEM, r, "[%s] StringUtil::StringToUtf8N It is failed", GetErrorMessage(r));
631 bool supported = false;
632 int ret = system_info_get_platform_bool(systemKey.get(), &supported);
633 SysTryReturnResult(NID_SYS, ret == 0, E_OBJ_NOT_FOUND, "It is failed to get system information %ls from configration file.", tizenKey.GetPointer());
640 boolList.Add(new String(tizenKey), new Boolean(value));
647 _SystemInfoImpl::GetSysInfo(const String& key, UuId& value)
649 return E_OBJ_NOT_FOUND;
653 _SystemInfoImpl::GetSysInfoValuesN(const String& key, SystemInfoValueType type)
655 SetLastResult(E_OBJ_NOT_FOUND);
660 _SystemInfoImpl::GetPlatformVersion(String& platformVersion)
662 result r = E_SUCCESS;
663 String tizenKey(_PLATFORM_VERSION);
665 r = GetFromRegistry(tizenKey, platformVersion);
669 char* pStringValue = null;
671 tizenKey.SubString(7, tKey);
672 SysTryReturnResult(NID_SYS, tKey.GetLength() > 0, E_SYSTEM, "Required key should be longer than 0.");
675 unique_ptr< char[] > systemKey(_StringConverter::CopyToCharArrayN(tKey));
677 SysTryReturn(NID_SYS, r == E_SUCCESS, E_SYSTEM, r, "[%s] StringUtil::StringToUtf8N It is failed", GetErrorMessage(r));
678 int ret = system_info_get_platform_string(systemKey.get(), &pStringValue);
680 SysTryReturnResult(NID_SYS, ret == 0, E_OBJ_NOT_FOUND, "It is failed to get system information %ls from configration file.", tizenKey.GetPointer());
682 r = StringUtil::Utf8ToString(pStringValue, platformVersion);
690 _SystemInfoImpl::GetBuildInfo(String& buildInfo)
692 result r = E_SUCCESS;
693 String tizenKey(_BUILD_STRING);
695 r = GetFromRegistry(tizenKey, buildInfo);
699 char* pStringValue = null;
701 tizenKey.SubString(7, tKey);
702 SysTryReturnResult(NID_SYS, tKey.GetLength() > 0, E_SYSTEM, "Required key should be longer than 0.");
705 unique_ptr< char[] > systemKey(_StringConverter::CopyToCharArrayN(tKey));
707 SysTryReturn(NID_SYS, r == E_SUCCESS, E_SYSTEM, r, "[%s] StringUtil::StringToUtf8N It is failed", GetErrorMessage(r));
708 int ret = system_info_get_platform_string(systemKey.get(), &pStringValue);
710 SysTryReturnResult(NID_SYS, ret == 0, E_OBJ_NOT_FOUND, "It is failed to get system information %ls from configration file.", tizenKey.GetPointer());
712 r = StringUtil::Utf8ToString(pStringValue, buildInfo);
720 _SystemInfoImpl::GetNativeApiVersion(String& nativeApiVersion)
722 result r = E_SUCCESS;
723 String tizenKey(_PLATFORM_NATIVE_API_VERSION);
725 r = GetFromRegistry(tizenKey, nativeApiVersion);
729 char* pStringValue = null;
731 tizenKey.SubString(7, tKey);
732 SysTryReturnResult(NID_SYS, tKey.GetLength() > 0, E_SYSTEM, "Required key should be longer than 0.");
735 unique_ptr< char[] > systemKey(_StringConverter::CopyToCharArrayN(tKey));
737 SysTryReturn(NID_SYS, r == E_SUCCESS, E_SYSTEM, r, "[%s] StringUtil::StringToUtf8N It is failed", GetErrorMessage(r));
738 int ret = system_info_get_platform_string(systemKey.get(), &pStringValue);
740 SysTryReturnResult(NID_SYS, ret == 0, E_OBJ_NOT_FOUND, "It is failed to get system information %ls from configration file.", tizenKey.GetPointer());
742 r = StringUtil::Utf8ToString(pStringValue, nativeApiVersion);
750 _SystemInfoImpl::GetWebApiVersion(String& webApiVersion)
752 result r = E_SUCCESS;
753 String tizenKey(_PLATFORM_WEB_API_VERSION);
755 r = GetFromRegistry(tizenKey, webApiVersion);
759 char* pStringValue = null;
761 tizenKey.SubString(7, tKey);
762 SysTryReturnResult(NID_SYS, tKey.GetLength() > 0, E_SYSTEM, "Required key should be longer than 0.");
765 unique_ptr< char[] > systemKey(_StringConverter::CopyToCharArrayN(tKey));
767 SysTryReturn(NID_SYS, r == E_SUCCESS, E_SYSTEM, r, "[%s] StringUtil::StringToUtf8N It is failed", GetErrorMessage(r));
768 int ret = system_info_get_platform_string(systemKey.get(), &pStringValue);
770 SysTryReturnResult(NID_SYS, ret == 0, E_OBJ_NOT_FOUND, "It is failed to get system information %ls from configration file.", tizenKey.GetPointer());
772 r = StringUtil::Utf8ToString(pStringValue, webApiVersion);
780 _SystemInfoImpl::GetImei(String& imei)
782 result r = E_SUCCESS;
785 TapiHandle* handle = null;
789 handle = tel_init(null);
790 SysTryReturnResult(NID_SYS, handle != null, E_SYSTEM, "It is failed to get handle of telephony.");
791 while(time_count < 30) //Wait 30 second.
793 ret = tel_check_modem_power_status(handle, &status);
794 SysLog(NID_SYS, "Modem check result is %d, status is %d.", handle, status);
795 if(ret != TAPI_API_SUCCESS)
797 SysLogException(NID_SYS, E_SYSTEM, "It is failed to get Modem status.");
812 ArrayList requestMessage;
813 ArrayList responseMessage;
815 _CommunicationDispatcherClient* pCommunicationDispatcherClient = _CommunicationDispatcherClient::GetInstance();
817 _IpcClient* pIpcClient = pCommunicationDispatcherClient->GetIpcClient();
818 SysTryReturn(NID_SYS, pIpcClient != null, E_OUT_OF_MEMORY, r, "It is failed to create IPC instance.");
820 requestMessage.Construct();
821 responseMessage.Construct();
823 String serviceId(_SYSTEM_SERVICE_ID);
824 String commandId(L"osp.system.command.get.imei.internal");
826 requestMessage.Add(serviceId);
827 requestMessage.Add(commandId);
829 unique_ptr<IoService_Request> pMsg(new (std::nothrow) IoService_Request(requestMessage, &responseMessage));
830 SysTryReturnResult(NID_SYS, pMsg != null, E_OUT_OF_MEMORY, "It is failed to create Ipc message");
832 r = pIpcClient->SendRequest(pMsg.get());
833 SysTryReturn(NID_SYS, r == E_SUCCESS, E_SYSTEM, r, "It is failed to send ipc message. [%s]", GetErrorMessage(r));
835 String* pResult = (String*)responseMessage.GetAt(_SYSTEM_RESPONSE_DATA);
836 String* pImei = (String*)responseMessage.GetAt(_SYSTEM_RESPONSE_DATA+1);
838 SysTryReturn(NID_SYS, pResult != null, r = E_SYSTEM, r, "It is failed to receive result on IPC response message.");
839 SysTryReturn(NID_SYS, pImei != null, r = E_SYSTEM, r, "It is failed to receive IMEI value on IPC response message.");
841 SysTryReturn(NID_SYS, *pResult != _SYSTEM_RESULT_PRIVILEGED, r = E_PRIVILEGE_DENIED, r, "It is failed to get privilege.");
842 SysTryReturn(NID_SYS, *pResult == _SYSTEM_RESULT_OK, r = E_SYSTEM, r, "It is failed to get IMEI value.");
847 responseMessage.RemoveAll(true);
853 _SystemInfoImpl::GetFromRegistry(const String& key, String& value)
855 result r = E_SUCCESS;
859 r = _reg.Construct(_REGISTRY_PATH, REG_OPEN_READ_ONLY, null);
860 SysTryReturnResult(NID_SYS, r == E_SUCCESS , r, " RegistryImpl construct is failed");
862 r = _reg.GetValue(_SYSTEM_INFO_SESSION, key, valStr);
863 SysTryReturnResult(NID_SYS, r == E_SUCCESS , r, " Registry GetValue is failed");
865 if(valStr == L"true" || valStr == L"false")
867 return E_OBJ_NOT_FOUND;
878 _SystemInfoImpl::GetFromRegistry(const String& key, int& value)
880 result r = E_SUCCESS;
884 r = _reg.Construct(_REGISTRY_PATH, REG_OPEN_READ_ONLY, null);
885 SysTryReturnResult(NID_SYS, r == E_SUCCESS, r, " RegistryImpl construct is failed");
887 r = _reg.GetValue(_SYSTEM_INFO_SESSION, key, valStr);
888 SysTryReturnResult(NID_SYS, r == E_SUCCESS, r, " Registry GetValue is failed");
889 SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, " Registry GetValue is failed");
890 r = Integer::Parse(valStr, value);
891 SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_OBJ_NOT_FOUND, " Integer::Parse() is failed");
896 _SystemInfoImpl::GetFromRegistry(const String& key, bool& value)
898 result r = E_SUCCESS;
902 r = _reg.Construct(_REGISTRY_PATH, REG_OPEN_READ_ONLY, null);
903 SysTryReturnResult(NID_SYS, r == E_SUCCESS, r, " RegistryImpl construct is failed");
905 r = _reg.GetValue(_SYSTEM_INFO_SESSION, key, valStr);
906 SysTryReturnResult(NID_SYS, r == E_SUCCESS, r, " Registry GetValue is failed");
907 SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, " Registry GetValue is failed");
908 if(valStr == L"true")
912 else if(valStr == L"false")
918 return E_OBJ_NOT_FOUND;
924 _SystemInfoImpl::GetInstance(SystemInfo& systeminfo)
926 return systeminfo.__pSystemInfoImpl;
928 const _SystemInfoImpl*
929 _SystemInfoImpl::GetInstance(const SystemInfo& systeminfo)
931 return systeminfo.__pSystemInfoImpl;