diff options
author | Martijn Coenen <maco@google.com> | 2013-04-12 15:37:55 -0700 |
---|---|---|
committer | Martijn Coenen <maco@google.com> | 2013-04-12 15:40:32 -0700 |
commit | 18cbef124c779d889b538f29dfa5880951a2c59c (patch) | |
tree | 861eb36fea1684873cfb0cd8dcd4957063409959 | |
parent | 027f41e53396c19c9b7572c49b7663c2e268c9af (diff) | |
download | android_packages_apps_Nfc-18cbef124c779d889b538f29dfa5880951a2c59c.tar.gz android_packages_apps_Nfc-18cbef124c779d889b538f29dfa5880951a2c59c.tar.bz2 android_packages_apps_Nfc-18cbef124c779d889b538f29dfa5880951a2c59c.zip |
Restore discovery notification callback when (de)selecting SE.
When the host opens the pipe to the SE for communication,
the notification callback is temporarily changed to a
SE-specific callback. In itself this is fine, because
there can be no other devices discovered while the eSE
is connected.
However, when disconnecting the connection from the host,
the PN544 already resumes discovery. This is before we
call enableDiscover(), and before we've restored the
correct target notification callback. This race-condition
can cause a crash.
Fix it by restoring the proper notification when
(de)selecting the secure element.
Bug: 8599167
Change-Id: I26816eb8851637de18058e974b98607e4379f55d
-rw-r--r-- | nxp/jni/com_android_nfc_NativeNfcManager.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/nxp/jni/com_android_nfc_NativeNfcManager.cpp b/nxp/jni/com_android_nfc_NativeNfcManager.cpp index c95642f5..098f8a72 100644 --- a/nxp/jni/com_android_nfc_NativeNfcManager.cpp +++ b/nxp/jni/com_android_nfc_NativeNfcManager.cpp @@ -1870,6 +1870,13 @@ static void com_android_nfc_NfcManager_doSelectSecureElement(JNIEnv *e, jobject goto clean_and_return; } + REENTRANCE_LOCK(); + ret = phLibNfc_RemoteDev_NtfRegister(&nat->registry_info, nfc_jni_Discovery_notification_callback, (void *)nat); + REENTRANCE_UNLOCK(); + if(ret != NFCSTATUS_SUCCESS) { + ALOGD("pphLibNfc_RemoteDev_NtfRegister returned 0x%02x",ret); + goto clean_and_return; + } TRACE("****** Select Secure Element ******"); TRACE("phLibNfc_SE_SetMode()"); @@ -1910,6 +1917,13 @@ static void com_android_nfc_NfcManager_doDeselectSecureElement(JNIEnv *e, jobjec goto clean_and_return; } + REENTRANCE_LOCK(); + ret = phLibNfc_RemoteDev_NtfRegister(&nat->registry_info, nfc_jni_Discovery_notification_callback, (void *)nat); + REENTRANCE_UNLOCK(); + if(ret != NFCSTATUS_SUCCESS) { + ALOGD("pphLibNfc_RemoteDev_NtfRegister returned 0x%02x",ret); + goto clean_and_return; + } TRACE("****** Deselect Secure Element ******"); TRACE("phLibNfc_SE_SetMode()"); |