diff options
| author | 2017-05-15 13:53:04 +0900 | |
|---|---|---|
| committer | 2017-05-26 20:53:10 +0000 | |
| commit | dd0c9bbbb2d4b0c1ff633f2451fad892493a4c44 (patch) | |
| tree | cddb7a535eba0ea8280e574fffc090cd567116b8 | |
| parent | 21cc4bcd01266446b438e6c7a51cb8d63d61039f (diff) | |
Add ID_LENGTH field for Empty type record
If ID_LENGTH field is omitted from Empty Type record, it cannot be
detected as Ndef since the data is strictly checked by e3fc7d9954.
But it is not possible to create raw bytes of Empty Type record
which can meet this condition by using NdefRecord/NdefMessage.
To fix this issue, added ID_LENGTH field to Empty type record.
Bug: 38299566
Test: Write and read NDEF tag with empty type record
Change-Id: Idb58c80cf8562a8b314f4ddeccdc627dc0c6f5b4
| -rw-r--r-- | core/java/android/nfc/NdefRecord.java | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/core/java/android/nfc/NdefRecord.java b/core/java/android/nfc/NdefRecord.java index 2c9ce3f99285..093a9b469cb8 100644 --- a/core/java/android/nfc/NdefRecord.java +++ b/core/java/android/nfc/NdefRecord.java @@ -938,7 +938,7 @@ public final class NdefRecord implements Parcelable { */ void writeToByteBuffer(ByteBuffer buffer, boolean mb, boolean me) { boolean sr = mPayload.length < 256; - boolean il = mId.length > 0; + boolean il = mTnf == TNF_EMPTY ? true : mId.length > 0; byte flags = (byte)((mb ? FLAG_MB : 0) | (me ? FLAG_ME : 0) | (sr ? FLAG_SR : 0) | (il ? FLAG_IL : 0) | mTnf); @@ -966,7 +966,7 @@ public final class NdefRecord implements Parcelable { int length = 3 + mType.length + mId.length + mPayload.length; boolean sr = mPayload.length < 256; - boolean il = mId.length > 0; + boolean il = mTnf == TNF_EMPTY ? true : mId.length > 0; if (!sr) length += 3; if (il) length += 1; |