summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJihoon Jung <jh8801.jung@samsung.com>2017-01-09 08:35:55 (GMT)
committerJihoon Jung <jh8801.jung@samsung.com>2017-01-09 08:39:15 (GMT)
commita60df37c1de1a7e20f28810a345997cc172a4af0 (patch)
tree4f54b001731112bb76a9db38793b205e5168f3d8
parent611b603aafdb769e9dff3ac6cc2807df9fd48093 (diff)
downloadnfc-a60df37c1de1a7e20f28810a345997cc172a4af0.zip
nfc-a60df37c1de1a7e20f28810a345997cc172a4af0.tar.gz
nfc-a60df37c1de1a7e20f28810a345997cc172a4af0.tar.bz2
Change-Id: I0400831aaa992de1c3b52b701b5422d13716cdee
-rwxr-xr-x[-rw-r--r--]Tizen.Network.Nfc/Tizen.Network.Nfc.project.json5
-rwxr-xr-x[-rw-r--r--]Tizen.Network.Nfc/Tizen.Network.Nfc/NfcManager.cs121
-rwxr-xr-x[-rw-r--r--]Tizen.Network.Nfc/Tizen.Network.Nfc/NfcNdefMessage.cs13
-rwxr-xr-xTizen.Network.Nfc/Tizen.Network.Nfc/NfcNdefRecord.cs12
-rwxr-xr-x[-rw-r--r--]Tizen.Network.Nfc/Tizen.Network.Nfc/NfcP2p.cs10
-rwxr-xr-x[-rw-r--r--]Tizen.Network.Nfc/Tizen.Network.Nfc/NfcP2pAdapter.cs10
-rwxr-xr-x[-rw-r--r--]Tizen.Network.Nfc/Tizen.Network.Nfc/NfcTagAdapter.cs10
-rw-r--r--packaging/csapi-network-nfc.spec2
8 files changed, 143 insertions, 40 deletions
diff --git a/Tizen.Network.Nfc/Tizen.Network.Nfc.project.json b/Tizen.Network.Nfc/Tizen.Network.Nfc.project.json
index a4c6be0..303764a 100644..100755
--- a/Tizen.Network.Nfc/Tizen.Network.Nfc.project.json
+++ b/Tizen.Network.Nfc/Tizen.Network.Nfc.project.json
@@ -1,7 +1,8 @@
-{
+{
"dependencies": {
"NETStandard.Library": "1.6.0",
- "Tizen": "1.0.2"
+ "Tizen": "1.0.2",
+ "Tizen.System": "1.0.5"
},
"frameworks": {
"netstandard1.3": {}
diff --git a/Tizen.Network.Nfc/Tizen.Network.Nfc/NfcManager.cs b/Tizen.Network.Nfc/Tizen.Network.Nfc/NfcManager.cs
index b743fb5..e0a82a2 100644..100755
--- a/Tizen.Network.Nfc/Tizen.Network.Nfc/NfcManager.cs
+++ b/Tizen.Network.Nfc/Tizen.Network.Nfc/NfcManager.cs
@@ -17,6 +17,7 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
+using Tizen.System;
namespace Tizen.Network.Nfc
{
@@ -33,6 +34,13 @@ namespace Tizen.Network.Nfc
{
get
{
+ bool isNfcSupported = SystemInfo.TryGetValue("http://tizen.org/feature/network.nfc", out isNfcSupported);
+
+ if (!isNfcSupported)
+ {
+ return false;
+ }
+
try
{
return NfcManagerImpl.Instance.IsSupported;
@@ -51,6 +59,13 @@ namespace Tizen.Network.Nfc
{
get
{
+ bool isNfcSupported = SystemInfo.TryGetValue("http://tizen.org/feature/network.nfc", out isNfcSupported);
+
+ if (!isNfcSupported)
+ {
+ return false;
+ }
+
try
{
return NfcManagerImpl.Instance.IsActivated;
@@ -69,6 +84,14 @@ namespace Tizen.Network.Nfc
{
get
{
+ bool isNfcSupported = SystemInfo.TryGetValue("http://tizen.org/feature/network.nfc", out isNfcSupported);
+ bool isTagSupported = SystemInfo.TryGetValue("http://tizen.org/feature/network.nfc.tag", out isTagSupported);
+
+ if (!isNfcSupported || !isTagSupported)
+ {
+ return NfcTagFilterType.AllDisable;
+ }
+
try
{
return NfcManagerImpl.Instance.TagFilterType;
@@ -80,12 +103,21 @@ namespace Tizen.Network.Nfc
}
set
{
+ bool isNfcSupported = SystemInfo.TryGetValue("http://tizen.org/feature/network.nfc", out isNfcSupported);
+ bool isTagSupported = SystemInfo.TryGetValue("http://tizen.org/feature/network.nfc.tag", out isTagSupported);
+
+ if (!isNfcSupported || !isTagSupported)
+ {
+ return;
+ }
+
try
{
NfcManagerImpl.Instance.TagFilterType = value;
}
catch (TypeInitializationException)
{
+ return;
}
}
}
@@ -97,6 +129,14 @@ namespace Tizen.Network.Nfc
{
get
{
+ bool isNfcSupported = SystemInfo.TryGetValue("http://tizen.org/feature/network.nfc", out isNfcSupported);
+ bool isCeSupported = SystemInfo.TryGetValue("http://tizen.org/feature/network.nfc.cardemulation", out isCeSupported);
+
+ if (!isNfcSupported || !isCeSupported)
+ {
+ return NfcSecureElementType.Disable;
+ }
+
try
{
return NfcManagerImpl.Instance.SecureElementType;
@@ -125,6 +165,13 @@ namespace Tizen.Network.Nfc
{
get
{
+ bool isNfcSupported = SystemInfo.TryGetValue("http://tizen.org/feature/network.nfc", out isNfcSupported);
+
+ if (!isNfcSupported)
+ {
+ return false;
+ }
+
try
{
return NfcManagerImpl.Instance.SystemHandlerEnabled;
@@ -136,12 +183,20 @@ namespace Tizen.Network.Nfc
}
set
{
+ bool isNfcSupported = SystemInfo.TryGetValue("http://tizen.org/feature/network.nfc", out isNfcSupported);
+
+ if (!isNfcSupported)
+ {
+ return;
+ }
+
try
{
NfcManagerImpl.Instance.SystemHandlerEnabled = value;
}
catch (TypeInitializationException)
{
+ return;
}
}
}
@@ -153,6 +208,13 @@ namespace Tizen.Network.Nfc
{
get
{
+ bool isNfcSupported = SystemInfo.TryGetValue("http://tizen.org/feature/network.nfc", out isNfcSupported);
+
+ if (!isNfcSupported)
+ {
+ return null;
+ }
+
try
{
return NfcManagerImpl.Instance.CachedNdefMessage;
@@ -169,6 +231,14 @@ namespace Tizen.Network.Nfc
/// </summary>
static public NfcTagAdapter GetTagAdapter()
{
+ bool isNfcSupported = SystemInfo.TryGetValue("http://tizen.org/feature/network.nfc", out isNfcSupported);
+ bool isTagSupported = SystemInfo.TryGetValue("http://tizen.org/feature/network.nfc.tag", out isTagSupported);
+
+ if (!isNfcSupported || !isTagSupported)
+ {
+ throw new NotSupportedException();
+ }
+
try
{
return NfcManagerImpl.Instance.TagAdapter;
@@ -184,6 +254,14 @@ namespace Tizen.Network.Nfc
/// </summary>
static public NfcP2pAdapter GetP2pAdapter()
{
+ bool isNfcSupported = SystemInfo.TryGetValue("http://tizen.org/feature/network.nfc", out isNfcSupported);
+ bool isP2pSupported = SystemInfo.TryGetValue("http://tizen.org/feature/network.nfc.p2p", out isP2pSupported);
+
+ if (!isNfcSupported || !isP2pSupported)
+ {
+ throw new NotSupportedException();
+ }
+
try
{
return NfcManagerImpl.Instance.P2pAdapter;
@@ -199,6 +277,14 @@ namespace Tizen.Network.Nfc
/// </summary>
static public NfcCardEmulationAdapter GetCardEmulationAdapter()
{
+ bool isNfcSupported = SystemInfo.TryGetValue("http://tizen.org/feature/network.nfc", out isNfcSupported);
+ bool isCeSupported = SystemInfo.TryGetValue("http://tizen.org/feature/network.nfc.cardemulation", out isCeSupported);
+
+ if (!isNfcSupported || !isCeSupported)
+ {
+ throw new NotSupportedException();
+ }
+
try
{
return NfcManagerImpl.Instance.CardEmulationAdapter;
@@ -215,6 +301,13 @@ namespace Tizen.Network.Nfc
/// <returns>A task indicates whether the Activate method is done or not.</returns>
static public Task SetActivateAsync(bool activation)
{
+ bool isNfcSupported = SystemInfo.TryGetValue("http://tizen.org/feature/network.nfc", out isNfcSupported);
+
+ if (!isNfcSupported)
+ {
+ throw new NotSupportedException();
+ }
+
try
{
return NfcManagerImpl.Instance.SetActivateAsync(activation);
@@ -232,6 +325,13 @@ namespace Tizen.Network.Nfc
{
add
{
+ bool isNfcSupported = SystemInfo.TryGetValue("http://tizen.org/feature/network.nfc", out isNfcSupported);
+
+ if (!isNfcSupported)
+ {
+ throw new NotSupportedException();
+ }
+
try
{
NfcManagerImpl.Instance.ActivationChanged += value;
@@ -243,6 +343,13 @@ namespace Tizen.Network.Nfc
}
remove
{
+ bool isNfcSupported = SystemInfo.TryGetValue("http://tizen.org/feature/network.nfc", out isNfcSupported);
+
+ if (!isNfcSupported)
+ {
+ throw new NotSupportedException();
+ }
+
try
{
NfcManagerImpl.Instance.ActivationChanged -= value;
@@ -261,6 +368,13 @@ namespace Tizen.Network.Nfc
{
add
{
+ bool isNfcSupported = SystemInfo.TryGetValue("http://tizen.org/feature/network.nfc", out isNfcSupported);
+
+ if (!isNfcSupported)
+ {
+ throw new NotSupportedException();
+ }
+
try
{
NfcManagerImpl.Instance.NdefMessageDiscovered += value;
@@ -272,6 +386,13 @@ namespace Tizen.Network.Nfc
}
remove
{
+ bool isNfcSupported = SystemInfo.TryGetValue("http://tizen.org/feature/network.nfc", out isNfcSupported);
+
+ if (!isNfcSupported)
+ {
+ throw new NotSupportedException();
+ }
+
try
{
NfcManagerImpl.Instance.NdefMessageDiscovered -= value;
diff --git a/Tizen.Network.Nfc/Tizen.Network.Nfc/NfcNdefMessage.cs b/Tizen.Network.Nfc/Tizen.Network.Nfc/NfcNdefMessage.cs
index 727a097..0e22636 100644..100755
--- a/Tizen.Network.Nfc/Tizen.Network.Nfc/NfcNdefMessage.cs
+++ b/Tizen.Network.Nfc/Tizen.Network.Nfc/NfcNdefMessage.cs
@@ -67,13 +67,6 @@ namespace Tizen.Network.Nfc
~NfcNdefMessage()
{
- int ret = Interop.Nfc.NdefMessage.Destroy(_messageHandle);
-
- if (ret != (int)NfcError.None)
- {
- Log.Error(Globals.LogTag, "Failed to destroy ndef message, Error - " + (NfcError)ret);
- }
-
Dispose(false);
}
@@ -91,6 +84,12 @@ namespace Tizen.Network.Nfc
if (disposing)
{
// Free managed objects.
+ int ret = Interop.Nfc.NdefMessage.Destroy(_messageHandle);
+
+ if (ret != (int)NfcError.None)
+ {
+ Log.Error(Globals.LogTag, "Failed to destroy ndef message, Error - " + (NfcError)ret);
+ }
}
//Free unmanaged objects
disposed = true;
diff --git a/Tizen.Network.Nfc/Tizen.Network.Nfc/NfcNdefRecord.cs b/Tizen.Network.Nfc/Tizen.Network.Nfc/NfcNdefRecord.cs
index 33e822e..ca755f6 100755
--- a/Tizen.Network.Nfc/Tizen.Network.Nfc/NfcNdefRecord.cs
+++ b/Tizen.Network.Nfc/Tizen.Network.Nfc/NfcNdefRecord.cs
@@ -285,12 +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);
- }
+ 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;
diff --git a/Tizen.Network.Nfc/Tizen.Network.Nfc/NfcP2p.cs b/Tizen.Network.Nfc/Tizen.Network.Nfc/NfcP2p.cs
index fd85440..1010d81 100644..100755
--- a/Tizen.Network.Nfc/Tizen.Network.Nfc/NfcP2p.cs
+++ b/Tizen.Network.Nfc/Tizen.Network.Nfc/NfcP2p.cs
@@ -40,25 +40,18 @@ namespace Tizen.Network.Nfc
{
add
{
- if (_p2pDataReceived == null)
- {
- RegisterP2pDataReceivedEvent();
- }
_p2pDataReceived += value;
}
remove
{
_p2pDataReceived -= value;
- if (_p2pDataReceived == null)
- {
- UnregisterP2pDataReceivedEvent();
- }
}
}
internal NfcP2p(IntPtr handle)
{
_p2pTargetHandle = handle;
+ RegisterP2pDataReceivedEvent();
}
~NfcP2p()
@@ -80,6 +73,7 @@ namespace Tizen.Network.Nfc
if (disposing)
{
// Free managed objects.
+ UnregisterP2pDataReceivedEvent();
}
//Free unmanaged objects
disposed = true;
diff --git a/Tizen.Network.Nfc/Tizen.Network.Nfc/NfcP2pAdapter.cs b/Tizen.Network.Nfc/Tizen.Network.Nfc/NfcP2pAdapter.cs
index 25af7d4..646f178 100644..100755
--- a/Tizen.Network.Nfc/Tizen.Network.Nfc/NfcP2pAdapter.cs
+++ b/Tizen.Network.Nfc/Tizen.Network.Nfc/NfcP2pAdapter.cs
@@ -40,24 +40,17 @@ namespace Tizen.Network.Nfc
{
add
{
- if (_p2pTargetDiscovered == null)
- {
- RegisterP2pTargetDiscoveredEvent();
- }
_p2pTargetDiscovered += value;
}
remove
{
_p2pTargetDiscovered -= value;
- if (_p2pTargetDiscovered == null)
- {
- UnregisterP2pTargetDiscoveredEvent();
- }
}
}
internal NfcP2pAdapter()
{
+ RegisterP2pTargetDiscoveredEvent();
}
~NfcP2pAdapter()
@@ -79,6 +72,7 @@ namespace Tizen.Network.Nfc
if (disposing)
{
// Free managed objects.
+ UnregisterP2pTargetDiscoveredEvent();
}
//Free unmanaged objects
disposed = true;
diff --git a/Tizen.Network.Nfc/Tizen.Network.Nfc/NfcTagAdapter.cs b/Tizen.Network.Nfc/Tizen.Network.Nfc/NfcTagAdapter.cs
index 815b75f..97532b5 100644..100755
--- a/Tizen.Network.Nfc/Tizen.Network.Nfc/NfcTagAdapter.cs
+++ b/Tizen.Network.Nfc/Tizen.Network.Nfc/NfcTagAdapter.cs
@@ -40,24 +40,17 @@ namespace Tizen.Network.Nfc
{
add
{
- if (_tagDiscovered == null)
- {
- RegisterTagDiscoveredEvent();
- }
_tagDiscovered += value;
}
remove
{
_tagDiscovered -= value;
- if (_tagDiscovered == null)
- {
- UnregisterTagDiscoveredEvent();
- }
}
}
internal NfcTagAdapter()
{
+ RegisterTagDiscoveredEvent();
}
~NfcTagAdapter()
@@ -79,6 +72,7 @@ namespace Tizen.Network.Nfc
if (disposing)
{
// Free managed objects.
+ UnregisterTagDiscoveredEvent();
}
//Free unmanaged objects
disposed = true;
diff --git a/packaging/csapi-network-nfc.spec b/packaging/csapi-network-nfc.spec
index 1a00bc7..3c27369 100644
--- a/packaging/csapi-network-nfc.spec
+++ b/packaging/csapi-network-nfc.spec
@@ -8,7 +8,7 @@
Name: csapi-network-nfc
Summary: Tizen Nfc API for C#
-Version: 1.0.2
+Version: 1.0.3
Release: 1
Group: Development/Libraries
License: Apache-2.0