diff options
author | Sunil Jogi <sunil.jogi@nxp.com> | 2012-04-11 13:11:03 -0700 |
---|---|---|
committer | Martijn Coenen <maco@google.com> | 2012-04-20 12:18:29 -0700 |
commit | 37058bf7b59def2f9a565ae5b16aae54e80e9e95 (patch) | |
tree | e9e3e692da9608a3cd6d2e295e5fac2be3451bcd /src/com | |
parent | 290a6967a04f49dc3969dced9f82c1636a7e7902 (diff) | |
download | packages_apps_nfc-37058bf7b59def2f9a565ae5b16aae54e80e9e95.zip packages_apps_nfc-37058bf7b59def2f9a565ae5b16aae54e80e9e95.tar.gz packages_apps_nfc-37058bf7b59def2f9a565ae5b16aae54e80e9e95.tar.bz2 |
Added shared prefs for SE wired mode
When SE is in wired mode shared prefs sets the se_wired to true,
when SE is no more in wired mode shared prefs sets se_wired to
false. Default value for se_wired is false. se_wired shared pref
is set during the NFC initialization.
Change-Id: I9a3565c23035802895c8e99c671483c808312e0e
Diffstat (limited to 'src/com')
-rwxr-xr-x | src/com/android/nfc/NfcService.java | 2 | ||||
-rwxr-xr-x | src/com/android/nfc/nxp/NativeNfcManager.java | 31 | ||||
-rwxr-xr-x | src/com/android/nfc/nxp/NativeNfcSecureElement.java | 46 |
3 files changed, 66 insertions, 13 deletions
diff --git a/src/com/android/nfc/NfcService.java b/src/com/android/nfc/NfcService.java index ecff25c..9e4e21b 100755 --- a/src/com/android/nfc/NfcService.java +++ b/src/com/android/nfc/NfcService.java @@ -320,7 +320,7 @@ public class NfcService extends Application implements DeviceHostListener { mNfcDispatcher = new NfcDispatcher(this, handoverManager); mP2pLinkManager = new P2pLinkManager(mContext, handoverManager); - mSecureElement = new NativeNfcSecureElement(); + mSecureElement = new NativeNfcSecureElement(mContext); mEeRoutingState = ROUTE_OFF; mNfceeAccessControl = new NfceeAccessControl(this); diff --git a/src/com/android/nfc/nxp/NativeNfcManager.java b/src/com/android/nfc/nxp/NativeNfcManager.java index 1a50805..4bd8c24 100755 --- a/src/com/android/nfc/nxp/NativeNfcManager.java +++ b/src/com/android/nfc/nxp/NativeNfcManager.java @@ -38,7 +38,7 @@ public class NativeNfcManager implements DeviceHost { private static final String NFC_CONTROLLER_FIRMWARE_FILE_NAME = "/vendor/firmware/libpn544_fw.so"; - private static final String PREF = "NxpDeviceHost"; + static final String PREF = "NxpDeviceHost"; private static final String PREF_FIRMWARE_MODTIME = "firmware_modtime"; private static final long FIRMWARE_MODTIME_DEFAULT = -1; @@ -112,11 +112,36 @@ public class NativeNfcManager implements DeviceHost { } } + private native boolean doInitialize(); + @Override - public native boolean initialize(); + public boolean initialize() { + SharedPreferences prefs = mContext.getSharedPreferences(PREF, Context.MODE_PRIVATE); + SharedPreferences.Editor editor = prefs.edit(); + + if (prefs.getBoolean(NativeNfcSecureElement.PREF_SE_WIRED, false)) { + try { + Thread.sleep (12000); + editor.putBoolean(NativeNfcSecureElement.PREF_SE_WIRED, false); + editor.apply(); + } catch (InterruptedException e) { } + } + + return doInitialize(); + } + + private native boolean doDeinitialize(); @Override - public native boolean deinitialize(); + public boolean deinitialize() { + SharedPreferences prefs = mContext.getSharedPreferences(PREF, Context.MODE_PRIVATE); + SharedPreferences.Editor editor = prefs.edit(); + + editor.putBoolean(NativeNfcSecureElement.PREF_SE_WIRED, false); + editor.apply(); + + return doDeinitialize(); + } @Override public native void enableDiscovery(); diff --git a/src/com/android/nfc/nxp/NativeNfcSecureElement.java b/src/com/android/nfc/nxp/NativeNfcSecureElement.java index 768ad2f..88f9b9d 100755 --- a/src/com/android/nfc/nxp/NativeNfcSecureElement.java +++ b/src/com/android/nfc/nxp/NativeNfcSecureElement.java @@ -16,6 +16,8 @@ package com.android.nfc.nxp; +import android.content.Context; +import android.content.SharedPreferences; /** @@ -24,16 +26,42 @@ package com.android.nfc.nxp; * {@hide} */ public class NativeNfcSecureElement { - - public NativeNfcSecureElement() { } - - public native int doOpenSecureElementConnection(); - - public native boolean doDisconnect(int handle); - + + static final String PREF_SE_WIRED = "se_wired"; + + private final Context mContext; + + SharedPreferences mPrefs; + SharedPreferences.Editor mPrefsEditor; + + public NativeNfcSecureElement(Context context) { + mContext = context; + + mPrefs = mContext.getSharedPreferences(NativeNfcManager.PREF, Context.MODE_PRIVATE); + mPrefsEditor = mPrefs.edit(); + } + + private native int doNativeOpenSecureElementConnection(); + + public int doOpenSecureElementConnection() { + mPrefsEditor.putBoolean(PREF_SE_WIRED, true); + mPrefsEditor.apply(); + + return doNativeOpenSecureElementConnection(); + } + + private native boolean doNativeDisconnectSecureElementConnection(int handle); + + public boolean doDisconnect(int handle) { + mPrefsEditor.putBoolean(PREF_SE_WIRED, false); + mPrefsEditor.apply(); + + return doNativeDisconnectSecureElementConnection(handle); + } + public native byte[] doTransceive(int handle, byte[] data); - + public native int[] doGetTechList(int handle); - + public native byte [] doGetUid(int handle); } |