From: chleun-moon <32117100+chleun-moon@users.noreply.github.com> Date: Tue, 13 Mar 2018 09:52:11 +0000 (+0900) Subject: Revert "[Connection][WiFi] Handling exception for event and async methods (#155)... X-Git-Tag: 4.0.1.14111^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=fd9f96e3df679a9af8de11d8b227dfa33ff4cf80;p=platform%2Fcore%2Fcsapi%2Ftizenfx.git Revert "[Connection][WiFi] Handling exception for event and async methods (#155)" (#157) This reverts commit 0beeb74bff3ba91267f4a301201d7e2fc2402d65. --- diff --git a/src/Tizen.Network.Connection/Tizen.Network.Connection/ConnectionInternalManager.cs b/src/Tizen.Network.Connection/Tizen.Network.Connection/ConnectionInternalManager.cs index 7f3718ad4..91e9fe115 100755 --- a/src/Tizen.Network.Connection/Tizen.Network.Connection/ConnectionInternalManager.cs +++ b/src/Tizen.Network.Connection/Tizen.Network.Connection/ConnectionInternalManager.cs @@ -18,10 +18,10 @@ using System; using System.Collections.Generic; using System.Linq; using System.Text; +using System.Threading; using System.Threading.Tasks; using System.Runtime.InteropServices; using System.Collections; -using System.Threading; using Tizen.Applications; namespace Tizen.Network.Connection @@ -34,6 +34,7 @@ namespace Tizen.Network.Connection public HandleHolder() { _tid = Thread.CurrentThread.ManagedThreadId; + Log.Info(Globals.LogTag, "PInvoke connection_create for Thread " + _tid); int ret = Interop.Connection.Create(_tid, out Handle); Log.Info(Globals.LogTag, "Handle: " + Handle); @@ -122,15 +123,7 @@ namespace Tizen.Network.Connection { if (_ConnectionTypeChanged == null) { - try - { - ConnectionTypeChangedStart(); - } - catch (Exception e) - { - Log.Error(Globals.LogTag, "Exception on adding ConnectionTypeChanged\n" + e.ToString()); - return; - } + ConnectionTypeChangedStart(); } _ConnectionTypeChanged += value; }, null); @@ -142,14 +135,7 @@ namespace Tizen.Network.Connection _ConnectionTypeChanged -= value; if (_ConnectionTypeChanged == null) { - try - { - ConnectionTypeChangedStop(); - } - catch (Exception e) - { - Log.Error(Globals.LogTag, "Exception on removing ConnectionTypeChanged\n" + e.ToString()); - } + ConnectionTypeChangedStop(); } }, null); } @@ -193,15 +179,7 @@ namespace Tizen.Network.Connection { if (_EthernetCableStateChanged == null) { - try - { - EthernetCableStateChangedStart(); - } - catch (Exception e) - { - Log.Error(Globals.LogTag, "Exception on adding EthernetCableStateChanged\n" + e.ToString()); - return; - } + EthernetCableStateChangedStart(); } _EthernetCableStateChanged += value; }, null); @@ -213,14 +191,7 @@ namespace Tizen.Network.Connection _EthernetCableStateChanged -= value; if (_EthernetCableStateChanged == null) { - try - { - EthernetCableStateChangedStop(); - } - catch (Exception e) - { - Log.Error(Globals.LogTag, "Exception on removing EthernetCableStateChanged\n" + e.ToString()); - } + EthernetCableStateChangedStop(); } }, null); } @@ -268,15 +239,7 @@ namespace Tizen.Network.Connection { if (_IPAddressChanged == null) { - try - { - IPAddressChangedStart(); - } - catch (Exception e) - { - Log.Error(Globals.LogTag, "Exception on adding IPAddressChanged\n" + e.ToString()); - return; - } + IPAddressChangedStart(); } _IPAddressChanged += value; }, null); @@ -289,14 +252,7 @@ namespace Tizen.Network.Connection _IPAddressChanged -= value; if (_IPAddressChanged == null) { - try - { - IPAddressChangedStop(); - } - catch (Exception e) - { - Log.Error(Globals.LogTag, "Exception on removing IPAddressChanged\n" + e.ToString()); - } + IPAddressChangedStop(); } }, null); } @@ -344,15 +300,7 @@ namespace Tizen.Network.Connection { if (_ProxyAddressChanged == null) { - try - { - ProxyAddressChangedStart(); - } - catch (Exception e) - { - Log.Error(Globals.LogTag, "Exception on adding ProxyAddressChanged\n" + e.ToString()); - return; - } + ProxyAddressChangedStart(); } _ProxyAddressChanged += value; }, null); @@ -364,14 +312,7 @@ namespace Tizen.Network.Connection _ProxyAddressChanged -= value; if (_ProxyAddressChanged == null) { - try - { - ProxyAddressChangedStop(); - } - catch (Exception e) - { - Log.Error(Globals.LogTag, "Exception on removing ProxyAddressChanged\n" + e.ToString()); - } + ProxyAddressChangedStop(); } }, null); } @@ -880,21 +821,13 @@ namespace Tizen.Network.Connection context.Post((x) => { Log.Info(Globals.LogTag, "Interop.Connection.SetDefaultCellularServiceProfileAsync " + profile.Name); - try - { - int ret = Interop.Connection.SetDefaultCellularServiceProfileAsync(GetHandle(), (int)type, profile.ProfileHandle, Callback, (IntPtr)0); - - if ((ConnectionError)ret != ConnectionError.None) - { - Log.Error(Globals.LogTag, "It failed to set default cellular profile, " + (ConnectionError)ret); - ConnectionErrorFactory.CheckFeatureUnsupportedException(ret, "http://tizen.org/feature/network.telephony"); - ConnectionErrorFactory.CheckHandleNullException(ret, (GetHandle() == IntPtr.Zero || profile.ProfileHandle == IntPtr.Zero), "Connection or Profile Handle may have been disposed or released"); - ConnectionErrorFactory.ThrowConnectionException(ret); - } - } catch (Exception e) + int ret = Interop.Connection.SetDefaultCellularServiceProfileAsync(GetHandle(), (int)type, profile.ProfileHandle, Callback, (IntPtr)0); + if ((ConnectionError)ret != ConnectionError.None) { - Log.Error(Globals.LogTag, "Exception on SetDefaultCellularServiceProfileAsync\n" + e.ToString()); - task.SetException(e); + Log.Error(Globals.LogTag, "It failed to set default cellular profile, " + (ConnectionError)ret); + ConnectionErrorFactory.CheckFeatureUnsupportedException(ret, "http://tizen.org/feature/network.telephony"); + ConnectionErrorFactory.CheckHandleNullException(ret, (GetHandle() == IntPtr.Zero || profile.ProfileHandle == IntPtr.Zero), "Connection or Profile Handle may have been disposed or released"); + ConnectionErrorFactory.ThrowConnectionException(ret); } }, null); @@ -978,21 +911,13 @@ namespace Tizen.Network.Connection context.Post((x) => { Log.Info(Globals.LogTag, "Interop.Connection.OpenProfile " + profile.Name); - try - { - int ret = Interop.Connection.OpenProfile(GetHandle(), profile.ProfileHandle, Callback, IntPtr.Zero); - if ((ConnectionError)ret != ConnectionError.None) - { - Log.Error(Globals.LogTag, "It failed to connect profile, " + (ConnectionError)ret); - ConnectionErrorFactory.CheckFeatureUnsupportedException(ret, "http://tizen.org/feature/network.telephony " + "http://tizen.org/feature/network.wifi " + "http://tizen.org/feature/network.tethering.bluetooth"); - ConnectionErrorFactory.CheckHandleNullException(ret, (GetHandle() == IntPtr.Zero || profile.ProfileHandle == IntPtr.Zero), "Connection or Profile Handle may have been disposed or released"); - ConnectionErrorFactory.ThrowConnectionException(ret); - } - } - catch (Exception e) + int ret = Interop.Connection.OpenProfile(GetHandle(), profile.ProfileHandle, Callback, IntPtr.Zero); + if ((ConnectionError)ret != ConnectionError.None) { - Log.Error(Globals.LogTag, "Exception on OpenProfile\n" + e.ToString()); - task.SetException(e); + Log.Error(Globals.LogTag, "It failed to connect profile, " + (ConnectionError)ret); + ConnectionErrorFactory.CheckFeatureUnsupportedException(ret, "http://tizen.org/feature/network.telephony " + "http://tizen.org/feature/network.wifi " + "http://tizen.org/feature/network.tethering.bluetooth"); + ConnectionErrorFactory.CheckHandleNullException(ret, (GetHandle() == IntPtr.Zero || profile.ProfileHandle == IntPtr.Zero), "Connection or Profile Handle may have been disposed or released"); + ConnectionErrorFactory.ThrowConnectionException(ret); } }, null); @@ -1029,22 +954,14 @@ namespace Tizen.Network.Connection context.Post((x) => { Log.Info(Globals.LogTag, "Interop.Connection.CloseProfile " + profile.Name); - try - { - int ret = Interop.Connection.CloseProfile(GetHandle(), profile.ProfileHandle, Callback, IntPtr.Zero); - if ((ConnectionError)ret != ConnectionError.None) - { - Log.Error(Globals.LogTag, "It failed to disconnect profile, " + (ConnectionError)ret); - ConnectionErrorFactory.CheckFeatureUnsupportedException(ret, "http://tizen.org/feature/network.telephony " + "http://tizen.org/feature/network.wifi " + "http://tizen.org/feature/network.tethering.bluetooth"); - ConnectionErrorFactory.CheckPermissionDeniedException(ret, "(http://tizen.org/privilege/network.set)"); - ConnectionErrorFactory.CheckHandleNullException(ret, (GetHandle() == IntPtr.Zero || profile.ProfileHandle == IntPtr.Zero), "Connection or Profile Handle may have been disposed or released"); - ConnectionErrorFactory.ThrowConnectionException(ret); - } - } - catch (Exception e) + int ret = Interop.Connection.CloseProfile(GetHandle(), profile.ProfileHandle, Callback, IntPtr.Zero); + if ((ConnectionError)ret != ConnectionError.None) { - Log.Error(Globals.LogTag, "Exception on CloseProfile\n" + e.ToString()); - task.SetException(e); + Log.Error(Globals.LogTag, "It failed to disconnect profile, " + (ConnectionError)ret); + ConnectionErrorFactory.CheckFeatureUnsupportedException(ret, "http://tizen.org/feature/network.telephony " + "http://tizen.org/feature/network.wifi " + "http://tizen.org/feature/network.tethering.bluetooth"); + ConnectionErrorFactory.CheckPermissionDeniedException(ret, "(http://tizen.org/privilege/network.set)"); + ConnectionErrorFactory.CheckHandleNullException(ret, (GetHandle() == IntPtr.Zero || profile.ProfileHandle == IntPtr.Zero), "Connection or Profile Handle may have been disposed or released"); + ConnectionErrorFactory.ThrowConnectionException(ret); } }, null); diff --git a/src/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiAP.cs b/src/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiAP.cs index cc72ad680..24d8476cc 100755 --- a/src/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiAP.cs +++ b/src/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiAP.cs @@ -135,8 +135,11 @@ namespace Tizen.Network.WiFi if (_disposed) return; - Interop.WiFi.AP.Destroy(_apHandle); - _apHandle = IntPtr.Zero; + if (disposing) + { + Interop.WiFi.AP.Destroy(_apHandle); + _apHandle = IntPtr.Zero; + } _disposed = true; } @@ -246,19 +249,11 @@ namespace Tizen.Network.WiFi context.Post((x) => { Log.Info(Globals.LogTag, "Interop.WiFi.Connect"); - try - { - int ret = Interop.WiFi.Connect(WiFiManagerImpl.Instance.GetSafeHandle(), _apHandle, _callback_map[id], id); - if (ret != (int)WiFiError.None) - { - Log.Error(Globals.LogTag, "Failed to connect wifi, Error - " + (WiFiError)ret); - WiFiErrorFactory.ThrowWiFiException(ret, WiFiManagerImpl.Instance.GetSafeHandle().DangerousGetHandle(), _apHandle); - } - } - catch (Exception e) + int ret = Interop.WiFi.Connect(WiFiManagerImpl.Instance.GetSafeHandle(), _apHandle, _callback_map[id], id); + if (ret != (int)WiFiError.None) { - Log.Error(Globals.LogTag, "Exception on ConnectAsync\n" + e.ToString()); - task.SetException(e); + Log.Error(Globals.LogTag, "Failed to connect wifi, Error - " + (WiFiError)ret); + WiFiErrorFactory.ThrowWiFiException(ret, WiFiManagerImpl.Instance.GetSafeHandle().DangerousGetHandle(), _apHandle); } }, null); @@ -315,41 +310,33 @@ namespace Tizen.Network.WiFi context.Post((x) => { - try + int ret = -1; + if (info.GetType() == typeof(WpsPbcInfo)) { - int ret = -1; - if (info.GetType() == typeof(WpsPbcInfo)) - { - Log.Info(Globals.LogTag, "Interop.WiFi.ConnectByWpsPb"); - ret = Interop.WiFi.ConnectByWpsPbc(WiFiManagerImpl.Instance.GetSafeHandle(), _apHandle, _callback_map[id], id); - } - else if (info.GetType() == typeof(WpsPinInfo)) + Log.Info(Globals.LogTag, "Interop.WiFi.ConnectByWpsPb"); + ret = Interop.WiFi.ConnectByWpsPbc(WiFiManagerImpl.Instance.GetSafeHandle(), _apHandle, _callback_map[id], id); + } + else if (info.GetType() == typeof(WpsPinInfo)) + { + WpsPinInfo pinInfo = (WpsPinInfo)info; + if (pinInfo.GetWpsPin() == null) { - WpsPinInfo pinInfo = (WpsPinInfo)info; - if (pinInfo.GetWpsPin() == null) - { - throw new ArgumentNullException("Wps pin should not be null"); - } - - if (pinInfo.GetWpsPin().Length == 0 || pinInfo.GetWpsPin().Length > 8) - { - throw new ArgumentOutOfRangeException("Wps pin should not be empty or more than 7 characters"); - } - - Log.Info(Globals.LogTag, "Interop.WiFi.ConnectByWpsPin"); - ret = Interop.WiFi.ConnectByWpsPin(WiFiManagerImpl.Instance.GetSafeHandle(), _apHandle, pinInfo.GetWpsPin(), _callback_map[id], id); + throw new ArgumentNullException("Wps pin should not be null"); } - if (ret != (int)WiFiError.None) + if (pinInfo.GetWpsPin().Length == 0 || pinInfo.GetWpsPin().Length > 8) { - Log.Error(Globals.LogTag, "Failed to connect wifi, Error - " + (WiFiError)ret); - WiFiErrorFactory.ThrowWiFiException(ret, WiFiManagerImpl.Instance.GetSafeHandle().DangerousGetHandle(), _apHandle); + throw new ArgumentOutOfRangeException("Wps pin should not be empty or more than 7 characters"); } + + Log.Info(Globals.LogTag, "Interop.WiFi.ConnectByWpsPin"); + ret = Interop.WiFi.ConnectByWpsPin(WiFiManagerImpl.Instance.GetSafeHandle(), _apHandle, pinInfo.GetWpsPin(), _callback_map[id], id); } - catch (Exception e) + + if (ret != (int)WiFiError.None) { - Log.Error(Globals.LogTag, "Exception on ConnectWpsAsync\n" + e.ToString()); - task.SetException(e); + Log.Error(Globals.LogTag, "Failed to connect wifi, Error - " + (WiFiError)ret); + WiFiErrorFactory.ThrowWiFiException(ret, WiFiManagerImpl.Instance.GetSafeHandle().DangerousGetHandle(), _apHandle); } }, null); @@ -406,41 +393,33 @@ namespace Tizen.Network.WiFi s_context.Post((x) => { - try + int ret = -1; + if (info.GetType() == typeof(WpsPbcInfo)) { - int ret = -1; - if (info.GetType() == typeof(WpsPbcInfo)) - { - Log.Info(Globals.LogTag, "Interop.WiFi.ConnectByWpsPbcWithoutSsid"); - ret = Interop.WiFi.ConnectByWpsPbcWithoutSsid(WiFiManagerImpl.Instance.GetSafeHandle(), s_callbackMap[id], id); - } - else if (info.GetType() == typeof(WpsPinInfo)) + Log.Info(Globals.LogTag, "Interop.WiFi.ConnectByWpsPbcWithoutSsid"); + ret = Interop.WiFi.ConnectByWpsPbcWithoutSsid(WiFiManagerImpl.Instance.GetSafeHandle(), s_callbackMap[id], id); + } + else if (info.GetType() == typeof(WpsPinInfo)) + { + WpsPinInfo pinInfo = (WpsPinInfo)info; + if (pinInfo.GetWpsPin() == null) { - WpsPinInfo pinInfo = (WpsPinInfo)info; - if (pinInfo.GetWpsPin() == null) - { - throw new ArgumentNullException("Wps pin should not be null"); - } - - if (pinInfo.GetWpsPin().Length != 4 && pinInfo.GetWpsPin().Length != 8) - { - throw new ArgumentOutOfRangeException("Wps pin should be of 4 or 8 characters long"); - } - - Log.Info(Globals.LogTag, "Interop.WiFi.ConnectByWpsPinWithoutSsid"); - ret = Interop.WiFi.ConnectByWpsPinWithoutSsid(WiFiManagerImpl.Instance.GetSafeHandle(), pinInfo.GetWpsPin(), s_callbackMap[id], id); + throw new ArgumentNullException("Wps pin should not be null"); } - if (ret != (int)WiFiError.None) + if (pinInfo.GetWpsPin().Length != 4 && pinInfo.GetWpsPin().Length != 8) { - Log.Error(Globals.LogTag, "Failed to connect wifi, Error - " + (WiFiError)ret); - WiFiErrorFactory.ThrowWiFiException(ret, WiFiManagerImpl.Instance.GetSafeHandle().DangerousGetHandle()); + throw new ArgumentOutOfRangeException("Wps pin should be of 4 or 8 characters long"); } + + Log.Info(Globals.LogTag, "Interop.WiFi.ConnectByWpsPinWithoutSsid"); + ret = Interop.WiFi.ConnectByWpsPinWithoutSsid(WiFiManagerImpl.Instance.GetSafeHandle(), pinInfo.GetWpsPin(), s_callbackMap[id], id); } - catch (Exception e) + + if (ret != (int)WiFiError.None) { - Log.Error(Globals.LogTag, "Exception on ConnectWpsWithoutSsidAsync\n" + e.ToString()); - task.SetException(e); + Log.Error(Globals.LogTag, "Failed to connect wifi, Error - " + (WiFiError)ret); + WiFiErrorFactory.ThrowWiFiException(ret, WiFiManagerImpl.Instance.GetSafeHandle().DangerousGetHandle()); } }, null); @@ -495,19 +474,11 @@ namespace Tizen.Network.WiFi context.Post((x) => { Log.Info(Globals.LogTag, "Interop.WiFi.Disconnect"); - try - { - int ret = Interop.WiFi.Disconnect(WiFiManagerImpl.Instance.GetSafeHandle(), _apHandle, _callback_map[id], id); - if (ret != (int)WiFiError.None) - { - Log.Error(Globals.LogTag, "Failed to disconnect wifi, Error - " + (WiFiError)ret); - WiFiErrorFactory.ThrowWiFiException(ret, WiFiManagerImpl.Instance.GetSafeHandle().DangerousGetHandle(), _apHandle); - } - } - catch (Exception e) + int ret = Interop.WiFi.Disconnect(WiFiManagerImpl.Instance.GetSafeHandle(), _apHandle, _callback_map[id], id); + if (ret != (int)WiFiError.None) { - Log.Error(Globals.LogTag, "Exception on Disconnect\n" + e.ToString()); - task.SetException(e); + Log.Error(Globals.LogTag, "Failed to disconnect wifi, Error - " + (WiFiError)ret); + WiFiErrorFactory.ThrowWiFiException(ret, WiFiManagerImpl.Instance.GetSafeHandle().DangerousGetHandle(), _apHandle); } }, null); diff --git a/src/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiConfiguration.cs b/src/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiConfiguration.cs index 1fd57bc05..ea34275e6 100755 --- a/src/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiConfiguration.cs +++ b/src/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiConfiguration.cs @@ -219,8 +219,11 @@ namespace Tizen.Network.WiFi if (_disposed) return; - Interop.WiFi.Config.Destroy(_configHandle); - _configHandle = IntPtr.Zero; + if (disposing) + { + Interop.WiFi.Config.Destroy(_configHandle); + _configHandle = IntPtr.Zero; + } _disposed = true; } diff --git a/src/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiManagerImpl.cs b/src/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiManagerImpl.cs index 0578f0169..9ac1150e0 100755 --- a/src/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiManagerImpl.cs +++ b/src/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiManagerImpl.cs @@ -314,19 +314,11 @@ namespace Tizen.Network.WiFi context.Post((x) => { Log.Info(Globals.LogTag, "Interop.WiFi.ActivateAsync"); - try - { - int ret = Interop.WiFi.Activate(GetSafeHandle(), _callback_map[id], id); - if (ret != (int)WiFiError.None) - { - Log.Error(Globals.LogTag, "Failed to activate wifi, Error - " + (WiFiError)ret); - WiFiErrorFactory.ThrowWiFiException(ret, GetSafeHandle().DangerousGetHandle()); - } - } - catch (Exception e) + int ret = Interop.WiFi.Activate(GetSafeHandle(), _callback_map[id], id); + if (ret != (int)WiFiError.None) { - Log.Error(Globals.LogTag, "Exception on ActivateAsync\n" + e.ToString()); - task.SetException(e); + Log.Error(Globals.LogTag, "Failed to activate wifi, Error - " + (WiFiError)ret); + WiFiErrorFactory.ThrowWiFiException(ret, GetSafeHandle().DangerousGetHandle()); } }, null); @@ -363,19 +355,11 @@ namespace Tizen.Network.WiFi context.Post((x) => { Log.Info(Globals.LogTag, "Interop.WiFi.ActivateWithWiFiPickerTestedAsync"); - try - { - int ret = Interop.WiFi.ActivateWithWiFiPickerTested(GetSafeHandle(), _callback_map[id], id); - if (ret != (int)WiFiError.None) - { - Log.Error(Globals.LogTag, "Failed to activate wifi, Error - " + (WiFiError)ret); - WiFiErrorFactory.ThrowWiFiException(ret, GetSafeHandle().DangerousGetHandle()); - } - } - catch (Exception e) + int ret = Interop.WiFi.ActivateWithWiFiPickerTested(GetSafeHandle(), _callback_map[id], id); + if (ret != (int)WiFiError.None) { - Log.Error(Globals.LogTag, "Exception on ActivateWithWiFiPickerTestedAsync\n" + e.ToString()); - task.SetException(e); + Log.Error(Globals.LogTag, "Failed to activate wifi, Error - " + (WiFiError)ret); + WiFiErrorFactory.ThrowWiFiException(ret, GetSafeHandle().DangerousGetHandle()); } }, null); @@ -412,19 +396,11 @@ namespace Tizen.Network.WiFi context.Post((x) => { Log.Info(Globals.LogTag, "Interop.WiFi.Deactivate"); - try - { - int ret = Interop.WiFi.Deactivate(GetSafeHandle(), _callback_map[id], id); - if (ret != (int)WiFiError.None) - { - Log.Error(Globals.LogTag, "Failed to deactivate wifi, Error - " + (WiFiError)ret); - WiFiErrorFactory.ThrowWiFiException(ret, GetSafeHandle().DangerousGetHandle()); - } - } - catch (Exception e) + int ret = Interop.WiFi.Deactivate(GetSafeHandle(), _callback_map[id], id); + if (ret != (int)WiFiError.None) { - Log.Error(Globals.LogTag, "Exception on Deactivate\n" + e.ToString()); - task.SetException(e); + Log.Error(Globals.LogTag, "Failed to deactivate wifi, Error - " + (WiFiError)ret); + WiFiErrorFactory.ThrowWiFiException(ret, GetSafeHandle().DangerousGetHandle()); } }, null); @@ -461,19 +437,11 @@ namespace Tizen.Network.WiFi context.Post((x) => { Log.Info(Globals.LogTag, "Interop.WiFi.Scan"); - try - { - int ret = Interop.WiFi.Scan(GetSafeHandle(), _callback_map[id], id); - if (ret != (int)WiFiError.None) - { - Log.Error(Globals.LogTag, "Failed to scan all AP, Error - " + (WiFiError)ret); - WiFiErrorFactory.ThrowWiFiException(ret, GetSafeHandle().DangerousGetHandle()); - } - } - catch (Exception e) + int ret = Interop.WiFi.Scan(GetSafeHandle(), _callback_map[id], id); + if (ret != (int)WiFiError.None) { - Log.Error(Globals.LogTag, "Exception on Scan\n" + e.ToString()); - task.SetException(e); + Log.Error(Globals.LogTag, "Failed to scan all AP, Error - " + (WiFiError)ret); + WiFiErrorFactory.ThrowWiFiException(ret, GetSafeHandle().DangerousGetHandle()); } }, null); @@ -510,19 +478,11 @@ namespace Tizen.Network.WiFi context.Post((x) => { Log.Info(Globals.LogTag, "Interop.WiFi.ScanSpecificAPAsync"); - try - { - int ret = Interop.WiFi.ScanSpecificAP(GetSafeHandle(), essid, _callback_map[id], id); - if (ret != (int)WiFiError.None) - { - Log.Error(Globals.LogTag, "Failed to scan with specific AP, Error - " + (WiFiError)ret); - WiFiErrorFactory.ThrowWiFiException(ret, GetSafeHandle().DangerousGetHandle()); - } - } - catch (Exception e) + int ret = Interop.WiFi.ScanSpecificAP(GetSafeHandle(), essid, _callback_map[id], id); + if (ret != (int)WiFiError.None) { - Log.Error(Globals.LogTag, "Exception on ScanSpecificAPAsync\n" + e.ToString()); - task.SetException(e); + Log.Error(Globals.LogTag, "Failed to scan with specific AP, Error - " + (WiFiError)ret); + WiFiErrorFactory.ThrowWiFiException(ret, GetSafeHandle().DangerousGetHandle()); } }, null); diff --git a/src/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiNetworkChange.cs b/src/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiNetworkChange.cs index 4c39c98d5..122c9050b 100755 --- a/src/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiNetworkChange.cs +++ b/src/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiNetworkChange.cs @@ -62,14 +62,7 @@ namespace Tizen.Network.WiFi { if (_deviceStateChanged == null) { - try - { - RegisterDeviceStateChangedEvent(); - } catch (Exception e) - { - Log.Error(Globals.LogTag, "Exception on adding DeviceStateChanged\n" + e.ToString()); - return; - } + RegisterDeviceStateChangedEvent(); } _deviceStateChanged += value; }, null); @@ -81,14 +74,7 @@ namespace Tizen.Network.WiFi _deviceStateChanged -= value; if (_deviceStateChanged == null) { - try - { - UnregisterDeviceStateChangedEvent(); - } - catch (Exception e) - { - Log.Error(Globals.LogTag, "Exception on removing DeviceStateChanged\n" + e.ToString()); - } + UnregisterDeviceStateChangedEvent(); } }, null); } @@ -102,15 +88,7 @@ namespace Tizen.Network.WiFi { if (_connectionStateChanged == null) { - try - { - RegisterConnectionStateChangedEvent(); - } - catch (Exception e) - { - Log.Error(Globals.LogTag, "Exception on adding ConnectionStateChanged\n" + e.ToString()); - return; - } + RegisterConnectionStateChangedEvent(); } _connectionStateChanged += value; }, null); @@ -122,14 +100,7 @@ namespace Tizen.Network.WiFi _connectionStateChanged -= value; if (_connectionStateChanged == null) { - try - { - UnregisterConnectionStateChangedEvent(); - } - catch (Exception e) - { - Log.Error(Globals.LogTag, "Exception on removing ConnectionStateChanged\n" + e.ToString()); - } + UnregisterConnectionStateChangedEvent(); } }, null); } @@ -143,15 +114,7 @@ namespace Tizen.Network.WiFi { if (_rssiLevelChanged == null) { - try - { - RegisterRssiLevelChangedEvent(); - } - catch (Exception e) - { - Log.Error(Globals.LogTag, "Exception on adding RssiLevelChanged\n" + e.ToString()); - return; - } + RegisterRssiLevelChangedEvent(); } _rssiLevelChanged += value; }, null); @@ -163,14 +126,7 @@ namespace Tizen.Network.WiFi _rssiLevelChanged -= value; if (_rssiLevelChanged == null) { - try - { - UnregisterRssiLevelChangedEvent(); - } - catch (Exception e) - { - Log.Error(Globals.LogTag, "Exception on removing RssiLevelChanged\n" + e.ToString()); - } + UnregisterRssiLevelChangedEvent(); } }, null); } @@ -184,15 +140,7 @@ namespace Tizen.Network.WiFi { if (_backgroundScanFinished == null) { - try - { - RegisterBackgroundScanFinishedEvent(); - } - catch (Exception e) - { - Log.Error(Globals.LogTag, "Exception on adding BackgroundScanFinished\n" + e.ToString()); - return; - } + RegisterBackgroundScanFinishedEvent(); } _backgroundScanFinished += value; }, null); @@ -204,14 +152,7 @@ namespace Tizen.Network.WiFi _backgroundScanFinished -= value; if (_backgroundScanFinished == null) { - try - { - UnregisterBackgroundScanFinishedEvent(); - } - catch (Exception e) - { - Log.Error(Globals.LogTag, "Exception on removing BackgroundScanFinished\n" + e.ToString()); - } + UnregisterBackgroundScanFinishedEvent(); } }, null); }