2 * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 using System.Runtime.InteropServices;
19 using System.Collections.Generic;
21 namespace Tizen.Network.Nfc
24 /// A class for managing the Secure Element information.
26 /// <since_tizen> 3 </since_tizen>
27 public class NfcSecureElement : IDisposable
29 private IntPtr _secureElementHandle = IntPtr.Zero;
30 private bool disposed = false;
32 internal NfcSecureElement(IntPtr handle)
34 _secureElementHandle = handle;
45 GC.SuppressFinalize(this);
48 private void Dispose(bool disposing)
55 // Free managed objects.
57 //Free unmanaged objects
62 /// Send APDU(Application Protocol Data Unit) response to CLF(Contactless Front-end).
64 /// <since_tizen> 3 </since_tizen>
65 /// <param name="response">The bytes array of response data.</param>
66 /// <param name="responseLength">The size of response bytes array.</param>
67 /// <privilege>http://tizen.org/privilege/nfc.cardemulation</privilege>
68 /// <exception cref="NotSupportedException">Thrown when Nfc is not supported.</exception>
69 /// <exception cref="ArgumentException">Thrown when method is failed due to an invalid parameter.</exception>
70 /// <exception cref="InvalidOperationException">Thrown when the method failed due to invalid operation.</exception>
71 public void HceSendApduResponse(byte[] response, uint responseLength)
73 int ret = Interop.Nfc.CardEmulation.HceSendApduRespondse(_secureElementHandle, response, responseLength);
74 if (ret != (int)NfcError.None)
76 Log.Error(Globals.LogTag, "Failed to hcd send apdu response, Error - " + (NfcError)ret);
77 NfcErrorFactory.ThrowNfcException(ret);
81 internal IntPtr GetHandle()
83 return _secureElementHandle;