Fix System issues
authorJoohyun Kim <joohyune.kim@samsung.com>
Wed, 27 Mar 2013 01:02:56 +0000 (10:02 +0900)
committerJoohyun Kim <joohyune.kim@samsung.com>
Wed, 27 Mar 2013 01:02:56 +0000 (10:02 +0900)
Change-Id: I452ff6cfb75ffed5ab8762f0ee250cf91f415088
Signed-off-by: Joohyun Kim <joohyune.kim@samsung.com>
inc/FSysSystemInfo.h
src/system/FSys_CommunicationDispatcherClient.cpp
src/system/FSys_DeviceManagerImpl.cpp
src/system/FSys_PowerManagerImpl.cpp
src/system/FSys_RuntimeInfoImpl.cpp
src/system/FSys_SystemInfoImpl.cpp

index 91f2d3f..5c8e8eb 100644 (file)
@@ -254,7 +254,7 @@ public:
         */
        static result GetWebApiVersion(Tizen::Base::String& webApiVersion);
 
-       /*
+       /**
         * Gets the platform build information.
         *
         * @since 2.1
index 6c8ebcb..3d47a9d 100644 (file)
@@ -131,6 +131,8 @@ _CommunicationDispatcherClient::OnDataReceived(const ArrayList& data)
        listener->OnDataReceived(data);
 
        SysLog(NID_SYS, "Message is delivered to \"%ls\"[%x]", pServiceId->GetPointer(), listener);
+       ArrayList* temp = const_cast< ArrayList *> (&data);
+       temp->RemoveAll(true);
 }
 
 }}
index 93d7713..0137a67 100644 (file)
@@ -86,10 +86,10 @@ static const wchar_t* _DEVICE_MANAGER_STATE_CLOSED = L"Closed";
 static const wchar_t* _SYSTEM_INFO_NETWORK_BLUETOOTH = L"http://tizen.org/feature/network.bluetooth";
 static const wchar_t* _SYSTEM_INFO_INPUT_KEYBOARD = L"http://tizen.org/feature/input.keyboard";
 static const wchar_t* _SYSTEM_INFO_TVOUT_SUPPORTED = L"http://tizen.org/feature/screen.output.rca";
+static const wchar_t* _SYSTEM_INFO_HDMI = L"http://tizen.org/feature/screen.output.hdmi";
 
 _DeviceManagerImpl* _DeviceManagerImpl::__pDeviceManagerImpl = null;
 
-
 class _DeviceManagerEventArg : public IEventArg
 {
 public:
@@ -108,11 +108,7 @@ protected:
                IDeviceEventListener* pListener = dynamic_cast<IDeviceEventListener*> (&listener);
                const _DeviceManagerEventArg* pArg = dynamic_cast<const _DeviceManagerEventArg*>(&arg);
 
-               if(pListener == null || pArg == null)
-               {
-                       SysLogException(NID_SYS, E_SYSTEM, "listener or arg is null.");
-                       return;
-               }
+               SysTryReturnVoidResult(NID_SYS, pListener != null && pArg != null, E_SYSTEM, "Parameters are not available.");
 
                pListener->OnDeviceStateChanged(pArg->deviceType, pArg->state);
        }
@@ -308,10 +304,8 @@ _DeviceManagerImpl::MmcEventVconfCallback(keynode_t* node, void* userData)
                        String event;
                        int value = 0;
                        int ret = vconf_get_int(VCONFKEY_APPSERVICE_MMC_STATUS, &value);
-                       if(ret == -1)
-                       {
-                               SysLogException(NID_SYS, E_SYSTEM, "VCONFKEY_APPSERVICE_MMC_STATUS is error");
-                       }
+                       SysTryReturnVoidResult(NID_SYS, ret == 0, E_SYSTEM, "VCONFKEY_APPSERVICE_MMC_STATUS is error");
+
                        if (value == 1)
                        {
                                event = _DEVICE_MANAGER_STATE_MOUNTED;
@@ -419,11 +413,8 @@ _DeviceManagerImpl::SendEvent(DeviceType deviceType, String& state)
                                return;
                        }
                        std::unique_ptr<_DeviceManagerEventArg> pDeviceManagerEventArg(new (std::nothrow) _DeviceManagerEventArg());
-                       if(pDeviceManagerEventArg == null)
-                       {
-                               SysLogException(NID_SYS, E_OUT_OF_MEMORY, "It is failed to create instance of DeviceManagerEventArg");
-                               return;
-                       }
+                       SysTryReturnVoidResult(NID_SYS, pDeviceManagerEventArg != null, E_OUT_OF_MEMORY, "It is failed to create instance of DeviceManagerEventArg");
+
                        pDeviceManagerEventArg->deviceType = deviceType;
                        pDeviceManagerEventArg->state = state;
 
@@ -678,12 +669,14 @@ _DeviceManagerImpl::AddOnExistedListener(DeviceType deviceType, const IDeviceEve
                                {
                                        int value = 0;
                                        int ret = 0;
+                                       bool supported = false;
+                                       r = _SystemInfoImpl::GetSysInfo(_SYSTEM_INFO_HDMI, supported);
+                                       SysTryReturnResult(NID_SYS, supported == true, E_UNSUPPORTED_OPERATION, "Current device does not support HDMI.");
+
                                        ret = vconf_get_int(VCONFKEY_SYSMAN_HDMI, &value);
                                        SysTryReturnResult(NID_SYS, !(ret < 0), E_SYSTEM, "vconf_get_int failed Output value is %d", value);
-                                       if(value < 0)
-                                       {
-                                               return E_UNSUPPORTED_OPERATION;
-                                       }
+                                       SysTryReturnResult(NID_SYS, value >= 0, E_UNSUPPORTED_OPERATION, "Current device does not support HDMI.");
+
                                        if(pDeviceEventListenerContainer->__hdmi == true)
                                        {
                                                r = E_OBJ_ALREADY_EXIST;
@@ -1080,11 +1073,7 @@ _DeviceManagerImpl::SendEvent(runtime_info_key_e key)
 
                bool state = false;
                ret = runtime_info_get_value_bool(RUNTIME_INFO_KEY_USB_CONNECTED, &state);
-               if (ret != RUNTIME_INFO_ERROR_NONE)
-               {
-                       SysLogException(NID_SYS, E_SYSTEM, "It is failed to get usb state");
-                       return;
-               }
+               SysTryReturnVoidResult(NID_SYS, ret == RUNTIME_INFO_ERROR_NONE, E_SYSTEM, "It is failed to get usb state.");
 
                if (state == true)
                {
@@ -1102,12 +1091,7 @@ _DeviceManagerImpl::SendEvent(runtime_info_key_e key)
                type = DEVICE_TYPE_CHARGER;
 
                bool state = false;
-               ret = runtime_info_get_value_bool(RUNTIME_INFO_KEY_CHARGER_CONNECTED, &state);
-               if (ret != RUNTIME_INFO_ERROR_NONE)
-               {
-                       SysLogException(NID_SYS, E_SYSTEM, "It is failed to get charger state");
-                       return;
-               }
+               SysTryReturnVoidResult(NID_SYS, ret == RUNTIME_INFO_ERROR_NONE, E_SYSTEM, "It is failed to get charger state.");
 
                if (state == true)
                {
@@ -1126,11 +1110,7 @@ _DeviceManagerImpl::SendEvent(runtime_info_key_e key)
 
                bool state = false;
                ret = runtime_info_get_value_bool(RUNTIME_INFO_KEY_TV_OUT_CONNECTED, &state);
-               if (ret != RUNTIME_INFO_ERROR_NONE)
-               {
-                       SysLogException(NID_SYS, E_SYSTEM, "It is failed to get tv connect state");
-                       return;
-               }
+               SysTryReturnVoidResult(NID_SYS, ret == RUNTIME_INFO_ERROR_NONE, E_SYSTEM, "It is failed to get tv connect state.");
 
                if (state == true)
                {
@@ -1146,11 +1126,7 @@ _DeviceManagerImpl::SendEvent(runtime_info_key_e key)
        {
                int state = 0;
                ret = runtime_info_get_value_int(RUNTIME_INFO_KEY_AUDIO_JACK_STATUS, &state);
-               if (ret != RUNTIME_INFO_ERROR_NONE)
-               {
-                       SysLogException(NID_SYS, E_SYSTEM, "It is failed to get audion jack state");
-                       return;
-               }
+               SysTryReturnVoidResult(NID_SYS, ret == RUNTIME_INFO_ERROR_NONE, E_SYSTEM, "It is failed to get audio connect state.");
 
                if (state == RUNTIME_INFO_AUDIO_JACK_STATUS_UNCONNECTED)
                {
@@ -1193,11 +1169,7 @@ _DeviceManagerImpl::SendEvent(runtime_info_key_e key)
 
                bool state = false;
                ret = runtime_info_get_value_bool(RUNTIME_INFO_KEY_SLIDING_KEYBOARD_OPENED, &state);
-               if (ret != RUNTIME_INFO_ERROR_NONE)
-               {
-                       SysLogException(NID_SYS, E_SYSTEM, "It is failed to get keyboard state");
-                       return;
-               }
+               SysTryReturnVoidResult(NID_SYS, ret == RUNTIME_INFO_ERROR_NONE, E_SYSTEM, "It is failed to get built-in keyboard state.");
 
                if (state == true)
                {
@@ -1400,7 +1372,7 @@ _DeviceManagerImpl::GetState(DeviceType deviceType, String& state)
        {
                bool keyboard = false;
                r = _SystemInfoImpl::GetSysInfo(_SYSTEM_INFO_INPUT_KEYBOARD, keyboard);
-               SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "Fail to get keyboard option.");
+               SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to get keyboard option.");
                if (keyboard == false)
                {
                        if(!_AppInfo::IsOspCompat())
@@ -1417,6 +1389,10 @@ _DeviceManagerImpl::GetState(DeviceType deviceType, String& state)
        case DEVICE_TYPE_HDMI:
        {
                int ret = 0;
+               bool supported = false;
+               r = _SystemInfoImpl::GetSysInfo(_SYSTEM_INFO_HDMI, supported);
+               SysTryReturnResult(NID_SYS, supported == false, E_UNSUPPORTED_OPERATION, "Current device does not support HDMI.");
+
                ret = vconf_get_int(VCONFKEY_SYSMAN_HDMI, &value);
                SysTryReturnResult(NID_SYS, !(ret < 0), E_SYSTEM, "vconf_get_int failed Output value is %d", value);
                if (value == 1)
index 82da699..e32b94f 100644 (file)
@@ -232,7 +232,6 @@ PowerChangedCallback(power_state_e state, void* userData)
                        {
                                while(pEnumerator->MoveNext() == E_SUCCESS)
                                {
-
                                        pEnumerator->GetCurrent(pIPowerManagerEventListener);
                                        if(pIPowerManagerEventListener != null)
                                        {
index 0d4bf1d..582d453 100644 (file)
@@ -104,9 +104,6 @@ static const char* const _PROC_KEY_SYSTEM_MEMORY_FREE = "MemFree";
 static const char* const _PROC_KEY_PROCESS_MEMORY = "VmSize";
 
 static const char* const _ROOT_PATH = "/";
-static const char* const _STORAGE_PATH = "/opt/storage/sdcard";
-static const char* const _MEDIA_PATH = "/opt/usr/media";
-static const char* const _INTERNAL_PATH = "/opt";
 
 static const int _MAX_BUFFER_LENGTH = 1024;
 
@@ -439,20 +436,12 @@ _RuntimeInfoImpl::IsChargingMode(bool& value)
 result
 _RuntimeInfoImpl::GetAvailableInternalStorage(long long& value)
 {
-       long long temp = 0;
        long long total = 0;
        result r = E_SUCCESS;
 
-       r = GetCapacity(_ROOT_PATH, total, temp);
+       r = GetCapacity(_ROOT_PATH, total, value);
        SysTryReturn(NID_SYS, !IsFailed(r), E_SYSTEM, r, "[E_SYSTEM] system error has occurred. ");
 
-       value += temp;
-
-       r = GetCapacity(_INTERNAL_PATH, total, temp);
-       SysTryReturn(NID_SYS, !IsFailed(r), E_SYSTEM, r, "[E_SYSTEM] system error has occurred. ");
-
-       value += temp;
-
        return E_SUCCESS;
 }
 result
@@ -470,15 +459,23 @@ _RuntimeInfoImpl::GetAvailableExternalStorage(long long& value)
                value = 0;
                return E_SUCCESS;
        }
-
-       return GetCapacity(_STORAGE_PATH, total, value);
+       char* directoryPath = _StringConverter::CopyToCharArrayN(_EnvironmentImpl::GetExternalStoragePath());
+       SysTryReturnResult(NID_SYS, directoryPath != null, E_SYSTEM, "It is failed to get external directory path.");
+       result r = GetCapacity(directoryPath, total, value);
+       delete directoryPath;
+       return r ;
 }
 
 result
 _RuntimeInfoImpl::GetAvailableMediaStorage(long long& value)
 {
        long long total = 0;
-       return GetCapacity(_MEDIA_PATH, total, value);
+
+       char* directoryPath = _StringConverter::CopyToCharArrayN(_EnvironmentImpl::GetMediaPath());
+       SysTryReturnResult(NID_SYS, directoryPath != null, E_SYSTEM, "It is failed to get media directory path.");
+       result r = GetCapacity(directoryPath, total, value);
+       delete directoryPath;
+       return r;
 }
 
 result
index 8b23f9d..6cd8e41 100644 (file)
@@ -21,7 +21,9 @@
  */
 #include <unique_ptr.h>
 
