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; 18 19 import com.android.cts.verifier.ArrayTestListAdapter; 20 import com.android.cts.verifier.PassFailButtons; 21 import com.android.cts.verifier.R; 22 import com.android.cts.verifier.TestListAdapter.TestListItem; 23 import com.android.cts.verifier.nfc.hce.HceEmulatorTestActivity; 24 import com.android.cts.verifier.nfc.hce.HceReaderTestActivity; 25 import com.android.cts.verifier.nfc.hcef.HceFEmulatorTestActivity; 26 import com.android.cts.verifier.nfc.hcef.HceFReaderTestActivity; 27 import com.android.cts.verifier.nfc.offhost.OffhostUiccEmulatorTestActivity; 28 import com.android.cts.verifier.nfc.offhost.OffhostUiccReaderTestActivity; 29 30 import android.content.Intent; 31 import android.content.pm.PackageManager; 32 import android.nfc.tech.MifareUltralight; 33 import android.nfc.tech.Ndef; 34 import android.nfc.tech.TagTechnology; 35 import android.os.Build; 36 import android.os.Bundle; 37 38 /** Activity that lists all the NFC tests. */ 39 public class NfcTestActivity extends PassFailButtons.TestListActivity { 40 41 private static final String NDEF_ID = 42 TagVerifierActivity.getTagTestId(Ndef.class); 43 44 private static final String MIFARE_ULTRALIGHT_ID = 45 TagVerifierActivity.getTagTestId(MifareUltralight.class); 46 47 private static final String FEATURE_NFC_MIFARE = "com.nxp.mifare"; 48 49 @Override onCreate(Bundle savedInstanceState)50 protected void onCreate(Bundle savedInstanceState) { 51 super.onCreate(savedInstanceState); 52 setContentView(R.layout.pass_fail_list); 53 setInfoResources(R.string.nfc_test, R.string.nfc_test_info, 0); 54 setPassFailButtonClickListeners(); 55 56 ArrayTestListAdapter adapter = new ArrayTestListAdapter(this); 57 58 if (getPackageManager().hasSystemFeature(PackageManager.FEATURE_NFC_BEAM)) { 59 adapter.add(TestListItem.newCategory(this, R.string.nfc_pee_2_pee)); 60 adapter.add(TestListItem.newTest(this, R.string.nfc_ndef_push_sender, 61 NdefPushSenderActivity.class.getName(), 62 new Intent(this, NdefPushSenderActivity.class), null)); 63 adapter.add(TestListItem.newTest(this, R.string.nfc_ndef_push_receiver, 64 NdefPushReceiverActivity.class.getName(), 65 new Intent(this, NdefPushReceiverActivity.class), null)); 66 67 if ("MNC".equals(Build.VERSION.CODENAME) || Build.VERSION.SDK_INT >= 23) { 68 adapter.add(TestListItem.newTest(this, R.string.nfc_llcp_version_check, 69 LlcpVersionActivity.class.getName(), 70 new Intent(this, LlcpVersionActivity.class), null)); 71 } 72 } 73 74 adapter.add(TestListItem.newCategory(this, R.string.nfc_tag_verification)); 75 adapter.add(TestListItem.newTest(this, R.string.nfc_ndef, 76 NDEF_ID, getTagIntent(Ndef.class), null)); 77 if (getPackageManager().hasSystemFeature(FEATURE_NFC_MIFARE)) { 78 adapter.add(TestListItem.newTest(this, R.string.nfc_mifare_ultralight, 79 MIFARE_ULTRALIGHT_ID, getTagIntent(MifareUltralight.class), null)); 80 } 81 82 if (getPackageManager().hasSystemFeature(PackageManager.FEATURE_NFC_HOST_CARD_EMULATION)) { 83 adapter.add(TestListItem.newCategory(this, R.string.nfc_hce)); 84 adapter.add(TestListItem.newTest(this, R.string.nfc_hce_reader_tests, 85 HceReaderTestActivity.class.getName(), 86 new Intent(this, HceReaderTestActivity.class), null)); 87 adapter.add(TestListItem.newTest(this, R.string.nfc_hce_emulator_tests, 88 HceEmulatorTestActivity.class.getName(), 89 new Intent(this, HceEmulatorTestActivity.class), null)); 90 } 91 92 if (getPackageManager().hasSystemFeature(PackageManager.FEATURE_NFC_HOST_CARD_EMULATION_NFCF)) { 93 adapter.add(TestListItem.newCategory(this, R.string.nfc_hce_f)); 94 adapter.add(TestListItem.newTest(this, R.string.nfc_hce_f_reader_tests, 95 HceFReaderTestActivity.class.getName(), 96 new Intent(this, HceFReaderTestActivity.class), null)); 97 adapter.add(TestListItem.newTest(this, R.string.nfc_hce_f_emulator_tests, 98 HceFEmulatorTestActivity.class.getName(), 99 new Intent(this, HceFEmulatorTestActivity.class), null)); 100 } 101 102 if (getPackageManager().hasSystemFeature(PackageManager.FEATURE_NFC_OFF_HOST_CARD_EMULATION_UICC)) { 103 adapter.add(TestListItem.newCategory(this, R.string.nfc_offhost_uicc)); 104 adapter.add(TestListItem.newTest(this, R.string.nfc_offhost_uicc_reader_tests, 105 OffhostUiccReaderTestActivity.class.getName(), 106 new Intent(this, OffhostUiccReaderTestActivity.class), null)); 107 adapter.add(TestListItem.newTest(this, R.string.nfc_offhost_uicc_emulator_tests, 108 OffhostUiccEmulatorTestActivity.class.getName(), 109 new Intent(this, OffhostUiccEmulatorTestActivity.class), null)); 110 } 111 112 setTestListAdapter(adapter); 113 } 114 getTagIntent(Class<? extends TagTechnology> primaryTech)115 private Intent getTagIntent(Class<? extends TagTechnology> primaryTech) { 116 return new Intent(this, TagVerifierActivity.class) 117 .putExtra(TagVerifierActivity.EXTRA_TECH, primaryTech.getName()); 118 } 119 } 120