Loading core/java/android/nfc/NdefRecord.java +16 −5 Original line number Diff line number Diff line Loading @@ -163,6 +163,18 @@ public final class NdefRecord implements Parcelable { * must not be null */ public NdefRecord(short tnf, byte[] type, byte[] id, byte[] payload) { /* New NDEF records created by applications will have FLAG_MB|FLAG_ME * set by default; when multiple records are stored in a * {@link NdefMessage}, these flags will be corrected when the {@link NdefMessage} * is serialized to bytes. */ this(tnf, type, id, payload, (byte)(FLAG_MB|FLAG_ME)); } /** * @hide */ /*package*/ NdefRecord(short tnf, byte[] type, byte[] id, byte[] payload, byte flags) { /* check arguments */ if ((type == null) || (id == null) || (payload == null)) { throw new IllegalArgumentException("Illegal null argument"); Loading @@ -172,9 +184,6 @@ public final class NdefRecord implements Parcelable { throw new IllegalArgumentException("TNF out of range " + tnf); } /* generate flag */ byte flags = FLAG_MB | FLAG_ME; /* Determine if it is a short record */ if(payload.length < 0xFF) { flags |= FLAG_SR; Loading Loading @@ -258,6 +267,7 @@ public final class NdefRecord implements Parcelable { } public void writeToParcel(Parcel dest, int flags) { dest.writeInt(mFlags); dest.writeInt(mTnf); dest.writeInt(mType.length); dest.writeByteArray(mType); Loading @@ -270,6 +280,7 @@ public final class NdefRecord implements Parcelable { public static final Parcelable.Creator<NdefRecord> CREATOR = new Parcelable.Creator<NdefRecord>() { public NdefRecord createFromParcel(Parcel in) { byte flags = (byte)in.readInt(); short tnf = (short)in.readInt(); int typeLength = in.readInt(); byte[] type = new byte[typeLength]; Loading @@ -281,7 +292,7 @@ public final class NdefRecord implements Parcelable { byte[] payload = new byte[payloadLength]; in.readByteArray(payload); return new NdefRecord(tnf, type, id, payload); return new NdefRecord(tnf, type, id, payload, flags); } public NdefRecord[] newArray(int size) { return new NdefRecord[size]; Loading core/jni/android_nfc_NdefMessage.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -86,7 +86,7 @@ static jint android_nfc_NdefMessage_parseNdefMessage(JNIEnv *e, jobject o, if (records_array == NULL) goto end; ctor = e->GetMethodID(record_cls, "<init>", "(S[B[B[B)V"); ctor = e->GetMethodID(record_cls, "<init>", "(S[B[B[BB)V"); for (i = 0; i < num_of_records; i++) { jbyteArray type, id, payload; Loading Loading @@ -128,7 +128,7 @@ static jint android_nfc_NdefMessage_parseNdefMessage(JNIEnv *e, jobject o, (jbyte *)record.PayloadData); new_record = e->NewObject(record_cls, ctor, (jshort)record.Tnf, type, id, payload); (jshort)record.Tnf, type, id, payload, (jbyte)record.Flags); e->SetObjectArrayElement(records_array, i, new_record); Loading core/jni/android_nfc_NdefRecord.cpp +6 −1 Original line number Diff line number Diff line Loading @@ -91,7 +91,7 @@ static jint android_nfc_NdefRecord_parseNdefRecord(JNIEnv *e, jobject o, jint ret = -1; phFriNfc_NdefRecord_t record; jfieldID mType, mId, mPayload, mTnf; jfieldID mType, mId, mPayload, mTnf, mFlags; jbyteArray type = NULL; jbyteArray id = NULL; jbyteArray payload = NULL; Loading Loading @@ -142,10 +142,15 @@ static jint android_nfc_NdefRecord_parseNdefRecord(JNIEnv *e, jobject o, if (payload == NULL) { goto clean_and_return; } e->SetByteArrayRegion(payload, 0, record.PayloadLength, (jbyte *)record.PayloadData); e->SetObjectField(o, mPayload, payload); /* Set flags field */ mFlags = e->GetFieldID(record_cls, "mFlags", "B"); e->SetIntField(o, mFlags, record.Flags); ret = 0; clean_and_return: Loading Loading
core/java/android/nfc/NdefRecord.java +16 −5 Original line number Diff line number Diff line Loading @@ -163,6 +163,18 @@ public final class NdefRecord implements Parcelable { * must not be null */ public NdefRecord(short tnf, byte[] type, byte[] id, byte[] payload) { /* New NDEF records created by applications will have FLAG_MB|FLAG_ME * set by default; when multiple records are stored in a * {@link NdefMessage}, these flags will be corrected when the {@link NdefMessage} * is serialized to bytes. */ this(tnf, type, id, payload, (byte)(FLAG_MB|FLAG_ME)); } /** * @hide */ /*package*/ NdefRecord(short tnf, byte[] type, byte[] id, byte[] payload, byte flags) { /* check arguments */ if ((type == null) || (id == null) || (payload == null)) { throw new IllegalArgumentException("Illegal null argument"); Loading @@ -172,9 +184,6 @@ public final class NdefRecord implements Parcelable { throw new IllegalArgumentException("TNF out of range " + tnf); } /* generate flag */ byte flags = FLAG_MB | FLAG_ME; /* Determine if it is a short record */ if(payload.length < 0xFF) { flags |= FLAG_SR; Loading Loading @@ -258,6 +267,7 @@ public final class NdefRecord implements Parcelable { } public void writeToParcel(Parcel dest, int flags) { dest.writeInt(mFlags); dest.writeInt(mTnf); dest.writeInt(mType.length); dest.writeByteArray(mType); Loading @@ -270,6 +280,7 @@ public final class NdefRecord implements Parcelable { public static final Parcelable.Creator<NdefRecord> CREATOR = new Parcelable.Creator<NdefRecord>() { public NdefRecord createFromParcel(Parcel in) { byte flags = (byte)in.readInt(); short tnf = (short)in.readInt(); int typeLength = in.readInt(); byte[] type = new byte[typeLength]; Loading @@ -281,7 +292,7 @@ public final class NdefRecord implements Parcelable { byte[] payload = new byte[payloadLength]; in.readByteArray(payload); return new NdefRecord(tnf, type, id, payload); return new NdefRecord(tnf, type, id, payload, flags); } public NdefRecord[] newArray(int size) { return new NdefRecord[size]; Loading
core/jni/android_nfc_NdefMessage.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -86,7 +86,7 @@ static jint android_nfc_NdefMessage_parseNdefMessage(JNIEnv *e, jobject o, if (records_array == NULL) goto end; ctor = e->GetMethodID(record_cls, "<init>", "(S[B[B[B)V"); ctor = e->GetMethodID(record_cls, "<init>", "(S[B[B[BB)V"); for (i = 0; i < num_of_records; i++) { jbyteArray type, id, payload; Loading Loading @@ -128,7 +128,7 @@ static jint android_nfc_NdefMessage_parseNdefMessage(JNIEnv *e, jobject o, (jbyte *)record.PayloadData); new_record = e->NewObject(record_cls, ctor, (jshort)record.Tnf, type, id, payload); (jshort)record.Tnf, type, id, payload, (jbyte)record.Flags); e->SetObjectArrayElement(records_array, i, new_record); Loading
core/jni/android_nfc_NdefRecord.cpp +6 −1 Original line number Diff line number Diff line Loading @@ -91,7 +91,7 @@ static jint android_nfc_NdefRecord_parseNdefRecord(JNIEnv *e, jobject o, jint ret = -1; phFriNfc_NdefRecord_t record; jfieldID mType, mId, mPayload, mTnf; jfieldID mType, mId, mPayload, mTnf, mFlags; jbyteArray type = NULL; jbyteArray id = NULL; jbyteArray payload = NULL; Loading Loading @@ -142,10 +142,15 @@ static jint android_nfc_NdefRecord_parseNdefRecord(JNIEnv *e, jobject o, if (payload == NULL) { goto clean_and_return; } e->SetByteArrayRegion(payload, 0, record.PayloadLength, (jbyte *)record.PayloadData); e->SetObjectField(o, mPayload, payload); /* Set flags field */ mFlags = e->GetFieldID(record_cls, "mFlags", "B"); e->SetIntField(o, mFlags, record.Flags); ret = 0; clean_and_return: Loading