+#include <FBaseBoolean.h>
 #include <FBaseInteger.h>
+#include <FBaseColHashMap.h>
 
 #include <FBase_NativeError.h>
 #include <FIo_RegistryImpl.h>
@@ -139,12 +141,29 @@ static const wchar_t* _WIFI_DIRECT_SUPPORTED = L"WiFiDirectSupported";
 static const wchar_t* _PLATFORM_VERSION = L"http://tizen.org/feature/platform.version";
 static const wchar_t* _PLATFORM_NATIVE_API_VERSION = L"http://tizen.org/feature/platform.native.api.version";
 static const wchar_t* _PLATFORM_WEB_API_VERSION = L"http://tizen.org/feature/platform.web.api.version";
-static const wchar_t* _BUID_STRING = L"http://tizen.org/system/build.string";
+static const wchar_t* _BUILD_STRING = L"http://tizen.org/system/build.string";
 
 static const wchar_t* _WAC_VERSION = L"WACVersion";
 static const wchar_t* _SUPPORTED = L"Supported";
 static const wchar_t* _UNSUPPORTED = L"Unsupported";
 
+static bool firstRequest = false;
+static HashMap integerList;
+static HashMap boolList;
+static HashMap stringList;
+
+void
+PrepareCache(void)
+{
+       if(firstRequest == false)
+       {
+               integerList.Construct();
+               boolList.Construct();
+               stringList.Construct();
+               firstRequest = true;
+       }
+}
+
 String
 _SystemInfoImpl::ConvertToTizen(const String& key)
 {
@@ -239,6 +258,18 @@ _SystemInfoImpl::GetSysInfo(const String& key, String& value)
        result r = E_OBJ_NOT_FOUND;
        String tizenKey = ConvertToTizen(key);
 
+       if (firstRequest == false)
+       {
+               PrepareCache();
+       }
+
+       String* pValue = (String*)stringList.GetValue(key);
+
+       if(pValue != null)
+       {
+               value = *pValue;
+       }
+
        if (key == _NETWORK_TYPE) //Compatibility
        {
                bool supported = false;
@@ -391,7 +422,7 @@ _SystemInfoImpl::GetSysInfo(const String& key, String& value)
                value.Clear();
                r = E_SUCCESS;
        }
-       else if (key == _PLATFORM_NATIVE_API_VERSION || key == _PLATFORM_WEB_API_VERSION || key == _PLATFORM_VERSION)
+       else if (key == _PLATFORM_NATIVE_API_VERSION || key == _PLATFORM_WEB_API_VERSION || key == _PLATFORM_VERSION || key == _BUILD_STRING)
        {
                r = E_OBJ_NOT_FOUND;
        }
@@ -401,6 +432,10 @@ _SystemInfoImpl::GetSysInfo(const String& key, String& 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)
+       {
+               stringList.Add(new String(key), new String(value));
+       }
        return r;
 }
 
