summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrad Lassey <lassey@google.com>2023-12-07 16:15:10 -0500
committerBrad Lassey <lassey@google.com>2023-12-07 16:15:10 -0500
commit5c31853117ca5d138268a7ca04defd8188618daf (patch)
treef87719bd1e1fa7260e1ee338f27404c2d3ba841b
parent195cd12913f40fd15fdd276ee4b9bb5eeedee09b (diff)
downloadNfc-5c31853117ca5d138268a7ca04defd8188618daf.tar.gz
Use ByteBuffer.getInt() for the polling frame timestamps.
Bug: b/315361306 Test: Tested manually Change-Id: I912732282f76e6a1521617f60b479b5a8c42b5cc
-rwxr-xr-xnci/src/com/android/nfc/dhimpl/NativeNfcManager.java10
1 files changed, 4 insertions, 6 deletions
diff --git a/nci/src/com/android/nfc/dhimpl/NativeNfcManager.java b/nci/src/com/android/nfc/dhimpl/NativeNfcManager.java
index 5d8de0f1..fbdcd4c2 100755
--- a/nci/src/com/android/nfc/dhimpl/NativeNfcManager.java
+++ b/nci/src/com/android/nfc/dhimpl/NativeNfcManager.java
@@ -25,6 +25,8 @@ import android.util.Log;
import com.android.nfc.DeviceHost;
import com.android.nfc.NfcDiscoveryParameters;
import java.io.FileDescriptor;
+import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
@@ -441,12 +443,8 @@ public class NativeNfcManager implements DeviceHost {
frame.putByte(HostApduService.POLLING_LOOP_GAIN_KEY, gain);
}
if (pos + TLV_timestamp_offset + 3 < data_len) {
- long timestamp =
- ((long) p_data[pos + TLV_timestamp_offset] << 24L) |
- ((long) p_data[pos + TLV_timestamp_offset + 1] << 16L) |
- ((long) p_data[pos + TLV_timestamp_offset + 2] << 8L) |
- ((long) p_data[pos + TLV_timestamp_offset + 3]);
- frame.putLong(HostApduService.POLLING_LOOP_TIMESTAMP_KEY, timestamp);
+ int timestamp = ByteBuffer.wrap(p_data, pos + TLV_timestamp_offset, 4).order(ByteOrder.LITTLE_ENDIAN).getInt();
+ frame.putInt(HostApduService.POLLING_LOOP_TIMESTAMP_KEY, timestamp);
}
pos += (length + 2);
}