Skip to content

Commit

Permalink
Merge pull request #452 from CLOUDERHEM/master
Browse files Browse the repository at this point in the history
Fix Parcel problem on Android 14
  • Loading branch information
ikarus23 authored Dec 27, 2023
2 parents 132fef7 + d143df2 commit 0abf97e
Showing 1 changed file with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import android.nfc.TagLostException;
import android.nfc.tech.MifareClassic;
import android.nfc.tech.NfcA;
import android.os.Build;
import android.os.Bundle;
import android.os.IBinder;
import android.os.Parcel;
Expand Down Expand Up @@ -131,6 +132,11 @@ public static Tag patchTag(Tag tag) {
oldParcel.readIntArray(oldTechList);
Bundle[] oldTechExtras = oldParcel.createTypedArray(Bundle.CREATOR);
int serviceHandle = oldParcel.readInt();
// Android 14
long mCookie = 0;
if (android.os.Build.VERSION.SDK_INT > Build.VERSION_CODES.TIRAMISU) {
mCookie = oldParcel.readLong();
}
int isMock = oldParcel.readInt();
IBinder tagService;
if (isMock == 0) {
Expand All @@ -151,9 +157,9 @@ public static Tag patchTag(Tag tag) {
nfcaIdx = i;
}
if (oldTechExtras[i] != null
&& oldTechExtras[i].containsKey("sak")) {
&& oldTechExtras[i].containsKey("sak")) {
sak = (short) (sak
| oldTechExtras[i].getShort("sak"));
| oldTechExtras[i].getShort("sak"));
isFirstSak = nfcaIdx == i;
}
} else if (techList[i].equals(MifareClassic.class.getName())) {
Expand Down Expand Up @@ -189,6 +195,11 @@ public static Tag patchTag(Tag tag) {
newParcel.writeIntArray(oldTechList);
newParcel.writeTypedArray(oldTechExtras, 0);
newParcel.writeInt(serviceHandle);
// Android 14
if (android.os.Build.VERSION.SDK_INT > Build.VERSION_CODES.TIRAMISU) {
newParcel.writeLong(mCookie);
}

newParcel.writeInt(isMock);
if (isMock == 0) {
newParcel.writeStrongBinder(tagService);
Expand Down

0 comments on commit 0abf97e

Please sign in to comment.