Add Test method to inject HCE data
Bug: 304449836
Test: Creating test method
Flag: TEST_ONLY
Merged-In: I0dc8c6223c1ae034d504910c4491073c8aa7fedb
Change-Id: I0dc8c6223c1ae034d504910c4491073c8aa7fedb
diff --git a/nfc/java/android/nfc/INfcAdapter.aidl b/nfc/java/android/nfc/INfcAdapter.aidl
index fd77820..90ca92f 100644
--- a/nfc/java/android/nfc/INfcAdapter.aidl
+++ b/nfc/java/android/nfc/INfcAdapter.aidl
@@ -104,6 +104,7 @@
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 1dfc81e..9ce1c82 100644
--- a/nfc/java/android/nfc/NfcAdapter.java
+++ b/nfc/java/android/nfc/NfcAdapter.java
@@ -2857,6 +2857,33 @@
}
/**
+ * 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