diff options
author | Martijn Coenen <maco@google.com> | 2011-11-28 09:56:49 -0800 |
---|---|---|
committer | Martijn Coenen <maco@google.com> | 2011-11-28 10:02:38 -0800 |
commit | 841409b8ad298d34de24e584f3c152f023c3d2f4 (patch) | |
tree | 01a910d1cb91492c3a396d7a0d9cbbcfca1a61e5 /src/com/android | |
parent | 483f3065021c878468ab0921140aa9a2c89b4246 (diff) | |
download | packages_apps_nfc-841409b8ad298d34de24e584f3c152f023c3d2f4.zip packages_apps_nfc-841409b8ad298d34de24e584f3c152f023c3d2f4.tar.gz packages_apps_nfc-841409b8ad298d34de24e584f3c152f023c3d2f4.tar.bz2 |
Fix NdefFormatable not showing up for NfcA technologies.
Regression from a patch applied long ago: the NfcA technology
used to have its higher-level type (Mifare / 4A) associated with it,
and the code that determined formatable used this. The patch
associated NfcA technology only with the 3A libnfc type, causing the
format check to return false for all of these types.
Change-Id: Idc02873de447b6d8121bff02af795a6a7f5058cf
Diffstat (limited to 'src/com/android')
-rwxr-xr-x | src/com/android/nfc/nxp/NativeNfcTag.java | 34 |
1 files changed, 23 insertions, 11 deletions
diff --git a/src/com/android/nfc/nxp/NativeNfcTag.java b/src/com/android/nfc/nxp/NativeNfcTag.java index dcbbf14..4c137d5 100755 --- a/src/com/android/nfc/nxp/NativeNfcTag.java +++ b/src/com/android/nfc/nxp/NativeNfcTag.java @@ -363,19 +363,31 @@ public class NativeNfcTag implements TagEndpoint { return result; } - native boolean doIsNdefFormatable(int libnfctype, byte[] uid, byte[] poll, byte[] act); + native boolean doIsIsoDepNdefFormatable(byte[] poll, byte[] act); @Override public synchronized boolean isNdefFormatable() { - // Call native code to determine at lower level if format - // is possible. It will need poll/activation time bytes for this. - int nfcaTechIndex = getTechIndex(TagTechnology.NFC_A); - int nfcvTechIndex = getTechIndex(TagTechnology.NFC_V); - if (nfcaTechIndex != -1) { - return doIsNdefFormatable(mTechLibNfcTypes[nfcaTechIndex], mUid, - mTechPollBytes[nfcaTechIndex], mTechActBytes[nfcaTechIndex]); - } else if (nfcvTechIndex != -1) { - return doIsNdefFormatable(mTechLibNfcTypes[nfcvTechIndex], mUid, - mTechPollBytes[nfcvTechIndex], mTechActBytes[nfcvTechIndex]); + if (hasTech(TagTechnology.MIFARE_CLASSIC) || hasTech(TagTechnology.MIFARE_ULTRALIGHT)) { + // These are always formatable + return true; + } + if (hasTech(TagTechnology.NFC_V)) { + // Currently libnfc only formats NXP NFC-V tags + if (mUid[5] >= 1 && mUid[5] <= 3 && mUid[6] == 0x04) { + return true; + } else { + return false; + } + } + // For ISO-DEP, call native code to determine at lower level if format + // is possible. It will need NFC-A poll/activation time bytes for this. + if (hasTech(TagTechnology.ISO_DEP)) { + int nfcaTechIndex = getTechIndex(TagTechnology.NFC_A); + if (nfcaTechIndex != -1) { + return doIsIsoDepNdefFormatable(mTechPollBytes[nfcaTechIndex], + mTechActBytes[nfcaTechIndex]); + } else { + return false; + } } else { // Formatting not supported by libNFC return false; |