From cd7f018ec0cff0fcdcfe1399aa2398b809f2e35e Mon Sep 17 00:00:00 2001 From: Martijn Coenen Date: Thu, 29 Mar 2012 16:09:24 -0700 Subject: Let connect() fail with an I/O exception if tag has left the field. Because connect() can sometimes be implemented without any I/O, (usually between transitions to/from the NDEF technology), it does not always notice when a tag has left the field. Since we promise in the API docs that it does, fix it by checking (cached) presence. Change-Id: Ie6ad1b5dec3621051e395d3be0d0e09615e53ebc --- src/com/android/nfc/NfcService.java | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/com') diff --git a/src/com/android/nfc/NfcService.java b/src/com/android/nfc/NfcService.java index dca96b9..560c5aa 100755 --- a/src/com/android/nfc/NfcService.java +++ b/src/com/android/nfc/NfcService.java @@ -853,6 +853,10 @@ public class NfcService extends Application implements DeviceHostListener { return ErrorCodes.ERROR_DISCONNECT; } + if (!tag.isPresent()) { + return ErrorCodes.ERROR_DISCONNECT; + } + if (technology == TagTechnology.NFC_B) { return ErrorCodes.ERROR_NOT_SUPPORTED; } -- cgit v1.1