• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2010 The Android Open Source Project
3  *
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
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16 
17 package com.android.nfc.nxp;
18 
19 import android.content.Context;
20 import android.content.SharedPreferences;
21 
22 
23 /**
24  * Native interface to the NFC Secure Element functions
25  *
26  * {@hide}
27  */
28 public class NativeNfcSecureElement {
29 
30     static final String PREF_SE_WIRED = "se_wired";
31 
32     private final Context mContext;
33 
34     SharedPreferences mPrefs;
35     SharedPreferences.Editor mPrefsEditor;
36 
NativeNfcSecureElement(Context context)37     public NativeNfcSecureElement(Context context) {
38         mContext = context;
39 
40         mPrefs = mContext.getSharedPreferences(NativeNfcManager.PREF, Context.MODE_PRIVATE);
41         mPrefsEditor = mPrefs.edit();
42     }
43 
doNativeOpenSecureElementConnection()44     private native int doNativeOpenSecureElementConnection();
45 
doOpenSecureElementConnection()46     public int doOpenSecureElementConnection() {
47         mPrefsEditor.putBoolean(PREF_SE_WIRED, true);
48         mPrefsEditor.apply();
49 
50         return doNativeOpenSecureElementConnection();
51     }
52 
doNativeDisconnectSecureElementConnection(int handle)53     private native boolean doNativeDisconnectSecureElementConnection(int handle);
54 
doDisconnect(int handle)55     public boolean doDisconnect(int handle) {
56         mPrefsEditor.putBoolean(PREF_SE_WIRED, false);
57         mPrefsEditor.apply();
58 
59         return doNativeDisconnectSecureElementConnection(handle);
60     }
61 
doTransceive(int handle, byte[] data)62     public native byte[] doTransceive(int handle, byte[] data);
63 
doGetTechList(int handle)64     public native int[] doGetTechList(int handle);
65 
doGetUid(int handle)66     public native byte [] doGetUid(int handle);
67 }
68