Fix System Cache issue
[platform/framework/native/appfw.git] / src / system / FSys_SystemInfoImpl.cpp
index b92aa5e..dde4c2e 100644 (file)
@@ -33,6 +33,7 @@
 
 #include "FSys_Types.h"
 #include "FSys_SystemClient.h"
+#include "FSys_CommunicationDispatcherClient.h"
 
 using namespace std;
 
@@ -43,7 +44,7 @@ using namespace Tizen::Io;
 namespace Tizen { namespace System
 {
 
-static const wchar_t* _REGISTRY_PATH = L"/tmp/osp/system_info_cache.ini";
+static const wchar_t* _REGISTRY_PATH = L"/opt/usr/etc/system_info_cache.ini";
 static const wchar_t* _SYSTEM_INFO_SESSION = L"SystemInformation";
 
 //Bluetooth
@@ -132,7 +133,6 @@ static const wchar_t* _NETWORK_TYPE = L"NetworkType";
 static const wchar_t* _NETWORK_EMERGENCY = L"Emergency";
 static const wchar_t* _NETWORK_NO_SERVICE = L"NoService";
 
-
 //WIFI
 static const wchar_t* _WIFI = L"http://tizen.org/feature/network.wifi";
 static const wchar_t* _WIFI_SUPPORTED = L"WiFiSupported";
@@ -436,8 +436,11 @@ _SystemInfoImpl::GetSysInfo(const String& key, String& value)
        else
        {
                r = GetFromRegistry(tizenKey, value);
-               SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_OBJ_NOT_FOUND, "It is failed to get the key[%ls]", tizenKey.GetPointer());
-               r = E_SUCCESS;
+               if(r != E_SUCCESS)
+               {
+                       _SystemClient* pSystemClient = _SystemClient::GetInstance();
+                       r = pSystemClient->GetValue(key, value);
+               }
        }
        if( r == E_SUCCESS)
        {
@@ -446,7 +449,6 @@ _SystemInfoImpl::GetSysInfo(const String& key, String& value)
        return r;
 }
 
-
 result
 _SystemInfoImpl::GetSysInfo(const String& key, int& value)
 {
@@ -463,6 +465,7 @@ _SystemInfoImpl::GetSysInfo(const String& key, int& value)
        if(pValue != null)
        {
                value = pValue->value;
+               return E_SUCCESS;
        }
 
        if (key == _CAMERA_COUNT)
@@ -483,7 +486,11 @@ _SystemInfoImpl::GetSysInfo(const String& key, int& value)
        else
        {
                r = GetFromRegistry(tizenKey, value);
-               SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_OBJ_NOT_FOUND, "It is failed to get the key[%ls]", tizenKey.GetPointer());
+               if(r != E_SUCCESS)
+               {
+                       _SystemClient* pSystemClient = _SystemClient::GetInstance();
+                       r = pSystemClient->GetValue(key, value);
+               }
        }
 
        if(r == E_SUCCESS)
@@ -494,21 +501,18 @@ _SystemInfoImpl::GetSysInfo(const String& key, int& value)
        return r;
 }
 
-
 result
 _SystemInfoImpl::GetSysInfo(const String& key, long long& value)
 {
        return E_OBJ_NOT_FOUND;
 }
 
-
 result
 _SystemInfoImpl::GetSysInfo(const String& key, double& value)
 {
        return E_OBJ_NOT_FOUND;
 }
 
-
 result
 _SystemInfoImpl::GetSysInfo(const String& key, bool& value)
 {
@@ -525,10 +529,15 @@ _SystemInfoImpl::GetSysInfo(const String& key, bool& value)
        if(pValue != null)
        {
                value = pValue->value;
+               return E_SUCCESS;
        }
 
-
        r = GetFromRegistry(tizenKey, value);
+       if(r != E_SUCCESS)
+       {
+               _SystemClient* pSystemClient = _SystemClient::GetInstance();
+               r = pSystemClient->GetValue(key, value);
+       }
        SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_OBJ_NOT_FOUND, "It is failed to get the key[%ls]", tizenKey.GetPointer());
 
        if(r == E_SUCCESS)
@@ -539,14 +548,12 @@ _SystemInfoImpl::GetSysInfo(const String& key, bool& value)
        return r;
 }
 
-
 result
 _SystemInfoImpl::GetSysInfo(const String& key, UuId& value)
 {
        return E_OBJ_NOT_FOUND;
 }
 
-
 Collection::IList*
 _SystemInfoImpl::GetSysInfoValuesN(const String& key, SystemInfoValueType type)
 {      
@@ -606,11 +613,10 @@ _SystemInfoImpl::GetImei(String& imei)
        ArrayList requestMessage;
        ArrayList responseMessage;
 
-       unique_ptr<_IpcClient> pIpcClient (new (std::nothrow) _IpcClient());
-       SysTryReturn(NID_SYS, pIpcClient != null, E_OUT_OF_MEMORY, r, "It is failed to create IPC instance.");
+       _CommunicationDispatcherClient* pCommunicationDispatcherClient = _CommunicationDispatcherClient::GetInstance();
 
-       r = pIpcClient->Construct(_COMMUNICATION_DISPATCHER_IPC_ID);
-       SysTryReturn(NID_SYS, r == E_SUCCESS, E_SYSTEM, r, "It is failed to create IpcClient. [%s]", GetErrorMessage(r));
+       _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();
@@ -685,10 +691,6 @@ _SystemInfoImpl::GetFromRegistry(const String& key, int& value)
 result
 _SystemInfoImpl::GetFromRegistry(const String& key, bool& value)
 {
-/*
-       _SystemClient* pSystemClient = _SystemClient::GetInstance();
-       pSystemClient->GetValue(key, value);
-*/
        result r = E_SUCCESS;
        _RegistryImpl _reg;
        String valStr;