summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartijn Coenen <maco@google.com>2013-04-16 19:51:15 -0700
committerMartijn Coenen <maco@google.com>2013-04-16 19:59:50 -0700
commit2526197cb8039c1fa66c950110c78cbc95de1bba (patch)
tree625ea21ac834e289a6f12867cfe23ebccfa5814f
parentd8d8a7f0f8620b3f81f2dc33ecd5c8c093d417a0 (diff)
downloadandroid_packages_apps_Nfc-2526197cb8039c1fa66c950110c78cbc95de1bba.tar.gz
android_packages_apps_Nfc-2526197cb8039c1fa66c950110c78cbc95de1bba.tar.bz2
android_packages_apps_Nfc-2526197cb8039c1fa66c950110c78cbc95de1bba.zip
Fix RF field stuck on race condition.
If we deactivate a tag to sleep after an NDEF check, we're waiting for a DEACTIVATE_NTF event from the core stack to unblock us. However, there is a code path where we can be unblocked even without a DEACTIVATE_NTF event. If you'd happen to remove the tag right after the deactivation, we'd be getting read/write interface errors, which erroneously unblock the deactivate before it has been completed. Then, we send another deactive command to go back to discovery. However, because the previous deactivate is still pending, the deactivate to discovery command gets dropped, and we stay in a situation where the RF field is stuck on, burning power. For now fix by adding RW_INTF_ERROR_EVTs to the list of events that do not unblock a thread waiting on deactivate. Ideally no other event is allowed to unblock, but we'll need more time to verify that is actually true. Bug: 8616351 Change-Id: I381046f0320fd4b31c5ec65d54ef2e9530c3b13c
-rwxr-xr-xnci/jni/NativeNfcManager.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/nci/jni/NativeNfcManager.cpp b/nci/jni/NativeNfcManager.cpp
index b1199f94..ccee293a 100755
--- a/nci/jni/NativeNfcManager.cpp
+++ b/nci/jni/NativeNfcManager.cpp
@@ -210,7 +210,13 @@ static void nfaConnectionCallback (UINT8 connEvent, tNFA_CONN_EVT_DATA* eventDat
tNFA_STATUS status = NFA_STATUS_FAILED;
ALOGD("%s: event= %u", __FUNCTION__, connEvent);
- if (gIsTagDeactivating && connEvent != NFA_DEACTIVATED_EVT && connEvent != NFA_PRESENCE_CHECK_EVT && connEvent != NFA_DATA_EVT)
+ // TODO this if can probably be completely removed. It's unclear why this
+ // was present in the initial code drop - either to work around NFCC,
+ // stack or certain NFC tags bugs. Until we verify removing it doesn't
+ // break things, leave it be.
+ if (gIsTagDeactivating && connEvent != NFA_DEACTIVATED_EVT &&
+ connEvent != NFA_PRESENCE_CHECK_EVT && connEvent != NFA_DATA_EVT &&
+ connEvent != NFA_RW_INTF_ERROR_EVT)
{
// special case to switching frame interface for ISO_DEP tags
gIsTagDeactivating = false;