1 /* 2 * Copyright (C) 2011 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.cts.verifier.nfc.hce; 18 19 import android.nfc.NfcAdapter; 20 import android.nfc.cardemulation.CardEmulation; 21 import com.android.cts.verifier.ArrayTestListAdapter; 22 import com.android.cts.verifier.PassFailButtons; 23 import com.android.cts.verifier.R; 24 import com.android.cts.verifier.TestListAdapter.TestListItem; 25 26 import android.content.Intent; 27 import android.content.pm.PackageManager; 28 import android.os.Bundle; 29 30 /** Activity that lists all the NFC HCE reader tests. */ 31 public class HceReaderTestActivity extends PassFailButtons.TestListActivity { 32 @Override onCreate(Bundle savedInstanceState)33 protected void onCreate(Bundle savedInstanceState) { 34 super.onCreate(savedInstanceState); 35 setContentView(R.layout.pass_fail_list); 36 setInfoResources(R.string.nfc_test, R.string.nfc_hce_reader_test_info, 0); 37 setPassFailButtonClickListeners(); 38 39 ArrayTestListAdapter adapter = new ArrayTestListAdapter(this); 40 41 if (getPackageManager().hasSystemFeature(PackageManager.FEATURE_NFC_HOST_CARD_EMULATION)) { 42 adapter.add(TestListItem.newCategory(this, R.string.nfc_hce_reader_tests)); 43 44 adapter.add(TestListItem.newTest(this, R.string.nfc_hce_protocol_params_reader, 45 ProtocolParamsReaderActivity.class.getName(), 46 new Intent(this, ProtocolParamsReaderActivity.class), null)); 47 48 adapter.add(TestListItem.newTest(this, R.string.nfc_hce_single_payment_reader, 49 getString(R.string.nfc_hce_single_payment_reader), 50 SinglePaymentEmulatorActivity.buildReaderIntent(this), null)); 51 52 adapter.add(TestListItem.newTest(this, R.string.nfc_hce_dual_payment_reader, 53 getString(R.string.nfc_hce_dual_payment_reader), 54 DualPaymentEmulatorActivity.buildReaderIntent(this), null)); 55 56 adapter.add(TestListItem.newTest(this, R.string.nfc_hce_change_default_reader, 57 getString(R.string.nfc_hce_change_default_reader), 58 ChangeDefaultEmulatorActivity.buildReaderIntent(this), null)); 59 60 adapter.add(TestListItem.newTest(this, R.string.nfc_hce_foreground_payment_reader, 61 getString(R.string.nfc_hce_foreground_payment_reader), 62 ForegroundPaymentEmulatorActivity.buildReaderIntent(this), null)); 63 64 adapter.add(TestListItem.newTest(this, R.string.nfc_hce_single_non_payment_reader, 65 getString(R.string.nfc_hce_single_non_payment_reader), 66 SingleNonPaymentEmulatorActivity.buildReaderIntent(this), null)); 67 68 adapter.add(TestListItem.newTest(this, R.string.nfc_hce_dual_non_payment_reader, 69 getString(R.string.nfc_hce_dual_non_payment_reader), 70 DualNonPaymentEmulatorActivity.buildReaderIntent(this), null)); 71 72 adapter.add(TestListItem.newTest(this, R.string.nfc_hce_conflicting_non_payment_reader, 73 getString(R.string.nfc_hce_conflicting_non_payment_reader), 74 ConflictingNonPaymentEmulatorActivity.buildReaderIntent(this), null)); 75 76 adapter.add(TestListItem.newTest(this, R.string.nfc_hce_foreground_non_payment_reader, 77 getString(R.string.nfc_hce_foreground_non_payment_reader), 78 ForegroundNonPaymentEmulatorActivity.buildReaderIntent(this), null)); 79 80 adapter.add(TestListItem.newTest(this, R.string.nfc_hce_throughput_reader, 81 getString(R.string.nfc_hce_throughput_reader), 82 ThroughputEmulatorActivity.buildReaderIntent(this), null)); 83 84 adapter.add(TestListItem.newTest(this, R.string.nfc_hce_tap_test_reader, 85 getString(R.string.nfc_hce_tap_test_reader), 86 TapTestEmulatorActivity.buildReaderIntent(this), null)); 87 88 adapter.add(TestListItem.newTest(this, R.string.nfc_hce_offhost_service_reader, 89 getString(R.string.nfc_hce_offhost_service_reader), 90 OffHostEmulatorActivity.buildReaderIntent(this), null)); 91 92 adapter.add(TestListItem.newTest(this, R.string.nfc_hce_on_and_offhost_service_reader, 93 getString(R.string.nfc_hce_on_and_offhost_service_reader), 94 OnAndOffHostEmulatorActivity.buildReaderIntent(this), null)); 95 96 adapter.add(TestListItem.newTest(this, R.string.nfc_hce_payment_dynamic_aids_reader, 97 getString(R.string.nfc_hce_payment_dynamic_aids_reader), 98 DynamicAidEmulatorActivity.buildReaderIntent(this), null)); 99 100 adapter.add(TestListItem.newTest(this, R.string.nfc_hce_large_num_aids_reader, 101 getString(R.string.nfc_hce_large_num_aids_reader), 102 LargeNumAidsEmulatorActivity.buildReaderIntent(this), null)); 103 104 NfcAdapter nfcAdapter = NfcAdapter.getDefaultAdapter(this); 105 CardEmulation cardEmulation = CardEmulation.getInstance(nfcAdapter); 106 if (cardEmulation.supportsAidPrefixRegistration()) { 107 adapter.add(TestListItem.newTest(this, R.string.nfc_hce_payment_prefix_aids_reader, 108 getString(R.string.nfc_hce_payment_prefix_aids_reader), 109 PrefixPaymentEmulatorActivity.buildReaderIntent(this), null)); 110 111 adapter.add(TestListItem.newTest(this, R.string.nfc_hce_payment_prefix_aids_reader_2, 112 getString(R.string.nfc_hce_payment_prefix_aids_reader_2), 113 PrefixPaymentEmulator2Activity.buildReaderIntent(this), null)); 114 115 adapter.add(TestListItem.newTest(this, R.string.nfc_hce_other_prefix_aids_reader, 116 getString(R.string.nfc_hce_other_prefix_aids_reader), 117 DualNonPaymentPrefixEmulatorActivity.buildReaderIntent(this), null)); 118 119 adapter.add(TestListItem.newTest(this, R.string.nfc_hce_other_conflicting_prefix_aids_reader, 120 getString(R.string.nfc_hce_other_conflicting_prefix_aids_reader), 121 ConflictingNonPaymentPrefixEmulatorActivity.buildReaderIntent(this), null)); 122 } 123 } 124 125 setTestListAdapter(adapter); 126 } 127 } 128