Don't dispatch tags when NDEF read times out.
If we get a timeout status from the stack, store
that state so we don't dispatch tags with empty
NDEF messages with a read timeout. This was already
done when we timed out while reading NDEF meta-data,
but not the message itself.
Also, don't play sounds during detection at all;
NDEF messages are usually so small that the "start
detect" sound is immediately followed by either a
"success" sound or a "failure" sound; we now only
play a sound if the tag was successfully read and
will be dispatched.
Bug: 31165960
Change-Id: I4738731ad3b265df08a22666e52d801578dd329f
diff --git a/nci/jni/NfcTag.cpp b/nci/jni/NfcTag.cpp
index ddf354a..c6e074b 100755
--- a/nci/jni/NfcTag.cpp
+++ b/nci/jni/NfcTag.cpp
@@ -1422,6 +1422,9 @@
{
SyncEventGuard g (mReadCompleteEvent);
mReadCompletedStatus = data->status;
+ mNdefDetectionTimedOut = data->status != NFA_STATUS_OK;
+ if (mNdefDetectionTimedOut)
+ ALOGE ("%s: NDEF detection timed out", fn);
mReadCompleteEvent.notifyOne ();
}
break;
diff --git a/nci/src/com/android/nfc/dhimpl/NativeNfcTag.java b/nci/src/com/android/nfc/dhimpl/NativeNfcTag.java
index c121a62..6e5ffca 100755
--- a/nci/src/com/android/nfc/dhimpl/NativeNfcTag.java
+++ b/nci/src/com/android/nfc/dhimpl/NativeNfcTag.java
@@ -812,11 +812,6 @@
if (generateEmptyNdef) {
ndefMsg = null;
- addNdefTechnology(null,
- getConnectedHandle(),
- getConnectedLibNfcType(),
- getConnectedTechnology(),
- supportedNdefLength, cardState);
foundFormattable = false;
reconnect();
}
diff --git a/src/com/android/nfc/NfcService.java b/src/com/android/nfc/NfcService.java
index d91e3b5..6b671e8 100755
--- a/src/com/android/nfc/NfcService.java
+++ b/src/com/android/nfc/NfcService.java
@@ -1848,12 +1848,6 @@
}
}
- boolean playSound = (readerParams == null ||
- (readerParams.flags & NfcAdapter.FLAG_READER_NO_PLATFORM_SOUNDS) == 0) &&
- debounceTagUid == null;
- if (mScreenState == ScreenStateHelper.SCREEN_STATE_ON_UNLOCKED && playSound) {
- playSound(SOUND_START);
- }
if (tag.getConnectedTechnology() == TagTechnology.NFC_BARCODE) {
// When these tags start containing NDEF, they will require
// the stack to deal with them in a different way, since
@@ -1870,9 +1864,6 @@
// First try to see if this was a bad tag read
if (!tag.reconnect()) {
tag.disconnect();
- if (playSound) {
- playSound(SOUND_ERROR);
- }
break;
}
}