Merge "Add CTS test for registering a large number of AIDs." into lmp-sprout-dev
diff --git a/apps/CtsVerifier/AndroidManifest.xml b/apps/CtsVerifier/AndroidManifest.xml
index cef1625..1c08e58 100644
--- a/apps/CtsVerifier/AndroidManifest.xml
+++ b/apps/CtsVerifier/AndroidManifest.xml
@@ -589,6 +589,10 @@
android:label="@string/nfc_hce_payment_dynamic_aids_emulator"
android:configChanges="keyboardHidden|orientation|screenSize" />
+ <activity android:name=".nfc.hce.LargeNumAidsEmulatorActivity"
+ android:label="@string/nfc_hce_large_num_aids_emulator"
+ android:configChanges="keyboardHidden|orientation|screenSize" />
+
<activity android:name=".nfc.hce.PrefixPaymentEmulatorActivity"
android:label="@string/nfc_hce_payment_prefix_aids_emulator"
android:configChanges="keyboardHidden|orientation|screenSize" />
@@ -724,6 +728,15 @@
</intent-filter>
<meta-data android:name="android.nfc.cardemulation.host_apdu_service" android:resource="@xml/access_prefix_aid_list"/>
</service>
+ <service android:name=".nfc.hce.LargeNumAidsService" android:exported="true"
+ android:permission="android.permission.BIND_NFC_SERVICE"
+ android:enabled="false">
+ <intent-filter>
+ <action android:name="android.nfc.cardemulation.action.HOST_APDU_SERVICE"/>
+ <category android:name="android.intent.category.DEFAULT"/>
+ </intent-filter>
+ <meta-data android:name="android.nfc.cardemulation.host_apdu_service" android:resource="@xml/payment_aid_list_1"/>
+ </service>
<!-- Service used for Camera ITS tests -->
<service android:name=".camera.its.ItsService" >
diff --git a/apps/CtsVerifier/res/values/strings.xml b/apps/CtsVerifier/res/values/strings.xml
index e8cca29..94cf90a 100644
--- a/apps/CtsVerifier/res/values/strings.xml
+++ b/apps/CtsVerifier/res/values/strings.xml
@@ -441,6 +441,10 @@
<string name="nfc_hce_payment_dynamic_aids_reader">Dynamic payment AIDs (Reader)</string>
<string name="nfc_hce_payment_dynamic_aids_help">This test tries to register dynamic AIDs for a payment service.</string>
+ <string name="nfc_hce_large_num_aids_emulator">Large number of AIDs (Emulator)</string>
+ <string name="nfc_hce_large_num_aids_reader">Large number of AIDs (Reader)</string>
+ <string name="nfc_hce_large_num_aids_help">This test tries to register a large number of different AIDs, to make sure there are no limitations on the maximum amount of HCE apps on the device. Note that this test may take a few seconds to complete; please be patient.</string>
+
<string name="nfc_hce_payment_prefix_aids_emulator">Payment prefix AIDs (Emulator)</string>
<string name="nfc_hce_payment_prefix_aids_reader">Payment prefix AIDs (Reader)</string>
<string name="nfc_hce_payment_prefix_aids_help">This test statically registers prefix AIDs for a payment service.</string>
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/nfc/hce/BaseEmulatorActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/nfc/hce/BaseEmulatorActivity.java
index 8aa82b5..5f3a10a 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/nfc/hce/BaseEmulatorActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/nfc/hce/BaseEmulatorActivity.java
@@ -45,7 +45,8 @@
PrefixPaymentService2.COMPONENT,
PrefixTransportService1.COMPONENT,
PrefixTransportService2.COMPONENT,
- PrefixAccessService.COMPONENT)
+ PrefixAccessService.COMPONENT,
+ LargeNumAidsService.COMPONENT)
);
@Override
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/nfc/hce/HceEmulatorTestActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/nfc/hce/HceEmulatorTestActivity.java
index 87fa3d1..b30bb73 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/nfc/hce/HceEmulatorTestActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/nfc/hce/HceEmulatorTestActivity.java
@@ -104,6 +104,10 @@
new Intent(this, OnAndOffHostEmulatorActivity.class), null));
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
+ adapter.add(TestListItem.newTest(this, R.string.nfc_hce_large_num_aids_emulator,
+ LargeNumAidsEmulatorActivity.class.getName(),
+ new Intent(this, LargeNumAidsEmulatorActivity.class), null));
+
adapter.add(TestListItem.newTest(this, R.string.nfc_hce_payment_dynamic_aids_emulator,
DynamicAidEmulatorActivity.class.getName(),
new Intent(this, DynamicAidEmulatorActivity.class), null));
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/nfc/hce/HceReaderTestActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/nfc/hce/HceReaderTestActivity.java
index 4c77871..035ce86 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/nfc/hce/HceReaderTestActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/nfc/hce/HceReaderTestActivity.java
@@ -103,6 +103,10 @@
SimpleReaderActivity.class.getName(),
DynamicAidEmulatorActivity.buildReaderIntent(this), null));
+ adapter.add(TestListItem.newTest(this, R.string.nfc_hce_large_num_aids_reader,
+ SimpleReaderActivity.class.getName(),
+ LargeNumAidsEmulatorActivity.buildReaderIntent(this), null));
+
NfcAdapter nfcAdapter = NfcAdapter.getDefaultAdapter(this);
CardEmulation cardEmulation = CardEmulation.getInstance(nfcAdapter);
if (cardEmulation.supportsAidPrefixRegistration()) {
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/nfc/hce/HceUtils.java b/apps/CtsVerifier/src/com/android/cts/verifier/nfc/hce/HceUtils.java
index c67169a..698948b 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/nfc/hce/HceUtils.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/nfc/hce/HceUtils.java
@@ -22,6 +22,9 @@
public static final String TRANSPORT_PREFIX_AID = "F001020304";
public static final String ACCESS_PREFIX_AID = "F005060708";
+ public static final String LARGE_NUM_AIDS_PREFIX = "F00102030414";
+ public static final String LARGE_NUM_AIDS_POSTFIX ="81";
+
public static void enableComponent(PackageManager pm, ComponentName component) {
pm.setComponentEnabledSetting(
component,
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/nfc/hce/LargeNumAidsEmulatorActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/nfc/hce/LargeNumAidsEmulatorActivity.java
new file mode 100644
index 0000000..db58252
--- /dev/null
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/nfc/hce/LargeNumAidsEmulatorActivity.java
@@ -0,0 +1,59 @@
+package com.android.cts.verifier.nfc.hce;
+
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.Intent;
+import android.nfc.cardemulation.CardEmulation;
+import android.os.Bundle;
+
+import com.android.cts.verifier.R;
+import com.android.cts.verifier.nfc.NfcDialogs;
+
+import java.util.ArrayList;
+
+public class LargeNumAidsEmulatorActivity extends BaseEmulatorActivity {
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.pass_fail_text);
+ setPassFailButtonClickListeners();
+ getPassButton().setEnabled(false);
+ setupServices(this, LargeNumAidsService.COMPONENT);
+ }
+
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+ }
+
+
+ @Override
+ void onServicesSetup(boolean result) {
+ ArrayList<String> aids = new ArrayList<String>();
+ for (int i = 0; i < 256; i++) {
+ aids.add(HceUtils.LARGE_NUM_AIDS_PREFIX + String.format("%02X", i) + HceUtils.LARGE_NUM_AIDS_POSTFIX);
+ }
+ mCardEmulation.registerAidsForService(LargeNumAidsService.COMPONENT,
+ CardEmulation.CATEGORY_OTHER, aids);
+ }
+
+ @Override
+ void onApduSequenceComplete(ComponentName component, long duration) {
+ if (component.equals(LargeNumAidsService.COMPONENT)) {
+ getPassButton().setEnabled(true);
+ }
+ }
+
+ public static Intent buildReaderIntent(Context context) {
+ Intent readerIntent = new Intent(context, SimpleReaderActivity.class);
+ readerIntent.putExtra(SimpleReaderActivity.EXTRA_APDUS,
+ LargeNumAidsService.getCommandSequence());
+ readerIntent.putExtra(SimpleReaderActivity.EXTRA_RESPONSES,
+ LargeNumAidsService.getResponseSequence());
+ readerIntent.putExtra(SimpleReaderActivity.EXTRA_LABEL,
+ context.getString(R.string.nfc_hce_large_num_aids_reader));
+ return readerIntent;
+ }
+}
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/nfc/hce/LargeNumAidsService.java b/apps/CtsVerifier/src/com/android/cts/verifier/nfc/hce/LargeNumAidsService.java
new file mode 100644
index 0000000..5883543
--- /dev/null
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/nfc/hce/LargeNumAidsService.java
@@ -0,0 +1,37 @@
+package com.android.cts.verifier.nfc.hce;
+
+import android.content.ComponentName;
+
+public class LargeNumAidsService extends HceService {
+ static final String TAG = "LargeNumAidsService";
+
+ static final ComponentName COMPONENT =
+ new ComponentName("com.android.cts.verifier",
+ LargeNumAidsService.class.getName());
+
+ public static final CommandApdu[] getCommandSequence() {
+ CommandApdu[] commands = new CommandApdu[256];
+ for (int i = 0; i < 256; i++) {
+ commands[i] = HceUtils.buildSelectApdu(HceUtils.LARGE_NUM_AIDS_PREFIX + String.format("%02X", i) +
+ HceUtils.LARGE_NUM_AIDS_POSTFIX, true);
+ }
+ return commands;
+ }
+
+ public static final String[] getResponseSequence() {
+ String[] responses = new String[256];
+ for (int i = 0; i < 256; i++) {
+ responses[i] = "9000" + String.format("%02X", i);
+ }
+ return responses;
+ }
+
+ public LargeNumAidsService() {
+ initialize(getCommandSequence(), getResponseSequence());
+ }
+
+ @Override
+ public ComponentName getComponent() {
+ return COMPONENT;
+ }
+}
\ No newline at end of file