Implementing support for NFC observe mode, polling loop fingerprints
and field strength along with their associated APIs.
Bug: 294217286
Bug: 294435374
Bug: 296057223
Test: tested with CTS and manually
Change-Id: I4b0244fa5ffef7e7b28147ede2593a7477d1c86d
diff --git a/tests/tests/nfc/src/android/nfc/cts/HostApduServiceTest.java b/tests/tests/nfc/src/android/nfc/cts/HostApduServiceTest.java
index e551812..eb7d83c 100644
--- a/tests/tests/nfc/src/android/nfc/cts/HostApduServiceTest.java
+++ b/tests/tests/nfc/src/android/nfc/cts/HostApduServiceTest.java
@@ -3,12 +3,18 @@
import android.content.Intent;
import android.os.Bundle;
import android.os.Looper;
+import android.platform.test.annotations.RequiresFlagsEnabled;
+
+
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
+import java.util.ArrayList;
+
+
@RunWith(JUnit4.class)
public class HostApduServiceTest {
private CtsMyHostApduService service;
@@ -47,6 +53,15 @@
}
}
+ @Test
+ @RequiresFlagsEnabled(android.nfc.Flags.FLAG_NFC_READ_POLLING_LOOP)
+ public void testProcessPollingFrame() {
+ ArrayList<Bundle> frames = new ArrayList<Bundle>();
+ Bundle frame = new Bundle();
+ frames.add(frame);
+ service.processPollingFrames(frames);
+ }
+
@Test
public void testProcessCommandApdu() {
byte[] result = service.processCommandApdu(new byte[0], new Bundle());
diff --git a/tests/tests/nfc/src/android/nfc/cts/NfcAdapterTest.java b/tests/tests/nfc/src/android/nfc/cts/NfcAdapterTest.java
index 946cead..0cdb4b2 100644
--- a/tests/tests/nfc/src/android/nfc/cts/NfcAdapterTest.java
+++ b/tests/tests/nfc/src/android/nfc/cts/NfcAdapterTest.java
@@ -15,12 +15,12 @@
import android.content.IntentFilter;
import android.content.pm.PackageManager;
import android.nfc.*;
-import android.platform.test.annotations.RequiresFlagsEnabled;
-import android.platform.test.flag.junit.CheckFlagsRule;
-import android.platform.test.flag.junit.DeviceFlagsValueProvider;
import android.nfc.tech.*;
import android.os.Bundle;
import android.os.RemoteException;
+import android.platform.test.annotations.RequiresFlagsEnabled;
+import android.platform.test.flag.junit.CheckFlagsRule;
+import android.platform.test.flag.junit.DeviceFlagsValueProvider;
import androidx.test.InstrumentationRegistry;
import androidx.test.core.app.ApplicationProvider;
@@ -283,6 +283,30 @@
adapter.setReaderMode(false);
}
+ @Test
+ @RequiresFlagsEnabled(android.nfc.Flags.FLAG_NFC_OBSERVE_MODE)
+ public void testIsObserveModeSupported() {
+ NfcAdapter adapter = NfcAdapter.getDefaultAdapter(mContext);
+ boolean result = adapter.isObserveModeSupported();
+ Assert.assertTrue(result);
+ }
+
+ @Test
+ @RequiresFlagsEnabled(android.nfc.Flags.FLAG_NFC_OBSERVE_MODE)
+ public void testAllowTransaction() {
+ NfcAdapter adapter = NfcAdapter.getDefaultAdapter(mContext);
+ boolean result = adapter.allowTransaction();
+ Assert.assertTrue(result);
+ }
+
+ @Test
+ @RequiresFlagsEnabled(android.nfc.Flags.FLAG_NFC_OBSERVE_MODE)
+ public void testDisallowTransaction() {
+ NfcAdapter adapter = NfcAdapter.getDefaultAdapter(mContext);
+ boolean result = adapter.disallowTransaction();
+ Assert.assertTrue(result);
+ }
+
private class CtsReaderCallback implements NfcAdapter.ReaderCallback {
@Override
public void onTagDiscovered(Tag tag) {}