diff options
| author | 2011-01-14 16:26:45 +0100 | |
|---|---|---|
| committer | 2011-01-18 11:35:46 -0800 | |
| commit | 07e6f616d122496342a5bae51323bb218d88f7f2 (patch) | |
| tree | 392f1cc4a17815b71ff8ac618f62e8e371eaa225 | |
| parent | a701cf85a0167a6bb623343388a7dca6f2b61ac5 (diff) | |
Check NDEF before calling makeReadOnly().
Change-Id: Iadbaf5c29821eff78ad487b248af529febcdc4ce
| -rw-r--r-- | core/java/android/nfc/technology/Ndef.java | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/core/java/android/nfc/technology/Ndef.java b/core/java/android/nfc/technology/Ndef.java index 1c0afde052d0..f537941c79c7 100644 --- a/core/java/android/nfc/technology/Ndef.java +++ b/core/java/android/nfc/technology/Ndef.java @@ -221,18 +221,23 @@ public final class Ndef extends BasicTagTechnology { checkConnected(); try { - int errorCode = mTagService.ndefMakeReadOnly(mTag.getServiceHandle()); - switch (errorCode) { - case ErrorCodes.SUCCESS: - return true; - case ErrorCodes.ERROR_IO: - throw new IOException(); - case ErrorCodes.ERROR_INVALID_PARAM: - return false; - default: - // Should not happen - throw new IOException(); - } + if (mTagService.isNdef(mTag.getServiceHandle())) { + int errorCode = mTagService.ndefMakeReadOnly(mTag.getServiceHandle()); + switch (errorCode) { + case ErrorCodes.SUCCESS: + return true; + case ErrorCodes.ERROR_IO: + throw new IOException(); + case ErrorCodes.ERROR_INVALID_PARAM: + return false; + default: + // Should not happen + throw new IOException(); + } + } + else { + throw new IOException("Tag is not ndef"); + } } catch (RemoteException e) { Log.e(TAG, "NFC service dead", e); return false; |