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
diff --git a/core/java/android/nfc/NdefRecord.java b/core/java/android/nfc/NdefRecord.java
index 2c9ce3f..093a9b4 100644
--- a/core/java/android/nfc/NdefRecord.java
+++ b/core/java/android/nfc/NdefRecord.java
@@ -938,7 +938,7 @@
      */
     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 @@
         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;