diff options
author | doug yeager <doug@simplytapp.com> | 2012-09-26 10:38:56 -0500 |
---|---|---|
committer | Gerrit Code Review <gerrit@review.cyanogenmod.com> | 2012-10-03 22:14:58 -0700 |
commit | f08a77e3dbce757eced6ab7cd171254c8b2c9522 (patch) | |
tree | 01b62fd563ac89ccb9a06350f7b9fbb70e3ca0d6 /jni/com_android_nfc_NativeNfcManager.cpp | |
parent | 8efb854312c0a8526e70cf72d06cff598c7c2104 (diff) | |
download | packages_apps_nfc-f08a77e3dbce757eced6ab7cd171254c8b2c9522.zip packages_apps_nfc-f08a77e3dbce757eced6ab7cd171254c8b2c9522.tar.gz packages_apps_nfc-f08a77e3dbce757eced6ab7cd171254c8b2c9522.tar.bz2 |
on handsets where Gwallet is enabled, HCE turns off for good after Gwallet is fired up. This patch fixes the scenario of Gwallet and HCE living happily together. it is a fix, really, for the intended function of when an HCE application is in the forground, it has control, all other times Gwallet gets control of emulation from SE.
Change-Id: I8c37e2799c3a2232f7cc1b18d1b40c6986e98e44
Diffstat (limited to 'jni/com_android_nfc_NativeNfcManager.cpp')
-rwxr-xr-x | jni/com_android_nfc_NativeNfcManager.cpp | 98 |
1 files changed, 50 insertions, 48 deletions
diff --git a/jni/com_android_nfc_NativeNfcManager.cpp b/jni/com_android_nfc_NativeNfcManager.cpp index 2e7ebf2..495df4f 100755 --- a/jni/com_android_nfc_NativeNfcManager.cpp +++ b/jni/com_android_nfc_NativeNfcManager.cpp @@ -1724,38 +1724,20 @@ static void set_CE_A_mode(uint8_t mode, struct nfc_jni_native_data *nat) nfc_jni_CEcfg_callback, (void *)&cb_data); REENTRANCE_UNLOCK(); - if(status != NFCSTATUS_PENDING) + if(status == NFCSTATUS_PENDING) { - ALOGE("phLibNfc_Mgt_SetCE_14443_4_ConfigParams returned 0x%04x[%s]", status, - nfc_jni_get_status_name(status)); - goto clean_and_return; + sem_wait(&cb_data.sem); } TRACE("phLibNfc_Mgt_SetCE_14443_4_ConfigParams returned 0x%04x[%s]", status, nfc_jni_get_status_name(status)); - /* Wait for callback response */ - if(sem_wait(&cb_data.sem)) - { - ALOGE("Failed to wait for semaphore (errno=0x%08x)", errno); - goto clean_and_return; - } REENTRANCE_LOCK(); status = phLibNfc_Mgt_SetCE_A_14443_4_ConfigParams(FALSE, nfc_jni_CEcfg_callback, (void *)&cb_data); REENTRANCE_UNLOCK(); - if(status != NFCSTATUS_PENDING) - { - ALOGE("phLibNfc_Mgt_SetCE_14443_4_ConfigParams returned 0x%04x[%s]", status, - nfc_jni_get_status_name(status)); - goto clean_and_return; - } - TRACE("phLibNfc_Mgt_SetCE_14443_4_ConfigParams returned 0x%04x[%s]", status, - nfc_jni_get_status_name(status)); - /* Wait for callback response */ - if(sem_wait(&cb_data.sem)) + if(status == NFCSTATUS_PENDING) { - ALOGE("Failed to wait for semaphore (errno=0x%08x)", errno); - goto clean_and_return; + sem_wait(&cb_data.sem); } ceAOn=FALSE; @@ -1844,6 +1826,26 @@ static void set_CE_A_mode(uint8_t mode, struct nfc_jni_native_data *nat) if(mode==TURN_CE_ON || (mode==UNBLOCK_CE_CALLBACK && unblocked==TRUE && discoveryOn==TRUE)) { + TRACE("phLibNfc_SE_SetMode()"); + /* Set SE mode - Default */ + REENTRANCE_LOCK(); + status = phLibNfc_SE_SetMode(nat->seId, phLibNfc_SE_ActModeDefault, + nfc_jni_se_set_mode_callback, (void *)&cb_data); + REENTRANCE_UNLOCK(); + + TRACE("phLibNfc_SE_SetMode returned 0x%02x", status); + if (status != NFCSTATUS_PENDING) { + ALOGE("phLibNfc_SE_SetMode() returned 0x%04x[%s]", status, nfc_jni_get_status_name(status)); + goto clean_and_return; + } + TRACE("phLibNfc_SE_SetMode() returned 0x%04x[%s]", status, nfc_jni_get_status_name(status)); + + /* Wait for callback response */ + if (sem_wait(&cb_data.sem)) { + ALOGE("Failed to wait for semaphore (errno=0x%08x)", errno); + goto clean_and_return; + } + REENTRANCE_LOCK(); status = phLibNfc_Mgt_SetCE_A_14443_4_ConfigParams(TRUE, nfc_jni_CEcfg_callback, @@ -1919,38 +1921,18 @@ static void set_CE_B_mode(uint8_t mode, struct nfc_jni_native_data *nat) nfc_jni_CEcfg_callback, (void *)&cb_data); REENTRANCE_UNLOCK(); - if(status != NFCSTATUS_PENDING) - { - ALOGE("phLibNfc_Mgt_SetCE_14443_4_ConfigParams returned 0x%04x[%s]", status, - nfc_jni_get_status_name(status)); - goto clean_and_return; - } - TRACE("phLibNfc_Mgt_SetCE_14443_4_ConfigParams returned 0x%04x[%s]", status, - nfc_jni_get_status_name(status)); - /* Wait for callback response */ - if(sem_wait(&cb_data.sem)) + if(status == NFCSTATUS_PENDING) { - ALOGE("Failed to wait for semaphore (errno=0x%08x)", errno); - goto clean_and_return; + sem_wait(&cb_data.sem); } REENTRANCE_LOCK(); status = phLibNfc_Mgt_SetCE_B_14443_4_ConfigParams(FALSE, nfc_jni_CEcfg_callback, (void *)&cb_data); REENTRANCE_UNLOCK(); - if(status != NFCSTATUS_PENDING) - { - ALOGE("phLibNfc_Mgt_SetCE_14443_4_ConfigParams returned 0x%04x[%s]", status, - nfc_jni_get_status_name(status)); - goto clean_and_return; - } - TRACE("phLibNfc_Mgt_SetCE_14443_4_ConfigParams returned 0x%04x[%s]", status, - nfc_jni_get_status_name(status)); - /* Wait for callback response */ - if(sem_wait(&cb_data.sem)) + if(status == NFCSTATUS_PENDING) { - ALOGE("Failed to wait for semaphore (errno=0x%08x)", errno); - goto clean_and_return; + sem_wait(&cb_data.sem); } ceBOn=FALSE; @@ -2039,6 +2021,26 @@ static void set_CE_B_mode(uint8_t mode, struct nfc_jni_native_data *nat) if(mode==TURN_CE_ON || (mode==UNBLOCK_CE_CALLBACK && unblocked==TRUE && discoveryOn==TRUE)) { + TRACE("phLibNfc_SE_SetMode()"); + /* Set SE mode - Default */ + REENTRANCE_LOCK(); + status = phLibNfc_SE_SetMode(nat->seId, phLibNfc_SE_ActModeDefault, + nfc_jni_se_set_mode_callback, (void *)&cb_data); + REENTRANCE_UNLOCK(); + + TRACE("phLibNfc_SE_SetMode returned 0x%02x", status); + if (status != NFCSTATUS_PENDING) { + ALOGE("phLibNfc_SE_SetMode() returned 0x%04x[%s]", status, nfc_jni_get_status_name(status)); + goto clean_and_return; + } + TRACE("phLibNfc_SE_SetMode() returned 0x%04x[%s]", status, nfc_jni_get_status_name(status)); + + /* Wait for callback response */ + if (sem_wait(&cb_data.sem)) { + ALOGE("Failed to wait for semaphore (errno=0x%08x)", errno); + goto clean_and_return; + } + REENTRANCE_LOCK(); status = phLibNfc_Mgt_SetCE_B_14443_4_ConfigParams(TRUE, nfc_jni_CEcfg_callback, @@ -2625,8 +2627,8 @@ static void com_android_nfc_NfcManager_doSelectSecureElement(JNIEnv *e, jobject /* Retrieve native structure address */ nat = nfc_jni_get_nat(e, o); - set_CE_A_mode(UNBLOCK_CE_CALLBACK, nat); - set_CE_B_mode(UNBLOCK_CE_CALLBACK, nat); + set_CE_A_mode(TURN_CE_OFF, nat); + set_CE_B_mode(TURN_CE_OFF, nat); /* Create the local semaphore */ if (!nfc_cb_data_init(&cb_data, NULL)) { |