diff options
author | Martijn Coenen <maco@google.com> | 2013-02-11 12:42:43 -0800 |
---|---|---|
committer | Martijn Coenen <maco@google.com> | 2013-02-12 13:37:56 -0800 |
commit | c3981b9a0b39faed474480bc3dbd3e33bbd50b99 (patch) | |
tree | 48d8337a051ee5a86753ac0f5ed71ed4d50273b4 /nxp | |
parent | 97fe497ede803f09d45253ee5fba51bf03cb724a (diff) | |
download | android_packages_apps_Nfc-c3981b9a0b39faed474480bc3dbd3e33bbd50b99.tar.gz android_packages_apps_Nfc-c3981b9a0b39faed474480bc3dbd3e33bbd50b99.tar.bz2 android_packages_apps_Nfc-c3981b9a0b39faed474480bc3dbd3e33bbd50b99.zip |
Return more accurate errors for NfcEe.open.
There are a number of different conditions under
which access to the SE is not possible. Since some
of these require user intervention to resolve (ie
external field present), return a more accurate
reason for NfcEe.open failure.
Bug: 4304698
Change-Id: Ie947c29be12d554a02d9246264a9f0e026a37af8
Diffstat (limited to 'nxp')
-rw-r--r-- | nxp/jni/com_android_nfc.h | 9 | ||||
-rwxr-xr-x | nxp/jni/com_android_nfc_NativeNfcSecureElement.cpp | 7 |
2 files changed, 14 insertions, 2 deletions
diff --git a/nxp/jni/com_android_nfc.h b/nxp/jni/com_android_nfc.h index 56c229f1..1eed2049 100644 --- a/nxp/jni/com_android_nfc.h +++ b/nxp/jni/com_android_nfc.h @@ -105,6 +105,15 @@ extern "C" { #define SMX_SECURE_ELEMENT_ID 11259375 + +/* These must match the EE_ERROR_ types in NfcService.java */ +#define EE_ERROR_IO -1 +#define EE_ERROR_ALREADY_OPEN -2 +#define EE_ERROR_INIT -3 +#define EE_ERROR_LISTEN_MODE -4 +#define EE_ERROR_EXT_FIELD -5 +#define EE_ERROR_NFC_DISABLED -6 + /* Maximum byte length of an AID. */ #define AID_MAXLEN 16 diff --git a/nxp/jni/com_android_nfc_NativeNfcSecureElement.cpp b/nxp/jni/com_android_nfc_NativeNfcSecureElement.cpp index 79887a0e..9e0a6e23 100755 --- a/nxp/jni/com_android_nfc_NativeNfcSecureElement.cpp +++ b/nxp/jni/com_android_nfc_NativeNfcSecureElement.cpp @@ -179,6 +179,7 @@ static jint com_android_nfc_NativeNfcSecureElement_doOpenSecureElementConnection { NFCSTATUS ret; int semResult; + jint errorCode = EE_ERROR_INIT; phLibNfc_SE_List_t SE_List[PHLIBNFC_MAXNO_OF_SE]; uint8_t i, No_SE = PHLIBNFC_MAXNO_OF_SE, SmartMX_index=0, SmartMX_detected = 0; @@ -224,7 +225,8 @@ static jint com_android_nfc_NativeNfcSecureElement_doOpenSecureElementConnection /* Check if NFC device is already connected to a tag or P2P peer */ if (device_connected_flag == 1) { - ALOGD("Unable to open SE connection, device already connected to a P2P peer or a Tag"); + ALOGE("Unable to open SE connection, device already connected to a P2P peer or a Tag"); + errorCode = EE_ERROR_LISTEN_MODE; goto clean_and_return; } @@ -263,6 +265,7 @@ static jint com_android_nfc_NativeNfcSecureElement_doOpenSecureElementConnection { // There is an external RF field present, fail the open request ALOGD("Unable to open SE connection, external RF Field detected"); + errorCode = EE_ERROR_EXT_FIELD; goto clean_and_return; } @@ -464,7 +467,7 @@ clean_and_return: nfc_cb_data_deinit(&cb_data_SE_Notification); CONCURRENCY_UNLOCK(); - return 0; + return errorCode; } |