@@ -411,6 +446,18 @@ _SystemInfoImpl::GetSysInfo(const String& key, int& value)
        result r = E_SUCCESS;
        String tizenKey = ConvertToTizen(key);
 
+       if (firstRequest == false)
+       {
+               PrepareCache();
+       }
+
+       Integer* pValue = (Integer*)integerList.GetValue(key);
+
+       if(pValue != null)
+       {
+               value = pValue->value;
+       }
+
        if (key == _CAMERA_COUNT)
        {
                bool supported = false;
@@ -431,6 +478,11 @@ _SystemInfoImpl::GetSysInfo(const String& key, int& value)
                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)
+       {
+               integerList.Add(new String(key), new Integer(value));
+       }
        
        return r;
 }
@@ -456,10 +508,28 @@ _SystemInfoImpl::GetSysInfo(const String& key, bool& value)
        result r = E_SUCCESS;
        String tizenKey = ConvertToTizen(key);
 
+       if (firstRequest == false)
+       {
+               PrepareCache();
+       }
+
+       Boolean* pValue = (Boolean*)boolList.GetValue(key);
+
+       if(pValue != null)
+       {
+               value = pValue->value;
+       }
+
+
        r = GetFromRegistry(tizenKey, value);
        SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_OBJ_NOT_FOUND, "It is failed to get the key[%ls]", tizenKey.GetPointer());
 
-       return E_SUCCESS;
+       if(r == E_SUCCESS)
+       {
+               boolList.Add(new String(key), new Boolean(value));
+       }
+
+       return r;
 }
 
 
@@ -492,7 +562,7 @@ result
 _SystemInfoImpl::GetBuildInfo(String& buildInfo)
 {
        result r = E_SUCCESS;
-       String tizenKey(_BUID_STRING);
+       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());