From 54e1954668a1f2015f9b98009b2ef16df13a4c5e Mon Sep 17 00:00:00 2001 From: Kichan Kwon Date: Tue, 22 Aug 2017 17:33:14 +0900 Subject: [PATCH] [Information] Integrate error type and log tag - Cornerstone for integrating the get function of runtime-info and system-info - It is not problem because both CAPI packages are using same Tizen error Change-Id: I41035a8a8b10b24fc51f7a4a917ebc655c216ad1 Signed-off-by: Kichan Kwon --- .../InformationErrorFactory.cs} | 24 +- .../Interop/Interop.RuntimeInfo.cs | 26 +-- .../Interop/Interop.SystemInfo.cs | 32 +-- .../RuntimeInfo/RuntimeInformation.cs | 246 ++++++++++----------- .../SystemInfo/SystemInfo.cs | 36 ++- .../Usage/ProcessCpuUsage.cs | 16 +- .../Usage/ProcessMemoryUsage.cs | 36 +-- .../Usage/SystemCpuUsage.cs | 34 +-- .../Usage/SystemMemoryUsage.cs | 8 +- 9 files changed, 223 insertions(+), 235 deletions(-) rename src/Tizen.System.Information/{RuntimeInfo/RuntimeInfoErrorFactory.cs => Common/InformationErrorFactory.cs} (73%) mode change 100644 => 100755 mode change 100644 => 100755 src/Tizen.System.Information/Interop/Interop.SystemInfo.cs diff --git a/src/Tizen.System.Information/RuntimeInfo/RuntimeInfoErrorFactory.cs b/src/Tizen.System.Information/Common/InformationErrorFactory.cs old mode 100644 new mode 100755 similarity index 73% rename from src/Tizen.System.Information/RuntimeInfo/RuntimeInfoErrorFactory.cs rename to src/Tizen.System.Information/Common/InformationErrorFactory.cs index e9fee57..906961d --- a/src/Tizen.System.Information/RuntimeInfo/RuntimeInfoErrorFactory.cs +++ b/src/Tizen.System.Information/Common/InformationErrorFactory.cs @@ -22,7 +22,7 @@ using Tizen.Internals.Errors; namespace Tizen.System { [EditorBrowsable(EditorBrowsableState.Never)] - internal enum RuntimeInfoError + internal enum InformationError { None = ErrorCode.None, InvalidParameter = ErrorCode.InvalidParameter, @@ -35,38 +35,38 @@ namespace Tizen.System } [EditorBrowsable(EditorBrowsableState.Never)] - internal static class RuntimeInfoErrorFactory + internal static class InformationErrorFactory { - internal const string LogTag = "Tizen.System.RuntimeInformation"; + internal const string LogTag = "Tizen.System.Information"; - internal static void ThrowException(int err) + internal static void ThrowException(InformationError err) { - RuntimeInfoError error = (RuntimeInfoError)err; - if (error == RuntimeInfoError.InvalidParameter) + InformationError error = (InformationError)err; + if (error == InformationError.InvalidParameter) { throw new ArgumentException("Invalid parameter"); } - else if (error == RuntimeInfoError.OutOfMemory) + else if (error == InformationError.OutOfMemory) { throw new OutOfMemoryException("Out of memory"); } - else if (error == RuntimeInfoError.Io) + else if (error == InformationError.Io) { throw new IOException("I/O Error"); } - else if (error == RuntimeInfoError.RemoteIo) + else if (error == InformationError.RemoteIo) { throw new IOException("Remote I/O Error"); } - else if (error == RuntimeInfoError.PermissionDenied) + else if (error == InformationError.PermissionDenied) { throw new UnauthorizedAccessException("Permission denied"); } - else if (error == RuntimeInfoError.NotSupported) + else if (error == InformationError.NotSupported) { throw new NotSupportedException("Not supported"); } - else if (error == RuntimeInfoError.NoData) + else if (error == InformationError.NoData) { throw new NotSupportedException("No data"); } diff --git a/src/Tizen.System.Information/Interop/Interop.RuntimeInfo.cs b/src/Tizen.System.Information/Interop/Interop.RuntimeInfo.cs index 705df5a..8c177a1 100755 --- a/src/Tizen.System.Information/Interop/Interop.RuntimeInfo.cs +++ b/src/Tizen.System.Information/Interop/Interop.RuntimeInfo.cs @@ -63,42 +63,42 @@ internal static partial class Interop } [DllImport(Libraries.RuntimeInfo, EntryPoint = "runtime_info_get_value_int")] - public static extern int GetValue(RuntimeInformationKey key, out int status); + public static extern InformationError GetValue(RuntimeInformationKey key, out int status); [DllImport(Libraries.RuntimeInfo, EntryPoint = "runtime_info_get_value_bool")] - public static extern int GetValue(RuntimeInformationKey key, out bool status); + public static extern InformationError GetValue(RuntimeInformationKey key, out bool status); [DllImport(Libraries.RuntimeInfo, EntryPoint = "runtime_info_get_value_double")] - public static extern int GetValue(RuntimeInformationKey key, out double status); + public static extern InformationError GetValue(RuntimeInformationKey key, out double status); [DllImport(Libraries.RuntimeInfo, EntryPoint = "runtime_info_get_value_string")] - public static extern int GetValue(RuntimeInformationKey key, out string status); + public static extern InformationError GetValue(RuntimeInformationKey key, out string status); [DllImport(Libraries.RuntimeInfo, EntryPoint = "runtime_info_get_system_memory_info")] - public static extern int GetSystemMemoryInfo(out MemoryInfo memoryInfo); + public static extern InformationError GetSystemMemoryInfo(out MemoryInfo memoryInfo); [DllImport(Libraries.RuntimeInfo, EntryPoint = "runtime_info_get_process_memory_info")] - public static extern int GetProcessMemoryInfo(int[] pid, int size, ref IntPtr array); + public static extern InformationError GetProcessMemoryInfo(int[] pid, int size, ref IntPtr array); [DllImport(Libraries.RuntimeInfo, EntryPoint = "runtime_info_get_cpu_usage")] - public static extern int GetCpuUsage(out CpuUsage cpuUsage); + public static extern InformationError GetCpuUsage(out CpuUsage cpuUsage); [DllImport(Libraries.RuntimeInfo, EntryPoint = "runtime_info_get_process_cpu_usage")] - public static extern int GetProcessCpuUsage(int[] pid, int size, ref IntPtr array); + public static extern InformationError GetProcessCpuUsage(int[] pid, int size, ref IntPtr array); [DllImport(Libraries.RuntimeInfo, EntryPoint = "runtime_info_get_processor_count")] - public static extern int GetProcessorCount(out int processorCount); + public static extern InformationError GetProcessorCount(out int processorCount); [DllImport(Libraries.RuntimeInfo, EntryPoint = "runtime_info_get_processor_current_frequency")] - public static extern int GetProcessorCurrentFrequency(int coreId, out int cpuFreq); + public static extern InformationError GetProcessorCurrentFrequency(int coreId, out int cpuFreq); [DllImport(Libraries.RuntimeInfo, EntryPoint = "runtime_info_get_processor_max_frequency")] - public static extern int GetProcessorMaxFrequency(int coreId, out int cpuFreq); + public static extern InformationError GetProcessorMaxFrequency(int coreId, out int cpuFreq); [DllImport(Libraries.RuntimeInfo, EntryPoint = "runtime_info_set_changed_cb")] - public static extern int SetRuntimeInfoChangedCallback(RuntimeInformationKey runtimeInfoKey, RuntimeInformationChangedCallback cb, IntPtr userData); + public static extern InformationError SetRuntimeInfoChangedCallback(RuntimeInformationKey runtimeInfoKey, RuntimeInformationChangedCallback cb, IntPtr userData); [DllImport(Libraries.RuntimeInfo, EntryPoint = "runtime_info_unset_changed_cb")] - public static extern int UnsetRuntimeInfoChangedCallback(RuntimeInformationKey runtimeInfoKey); + public static extern InformationError UnsetRuntimeInfoChangedCallback(RuntimeInformationKey runtimeInfoKey); } } diff --git a/src/Tizen.System.Information/Interop/Interop.SystemInfo.cs b/src/Tizen.System.Information/Interop/Interop.SystemInfo.cs old mode 100644 new mode 100755 index de7282e..2e820be --- a/src/Tizen.System.Information/Interop/Interop.SystemInfo.cs +++ b/src/Tizen.System.Information/Interop/Interop.SystemInfo.cs @@ -14,23 +14,13 @@ * limitations under the License. */ -using System; +using Tizen.System; using System.Runtime.InteropServices; internal static partial class Interop { internal static partial class SystemInfo { - internal enum ErrorCode - { - None = Tizen.Internals.Errors.ErrorCode.None, - InvalidParameter = Tizen.Internals.Errors.ErrorCode.InvalidParameter, - OutOfMemory = Tizen.Internals.Errors.ErrorCode.OutOfMemory, - IoError = Tizen.Internals.Errors.ErrorCode.IoError, - PermissionDenied = Tizen.Internals.Errors.ErrorCode.PermissionDenied, - NotSupported = Tizen.Internals.Errors.ErrorCode.NoSuchDevice, - } - internal enum SystemInfoValueType { Bool = 0, @@ -47,33 +37,33 @@ internal static partial class Interop } [DllImport(Libraries.SystemInfo, EntryPoint = "system_info_get_platform_type")] - internal static extern ErrorCode SystemInfoGetPlatformType(string key, out SystemInfoValueType type); + internal static extern InformationError SystemInfoGetPlatformType(string key, out SystemInfoValueType type); [DllImport(Libraries.SystemInfo, EntryPoint = "system_info_get_custom_type")] - internal static extern ErrorCode SystemInfoGetCustomType(string key, out SystemInfoValueType type); + internal static extern InformationError SystemInfoGetCustomType(string key, out SystemInfoValueType type); [DllImport(Libraries.SystemInfo, EntryPoint = "system_info_get_platform_bool")] - internal static extern ErrorCode SystemInfoGetPlatformBool(string key, out bool value); + internal static extern InformationError SystemInfoGetPlatformBool(string key, out bool value); [DllImport(Libraries.SystemInfo, EntryPoint = "system_info_get_platform_int")] - internal static extern ErrorCode SystemInfoGetPlatformInt(string key, out int value); + internal static extern InformationError SystemInfoGetPlatformInt(string key, out int value); [DllImport(Libraries.SystemInfo, EntryPoint = "system_info_get_platform_double")] - internal static extern ErrorCode SystemInfoGetPlatformDouble(string key, out double value); + internal static extern InformationError SystemInfoGetPlatformDouble(string key, out double value); [DllImport(Libraries.SystemInfo, EntryPoint = "system_info_get_platform_string")] - internal static extern ErrorCode SystemInfoGetPlatformString(string key, out string value); + internal static extern InformationError SystemInfoGetPlatformString(string key, out string value); [DllImport(Libraries.SystemInfo, EntryPoint = "system_info_get_custom_bool")] - internal static extern ErrorCode SystemInfoGetCustomBool(string key, out bool value); + internal static extern InformationError SystemInfoGetCustomBool(string key, out bool value); [DllImport(Libraries.SystemInfo, EntryPoint = "system_info_get_custom_int")] - internal static extern ErrorCode SystemInfoGetCustomInt(string key, out int value); + internal static extern InformationError SystemInfoGetCustomInt(string key, out int value); [DllImport(Libraries.SystemInfo, EntryPoint = "system_info_get_custom_double")] - internal static extern ErrorCode SystemInfoGetCustomDouble(string key, out double value); + internal static extern InformationError SystemInfoGetCustomDouble(string key, out double value); [DllImport(Libraries.SystemInfo, EntryPoint = "system_info_get_custom_string")] - internal static extern ErrorCode SystemInfoGetCustomString(string key, out string value); + internal static extern InformationError SystemInfoGetCustomString(string key, out string value); } } diff --git a/src/Tizen.System.Information/RuntimeInfo/RuntimeInformation.cs b/src/Tizen.System.Information/RuntimeInfo/RuntimeInformation.cs index 0910768..70428b5 100755 --- a/src/Tizen.System.Information/RuntimeInfo/RuntimeInformation.cs +++ b/src/Tizen.System.Information/RuntimeInfo/RuntimeInformation.cs @@ -195,7 +195,7 @@ namespace Tizen.System { if (!s_keyTVkeyMapping.TryGetValue(key, out key_TV)) { - RuntimeInfoErrorFactory.ThrowException((int)RuntimeInfoError.InvalidParameter); + InformationErrorFactory.ThrowException(InformationError.InvalidParameter); } return (RuntimeInformationKey)key_TV; } @@ -207,17 +207,17 @@ namespace Tizen.System Type value; if (!s_keyDataTypeMapping.TryGetValue(key, out value)) { - RuntimeInfoErrorFactory.ThrowException((int)RuntimeInfoError.InvalidParameter); + InformationErrorFactory.ThrowException(InformationError.InvalidParameter); } if (s_keyDataTypeMapping[key] == typeof(int)) { int status; - int ret = Interop.RuntimeInfo.GetValue(ConvertKeyIfTvProduct(key), out status); - if (ret != (int)RuntimeInfoError.None) + InformationError ret = Interop.RuntimeInfo.GetValue(ConvertKeyIfTvProduct(key), out status); + if (ret != InformationError.None) { - Log.Error(RuntimeInfoErrorFactory.LogTag, "Interop failed to get value for key {0}", key.ToString()); - RuntimeInfoErrorFactory.ThrowException(ret); + Log.Error(InformationErrorFactory.LogTag, "Interop failed to get value for key {0}", key.ToString()); + InformationErrorFactory.ThrowException(ret); } return status; @@ -225,11 +225,11 @@ namespace Tizen.System else { bool status; - int ret = Interop.RuntimeInfo.GetValue(ConvertKeyIfTvProduct(key), out status); - if (ret != (int)RuntimeInfoError.None) + InformationError ret = Interop.RuntimeInfo.GetValue(ConvertKeyIfTvProduct(key), out status); + if (ret != InformationError.None) { - Log.Error(RuntimeInfoErrorFactory.LogTag, "Interop failed to get value for key {0}", key.ToString()); - RuntimeInfoErrorFactory.ThrowException(ret); + Log.Error(InformationErrorFactory.LogTag, "Interop failed to get value for key {0}", key.ToString()); + InformationErrorFactory.ThrowException(ret); } return status; @@ -249,7 +249,7 @@ namespace Tizen.System { if (!s_keyDataTypeMapping.ContainsKey(key)) { - Log.Error(RuntimeInfoErrorFactory.LogTag, "Invalid data type"); + Log.Error(InformationErrorFactory.LogTag, "Invalid data type"); throw new ArgumentException("Invalid parameter"); } @@ -281,11 +281,11 @@ namespace Tizen.System { if (s_bluetoothEnabled == null) { - int ret = Interop.RuntimeInfo.SetRuntimeInfoChangedCallback(ConvertKeyIfTvProduct(RuntimeInformationKey.Bluetooth), s_runtimeInfoChangedCallback, IntPtr.Zero); - if (ret != (int)RuntimeInfoError.None) + InformationError ret = Interop.RuntimeInfo.SetRuntimeInfoChangedCallback(ConvertKeyIfTvProduct(RuntimeInformationKey.Bluetooth), s_runtimeInfoChangedCallback, IntPtr.Zero); + if (ret != InformationError.None) { - Log.Error(RuntimeInfoErrorFactory.LogTag, "Interop failed to add event handler"); - RuntimeInfoErrorFactory.ThrowException(ret); + Log.Error(InformationErrorFactory.LogTag, "Interop failed to add event handler"); + InformationErrorFactory.ThrowException(ret); } } s_bluetoothEnabled += value; @@ -295,11 +295,11 @@ namespace Tizen.System s_bluetoothEnabled -= value; if (s_bluetoothEnabled == null) { - int ret = Interop.RuntimeInfo.UnsetRuntimeInfoChangedCallback(ConvertKeyIfTvProduct(RuntimeInformationKey.Bluetooth)); - if (ret != (int)RuntimeInfoError.None) + InformationError ret = Interop.RuntimeInfo.UnsetRuntimeInfoChangedCallback(ConvertKeyIfTvProduct(RuntimeInformationKey.Bluetooth)); + if (ret != InformationError.None) { - Log.Error(RuntimeInfoErrorFactory.LogTag, "Interop failed to add event handler"); - RuntimeInfoErrorFactory.ThrowException(ret); + Log.Error(InformationErrorFactory.LogTag, "Interop failed to add event handler"); + InformationErrorFactory.ThrowException(ret); } } } @@ -313,11 +313,11 @@ namespace Tizen.System { if (s_wifiHotspotEnabled == null) { - int ret = Interop.RuntimeInfo.SetRuntimeInfoChangedCallback(ConvertKeyIfTvProduct(RuntimeInformationKey.WifiHotspot), s_runtimeInfoChangedCallback, IntPtr.Zero); - if (ret != (int)RuntimeInfoError.None) + InformationError ret = Interop.RuntimeInfo.SetRuntimeInfoChangedCallback(ConvertKeyIfTvProduct(RuntimeInformationKey.WifiHotspot), s_runtimeInfoChangedCallback, IntPtr.Zero); + if (ret != InformationError.None) { - Log.Error(RuntimeInfoErrorFactory.LogTag, "Interop failed to add event handler"); - RuntimeInfoErrorFactory.ThrowException(ret); + Log.Error(InformationErrorFactory.LogTag, "Interop failed to add event handler"); + InformationErrorFactory.ThrowException(ret); } } s_wifiHotspotEnabled += value; @@ -327,11 +327,11 @@ namespace Tizen.System s_wifiHotspotEnabled -= value; if (s_wifiHotspotEnabled == null) { - int ret = Interop.RuntimeInfo.UnsetRuntimeInfoChangedCallback(ConvertKeyIfTvProduct(RuntimeInformationKey.WifiHotspot)); - if (ret != (int)RuntimeInfoError.None) + InformationError ret = Interop.RuntimeInfo.UnsetRuntimeInfoChangedCallback(ConvertKeyIfTvProduct(RuntimeInformationKey.WifiHotspot)); + if (ret != InformationError.None) { - Log.Error(RuntimeInfoErrorFactory.LogTag, "Interop failed to add event handler"); - RuntimeInfoErrorFactory.ThrowException(ret); + Log.Error(InformationErrorFactory.LogTag, "Interop failed to add event handler"); + InformationErrorFactory.ThrowException(ret); } } } @@ -345,11 +345,11 @@ namespace Tizen.System { if (s_bluetoothTetheringEnabled == null) { - int ret = Interop.RuntimeInfo.SetRuntimeInfoChangedCallback(ConvertKeyIfTvProduct(RuntimeInformationKey.BluetoothTethering), s_runtimeInfoChangedCallback, IntPtr.Zero); - if (ret != (int)RuntimeInfoError.None) + InformationError ret = Interop.RuntimeInfo.SetRuntimeInfoChangedCallback(ConvertKeyIfTvProduct(RuntimeInformationKey.BluetoothTethering), s_runtimeInfoChangedCallback, IntPtr.Zero); + if (ret != InformationError.None) { - Log.Error(RuntimeInfoErrorFactory.LogTag, "Interop failed to add event handler"); - RuntimeInfoErrorFactory.ThrowException(ret); + Log.Error(InformationErrorFactory.LogTag, "Interop failed to add event handler"); + InformationErrorFactory.ThrowException(ret); } } s_bluetoothTetheringEnabled += value; @@ -359,11 +359,11 @@ namespace Tizen.System s_bluetoothTetheringEnabled -= value; if (s_bluetoothTetheringEnabled == null) { - int ret = Interop.RuntimeInfo.UnsetRuntimeInfoChangedCallback(ConvertKeyIfTvProduct(RuntimeInformationKey.BluetoothTethering)); - if (ret != (int)RuntimeInfoError.None) + InformationError ret = Interop.RuntimeInfo.UnsetRuntimeInfoChangedCallback(ConvertKeyIfTvProduct(RuntimeInformationKey.BluetoothTethering)); + if (ret != InformationError.None) { - Log.Error(RuntimeInfoErrorFactory.LogTag, "Interop failed to add event handler"); - RuntimeInfoErrorFactory.ThrowException(ret); + Log.Error(InformationErrorFactory.LogTag, "Interop failed to add event handler"); + InformationErrorFactory.ThrowException(ret); } } } @@ -377,11 +377,11 @@ namespace Tizen.System { if (s_usbTetheringEnabled == null) { - int ret = Interop.RuntimeInfo.SetRuntimeInfoChangedCallback(ConvertKeyIfTvProduct(RuntimeInformationKey.UsbTethering), s_runtimeInfoChangedCallback, IntPtr.Zero); - if (ret != (int)RuntimeInfoError.None) + InformationError ret = Interop.RuntimeInfo.SetRuntimeInfoChangedCallback(ConvertKeyIfTvProduct(RuntimeInformationKey.UsbTethering), s_runtimeInfoChangedCallback, IntPtr.Zero); + if (ret != InformationError.None) { - Log.Error(RuntimeInfoErrorFactory.LogTag, "Interop failed to add event handler"); - RuntimeInfoErrorFactory.ThrowException(ret); + Log.Error(InformationErrorFactory.LogTag, "Interop failed to add event handler"); + InformationErrorFactory.ThrowException(ret); } } s_usbTetheringEnabled += value; @@ -391,11 +391,11 @@ namespace Tizen.System s_usbTetheringEnabled -= value; if (s_usbTetheringEnabled == null) { - int ret = Interop.RuntimeInfo.UnsetRuntimeInfoChangedCallback(ConvertKeyIfTvProduct(RuntimeInformationKey.UsbTethering)); - if (ret != (int)RuntimeInfoError.None) + InformationError ret = Interop.RuntimeInfo.UnsetRuntimeInfoChangedCallback(ConvertKeyIfTvProduct(RuntimeInformationKey.UsbTethering)); + if (ret != InformationError.None) { - Log.Error(RuntimeInfoErrorFactory.LogTag, "Interop failed to add event handler"); - RuntimeInfoErrorFactory.ThrowException(ret); + Log.Error(InformationErrorFactory.LogTag, "Interop failed to add event handler"); + InformationErrorFactory.ThrowException(ret); } } } @@ -409,11 +409,11 @@ namespace Tizen.System { if (s_packetDataEnabled == null) { - int ret = Interop.RuntimeInfo.SetRuntimeInfoChangedCallback(ConvertKeyIfTvProduct(RuntimeInformationKey.PacketData), s_runtimeInfoChangedCallback, IntPtr.Zero); - if (ret != (int)RuntimeInfoError.None) + InformationError ret = Interop.RuntimeInfo.SetRuntimeInfoChangedCallback(ConvertKeyIfTvProduct(RuntimeInformationKey.PacketData), s_runtimeInfoChangedCallback, IntPtr.Zero); + if (ret != InformationError.None) { - Log.Error(RuntimeInfoErrorFactory.LogTag, "Interop failed to add event handler"); - RuntimeInfoErrorFactory.ThrowException(ret); + Log.Error(InformationErrorFactory.LogTag, "Interop failed to add event handler"); + InformationErrorFactory.ThrowException(ret); } } s_packetDataEnabled += value; @@ -423,11 +423,11 @@ namespace Tizen.System s_packetDataEnabled -= value; if (s_packetDataEnabled == null) { - int ret = Interop.RuntimeInfo.UnsetRuntimeInfoChangedCallback(ConvertKeyIfTvProduct(RuntimeInformationKey.PacketData)); - if (ret != (int)RuntimeInfoError.None) + InformationError ret = Interop.RuntimeInfo.UnsetRuntimeInfoChangedCallback(ConvertKeyIfTvProduct(RuntimeInformationKey.PacketData)); + if (ret != InformationError.None) { - Log.Error(RuntimeInfoErrorFactory.LogTag, "Interop failed to add event handler"); - RuntimeInfoErrorFactory.ThrowException(ret); + Log.Error(InformationErrorFactory.LogTag, "Interop failed to add event handler"); + InformationErrorFactory.ThrowException(ret); } } } @@ -441,11 +441,11 @@ namespace Tizen.System { if (s_dataRoamingEnabled == null) { - int ret = Interop.RuntimeInfo.SetRuntimeInfoChangedCallback(ConvertKeyIfTvProduct(RuntimeInformationKey.DataRoaming), s_runtimeInfoChangedCallback, IntPtr.Zero); - if (ret != (int)RuntimeInfoError.None) + InformationError ret = Interop.RuntimeInfo.SetRuntimeInfoChangedCallback(ConvertKeyIfTvProduct(RuntimeInformationKey.DataRoaming), s_runtimeInfoChangedCallback, IntPtr.Zero); + if (ret != InformationError.None) { - Log.Error(RuntimeInfoErrorFactory.LogTag, "Interop failed to add event handler"); - RuntimeInfoErrorFactory.ThrowException(ret); + Log.Error(InformationErrorFactory.LogTag, "Interop failed to add event handler"); + InformationErrorFactory.ThrowException(ret); } } s_dataRoamingEnabled += value; @@ -455,11 +455,11 @@ namespace Tizen.System s_dataRoamingEnabled -= value; if (s_dataRoamingEnabled == null) { - int ret = Interop.RuntimeInfo.UnsetRuntimeInfoChangedCallback(ConvertKeyIfTvProduct(RuntimeInformationKey.DataRoaming)); - if (ret != (int)RuntimeInfoError.None) + InformationError ret = Interop.RuntimeInfo.UnsetRuntimeInfoChangedCallback(ConvertKeyIfTvProduct(RuntimeInformationKey.DataRoaming)); + if (ret != InformationError.None) { - Log.Error(RuntimeInfoErrorFactory.LogTag, "Interop failed to add event handler"); - RuntimeInfoErrorFactory.ThrowException(ret); + Log.Error(InformationErrorFactory.LogTag, "Interop failed to add event handler"); + InformationErrorFactory.ThrowException(ret); } } } @@ -473,11 +473,11 @@ namespace Tizen.System { if (s_vibrationEnabled == null) { - int ret = Interop.RuntimeInfo.SetRuntimeInfoChangedCallback(ConvertKeyIfTvProduct(RuntimeInformationKey.Vibration), s_runtimeInfoChangedCallback, IntPtr.Zero); - if (ret != (int)RuntimeInfoError.None) + InformationError ret = Interop.RuntimeInfo.SetRuntimeInfoChangedCallback(ConvertKeyIfTvProduct(RuntimeInformationKey.Vibration), s_runtimeInfoChangedCallback, IntPtr.Zero); + if (ret != InformationError.None) { - Log.Error(RuntimeInfoErrorFactory.LogTag, "Interop failed to add event handler"); - RuntimeInfoErrorFactory.ThrowException(ret); + Log.Error(InformationErrorFactory.LogTag, "Interop failed to add event handler"); + InformationErrorFactory.ThrowException(ret); } } s_vibrationEnabled += value; @@ -487,11 +487,11 @@ namespace Tizen.System s_vibrationEnabled -= value; if (s_vibrationEnabled == null) { - int ret = Interop.RuntimeInfo.UnsetRuntimeInfoChangedCallback(ConvertKeyIfTvProduct(RuntimeInformationKey.Vibration)); - if (ret != (int)RuntimeInfoError.None) + InformationError ret = Interop.RuntimeInfo.UnsetRuntimeInfoChangedCallback(ConvertKeyIfTvProduct(RuntimeInformationKey.Vibration)); + if (ret != InformationError.None) { - Log.Error(RuntimeInfoErrorFactory.LogTag, "Interop failed to add event handler"); - RuntimeInfoErrorFactory.ThrowException(ret); + Log.Error(InformationErrorFactory.LogTag, "Interop failed to add event handler"); + InformationErrorFactory.ThrowException(ret); } } } @@ -505,11 +505,11 @@ namespace Tizen.System { if (s_audioJackConnected == null) { - int ret = Interop.RuntimeInfo.SetRuntimeInfoChangedCallback(ConvertKeyIfTvProduct(RuntimeInformationKey.AudioJack), s_runtimeInfoChangedCallback, IntPtr.Zero); - if (ret != (int)RuntimeInfoError.None) + InformationError ret = Interop.RuntimeInfo.SetRuntimeInfoChangedCallback(ConvertKeyIfTvProduct(RuntimeInformationKey.AudioJack), s_runtimeInfoChangedCallback, IntPtr.Zero); + if (ret != InformationError.None) { - Log.Error(RuntimeInfoErrorFactory.LogTag, "Interop failed to add event handler"); - RuntimeInfoErrorFactory.ThrowException(ret); + Log.Error(InformationErrorFactory.LogTag, "Interop failed to add event handler"); + InformationErrorFactory.ThrowException(ret); } } s_audioJackConnected += value; @@ -519,11 +519,11 @@ namespace Tizen.System s_audioJackConnected -= value; if (s_audioJackConnected == null) { - int ret = Interop.RuntimeInfo.UnsetRuntimeInfoChangedCallback(ConvertKeyIfTvProduct(RuntimeInformationKey.AudioJack)); - if (ret != (int)RuntimeInfoError.None) + InformationError ret = Interop.RuntimeInfo.UnsetRuntimeInfoChangedCallback(ConvertKeyIfTvProduct(RuntimeInformationKey.AudioJack)); + if (ret != InformationError.None) { - Log.Error(RuntimeInfoErrorFactory.LogTag, "Interop failed to add event handler"); - RuntimeInfoErrorFactory.ThrowException(ret); + Log.Error(InformationErrorFactory.LogTag, "Interop failed to add event handler"); + InformationErrorFactory.ThrowException(ret); } } } @@ -537,11 +537,11 @@ namespace Tizen.System { if (s_gpsStatusChanged == null) { - int ret = Interop.RuntimeInfo.SetRuntimeInfoChangedCallback(ConvertKeyIfTvProduct(RuntimeInformationKey.Gps), s_runtimeInfoChangedCallback, IntPtr.Zero); - if (ret != (int)RuntimeInfoError.None) + InformationError ret = Interop.RuntimeInfo.SetRuntimeInfoChangedCallback(ConvertKeyIfTvProduct(RuntimeInformationKey.Gps), s_runtimeInfoChangedCallback, IntPtr.Zero); + if (ret != InformationError.None) { - Log.Error(RuntimeInfoErrorFactory.LogTag, "Interop failed to add event handler"); - RuntimeInfoErrorFactory.ThrowException(ret); + Log.Error(InformationErrorFactory.LogTag, "Interop failed to add event handler"); + InformationErrorFactory.ThrowException(ret); } } s_gpsStatusChanged += value; @@ -551,11 +551,11 @@ namespace Tizen.System s_gpsStatusChanged -= value; if (s_gpsStatusChanged == null) { - int ret = Interop.RuntimeInfo.UnsetRuntimeInfoChangedCallback(ConvertKeyIfTvProduct(RuntimeInformationKey.Gps)); - if (ret != (int)RuntimeInfoError.None) + InformationError ret = Interop.RuntimeInfo.UnsetRuntimeInfoChangedCallback(ConvertKeyIfTvProduct(RuntimeInformationKey.Gps)); + if (ret != InformationError.None) { - Log.Error(RuntimeInfoErrorFactory.LogTag, "Interop failed to add event handler"); - RuntimeInfoErrorFactory.ThrowException(ret); + Log.Error(InformationErrorFactory.LogTag, "Interop failed to add event handler"); + InformationErrorFactory.ThrowException(ret); } } } @@ -569,11 +569,11 @@ namespace Tizen.System { if (s_batteryIsCharging == null) { - int ret = Interop.RuntimeInfo.SetRuntimeInfoChangedCallback(ConvertKeyIfTvProduct(RuntimeInformationKey.BatteryIsCharging), s_runtimeInfoChangedCallback, IntPtr.Zero); - if (ret != (int)RuntimeInfoError.None) + InformationError ret = Interop.RuntimeInfo.SetRuntimeInfoChangedCallback(ConvertKeyIfTvProduct(RuntimeInformationKey.BatteryIsCharging), s_runtimeInfoChangedCallback, IntPtr.Zero); + if (ret != InformationError.None) { - Log.Error(RuntimeInfoErrorFactory.LogTag, "Interop failed to add event handler"); - RuntimeInfoErrorFactory.ThrowException(ret); + Log.Error(InformationErrorFactory.LogTag, "Interop failed to add event handler"); + InformationErrorFactory.ThrowException(ret); } } s_batteryIsCharging += value; @@ -583,11 +583,11 @@ namespace Tizen.System s_batteryIsCharging -= value; if (s_batteryIsCharging == null) { - int ret = Interop.RuntimeInfo.UnsetRuntimeInfoChangedCallback(ConvertKeyIfTvProduct(RuntimeInformationKey.BatteryIsCharging)); - if (ret != (int)RuntimeInfoError.None) + InformationError ret = Interop.RuntimeInfo.UnsetRuntimeInfoChangedCallback(ConvertKeyIfTvProduct(RuntimeInformationKey.BatteryIsCharging)); + if (ret != InformationError.None) { - Log.Error(RuntimeInfoErrorFactory.LogTag, "Interop failed to add event handler"); - RuntimeInfoErrorFactory.ThrowException(ret); + Log.Error(InformationErrorFactory.LogTag, "Interop failed to add event handler"); + InformationErrorFactory.ThrowException(ret); } } } @@ -601,11 +601,11 @@ namespace Tizen.System { if (s_tvOutConnected == null) { - int ret = Interop.RuntimeInfo.SetRuntimeInfoChangedCallback(ConvertKeyIfTvProduct(RuntimeInformationKey.TvOut), s_runtimeInfoChangedCallback, IntPtr.Zero); - if (ret != (int)RuntimeInfoError.None) + InformationError ret = Interop.RuntimeInfo.SetRuntimeInfoChangedCallback(ConvertKeyIfTvProduct(RuntimeInformationKey.TvOut), s_runtimeInfoChangedCallback, IntPtr.Zero); + if (ret != InformationError.None) { - Log.Error(RuntimeInfoErrorFactory.LogTag, "Interop failed to add event handler"); - RuntimeInfoErrorFactory.ThrowException(ret); + Log.Error(InformationErrorFactory.LogTag, "Interop failed to add event handler"); + InformationErrorFactory.ThrowException(ret); } } s_tvOutConnected += value; @@ -615,11 +615,11 @@ namespace Tizen.System s_tvOutConnected -= value; if (s_tvOutConnected == null) { - int ret = Interop.RuntimeInfo.UnsetRuntimeInfoChangedCallback(ConvertKeyIfTvProduct(RuntimeInformationKey.TvOut)); - if (ret != (int)RuntimeInfoError.None) + InformationError ret = Interop.RuntimeInfo.UnsetRuntimeInfoChangedCallback(ConvertKeyIfTvProduct(RuntimeInformationKey.TvOut)); + if (ret != InformationError.None) { - Log.Error(RuntimeInfoErrorFactory.LogTag, "Interop failed to add event handler"); - RuntimeInfoErrorFactory.ThrowException(ret); + Log.Error(InformationErrorFactory.LogTag, "Interop failed to add event handler"); + InformationErrorFactory.ThrowException(ret); } } } @@ -633,11 +633,11 @@ namespace Tizen.System { if (s_audioJackConnectorChanged == null) { - int ret = Interop.RuntimeInfo.SetRuntimeInfoChangedCallback(ConvertKeyIfTvProduct(RuntimeInformationKey.AudioJackConnector), s_runtimeInfoChangedCallback, IntPtr.Zero); - if (ret != (int)RuntimeInfoError.None) + InformationError ret = Interop.RuntimeInfo.SetRuntimeInfoChangedCallback(ConvertKeyIfTvProduct(RuntimeInformationKey.AudioJackConnector), s_runtimeInfoChangedCallback, IntPtr.Zero); + if (ret != InformationError.None) { - Log.Error(RuntimeInfoErrorFactory.LogTag, "Interop failed to add event handler"); - RuntimeInfoErrorFactory.ThrowException(ret); + Log.Error(InformationErrorFactory.LogTag, "Interop failed to add event handler"); + InformationErrorFactory.ThrowException(ret); } } s_audioJackConnectorChanged += value; @@ -647,11 +647,11 @@ namespace Tizen.System s_audioJackConnectorChanged -= value; if (s_audioJackConnectorChanged == null) { - int ret = Interop.RuntimeInfo.UnsetRuntimeInfoChangedCallback(ConvertKeyIfTvProduct(RuntimeInformationKey.AudioJackConnector)); - if (ret != (int)RuntimeInfoError.None) + InformationError ret = Interop.RuntimeInfo.UnsetRuntimeInfoChangedCallback(ConvertKeyIfTvProduct(RuntimeInformationKey.AudioJackConnector)); + if (ret != InformationError.None) { - Log.Error(RuntimeInfoErrorFactory.LogTag, "Interop failed to add event handler"); - RuntimeInfoErrorFactory.ThrowException(ret); + Log.Error(InformationErrorFactory.LogTag, "Interop failed to add event handler"); + InformationErrorFactory.ThrowException(ret); } } } @@ -665,11 +665,11 @@ namespace Tizen.System { if (s_chargerConnected == null) { - int ret = Interop.RuntimeInfo.SetRuntimeInfoChangedCallback(ConvertKeyIfTvProduct(RuntimeInformationKey.Charger), s_runtimeInfoChangedCallback, IntPtr.Zero); - if (ret != (int)RuntimeInfoError.None) + InformationError ret = Interop.RuntimeInfo.SetRuntimeInfoChangedCallback(ConvertKeyIfTvProduct(RuntimeInformationKey.Charger), s_runtimeInfoChangedCallback, IntPtr.Zero); + if (ret != InformationError.None) { - Log.Error(RuntimeInfoErrorFactory.LogTag, "Interop failed to add event handler"); - RuntimeInfoErrorFactory.ThrowException(ret); + Log.Error(InformationErrorFactory.LogTag, "Interop failed to add event handler"); + InformationErrorFactory.ThrowException(ret); } } s_chargerConnected += value; @@ -679,11 +679,11 @@ namespace Tizen.System s_chargerConnected -= value; if (s_chargerConnected == null) { - int ret = Interop.RuntimeInfo.UnsetRuntimeInfoChangedCallback(ConvertKeyIfTvProduct(RuntimeInformationKey.Charger)); - if (ret != (int)RuntimeInfoError.None) + InformationError ret = Interop.RuntimeInfo.UnsetRuntimeInfoChangedCallback(ConvertKeyIfTvProduct(RuntimeInformationKey.Charger)); + if (ret != InformationError.None) { - Log.Error(RuntimeInfoErrorFactory.LogTag, "Interop failed to add event handler"); - RuntimeInfoErrorFactory.ThrowException(ret); + Log.Error(InformationErrorFactory.LogTag, "Interop failed to add event handler"); + InformationErrorFactory.ThrowException(ret); } } } @@ -697,11 +697,11 @@ namespace Tizen.System { if (s_autoRotationEnabled == null) { - int ret = Interop.RuntimeInfo.SetRuntimeInfoChangedCallback(ConvertKeyIfTvProduct(RuntimeInformationKey.AutoRotation), s_runtimeInfoChangedCallback, IntPtr.Zero); - if (ret != (int)RuntimeInfoError.None) + InformationError ret = Interop.RuntimeInfo.SetRuntimeInfoChangedCallback(ConvertKeyIfTvProduct(RuntimeInformationKey.AutoRotation), s_runtimeInfoChangedCallback, IntPtr.Zero); + if (ret != InformationError.None) { - Log.Error(RuntimeInfoErrorFactory.LogTag, "Interop failed to add event handler"); - RuntimeInfoErrorFactory.ThrowException(ret); + Log.Error(InformationErrorFactory.LogTag, "Interop failed to add event handler"); + InformationErrorFactory.ThrowException(ret); } } s_autoRotationEnabled += value; @@ -711,11 +711,11 @@ namespace Tizen.System s_autoRotationEnabled -= value; if (s_autoRotationEnabled == null) { - int ret = Interop.RuntimeInfo.UnsetRuntimeInfoChangedCallback(ConvertKeyIfTvProduct(RuntimeInformationKey.AutoRotation)); - if (ret != (int)RuntimeInfoError.None) + InformationError ret = Interop.RuntimeInfo.UnsetRuntimeInfoChangedCallback(ConvertKeyIfTvProduct(RuntimeInformationKey.AutoRotation)); + if (ret != InformationError.None) { - Log.Error(RuntimeInfoErrorFactory.LogTag, "Interop failed to add event handler"); - RuntimeInfoErrorFactory.ThrowException(ret); + Log.Error(InformationErrorFactory.LogTag, "Interop failed to add event handler"); + InformationErrorFactory.ThrowException(ret); } } } diff --git a/src/Tizen.System.Information/SystemInfo/SystemInfo.cs b/src/Tizen.System.Information/SystemInfo/SystemInfo.cs index b551c1b..5f410e7 100755 --- a/src/Tizen.System.Information/SystemInfo/SystemInfo.cs +++ b/src/Tizen.System.Information/SystemInfo/SystemInfo.cs @@ -24,25 +24,23 @@ namespace Tizen.System /// public static class SystemInfo { - private const string LogTag = "Tizen.System"; - [EditorBrowsable(EditorBrowsableState.Never)] private static Interop.SystemInfo.SystemInfoType GetValueType(string key, out Interop.SystemInfo.SystemInfoValueType valueType) { - Interop.SystemInfo.ErrorCode err = Interop.SystemInfo.SystemInfoGetPlatformType(key, out valueType); - if (err == Interop.SystemInfo.ErrorCode.None) + InformationError err = Interop.SystemInfo.SystemInfoGetPlatformType(key, out valueType); + if (err == InformationError.None) { return Interop.SystemInfo.SystemInfoType.platform; } - Log.Debug(LogTag, string.Format("Key {0} not in platform system info", key)); + Log.Debug(InformationErrorFactory.LogTag, string.Format("Key {0} not in platform system info", key)); err = Interop.SystemInfo.SystemInfoGetCustomType(key, out valueType); - if (err == Interop.SystemInfo.ErrorCode.None) + if (err == InformationError.None) { return Interop.SystemInfo.SystemInfoType.Custom; } - Log.Debug(LogTag, string.Format("Key {0} not in custom system info", key)); + Log.Debug(InformationErrorFactory.LogTag, string.Format("Key {0} not in custom system info", key)); return Interop.SystemInfo.SystemInfoType.None; } @@ -142,7 +140,7 @@ namespace Tizen.System Interop.SystemInfo.SystemInfoValueType valueType; Interop.SystemInfo.SystemInfoType keyType = GetValueType(key, out valueType); - Interop.SystemInfo.ErrorCode err = Interop.SystemInfo.ErrorCode.InvalidParameter; + InformationError err = InformationError.InvalidParameter; if (keyType == Interop.SystemInfo.SystemInfoType.platform) { err = Interop.SystemInfo.SystemInfoGetPlatformBool(key, out value); @@ -155,9 +153,9 @@ namespace Tizen.System value = false; } - if (err != Interop.SystemInfo.ErrorCode.None) + if (err != InformationError.None) { - Log.Warn(LogTag, string.Format("Failed to get value for key: {0}. err = {1}", key, err)); + Log.Warn(InformationErrorFactory.LogTag, string.Format("Failed to get value for key: {0}. err = {1}", key, err)); return false; } @@ -176,7 +174,7 @@ namespace Tizen.System Interop.SystemInfo.SystemInfoValueType valueType; Interop.SystemInfo.SystemInfoType keyType = GetValueType(key, out valueType); - Interop.SystemInfo.ErrorCode err = Interop.SystemInfo.ErrorCode.InvalidParameter; + InformationError err = InformationError.InvalidParameter; if (keyType == Interop.SystemInfo.SystemInfoType.platform) { err = Interop.SystemInfo.SystemInfoGetPlatformInt(key, out value); @@ -190,9 +188,9 @@ namespace Tizen.System value = 0; } - if (err != Interop.SystemInfo.ErrorCode.None) + if (err != InformationError.None) { - Log.Warn(LogTag, string.Format("Failed to get value for key: {0}. err = {1}", key, err)); + Log.Warn(InformationErrorFactory.LogTag, string.Format("Failed to get value for key: {0}. err = {1}", key, err)); return false; } @@ -211,7 +209,7 @@ namespace Tizen.System Interop.SystemInfo.SystemInfoValueType valueType; Interop.SystemInfo.SystemInfoType keyType = GetValueType(key, out valueType); - Interop.SystemInfo.ErrorCode err = Interop.SystemInfo.ErrorCode.InvalidParameter; + InformationError err = InformationError.InvalidParameter; if (keyType == Interop.SystemInfo.SystemInfoType.platform) { err = Interop.SystemInfo.SystemInfoGetPlatformDouble(key, out value); @@ -225,9 +223,9 @@ namespace Tizen.System value = 0; } - if (err != Interop.SystemInfo.ErrorCode.None) + if (err != InformationError.None) { - Log.Warn(LogTag, string.Format("Failed to get value for key: {0}. err = {1}", key, err)); + Log.Warn(InformationErrorFactory.LogTag, string.Format("Failed to get value for key: {0}. err = {1}", key, err)); return false; } @@ -246,7 +244,7 @@ namespace Tizen.System Interop.SystemInfo.SystemInfoValueType valueType; Interop.SystemInfo.SystemInfoType keyType = GetValueType(key, out valueType); - Interop.SystemInfo.ErrorCode err = Interop.SystemInfo.ErrorCode.InvalidParameter; + InformationError err = InformationError.InvalidParameter; if (keyType == Interop.SystemInfo.SystemInfoType.platform) { err = Interop.SystemInfo.SystemInfoGetPlatformString(key, out value); @@ -260,9 +258,9 @@ namespace Tizen.System value = string.Empty; } - if (err != Interop.SystemInfo.ErrorCode.None) + if (err != InformationError.None) { - Log.Warn(LogTag, string.Format("Failed to get value for key: {0}. err = {1}", key, err)); + Log.Warn(InformationErrorFactory.LogTag, string.Format("Failed to get value for key: {0}. err = {1}", key, err)); return false; } diff --git a/src/Tizen.System.Information/Usage/ProcessCpuUsage.cs b/src/Tizen.System.Information/Usage/ProcessCpuUsage.cs index b664c1b..75a579c 100755 --- a/src/Tizen.System.Information/Usage/ProcessCpuUsage.cs +++ b/src/Tizen.System.Information/Usage/ProcessCpuUsage.cs @@ -64,8 +64,8 @@ namespace Tizen.System if (pid == Pids[i]) return Usages[i].UTime; - Log.Error(RuntimeInfoErrorFactory.LogTag, "Invalid pid"); - RuntimeInfoErrorFactory.ThrowException((int)RuntimeInfoError.InvalidParameter); + Log.Error(InformationErrorFactory.LogTag, "Invalid pid"); + InformationErrorFactory.ThrowException(InformationError.InvalidParameter); return 0; } @@ -82,8 +82,8 @@ namespace Tizen.System if (pid == Pids[i]) return Usages[i].STime; - Log.Error(RuntimeInfoErrorFactory.LogTag, "Invalid pid"); - RuntimeInfoErrorFactory.ThrowException((int)RuntimeInfoError.InvalidParameter); + Log.Error(InformationErrorFactory.LogTag, "Invalid pid"); + InformationErrorFactory.ThrowException(InformationError.InvalidParameter); return 0; } @@ -99,17 +99,17 @@ namespace Tizen.System /// Thrown when the caller does not have privilege to use this method. public void Update(IEnumerable pid) { - int ret; + InformationError ret; Pids = pid.ToArray(); IntPtr ptr = new IntPtr(); Count = Pids.Count(); ret = Interop.RuntimeInfo.GetProcessCpuUsage(Pids, Count, ref ptr); - if (ret != (int)RuntimeInfoError.None) + if (ret != InformationError.None) { - Log.Error(RuntimeInfoErrorFactory.LogTag, "Interop failed to get Process cpu usage"); - RuntimeInfoErrorFactory.ThrowException(ret); + Log.Error(InformationErrorFactory.LogTag, "Interop failed to get Process cpu usage"); + InformationErrorFactory.ThrowException(ret); } Usages = new Interop.RuntimeInfo.ProcessCpuUsage[Count]; diff --git a/src/Tizen.System.Information/Usage/ProcessMemoryUsage.cs b/src/Tizen.System.Information/Usage/ProcessMemoryUsage.cs index b1bd7d6..c10c8c9 100755 --- a/src/Tizen.System.Information/Usage/ProcessMemoryUsage.cs +++ b/src/Tizen.System.Information/Usage/ProcessMemoryUsage.cs @@ -64,8 +64,8 @@ namespace Tizen.System if (pid == Pids[i]) return Usages[i].Vsz; - Log.Error(RuntimeInfoErrorFactory.LogTag, "Invalid pid"); - RuntimeInfoErrorFactory.ThrowException((int)RuntimeInfoError.InvalidParameter); + Log.Error(InformationErrorFactory.LogTag, "Invalid pid"); + InformationErrorFactory.ThrowException(InformationError.InvalidParameter); return 0; } @@ -82,8 +82,8 @@ namespace Tizen.System if (pid == Pids[i]) return Usages[i].Rss; - Log.Error(RuntimeInfoErrorFactory.LogTag, "Invalid pid"); - RuntimeInfoErrorFactory.ThrowException((int)RuntimeInfoError.InvalidParameter); + Log.Error(InformationErrorFactory.LogTag, "Invalid pid"); + InformationErrorFactory.ThrowException(InformationError.InvalidParameter); return 0; } @@ -100,8 +100,8 @@ namespace Tizen.System if (pid == Pids[i]) return Usages[i].Pss; - Log.Error(RuntimeInfoErrorFactory.LogTag, "Invalid pid"); - RuntimeInfoErrorFactory.ThrowException((int)RuntimeInfoError.InvalidParameter); + Log.Error(InformationErrorFactory.LogTag, "Invalid pid"); + InformationErrorFactory.ThrowException(InformationError.InvalidParameter); return 0; } @@ -118,8 +118,8 @@ namespace Tizen.System if (pid == Pids[i]) return Usages[i].SharedClean; - Log.Error(RuntimeInfoErrorFactory.LogTag, "Invalid pid"); - RuntimeInfoErrorFactory.ThrowException((int)RuntimeInfoError.InvalidParameter); + Log.Error(InformationErrorFactory.LogTag, "Invalid pid"); + InformationErrorFactory.ThrowException(InformationError.InvalidParameter); return 0; } @@ -136,8 +136,8 @@ namespace Tizen.System if (pid == Pids[i]) return Usages[i].SharedDirty; - Log.Error(RuntimeInfoErrorFactory.LogTag, "Invalid pid"); - RuntimeInfoErrorFactory.ThrowException((int)RuntimeInfoError.InvalidParameter); + Log.Error(InformationErrorFactory.LogTag, "Invalid pid"); + InformationErrorFactory.ThrowException(InformationError.InvalidParameter); return 0; } @@ -154,8 +154,8 @@ namespace Tizen.System if (pid == Pids[i]) return Usages[i].PrivateClean; - Log.Error(RuntimeInfoErrorFactory.LogTag, "Invalid pid"); - RuntimeInfoErrorFactory.ThrowException((int)RuntimeInfoError.InvalidParameter); + Log.Error(InformationErrorFactory.LogTag, "Invalid pid"); + InformationErrorFactory.ThrowException(InformationError.InvalidParameter); return 0; } @@ -172,8 +172,8 @@ namespace Tizen.System if (pid == Pids[i]) return Usages[i].PrivateDirty; - Log.Error(RuntimeInfoErrorFactory.LogTag, "Invalid pid"); - RuntimeInfoErrorFactory.ThrowException((int)RuntimeInfoError.InvalidParameter); + Log.Error(InformationErrorFactory.LogTag, "Invalid pid"); + InformationErrorFactory.ThrowException(InformationError.InvalidParameter); return 0; } @@ -189,17 +189,17 @@ namespace Tizen.System /// Thrown when the caller does not have privilege to use this method. public void Update(IEnumerable pid) { - int ret; + InformationError ret; Pids = pid.ToArray(); IntPtr ptr = new IntPtr(); Count = Pids.Count(); ret = Interop.RuntimeInfo.GetProcessMemoryInfo(Pids, Count, ref ptr); - if (ret != (int)RuntimeInfoError.None) + if (ret != InformationError.None) { - Log.Error(RuntimeInfoErrorFactory.LogTag, "Interop failed to get Process cpu usage"); - RuntimeInfoErrorFactory.ThrowException(ret); + Log.Error(InformationErrorFactory.LogTag, "Interop failed to get Process cpu usage"); + InformationErrorFactory.ThrowException(ret); } Usages = new Interop.RuntimeInfo.ProcessMemoryInfo[Count]; diff --git a/src/Tizen.System.Information/Usage/SystemCpuUsage.cs b/src/Tizen.System.Information/Usage/SystemCpuUsage.cs index 32d007a..5573e0e 100755 --- a/src/Tizen.System.Information/Usage/SystemCpuUsage.cs +++ b/src/Tizen.System.Information/Usage/SystemCpuUsage.cs @@ -104,8 +104,8 @@ namespace Tizen.System { if(coreId < 0 || coreId >= ProcessorCount) { - Log.Error(RuntimeInfoErrorFactory.LogTag, "Invalid core ID " + coreId); - RuntimeInfoErrorFactory.ThrowException((int)RuntimeInfoError.InvalidParameter); + Log.Error(InformationErrorFactory.LogTag, "Invalid core ID " + coreId); + InformationErrorFactory.ThrowException(InformationError.InvalidParameter); } return CurrentFrequencies[coreId]; @@ -122,8 +122,8 @@ namespace Tizen.System { if (coreId < 0 || coreId >= ProcessorCount) { - Log.Error(RuntimeInfoErrorFactory.LogTag, "Invalid core ID " + coreId); - RuntimeInfoErrorFactory.ThrowException((int)RuntimeInfoError.InvalidParameter); + Log.Error(InformationErrorFactory.LogTag, "Invalid core ID " + coreId); + InformationErrorFactory.ThrowException(InformationError.InvalidParameter); } return MaxFrequencies[coreId]; @@ -137,21 +137,21 @@ namespace Tizen.System /// Thrown when this system does not store the current CPU frequency. public void Update() { - int ret; + InformationError ret; int count; ret = Interop.RuntimeInfo.GetCpuUsage(out Usage); - if (ret != (int)RuntimeInfoError.None) + if (ret != InformationError.None) { - Log.Error(RuntimeInfoErrorFactory.LogTag, "Interop failed to get cpu usage"); - RuntimeInfoErrorFactory.ThrowException(ret); + Log.Error(InformationErrorFactory.LogTag, "Interop failed to get cpu usage"); + InformationErrorFactory.ThrowException(ret); } ret = Interop.RuntimeInfo.GetProcessorCount(out count); - if (ret != (int)RuntimeInfoError.None) + if (ret != InformationError.None) { - Log.Error(RuntimeInfoErrorFactory.LogTag, "Interop failed to get Processor count"); - RuntimeInfoErrorFactory.ThrowException(ret); + Log.Error(InformationErrorFactory.LogTag, "Interop failed to get Processor count"); + InformationErrorFactory.ThrowException(ret); return; } @@ -162,17 +162,17 @@ namespace Tizen.System for (int coreId = 0; coreId < ProcessorCount; coreId++) { ret = Interop.RuntimeInfo.GetProcessorCurrentFrequency(coreId, out CurrentFrequencies[coreId]); - if (ret != (int)RuntimeInfoError.None) + if (ret != InformationError.None) { - Log.Error(RuntimeInfoErrorFactory.LogTag, "Interop failed to get the current frequency of processor " + coreId); - RuntimeInfoErrorFactory.ThrowException(ret); + Log.Error(InformationErrorFactory.LogTag, "Interop failed to get the current frequency of processor " + coreId); + InformationErrorFactory.ThrowException(ret); } ret = Interop.RuntimeInfo.GetProcessorMaxFrequency(coreId, out MaxFrequencies[coreId]); - if (ret != (int)RuntimeInfoError.None) + if (ret != InformationError.None) { - Log.Error(RuntimeInfoErrorFactory.LogTag, "Interop failed to get the max frequency of processor " + coreId); - RuntimeInfoErrorFactory.ThrowException(ret); + Log.Error(InformationErrorFactory.LogTag, "Interop failed to get the max frequency of processor " + coreId); + InformationErrorFactory.ThrowException(ret); } } } diff --git a/src/Tizen.System.Information/Usage/SystemMemoryUsage.cs b/src/Tizen.System.Information/Usage/SystemMemoryUsage.cs index 4c6f718..f7508ae 100755 --- a/src/Tizen.System.Information/Usage/SystemMemoryUsage.cs +++ b/src/Tizen.System.Information/Usage/SystemMemoryUsage.cs @@ -102,11 +102,11 @@ namespace Tizen.System /// Thrown when I/O error occurs while reading from the system. public void Update() { - int ret = Interop.RuntimeInfo.GetSystemMemoryInfo(out Info); - if (ret != (int)RuntimeInfoError.None) + InformationError ret = Interop.RuntimeInfo.GetSystemMemoryInfo(out Info); + if (ret != InformationError.None) { - Log.Error(RuntimeInfoErrorFactory.LogTag, "Interop failed to get System memory information"); - RuntimeInfoErrorFactory.ThrowException(ret); + Log.Error(InformationErrorFactory.LogTag, "Interop failed to get System memory information"); + InformationErrorFactory.ThrowException(ret); } } } -- 2.7.4