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.Build; 29 import android.os.Bundle; 30 import android.os.SystemProperties; 31 32 /** Activity that lists all the NFC HCE reader tests. */ 33 public class HceReaderTestActivity extends PassFailButtons.TestListActivity { 34 @Override onCreate(Bundle savedInstanceState)35 protected void onCreate(Bundle savedInstanceState) { 36 super.onCreate(savedInstanceState); 37 setContentView(R.layout.pass_fail_list); 38 setInfoResources(R.string.nfc_test, R.string.nfc_hce_reader_test_info, 0); 39 setPassFailButtonClickListeners(); 40 41 ArrayTestListAdapter adapter = new ArrayTestListAdapter(this); 42 43 if (getPackageManager().hasSystemFeature(PackageManager.FEATURE_NFC_HOST_CARD_EMULATION)) { 44 adapter.add(TestListItem.newCategory(this, R.string.nfc_hce_reader_tests)); 45 46 adapter.add(TestListItem.newTest(this, R.string.nfc_hce_protocol_params_reader, 47 ProtocolParamsReaderActivity.class.getName(), 48 new Intent(this, ProtocolParamsReaderActivity.class), null)); 49 50 adapter.add(TestListItem.newTest(this, R.string.nfc_hce_single_payment_reader, 51 getString(R.string.nfc_hce_single_payment_reader), 52 SinglePaymentEmulatorActivity.buildReaderIntent(this), null)); 53 54 adapter.add(TestListItem.newTest(this, R.string.nfc_hce_dual_payment_reader, 55 getString(R.string.nfc_hce_dual_payment_reader), 56 DualPaymentEmulatorActivity.buildReaderIntent(this), null)); 57 58 adapter.add(TestListItem.newTest(this, R.string.nfc_hce_change_default_reader, 59 getString(R.string.nfc_hce_change_default_reader), 60 ChangeDefaultEmulatorActivity.buildReaderIntent(this), null)); 61 62 adapter.add(TestListItem.newTest(this, R.string.nfc_hce_foreground_payment_reader, 63 getString(R.string.nfc_hce_foreground_payment_reader), 64 ForegroundPaymentEmulatorActivity.buildReaderIntent(this), null)); 65 66 adapter.add(TestListItem.newTest(this, R.string.nfc_hce_single_non_payment_reader, 67 getString(R.string.nfc_hce_single_non_payment_reader), 68 SingleNonPaymentEmulatorActivity.buildReaderIntent(this), null)); 69 70 adapter.add(TestListItem.newTest(this, R.string.nfc_hce_dual_non_payment_reader, 71 getString(R.string.nfc_hce_dual_non_payment_reader), 72 DualNonPaymentEmulatorActivity.buildReaderIntent(this), null)); 73 74 adapter.add(TestListItem.newTest(this, R.string.nfc_hce_conflicting_non_payment_reader, 75 getString(R.string.nfc_hce_conflicting_non_payment_reader), 76 ConflictingNonPaymentEmulatorActivity.buildReaderIntent(this), null)); 77 78 adapter.add(TestListItem.newTest(this, R.string.nfc_hce_foreground_non_payment_reader, 79 getString(R.string.nfc_hce_foreground_non_payment_reader), 80 ForegroundNonPaymentEmulatorActivity.buildReaderIntent(this), null)); 81 82 adapter.add(TestListItem.newTest(this, R.string.nfc_hce_throughput_reader, 83 getString(R.string.nfc_hce_throughput_reader), 84 ThroughputEmulatorActivity.buildReaderIntent(this), null)); 85 86 adapter.add(TestListItem.newTest(this, R.string.nfc_hce_tap_test_reader, 87 getString(R.string.nfc_hce_tap_test_reader), 88 TapTestEmulatorActivity.buildReaderIntent(this), null)); 89 90 adapter.add(TestListItem.newTest(this, R.string.nfc_hce_offhost_service_reader, 91 getString(R.string.nfc_hce_offhost_service_reader), 92 OffHostEmulatorActivity.buildReaderIntent(this), null)); 93 94 adapter.add(TestListItem.newTest(this, R.string.nfc_hce_on_and_offhost_service_reader, 95 getString(R.string.nfc_hce_on_and_offhost_service_reader), 96 OnAndOffHostEmulatorActivity.buildReaderIntent(this), null)); 97 98 adapter.add(TestListItem.newTest(this, R.string.nfc_hce_payment_dynamic_aids_reader, 99 getString(R.string.nfc_hce_payment_dynamic_aids_reader), 100 DynamicAidEmulatorActivity.buildReaderIntent(this), null)); 101 102 adapter.add(TestListItem.newTest(this, R.string.nfc_hce_large_num_aids_reader, 103 getString(R.string.nfc_hce_large_num_aids_reader), 104 LargeNumAidsEmulatorActivity.buildReaderIntent(this), null)); 105 106 NfcAdapter nfcAdapter = NfcAdapter.getDefaultAdapter(this); 107 CardEmulation cardEmulation = CardEmulation.getInstance(nfcAdapter); 108 if (cardEmulation.supportsAidPrefixRegistration()) { 109 adapter.add(TestListItem.newTest(this, R.string.nfc_hce_payment_prefix_aids_reader, 110 getString(R.string.nfc_hce_payment_prefix_aids_reader), 111 PrefixPaymentEmulatorActivity.buildReaderIntent(this), null)); 112 113 adapter.add(TestListItem.newTest(this, R.string.nfc_hce_payment_prefix_aids_reader_2, 114 getString(R.string.nfc_hce_payment_prefix_aids_reader_2), 115 PrefixPaymentEmulator2Activity.buildReaderIntent(this), null)); 116 117 adapter.add(TestListItem.newTest(this, R.string.nfc_hce_other_prefix_aids_reader, 118 getString(R.string.nfc_hce_other_prefix_aids_reader), 119 DualNonPaymentPrefixEmulatorActivity.buildReaderIntent(this), null)); 120 121 adapter.add(TestListItem.newTest(this, R.string.nfc_hce_other_conflicting_prefix_aids_reader, 122 getString(R.string.nfc_hce_other_conflicting_prefix_aids_reader), 123 ConflictingNonPaymentPrefixEmulatorActivity.buildReaderIntent(this), null)); 124 } 125 126 int firstSdk = 127 SystemProperties.getInt("ro.product.first_api_level", Build.VERSION_CODES.S); 128 if (firstSdk >= Build.VERSION_CODES.S) { 129 adapter.add(TestListItem.newTest(this, R.string.nfc_screen_on_only_offhost_reader, 130 getString(R.string.nfc_screen_on_only_offhost_reader), 131 ScreenOnOnlyOffHostEmulatorActivity.buildReaderIntent(this), null)); 132 133 adapter.add(TestListItem.newTest(this, R.string.nfc_screen_off_hce_payment_reader, 134 getString(R.string.nfc_screen_off_hce_payment_reader), 135 ScreenOffPaymentEmulatorActivity.buildReaderIntent(this), null)); 136 } 137 } 138 139 setTestListAdapter(adapter); 140 } 141 } 142