• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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         if (getPackageManager().hasSystemFeature(PackageManager.FEATURE_NFC_BEAM)) {
57             adapter.add(TestListItem.newCategory(this, R.string.nfc_pee_2_pee));
58             adapter.add(TestListItem.newTest(this, R.string.nfc_ndef_push_sender,
59                     NdefPushSenderActivity.class.getName(),
60                     new Intent(this, NdefPushSenderActivity.class), null));
61             adapter.add(TestListItem.newTest(this, R.string.nfc_ndef_push_receiver,
62                     NdefPushReceiverActivity.class.getName(),
63                     new Intent(this, NdefPushReceiverActivity.class), null));
64 
65             if ("MNC".equals(Build.VERSION.CODENAME) || Build.VERSION.SDK_INT >= 23) {
66                 adapter.add(TestListItem.newTest(this, R.string.nfc_llcp_version_check,
67                         LlcpVersionActivity.class.getName(),
68                         new Intent(this, LlcpVersionActivity.class), null));
69             }
70         }
71 
72         adapter.add(TestListItem.newCategory(this, R.string.nfc_tag_verification));
73         adapter.add(TestListItem.newTest(this, R.string.nfc_ndef,
74                 NDEF_ID, getTagIntent(Ndef.class), null));
75         if (getPackageManager().hasSystemFeature(FEATURE_NFC_MIFARE)) {
76             adapter.add(TestListItem.newTest(this, R.string.nfc_mifare_ultralight,
77                     MIFARE_ULTRALIGHT_ID, getTagIntent(MifareUltralight.class), null));
78         }
79 
80         if (getPackageManager().hasSystemFeature(PackageManager.FEATURE_NFC_HOST_CARD_EMULATION)) {
81             adapter.add(TestListItem.newCategory(this, R.string.nfc_hce));
82             adapter.add(TestListItem.newTest(this, R.string.nfc_hce_reader_tests,
83                     HceReaderTestActivity.class.getName(),
84                     new Intent(this, HceReaderTestActivity.class), null));
85             adapter.add(TestListItem.newTest(this, R.string.nfc_hce_emulator_tests,
86                     HceEmulatorTestActivity.class.getName(),
87                     new Intent(this, HceEmulatorTestActivity.class), null));
88         }
89 
90         if (getPackageManager().hasSystemFeature(PackageManager.FEATURE_NFC_HOST_CARD_EMULATION_NFCF)) {
91             adapter.add(TestListItem.newCategory(this, R.string.nfc_hce_f));
92             adapter.add(TestListItem.newTest(this, R.string.nfc_hce_f_reader_tests,
93                     HceFReaderTestActivity.class.getName(),
94                     new Intent(this, HceFReaderTestActivity.class), null));
95             adapter.add(TestListItem.newTest(this, R.string.nfc_hce_f_emulator_tests,
96                     HceFEmulatorTestActivity.class.getName(),
97                     new Intent(this, HceFEmulatorTestActivity.class), null));
98         }
99 
100         setTestListAdapter(adapter);
101     }
102 
getTagIntent(Class<? extends TagTechnology> primaryTech)103     private Intent getTagIntent(Class<? extends TagTechnology> primaryTech) {
104         return new Intent(this, TagVerifierActivity.class)
105                 .putExtra(TagVerifierActivity.EXTRA_TECH, primaryTech.getName());
106     }
107 }
108