summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Brad Lassey <lassey@google.com> 2024-07-08 18:10:30 -0400
committer Brad Lassey <lassey@google.com> 2024-07-09 12:43:09 -0400
commitaf9d1b2a6a19e71b7b675fc99c39b74617c7b79e (patch)
tree4fbb858b62d594d89f7710c83aefe90bf7afd37d
parentd53bee22fa451a4a5aed20352d9c651a77eae9ab (diff)
Add Test method to inject HCE data
Bug: 304449836 Test: Creating test method Flag: TEST_ONLY Change-Id: I0dc8c6223c1ae034d504910c4491073c8aa7fedb
-rw-r--r--nfc/java/android/nfc/INfcAdapter.aidl1
-rw-r--r--nfc/java/android/nfc/NfcAdapter.java27
2 files changed, 28 insertions, 0 deletions
diff --git a/nfc/java/android/nfc/INfcAdapter.aidl b/nfc/java/android/nfc/INfcAdapter.aidl
index fd77820afc81..90ca92f299a4 100644
--- a/nfc/java/android/nfc/INfcAdapter.aidl
+++ b/nfc/java/android/nfc/INfcAdapter.aidl
@@ -104,6 +104,7 @@ interface INfcAdapter
void notifyPollingLoop(in PollingFrame frame);
void notifyHceDeactivated();
+ void notifyTestHceData(in int technology, in byte[] data);
int sendVendorNciMessage(int mt, int gid, int oid, in byte[] payload);
void registerVendorExtensionCallback(in INfcVendorNciCallback callbacks);
void unregisterVendorExtensionCallback(in INfcVendorNciCallback callbacks);
diff --git a/nfc/java/android/nfc/NfcAdapter.java b/nfc/java/android/nfc/NfcAdapter.java
index 1dfc81e2108e..9ce1c8257c17 100644
--- a/nfc/java/android/nfc/NfcAdapter.java
+++ b/nfc/java/android/nfc/NfcAdapter.java
@@ -2857,6 +2857,33 @@ public final class NfcAdapter {
}
/**
+ * Notifies the system of new HCE data for tests.
+ *
+ * @hide
+ */
+ @FlaggedApi(Flags.FLAG_NFC_READ_POLLING_LOOP)
+ public void notifyTestHceData(int technology, byte[] data) {
+ try {
+ if (sService == null) {
+ attemptDeadServiceRecovery(null);
+ }
+ sService.notifyTestHceData(technology, data);
+ } catch (RemoteException e) {
+ attemptDeadServiceRecovery(e);
+ // Try one more time
+ if (sService == null) {
+ Log.e(TAG, "Failed to recover NFC Service.");
+ return;
+ }
+ try {
+ sService.notifyTestHceData(technology, data);
+ } catch (RemoteException e2) {
+ Log.e(TAG, "Failed to recover NFC Service.");
+ }
+ }
+ }
+
+ /**
* Notifies the system of a an HCE session being deactivated.
* *
* @hide