summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJihoon Jung <jh8801.jung@samsung.com>2017-01-05 04:41:54 (GMT)
committerJihoon Jung <jh8801.jung@samsung.com>2017-01-05 09:00:22 (GMT)
commit611b603aafdb769e9dff3ac6cc2807df9fd48093 (patch)
tree83ec000300d1818b7b669562963d6c664a16ad27
parent7f1e8988b4982664f4356e44f090377a6c339b7d (diff)
downloadnfc-611b603aafdb769e9dff3ac6cc2807df9fd48093.zip
nfc-611b603aafdb769e9dff3ac6cc2807df9fd48093.tar.gz
nfc-611b603aafdb769e9dff3ac6cc2807df9fd48093.tar.bz2
Change-Id: Ieb3c8158941d4ceb01fef4b05faec9b42dee39c7
-rw-r--r--Tizen.Network.Nfc/Tizen.Network.Nfc/NfcCallbackData.cs8
-rw-r--r--Tizen.Network.Nfc/Tizen.Network.Nfc/NfcCardEmulationAdapter.cs86
-rw-r--r--Tizen.Network.Nfc/Tizen.Network.Nfc/NfcErrorFactory.cs4
-rw-r--r--Tizen.Network.Nfc/Tizen.Network.Nfc/NfcEventArgs.cs4
-rw-r--r--Tizen.Network.Nfc/Tizen.Network.Nfc/NfcManager.cs150
-rw-r--r--Tizen.Network.Nfc/Tizen.Network.Nfc/NfcManagerImpl.cs1
-rw-r--r--Tizen.Network.Nfc/Tizen.Network.Nfc/NfcNdefMessage.cs37
-rwxr-xr-x[-rw-r--r--]Tizen.Network.Nfc/Tizen.Network.Nfc/NfcNdefRecord.cs14
8 files changed, 154 insertions, 150 deletions
diff --git a/Tizen.Network.Nfc/Tizen.Network.Nfc/NfcCallbackData.cs b/Tizen.Network.Nfc/Tizen.Network.Nfc/NfcCallbackData.cs
index b76a52e..a779aab 100644
--- a/Tizen.Network.Nfc/Tizen.Network.Nfc/NfcCallbackData.cs
+++ b/Tizen.Network.Nfc/Tizen.Network.Nfc/NfcCallbackData.cs
@@ -24,6 +24,10 @@ namespace Tizen.Network.Nfc
/// </summary>
public class NfcTagInformation
{
+ internal NfcTagInformation()
+ {
+
+ }
/// <summary>
/// Key value.
/// </summary>
@@ -39,6 +43,10 @@ namespace Tizen.Network.Nfc
/// </summary>
public class NfcRegisteredAidInformation
{
+ internal NfcRegisteredAidInformation()
+ {
+
+ }
/// <summary>
/// Secure Element Type value.
/// </summary>
diff --git a/Tizen.Network.Nfc/Tizen.Network.Nfc/NfcCardEmulationAdapter.cs b/Tizen.Network.Nfc/Tizen.Network.Nfc/NfcCardEmulationAdapter.cs
index 23d7f3a..a9cef59 100644
--- a/Tizen.Network.Nfc/Tizen.Network.Nfc/NfcCardEmulationAdapter.cs
+++ b/Tizen.Network.Nfc/Tizen.Network.Nfc/NfcCardEmulationAdapter.cs
@@ -60,29 +60,6 @@ namespace Tizen.Network.Nfc
}
/// <summary>
- /// Event that is called when receiving Secure Element(SIM/UICC(Universal Integrated Circuit Card)) transaction event for 'Disable' type.
- /// </summary>
- public event EventHandler<SecureElementTranscationEventArgs> DisableSecureElementTransactionEvent
- {
- add
- {
- if (_secureElementTransactionEvent == null)
- {
- RegisterSecureElementTransactionEvent(NfcSecureElementType.Disable);
- }
- _secureElementTransactionEvent += value;
- }
- remove
- {
- _secureElementTransactionEvent -= value;
- if (_secureElementTransactionEvent == null)
- {
- UnregisterSecureElementTransactionEvent(NfcSecureElementType.Disable);
- }
- }
- }
-
- /// <summary>
/// Event that is called when receiving Secure Element(SIM/UICC(Universal Integrated Circuit Card)) transaction event for 'ESE(SmartMX)' type.
/// </summary>
public event EventHandler<SecureElementTranscationEventArgs> EseSecureElementTransactionEvent
@@ -129,52 +106,6 @@ namespace Tizen.Network.Nfc
}
/// <summary>
- /// Event that is called when receiving Secure Element(SIM/UICC(Universal Integrated Circuit Card)) transaction event for 'SDCard' type.
- /// </summary>
- public event EventHandler<SecureElementTranscationEventArgs> SdcardSecureElementTransactionEvent
- {
- add
- {
- if (_secureElementTransactionEvent == null)
- {
- RegisterSecureElementTransactionEvent(NfcSecureElementType.Sdcard);
- }
- _secureElementTransactionEvent += value;
- }
- remove
- {
- _secureElementTransactionEvent -= value;
- if (_secureElementTransactionEvent == null)
- {
- UnregisterSecureElementTransactionEvent(NfcSecureElementType.Sdcard);
- }
- }
- }
-
- /// <summary>
- /// Event that is called when receiving Secure Element(SIM/UICC(Universal Integrated Circuit Card)) transaction event for 'HCE(Host based card emulation)' type.
- /// </summary>
- public event EventHandler<SecureElementTranscationEventArgs> HceSecureElementTransactionEvent
- {
- add
- {
- if (_secureElementTransactionEvent == null)
- {
- RegisterSecureElementTransactionEvent(NfcSecureElementType.Hce);
- }
- _secureElementTransactionEvent += value;
- }
- remove
- {
- _secureElementTransactionEvent -= value;
- if (_secureElementTransactionEvent == null)
- {
- UnregisterSecureElementTransactionEvent(NfcSecureElementType.Hce);
- }
- }
- }
-
- /// <summary>
/// Event that is called when when receiving HCE(Host Card Emulation) event.
/// </summary>
public event EventHandler<HostCardEmulationEventArgs> HostCardEmulationEvent
@@ -294,22 +225,6 @@ namespace Tizen.Network.Nfc
}
/// <summary>
- /// Set the default route for each device status.
- /// </summary>
- /// <param name="seTypeInPoweredOn">The type of default Secure Element when device is powered on.</param>
- /// <param name="seTypeInPoweredOff">The type of default Secure Element when device is powered off.</param>
- /// <param name="seTypeInLowBattery">The type of default Secure Element when battery is low.</param>
- 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);
- }
- }
-
- /// <summary>
/// Gets the state whether an application to call this api is currently the activated handler for specific AID.
/// </summary>
/// <returns>'True' when application is currently the activated handler, otherwise 'False'.</returns>
@@ -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/Tizen.Network.Nfc/Tizen.Network.Nfc/NfcErrorFactory.cs b/Tizen.Network.Nfc/Tizen.Network.Nfc/NfcErrorFactory.cs
index 6e148c9..8b3f9df 100644
--- a/Tizen.Network.Nfc/Tizen.Network.Nfc/NfcErrorFactory.cs
+++ b/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/Tizen.Network.Nfc/Tizen.Network.Nfc/NfcEventArgs.cs b/Tizen.Network.Nfc/Tizen.Network.Nfc/NfcEventArgs.cs
index 015b0df..5aa93a2 100644
--- a/Tizen.Network.Nfc/Tizen.Network.Nfc/NfcEventArgs.cs
+++ b/Tizen.Network.Nfc/Tizen.Network.Nfc/NfcEventArgs.cs
@@ -106,7 +106,7 @@ namespace Tizen.Network.Nfc
/// <summary>
/// P2p object
/// </summary>
- public NfcP2p P2pTaget
+ public NfcP2p P2pTarget
{
get
{
@@ -240,7 +240,7 @@ namespace Tizen.Network.Nfc
/// <summary>
/// The Nfc hce event.
/// </summary>
- public NfcHceEvent HcdEvent
+ public NfcHceEvent HceEvent
{
get
{
diff --git a/Tizen.Network.Nfc/Tizen.Network.Nfc/NfcManager.cs b/Tizen.Network.Nfc/Tizen.Network.Nfc/NfcManager.cs
index 57eca3d..b743fb5 100644
--- a/Tizen.Network.Nfc/Tizen.Network.Nfc/NfcManager.cs
+++ b/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
/// </summary>
static public NfcTagAdapter GetTagAdapter()
{
- return NfcManagerImpl.Instance.TagAdapter;
+ try
+ {
+ return NfcManagerImpl.Instance.TagAdapter;
+ }
+ catch (TypeInitializationException e)
+ {
+ throw e.InnerException;
+ }
}
/// <summary>
@@ -117,7 +184,14 @@ namespace Tizen.Network.Nfc
/// </summary>
static public NfcP2pAdapter GetP2pAdapter()
{
- return NfcManagerImpl.Instance.P2pAdapter;
+ try
+ {
+ return NfcManagerImpl.Instance.P2pAdapter;
+ }
+ catch (TypeInitializationException e)
+ {
+ throw e.InnerException;
+ }
}
/// <summary>
@@ -125,7 +199,14 @@ namespace Tizen.Network.Nfc
/// </summary>
static public NfcCardEmulationAdapter GetCardEmulationAdapter()
{
- return NfcManagerImpl.Instance.CardEmulationAdapter;
+ try
+ {
+ return NfcManagerImpl.Instance.CardEmulationAdapter;
+ }
+ catch (TypeInitializationException e)
+ {
+ throw e.InnerException;
+ }
}
/// <summary>
@@ -134,7 +215,14 @@ namespace Tizen.Network.Nfc
/// <returns>A task indicates whether the Activate method is done or not.</returns>
static public Task SetActivateAsync(bool activation)
{
- return NfcManagerImpl.Instance.SetActivateAsync(activation);
+ try
+ {
+ return NfcManagerImpl.Instance.SetActivateAsync(activation);
+ }
+ catch (TypeInitializationException e)
+ {
+ throw e.InnerException;
+ }
}
/// <summary>
@@ -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/Tizen.Network.Nfc/Tizen.Network.Nfc/NfcManagerImpl.cs b/Tizen.Network.Nfc/Tizen.Network.Nfc/NfcManagerImpl.cs
index 238c0b6..68108a5 100644
--- a/Tizen.Network.Nfc/Tizen.Network.Nfc/NfcManagerImpl.cs
+++ b/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/Tizen.Network.Nfc/Tizen.Network.Nfc/NfcNdefMessage.cs b/Tizen.Network.Nfc/Tizen.Network.Nfc/NfcNdefMessage.cs
index 76891d9..727a097 100644
--- a/Tizen.Network.Nfc/Tizen.Network.Nfc/NfcNdefMessage.cs
+++ b/Tizen.Network.Nfc/Tizen.Network.Nfc/NfcNdefMessage.cs
@@ -47,26 +47,6 @@ namespace Tizen.Network.Nfc
}
/// <summary>
- /// The serial bytes array of NDEF message.
- /// </summary>
- 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);
- }
- }
-
- /// <summary>
/// Creates a object for the access point.
/// </summary>
public NfcNdefMessage()
@@ -80,22 +60,6 @@ namespace Tizen.Network.Nfc
}
}
- /// <summary>
- /// Creates NDEF message handle from raw serial bytes.
- /// </summary>
- /// <param name="rawData">The NDEF message in form of bytes array.</param>
- /// <param name="rawData">The size of bytes array.</param>
- 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/Tizen.Network.Nfc/Tizen.Network.Nfc/NfcNdefRecord.cs b/Tizen.Network.Nfc/Tizen.Network.Nfc/NfcNdefRecord.cs
index 10c2452..33e822e 100644..100755
--- a/Tizen.Network.Nfc/Tizen.Network.Nfc/NfcNdefRecord.cs
+++ b/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;