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