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