X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Fsystem%2FFSys_SystemInfoImpl.cpp;h=9d14647a26c907e54f3253e6b3afbb24012720e4;hb=084d62010cca1db8f0cc555cf55d8702485e16eb;hp=2b586c2e95279fd5fa583db7aa4e018b0856876e;hpb=d32f994b41189814e23507b7b50f686e984fe3fd;p=platform%2Fframework%2Fnative%2Fappfw.git diff --git a/src/system/FSys_SystemInfoImpl.cpp b/src/system/FSys_SystemInfoImpl.cpp index 2b586c2..9d14647 100644 --- a/src/system/FSys_SystemInfoImpl.cpp +++ b/src/system/FSys_SystemInfoImpl.cpp @@ -27,8 +27,11 @@ #include #include #include +#include +#include #include +#include #include #include #include @@ -43,6 +46,7 @@ using namespace std; using namespace Tizen::Base; using namespace Tizen::Base::Collection; using namespace Tizen::Io; +using namespace Tizen::Base::Utility; namespace Tizen { namespace System { @@ -263,6 +267,8 @@ _SystemInfoImpl::GetSysInfo(const String& key, String& value) result r = E_OBJ_NOT_FOUND; String tizenKey = ConvertToTizen(key); + SysLog(NID_SYS, "Request Key is %ls.", key.GetPointer()); + if (firstRequest == false) { PrepareCache(); @@ -438,37 +444,47 @@ _SystemInfoImpl::GetSysInfo(const String& key, String& value) } else if (tizenKey == _DUID) { - int ret = 0; - TapiHandle* handle = null; - int time_count = 0; - int status = 0; + r = GetFromRegistry(tizenKey, value); - handle = tel_init(null); - if(handle != null) + if(r != E_SUCCESS) { - while(time_count < 30) //Wait 30 second. - { - ret = tel_check_modem_power_status(handle, &status); - SysLog(NID_SYS, "Modem check result is %d, status is %d.", handle, status); - if(ret != TAPI_API_SUCCESS) - { - SysLogException(NID_SYS, E_SYSTEM, "It is failed to get Modem status."); - tel_deinit(handle); - return E_SYSTEM; - } - - if(status == 0) - { - break; - } - - usleep(1000000); - time_count++; - } - tel_deinit(handle); + ArrayList requestMessage; + ArrayList responseMessage; + + _CommunicationDispatcherClient* pCommunicationDispatcherClient = _CommunicationDispatcherClient::GetInstance(); + + _IpcClient* pIpcClient = pCommunicationDispatcherClient->GetIpcClient(); + SysTryReturn(NID_SYS, pIpcClient != null, E_OUT_OF_MEMORY, r, "It is failed to create IPC instance."); + + requestMessage.Construct(); + responseMessage.Construct(); + + String serviceId(_SYSTEM_SERVICE_ID); + String commandId(L"osp.system.command.get.duid.internal"); + + requestMessage.Add(serviceId); + requestMessage.Add(commandId); + + unique_ptr pMsg(new (std::nothrow) IoService_Request(requestMessage, &responseMessage)); + SysTryReturnResult(NID_SYS, pMsg != null, E_OUT_OF_MEMORY, "It is failed to create Ipc message"); + + r = pIpcClient->SendRequest(pMsg.get()); + SysTryReturn(NID_SYS, r == E_SUCCESS, E_SYSTEM, r, "It is failed to send ipc message. [%s]", GetErrorMessage(r)); + + String* pResult = (String*)responseMessage.GetAt(_SYSTEM_RESPONSE_DATA); + String* pDuid = (String*)responseMessage.GetAt(_SYSTEM_RESPONSE_DATA+1); + + SysTryReturn(NID_SYS, pResult != null, r = E_SYSTEM, r, "It is failed to receive result on IPC response message."); + SysTryReturn(NID_SYS, pDuid != null, r = E_SYSTEM, r, "It is failed to receive IMEI value on IPC response message."); + + SysTryReturn(NID_SYS, *pResult != _SYSTEM_RESULT_PRIVILEGED, r = E_PRIVILEGE_DENIED, r, "It is failed to get privilege."); + SysTryReturn(NID_SYS, *pResult == _SYSTEM_RESULT_OK, r = E_SYSTEM, r, "It is failed to get DUID value."); + + value = *pDuid; + +CATCH: + responseMessage.RemoveAll(true); } - _SystemClient* pSystemClient = _SystemClient::GetInstance(); - r = pSystemClient->GetValue(tizenKey, value); } else { @@ -476,8 +492,22 @@ _SystemInfoImpl::GetSysInfo(const String& key, String& value) if(r != E_SUCCESS) { - _SystemClient* pSystemClient = _SystemClient::GetInstance(); - r = pSystemClient->GetValue(tizenKey, value); + char* pStringValue = null; + String tKey; + tizenKey.SubString(7, tKey); + SysTryReturnResult(NID_SYS, tKey.GetLength() > 0, E_OBJ_NOT_FOUND, "Required key should be longer than 0."); + + ClearLastResult(); + unique_ptr< char[] > systemKey(_StringConverter::CopyToCharArrayN(tKey)); + r = GetLastResult(); + SysTryReturn(NID_SYS, r == E_SUCCESS, E_SYSTEM, r, "[%s] StringUtil::StringToUtf8N It is failed", GetErrorMessage(r)); + + int ret = system_info_get_platform_string(systemKey.get(), &pStringValue); + SysTryReturnResult(NID_SYS, ret == SYSTEM_INFO_ERROR_NONE, E_OBJ_NOT_FOUND, "It is failed to get system information %ls from configration file.", tizenKey.GetPointer()); + + r = StringUtil::Utf8ToString(pStringValue, value); + free(pStringValue); + r = E_SUCCESS; } } if( r == E_SUCCESS) @@ -493,6 +523,8 @@ _SystemInfoImpl::GetSysInfo(const String& key, int& value) result r = E_SUCCESS; String tizenKey = ConvertToTizen(key); + SysLog(NID_SYS, "Request Key is %ls.", key.GetPointer()); + if (firstRequest == false) { PrepareCache(); @@ -524,10 +556,22 @@ _SystemInfoImpl::GetSysInfo(const String& key, int& value) else { r = GetFromRegistry(tizenKey, value); - if(r != E_SUCCESS) + if(r != E_SUCCESS || tizenKey == _SCREEN_WIDTH || tizenKey == _SCREEN_HEIGHT || tizenKey == _SCREEN_DPI) { - _SystemClient* pSystemClient = _SystemClient::GetInstance(); - r = pSystemClient->GetValue(tizenKey, value); + int ret = 0; + String tKey; + + tizenKey.SubString(7, tKey); + SysTryReturnResult(NID_SYS, tKey.GetLength() > 0, E_OBJ_NOT_FOUND, "Required key should be longer than 0."); + + ClearLastResult(); + unique_ptr< char[] > systemKey(_StringConverter::CopyToCharArrayN(tKey)); + r = GetLastResult(); + SysTryReturn(NID_SYS, r == E_SUCCESS, E_SYSTEM, r, "[%s] StringUtil::StringToUtf8N It is failed", GetErrorMessage(r)); + + ret = system_info_get_platform_int(systemKey.get(), &value); + SysTryReturnResult(NID_SYS, ret == SYSTEM_INFO_ERROR_NONE, E_OBJ_NOT_FOUND, "It is failed to get system information %ls from configration file.", tizenKey.GetPointer()); + r = E_SUCCESS; } } @@ -557,6 +601,8 @@ _SystemInfoImpl::GetSysInfo(const String& key, bool& value) result r = E_SUCCESS; String tizenKey = ConvertToTizen(key); + SysLog(NID_SYS, "Request Key is %ls.", key.GetPointer()); + if (firstRequest == false) { PrepareCache(); @@ -570,31 +616,35 @@ _SystemInfoImpl::GetSysInfo(const String& key, bool& value) return E_SUCCESS; } - if(key == L"http://tizen.org/feature/input.keys.menu") - { - bool supported = false; - int ret = system_info_get_platform_bool("tizen.org/feature/input.keys.menu", &supported); - SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "It is failed to get system information from configration file."); - value = supported; - r = E_SUCCESS; - } - else if(key == L"http://tizen.org/feature/input.keys.back") + r = GetFromRegistry(tizenKey, value); + if(r != E_SUCCESS) { + String tKey; + tizenKey.SubString(7, tKey); + SysTryReturnResult(NID_SYS, tKey.GetLength() > 0, E_OBJ_NOT_FOUND, "Required key should be longer than 0."); + + ClearLastResult(); + unique_ptr< char[] > systemKey(_StringConverter::CopyToCharArrayN(tKey)); + r = GetLastResult(); + SysTryReturn(NID_SYS, r == E_SUCCESS, E_SYSTEM, r, "[%s] StringUtil::StringToUtf8N It is failed", GetErrorMessage(r)); + bool supported = false; - int ret = system_info_get_platform_bool("tizen.org/feature/input.keys.back", &supported); - SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "It is failed to get system information from configration file."); - value = supported; - r = E_SUCCESS; - } - else - { - r = GetFromRegistry(tizenKey, value); - if(r != E_SUCCESS) + int ret = system_info_get_platform_bool(systemKey.get(), &supported); + if(ret != SYSTEM_INFO_ERROR_NONE) { - _SystemClient* pSystemClient = _SystemClient::GetInstance(); - r = pSystemClient->GetValue(tizenKey, value); + String screenKey(L"http://tizen.org/feature/screen.size"); + String requiredKey; + tizenKey.SubString(0, screenKey.GetLength(), requiredKey); + + if(requiredKey == screenKey) + { + value = false; + } } - SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_OBJ_NOT_FOUND, "It is failed to get the key[%ls]", tizenKey.GetPointer()); + + SysTryReturnResult(NID_SYS, ret == SYSTEM_INFO_ERROR_NONE, E_OBJ_NOT_FOUND, "It is failed to get system information %ls from configration file.", tizenKey.GetPointer()); + value = supported; + r = E_SUCCESS; } if(r == E_SUCCESS) @@ -625,7 +675,26 @@ _SystemInfoImpl::GetPlatformVersion(String& platformVersion) String tizenKey(_PLATFORM_VERSION); r = GetFromRegistry(tizenKey, platformVersion); - SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to get the key[%ls]", tizenKey.GetPointer()); + + if(r != E_SUCCESS) + { + char* pStringValue = null; + String tKey; + tizenKey.SubString(7, tKey); + SysTryReturnResult(NID_SYS, tKey.GetLength() > 0, E_SYSTEM, "Required key should be longer than 0."); + + ClearLastResult(); + unique_ptr< char[] > systemKey(_StringConverter::CopyToCharArrayN(tKey)); + r = GetLastResult(); + SysTryReturn(NID_SYS, r == E_SUCCESS, E_SYSTEM, r, "[%s] StringUtil::StringToUtf8N It is failed", GetErrorMessage(r)); + + int ret = system_info_get_platform_string(systemKey.get(), &pStringValue); + SysTryReturnResult(NID_SYS, ret == SYSTEM_INFO_ERROR_NONE, E_OBJ_NOT_FOUND, "It is failed to get system information %ls from configration file.", tizenKey.GetPointer()); + + r = StringUtil::Utf8ToString(pStringValue, platformVersion); + free(pStringValue); + r = E_SUCCESS; + } return r; } @@ -636,7 +705,26 @@ _SystemInfoImpl::GetBuildInfo(String& buildInfo) String tizenKey(_BUILD_STRING); r = GetFromRegistry(tizenKey, buildInfo); - SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to get the key[%ls]", tizenKey.GetPointer()); + + if(r != E_SUCCESS) + { + char* pStringValue = null; + String tKey; + tizenKey.SubString(7, tKey); + SysTryReturnResult(NID_SYS, tKey.GetLength() > 0, E_SYSTEM, "Required key should be longer than 0."); + + ClearLastResult(); + unique_ptr< char[] > systemKey(_StringConverter::CopyToCharArrayN(tKey)); + r = GetLastResult(); + SysTryReturn(NID_SYS, r == E_SUCCESS, E_SYSTEM, r, "[%s] StringUtil::StringToUtf8N It is failed", GetErrorMessage(r)); + + int ret = system_info_get_platform_string(systemKey.get(), &pStringValue); + SysTryReturnResult(NID_SYS, ret == SYSTEM_INFO_ERROR_NONE, E_OBJ_NOT_FOUND, "It is failed to get system information %ls from configration file.", tizenKey.GetPointer()); + + r = StringUtil::Utf8ToString(pStringValue, buildInfo); + free(pStringValue); + r = E_SUCCESS; + } return r; } @@ -647,7 +735,26 @@ _SystemInfoImpl::GetNativeApiVersion(String& nativeApiVersion) String tizenKey(_PLATFORM_NATIVE_API_VERSION); r = GetFromRegistry(tizenKey, nativeApiVersion); - SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to get the key[%ls]", tizenKey.GetPointer()); + + if(r != E_SUCCESS) + { + char* pStringValue = null; + String tKey; + tizenKey.SubString(7, tKey); + SysTryReturnResult(NID_SYS, tKey.GetLength() > 0, E_SYSTEM, "Required key should be longer than 0."); + + ClearLastResult(); + unique_ptr< char[] > systemKey(_StringConverter::CopyToCharArrayN(tKey)); + r = GetLastResult(); + SysTryReturn(NID_SYS, r == E_SUCCESS, E_SYSTEM, r, "[%s] StringUtil::StringToUtf8N It is failed", GetErrorMessage(r)); + + int ret = system_info_get_platform_string(systemKey.get(), &pStringValue); + SysTryReturnResult(NID_SYS, ret == SYSTEM_INFO_ERROR_NONE, E_OBJ_NOT_FOUND, "It is failed to get system information %ls from configration file.", tizenKey.GetPointer()); + + r = StringUtil::Utf8ToString(pStringValue, nativeApiVersion); + free(pStringValue); + r = E_SUCCESS; + } return r; } @@ -658,7 +765,26 @@ _SystemInfoImpl::GetWebApiVersion(String& webApiVersion) String tizenKey(_PLATFORM_WEB_API_VERSION); r = GetFromRegistry(tizenKey, webApiVersion); - SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to get the key[%ls]", tizenKey.GetPointer()); + + if(r != E_SUCCESS) + { + char* pStringValue = null; + String tKey; + tizenKey.SubString(7, tKey); + SysTryReturnResult(NID_SYS, tKey.GetLength() > 0, E_SYSTEM, "Required key should be longer than 0."); + + ClearLastResult(); + unique_ptr< char[] > systemKey(_StringConverter::CopyToCharArrayN(tKey)); + r = GetLastResult(); + SysTryReturn(NID_SYS, r == E_SUCCESS, E_SYSTEM, r, "[%s] StringUtil::StringToUtf8N It is failed", GetErrorMessage(r)); + + int ret = system_info_get_platform_string(systemKey.get(), &pStringValue); + SysTryReturnResult(NID_SYS, ret == SYSTEM_INFO_ERROR_NONE, E_OBJ_NOT_FOUND, "It is failed to get system information %ls from configration file.", tizenKey.GetPointer()); + + r = StringUtil::Utf8ToString(pStringValue, webApiVersion); + free(pStringValue); + r = E_SUCCESS; + } return r; } @@ -718,16 +844,20 @@ _SystemInfoImpl::GetImei(String& imei) r = pIpcClient->SendRequest(pMsg.get()); SysTryReturn(NID_SYS, r == E_SUCCESS, E_SYSTEM, r, "It is failed to send ipc message. [%s]", GetErrorMessage(r)); - unique_ptr pResult((String*)responseMessage.GetAt(_SYSTEM_RESPONSE_DATA)); - unique_ptr pImei((String*)responseMessage.GetAt(_SYSTEM_RESPONSE_DATA+1)); + String* pResult = (String*)responseMessage.GetAt(_SYSTEM_RESPONSE_DATA); + String* pImei = (String*)responseMessage.GetAt(_SYSTEM_RESPONSE_DATA+1); - SysTryReturnResult(NID_SYS, pResult != null, E_SYSTEM, "It is failed to receive result on IPC response message."); - SysTryReturnResult(NID_SYS, pImei != null, E_SYSTEM, "It is failed to receive IMEI value on IPC response message."); + SysTryReturn(NID_SYS, pResult != null, r = E_SYSTEM, r, "It is failed to receive result on IPC response message."); + SysTryReturn(NID_SYS, pImei != null, r = E_SYSTEM, r, "It is failed to receive IMEI value on IPC response message."); - SysTryReturnResult(NID_SYS, *pResult != _SYSTEM_RESULT_PRIVILEGED, E_PRIVILEGE_DENIED, "It is failed to get privilege."); - SysTryReturnResult(NID_SYS, *pResult == _SYSTEM_RESULT_OK, E_SYSTEM, "It is failed to get IMEI value."); + SysTryReturn(NID_SYS, *pResult != _SYSTEM_RESULT_PRIVILEGED, r = E_PRIVILEGE_DENIED, r, "It is failed to get privilege."); + SysTryReturn(NID_SYS, *pResult == _SYSTEM_RESULT_OK, r = E_SYSTEM, r, "It is failed to get IMEI value."); imei = *pImei; + +CATCH: + responseMessage.RemoveAll(true); + return r; } @@ -762,6 +892,7 @@ _SystemInfoImpl::GetFromRegistry(const String& key, int& value) result r = E_SUCCESS; _RegistryImpl _reg; String valStr; + r = _reg.Construct(_REGISTRY_PATH, REG_OPEN_READ_ONLY, null); SysTryReturnResult(NID_SYS, r == E_SUCCESS, r, " RegistryImpl construct is failed"); @@ -779,6 +910,7 @@ _SystemInfoImpl::GetFromRegistry(const String& key, bool& value) result r = E_SUCCESS; _RegistryImpl _reg; String valStr; + r = _reg.Construct(_REGISTRY_PATH, REG_OPEN_READ_ONLY, null); SysTryReturnResult(NID_SYS, r == E_SUCCESS, r, " RegistryImpl construct is failed");