From 1d74bc525d0455706beab8c6bf7fa487c7e3cee5 Mon Sep 17 00:00:00 2001 From: Jihoon Jung Date: Thu, 5 Jan 2017 13:41:54 +0900 Subject: [PATCH] change for TC failed Change-Id: Ieb3c8158941d4ceb01fef4b05faec9b42dee39c7 --- .../Tizen.Network.Nfc/NfcCallbackData.cs | 8 ++ .../Tizen.Network.Nfc/NfcCardEmulationAdapter.cs | 86 +----------- .../Tizen.Network.Nfc/NfcErrorFactory.cs | 4 + .../Tizen.Network.Nfc/NfcEventArgs.cs | 4 +- .../Tizen.Network.Nfc/NfcManager.cs | 150 ++++++++++++++++++--- .../Tizen.Network.Nfc/NfcManagerImpl.cs | 1 - .../Tizen.Network.Nfc/NfcNdefMessage.cs | 37 ----- .../Tizen.Network.Nfc/NfcNdefRecord.cs | 14 +- 8 files changed, 154 insertions(+), 150 deletions(-) mode change 100644 => 100755 src/Tizen.Network.Nfc/Tizen.Network.Nfc/NfcNdefRecord.cs diff --git a/src/Tizen.Network.Nfc/Tizen.Network.Nfc/NfcCallbackData.cs b/src/Tizen.Network.Nfc/Tizen.Network.Nfc/NfcCallbackData.cs index b76a52e..a779aab 100644 --- a/src/Tizen.Network.Nfc/Tizen.Network.Nfc/NfcCallbackData.cs +++ b/src/Tizen.Network.Nfc/Tizen.Network.Nfc/NfcCallbackData.cs @@ -24,6 +24,10 @@ namespace Tizen.Network.Nfc /// public class NfcTagInformation { + internal NfcTagInformation() + { + + } /// /// Key value. /// @@ -39,6 +43,10 @@ namespace Tizen.Network.Nfc /// public class NfcRegisteredAidInformation { + internal NfcRegisteredAidInformation() + { + + } /// /// Secure Element Type value. /// diff --git a/src/Tizen.Network.Nfc/Tizen.Network.Nfc/NfcCardEmulationAdapter.cs b/src/Tizen.Network.Nfc/Tizen.Network.Nfc/NfcCardEmulationAdapter.cs index 23d7f3a..a9cef59 100644 --- a/src/Tizen.Network.Nfc/Tizen.Network.Nfc/NfcCardEmulationAdapter.cs +++ b/src/Tizen.Network.Nfc/Tizen.Network.Nfc/NfcCardEmulationAdapter.cs @@ -60,29 +60,6 @@ namespace Tizen.Network.Nfc } /// - /// Event that is called when receiving Secure Element(SIM/UICC(Universal Integrated Circuit Card)) transaction event for 'Disable' type. - /// - public event EventHandler DisableSecureElementTransactionEvent - { - add - { - if (_secureElementTransactionEvent == null) - { - RegisterSecureElementTransactionEvent(NfcSecureElementType.Disable); - } - _secureElementTransactionEvent += value; - } - remove - { - _secureElementTransactionEvent -= value; - if (_secureElementTransactionEvent == null) - { - UnregisterSecureElementTransactionEvent(NfcSecureElementType.Disable); - } - } - } - - /// /// Event that is called when receiving Secure Element(SIM/UICC(Universal Integrated Circuit Card)) transaction event for 'ESE(SmartMX)' type. /// public event EventHandler EseSecureElementTransactionEvent @@ -129,52 +106,6 @@ namespace Tizen.Network.Nfc } /// - /// Event that is called when receiving Secure Element(SIM/UICC(Universal Integrated Circuit Card)) transaction event for 'SDCard' type. - /// - public event EventHandler SdcardSecureElementTransactionEvent - { - add - { - if (_secureElementTransactionEvent == null) - { - RegisterSecureElementTransactionEvent(NfcSecureElementType.Sdcard); - } - _secureElementTransactionEvent += value; - } - remove - { - _secureElementTransactionEvent -= value; - if (_secureElementTransactionEvent == null) - { - UnregisterSecureElementTransactionEvent(NfcSecureElementType.Sdcard); - } - } - } - - /// - /// Event that is called when receiving Secure Element(SIM/UICC(Universal Integrated Circuit Card)) transaction event for 'HCE(Host based card emulation)' type. - /// - public event EventHandler HceSecureElementTransactionEvent - { - add - { - if (_secureElementTransactionEvent == null) - { - RegisterSecureElementTransactionEvent(NfcSecureElementType.Hce); - } - _secureElementTransactionEvent += value; - } - remove - { - _secureElementTransactionEvent -= value; - if (_secureElementTransactionEvent == null) - { - UnregisterSecureElementTransactionEvent(NfcSecureElementType.Hce); - } - } - } - - /// /// Event that is called when when receiving HCE(Host Card Emulation) event. /// public event EventHandler HostCardEmulationEvent @@ -294,22 +225,6 @@ namespace Tizen.Network.Nfc } /// - /// Set the default route for each device status. - /// - /// The type of default Secure Element when device is powered on. - /// The type of default Secure Element when device is powered off. - /// The type of default Secure Element when battery is low. - public void SetDefaultRoute(NfcSecureElementType seTypeInPoweredOn, NfcSecureElementType seTypeInPoweredOff, NfcSecureElementType seTypeInLowBattery) - { - int ret = Interop.Nfc.CardEmulation.SetDefaultRoute((int)seTypeInPoweredOn, (int)seTypeInPoweredOff, (int)seTypeInLowBattery); - if (ret != (int)NfcError.None) - { - Log.Error(Globals.LogTag, "Failed to set default route, Error - " + (NfcError)ret); - NfcErrorFactory.ThrowNfcException(ret); - } - } - - /// /// Gets the state whether an application to call this api is currently the activated handler for specific AID. /// /// 'True' when application is currently the activated handler, otherwise 'False'. @@ -497,6 +412,7 @@ namespace Tizen.Network.Nfc if (ret != (int)NfcError.None) { Log.Error(Globals.LogTag, "Failed to set host card emulation event callback, Error - " + (NfcError)ret); + NfcErrorFactory.ThrowNfcException(ret); } } diff --git a/src/Tizen.Network.Nfc/Tizen.Network.Nfc/NfcErrorFactory.cs b/src/Tizen.Network.Nfc/Tizen.Network.Nfc/NfcErrorFactory.cs index 6e148c9..8b3f9df 100644 --- a/src/Tizen.Network.Nfc/Tizen.Network.Nfc/NfcErrorFactory.cs +++ b/src/Tizen.Network.Nfc/Tizen.Network.Nfc/NfcErrorFactory.cs @@ -75,6 +75,10 @@ namespace Tizen.Network.Nfc { throw new ArgumentException(err.ToString()); } + else if (err == NfcError.NotSupportedError) + { + throw new NotSupportedException(); + } else { throw new InvalidOperationException(err.ToString()); diff --git a/src/Tizen.Network.Nfc/Tizen.Network.Nfc/NfcEventArgs.cs b/src/Tizen.Network.Nfc/Tizen.Network.Nfc/NfcEventArgs.cs index 015b0df..5aa93a2 100644 --- a/src/Tizen.Network.Nfc/Tizen.Network.Nfc/NfcEventArgs.cs +++ b/src/Tizen.Network.Nfc/Tizen.Network.Nfc/NfcEventArgs.cs @@ -106,7 +106,7 @@ namespace Tizen.Network.Nfc /// /// P2p object /// - public NfcP2p P2pTaget + public NfcP2p P2pTarget { get { @@ -240,7 +240,7 @@ namespace Tizen.Network.Nfc /// /// The Nfc hce event. /// - public NfcHceEvent HcdEvent + public NfcHceEvent HceEvent { get { diff --git a/src/Tizen.Network.Nfc/Tizen.Network.Nfc/NfcManager.cs b/src/Tizen.Network.Nfc/Tizen.Network.Nfc/NfcManager.cs index 57eca3d..b743fb5 100644 --- a/src/Tizen.Network.Nfc/Tizen.Network.Nfc/NfcManager.cs +++ b/src/Tizen.Network.Nfc/Tizen.Network.Nfc/NfcManager.cs @@ -33,7 +33,14 @@ namespace Tizen.Network.Nfc { get { - return NfcManagerImpl.Instance.IsSupported; + try + { + return NfcManagerImpl.Instance.IsSupported; + } + catch (TypeInitializationException) + { + return false; + } } } @@ -44,7 +51,14 @@ namespace Tizen.Network.Nfc { get { - return NfcManagerImpl.Instance.IsActivated; + try + { + return NfcManagerImpl.Instance.IsActivated; + } + catch (TypeInitializationException) + { + return false; + } } } @@ -55,11 +69,24 @@ namespace Tizen.Network.Nfc { get { - return NfcManagerImpl.Instance.TagFilterType; + try + { + return NfcManagerImpl.Instance.TagFilterType; + } + catch (TypeInitializationException) + { + return NfcTagFilterType.AllDisable; + } } set { - NfcManagerImpl.Instance.TagFilterType = value; + try + { + NfcManagerImpl.Instance.TagFilterType = value; + } + catch (TypeInitializationException) + { + } } } @@ -70,11 +97,24 @@ namespace Tizen.Network.Nfc { get { - return NfcManagerImpl.Instance.SecureElementType; + try + { + return NfcManagerImpl.Instance.SecureElementType; + } + catch (TypeInitializationException) + { + return NfcSecureElementType.Disable; + } } set { - NfcManagerImpl.Instance.SecureElementType = value; + try + { + NfcManagerImpl.Instance.SecureElementType = value; + } + catch (TypeInitializationException) + { + } } } @@ -85,11 +125,24 @@ namespace Tizen.Network.Nfc { get { - return NfcManagerImpl.Instance.SystemHandlerEnabled; + try + { + return NfcManagerImpl.Instance.SystemHandlerEnabled; + } + catch (TypeInitializationException) + { + return false; + } } set { - NfcManagerImpl.Instance.SystemHandlerEnabled = value; + try + { + NfcManagerImpl.Instance.SystemHandlerEnabled = value; + } + catch (TypeInitializationException) + { + } } } @@ -100,7 +153,14 @@ namespace Tizen.Network.Nfc { get { - return NfcManagerImpl.Instance.CachedNdefMessage; + try + { + return NfcManagerImpl.Instance.CachedNdefMessage; + } + catch (TypeInitializationException) + { + return null; + } } } @@ -109,7 +169,14 @@ namespace Tizen.Network.Nfc /// static public NfcTagAdapter GetTagAdapter() { - return NfcManagerImpl.Instance.TagAdapter; + try + { + return NfcManagerImpl.Instance.TagAdapter; + } + catch (TypeInitializationException e) + { + throw e.InnerException; + } } /// @@ -117,7 +184,14 @@ namespace Tizen.Network.Nfc /// static public NfcP2pAdapter GetP2pAdapter() { - return NfcManagerImpl.Instance.P2pAdapter; + try + { + return NfcManagerImpl.Instance.P2pAdapter; + } + catch (TypeInitializationException e) + { + throw e.InnerException; + } } /// @@ -125,7 +199,14 @@ namespace Tizen.Network.Nfc /// static public NfcCardEmulationAdapter GetCardEmulationAdapter() { - return NfcManagerImpl.Instance.CardEmulationAdapter; + try + { + return NfcManagerImpl.Instance.CardEmulationAdapter; + } + catch (TypeInitializationException e) + { + throw e.InnerException; + } } /// @@ -134,7 +215,14 @@ namespace Tizen.Network.Nfc /// A task indicates whether the Activate method is done or not. static public Task SetActivateAsync(bool activation) { - return NfcManagerImpl.Instance.SetActivateAsync(activation); + try + { + return NfcManagerImpl.Instance.SetActivateAsync(activation); + } + catch (TypeInitializationException e) + { + throw e.InnerException; + } } /// @@ -144,11 +232,25 @@ namespace Tizen.Network.Nfc { add { - NfcManagerImpl.Instance.ActivationChanged += value; + try + { + NfcManagerImpl.Instance.ActivationChanged += value; + } + catch (TypeInitializationException e) + { + throw e.InnerException; + } } remove { - NfcManagerImpl.Instance.ActivationChanged -= value; + try + { + NfcManagerImpl.Instance.ActivationChanged -= value; + } + catch (TypeInitializationException e) + { + throw e.InnerException; + } } } @@ -159,11 +261,25 @@ namespace Tizen.Network.Nfc { add { - NfcManagerImpl.Instance.NdefMessageDiscovered += value; + try + { + NfcManagerImpl.Instance.NdefMessageDiscovered += value; + } + catch (TypeInitializationException e) + { + throw e.InnerException; + } } remove { - NfcManagerImpl.Instance.NdefMessageDiscovered -= value; + try + { + NfcManagerImpl.Instance.NdefMessageDiscovered -= value; + } + catch (TypeInitializationException e) + { + throw e.InnerException; + } } } } diff --git a/src/Tizen.Network.Nfc/Tizen.Network.Nfc/NfcManagerImpl.cs b/src/Tizen.Network.Nfc/Tizen.Network.Nfc/NfcManagerImpl.cs index 238c0b6..68108a5 100644 --- a/src/Tizen.Network.Nfc/Tizen.Network.Nfc/NfcManagerImpl.cs +++ b/src/Tizen.Network.Nfc/Tizen.Network.Nfc/NfcManagerImpl.cs @@ -233,7 +233,6 @@ namespace Tizen.Network.Nfc if (ret != (int)NfcError.None) { Log.Error(Globals.LogTag, "Failed to deinitialize Nfc, Error - " + (NfcError)ret); - NfcErrorFactory.ThrowNfcException(ret); } } diff --git a/src/Tizen.Network.Nfc/Tizen.Network.Nfc/NfcNdefMessage.cs b/src/Tizen.Network.Nfc/Tizen.Network.Nfc/NfcNdefMessage.cs index 76891d9..727a097 100644 --- a/src/Tizen.Network.Nfc/Tizen.Network.Nfc/NfcNdefMessage.cs +++ b/src/Tizen.Network.Nfc/Tizen.Network.Nfc/NfcNdefMessage.cs @@ -47,26 +47,6 @@ namespace Tizen.Network.Nfc } /// - /// The serial bytes array of NDEF message. - /// - public byte[] Rawdata - { - get - { - IntPtr rawData; - uint rawDataSize; - int ret = Interop.Nfc.NdefMessage.GetRawData(_messageHandle, out rawData, out rawDataSize); - if (ret != (int)NfcError.None) - { - Log.Error(Globals.LogTag, "Failed to get rawdata, Error - " + (NfcError)ret); - return null; - } - - return NfcConvertUtil.UintLengthIntPtrToByteArray(rawData, rawDataSize); - } - } - - /// /// Creates a object for the access point. /// public NfcNdefMessage() @@ -80,22 +60,6 @@ namespace Tizen.Network.Nfc } } - /// - /// Creates NDEF message handle from raw serial bytes. - /// - /// The NDEF message in form of bytes array. - /// The size of bytes array. - public NfcNdefMessage(byte[] rawData, uint rawDataSize) - { - int ret = Interop.Nfc.NdefMessage.CreateRawData(out _messageHandle, rawData, rawDataSize); - - if (ret != (int)NfcError.None) - { - Log.Error(Globals.LogTag, "Failed to create Ndef Rawdata message, Error - " + (NfcError)ret); - NfcErrorFactory.ThrowNfcException(ret); - } - } - internal NfcNdefMessage(IntPtr messageHandle) { _messageHandle = messageHandle; @@ -108,7 +72,6 @@ namespace Tizen.Network.Nfc if (ret != (int)NfcError.None) { Log.Error(Globals.LogTag, "Failed to destroy ndef message, Error - " + (NfcError)ret); - NfcErrorFactory.ThrowNfcException(ret); } Dispose(false); diff --git a/src/Tizen.Network.Nfc/Tizen.Network.Nfc/NfcNdefRecord.cs b/src/Tizen.Network.Nfc/Tizen.Network.Nfc/NfcNdefRecord.cs old mode 100644 new mode 100755 index 10c2452..33e822e --- a/src/Tizen.Network.Nfc/Tizen.Network.Nfc/NfcNdefRecord.cs +++ b/src/Tizen.Network.Nfc/Tizen.Network.Nfc/NfcNdefRecord.cs @@ -268,14 +268,6 @@ namespace Tizen.Network.Nfc ~NfcNdefRecord() { - int ret = Interop.Nfc.NdefRecord.Destroy(_recordHandle); - - if (ret != (int)NfcError.None) - { - Log.Error(Globals.LogTag, "Failed to destroy ndef record, Error - " + (NfcError)ret); - NfcErrorFactory.ThrowNfcException(ret); - } - Dispose(false); } @@ -293,6 +285,12 @@ namespace Tizen.Network.Nfc if (disposing) { // Free managed objects. + int ret = Interop.Nfc.NdefRecord.Destroy(_recordHandle); + + if (ret != (int)NfcError.None) + { + Log.Error(Globals.LogTag, "Failed to destroy ndef record, Error - " + (NfcError)ret); + } } //Free unmanaged objects disposed = true; -- 2.7.4