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 /// The 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;
38 /// NfcSecureElement destructor.
51 GC.SuppressFinalize(this);
54 private void Dispose(bool disposing)
61 // Free managed objects.
63 //Free unmanaged objects
68 /// Sends the APDU (Application Protocol Data Unit) response to the CLF (Contactless Front-end).
70 /// <since_tizen> 3 </since_tizen>
71 /// <param name="response">The bytes array of the response data.</param>
72 /// <param name="responseLength">The size of the response bytes array.</param>
73 /// <privilege>http://tizen.org/privilege/nfc.cardemulation</privilege>
74 /// <exception cref="NotSupportedException">Thrown when the NFC is not supported.</exception>
75 /// <exception cref="ArgumentException">Thrown when the method fails due to an invalid parameter.</exception>
76 /// <exception cref="InvalidOperationException">Thrown when the method fails due to an invalid operation.</exception>
77 public void HceSendApduResponse(byte[] response, uint responseLength)
79 int ret = Interop.Nfc.CardEmulation.HceSendApduRespondse(_secureElementHandle, response, responseLength);
80 if (ret != (int)NfcError.None)
82 Log.Error(Globals.LogTag, "Failed to hcd send apdu response, Error - " + (NfcError)ret);
83 NfcErrorFactory.ThrowNfcException(ret);
87 internal IntPtr GetHandle()
89 return _secureElementHandle;