* @brief This is the implementation file for _SystemInfoImpl class.
*/
#include <unique_ptr.h>
+#include <unistd.h>
+
+#include <system_info.h>
+#include <ITapiModem.h>
#include <FBaseBoolean.h>
#include <FBaseInteger.h>
#include <FBaseColHashMap.h>
+#include <FBaseUtilStringUtil.h>
+#include <FIoRegistry.h>
#include <FBase_NativeError.h>
+#include <FBase_StringConverter.h>
#include <FIo_RegistryImpl.h>
#include <FSys_SystemInfoImpl.h>
#include <FIo_AppServiceIpcMessages.h>
using namespace Tizen::Base;
using namespace Tizen::Base::Collection;
using namespace Tizen::Io;
+using namespace Tizen::Base::Utility;
namespace Tizen { namespace System
{
result r = E_OBJ_NOT_FOUND;
String tizenKey = ConvertToTizen(key);
+ SysLog(NID_SYS, "Request Key is %ls.", key.GetPointer());
+
if (firstRequest == false)
{
PrepareCache();
}
- String* pValue = (String*)stringList.GetValue(key);
+ String* pValue = (String*)stringList.GetValue(tizenKey);
if(pValue != null)
{
value = *pValue;
- r = E_SUCCESS;
+ return E_SUCCESS;
}
if (key == _NETWORK_TYPE) //Compatibility
{
r = E_OBJ_NOT_FOUND;
}
+ else if (tizenKey == _DUID)
+ {
+ r = GetFromRegistry(tizenKey, value);
+
+ if(r != E_SUCCESS)
+ {
+ 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<IoService_Request> 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);
+ }
+ }
else
{
r = GetFromRegistry(tizenKey, value);
if(r != E_SUCCESS)
{
- _SystemClient* pSystemClient = _SystemClient::GetInstance();
- r = pSystemClient->GetValue(key, 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)
{
- stringList.Add(new String(key), new String(value));
+ stringList.Add(new String(tizenKey), new String(value));
}
return r;
}
result r = E_SUCCESS;
String tizenKey = ConvertToTizen(key);
+ SysLog(NID_SYS, "Request Key is %ls.", key.GetPointer());
+
if (firstRequest == false)
{
PrepareCache();
}
- Integer* pValue = (Integer*)integerList.GetValue(key);
+ Integer* pValue = (Integer*)integerList.GetValue(tizenKey);
if(pValue != null)
{
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(key, 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;
}
}
if(r == E_SUCCESS)
{
- integerList.Add(new String(key), new Integer(value));
+ integerList.Add(new String(tizenKey), new Integer(value));
}
return r;
result r = E_SUCCESS;
String tizenKey = ConvertToTizen(key);
+ SysLog(NID_SYS, "Request Key is %ls.", key.GetPointer());
+
if (firstRequest == false)
{
PrepareCache();
}
- Boolean* pValue = (Boolean*)boolList.GetValue(key);
+ Boolean* pValue = (Boolean*)boolList.GetValue(tizenKey);
if(pValue != null)
{
r = GetFromRegistry(tizenKey, value);
if(r != E_SUCCESS)
{
- _SystemClient* pSystemClient = _SystemClient::GetInstance();
- r = pSystemClient->GetValue(key, value);
+ 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(systemKey.get(), &supported);
+ if(ret != SYSTEM_INFO_ERROR_NONE)
+ {
+ 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, 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;
}
- SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_OBJ_NOT_FOUND, "It is failed to get the key[%ls]", tizenKey.GetPointer());
if(r == E_SUCCESS)
{
- boolList.Add(new String(key), new Boolean(value));
+ boolList.Add(new String(tizenKey), new Boolean(value));
}
return r;
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;
}
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;
}
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;
}
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;
}
{
result r = E_SUCCESS;
+ int ret = 0;
+ TapiHandle* handle = null;
+ int time_count = 0;
+ int status = 0;
+
+ handle = tel_init(null);
+ SysTryReturnResult(NID_SYS, handle != null, E_SYSTEM, "It is failed to get handle of telephony.");
+ 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;
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<String> pResult((String*)responseMessage.GetAt(_SYSTEM_RESPONSE_DATA));
- unique_ptr<String> 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;
}
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");
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");