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 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 
24 import android.content.Intent;
25 import android.content.pm.PackageManager;
26 import android.nfc.NfcAdapter;
27 import android.nfc.cardemulation.CardEmulation;
28 import android.os.Build;
29 import android.os.Bundle;
30 
31 /** Activity that lists all the NFC HCE emulator tests. */
32 public class HceEmulatorTestActivity extends PassFailButtons.TestListActivity {
33 
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_emulator_test_info, 0);
39         setPassFailButtonClickListeners();
40 
41         ArrayTestListAdapter adapter = new ArrayTestListAdapter(this);
42 
43         NfcAdapter nfcAdapter = NfcAdapter.getDefaultAdapter(this);
44         CardEmulation cardEmulation = CardEmulation.getInstance(nfcAdapter);
45         if (getPackageManager().hasSystemFeature(PackageManager.FEATURE_NFC_HOST_CARD_EMULATION)) {
46             adapter.add(TestListItem.newCategory(this, R.string.nfc_hce_emulator_tests));
47 
48             /*
49              * Only add this test when supported in platform
50             adapter.add(TestListItem.newTest(this, R.string.nfc_hce_default_route_emulator,
51                     DefaultRouteEmulatorActivity.class.getName(),
52                     new Intent(this, DefaultRouteEmulatorActivity.class), null));
53             */
54             adapter.add(TestListItem.newTest(this, R.string.nfc_hce_protocol_params_emulator,
55                     ProtocolParamsEmulatorActivity.class.getName(),
56                     new Intent(this, ProtocolParamsEmulatorActivity.class), null));
57 
58             adapter.add(TestListItem.newTest(this, R.string.nfc_hce_single_payment_emulator,
59                     SinglePaymentEmulatorActivity.class.getName(),
60                     new Intent(this, SinglePaymentEmulatorActivity.class), null));
61 
62             adapter.add(TestListItem.newTest(this, R.string.nfc_hce_dual_payment_emulator,
63                     DualPaymentEmulatorActivity.class.getName(),
64                     new Intent(this, DualPaymentEmulatorActivity.class), null));
65 
66             adapter.add(TestListItem.newTest(this, R.string.nfc_hce_change_default_emulator,
67                     ChangeDefaultEmulatorActivity.class.getName(),
68                     new Intent(this, ChangeDefaultEmulatorActivity.class), null));
69 
70             adapter.add(TestListItem.newTest(this, R.string.nfc_hce_foreground_payment_emulator,
71                     ForegroundPaymentEmulatorActivity.class.getName(),
72                     new Intent(this, ForegroundPaymentEmulatorActivity.class), null));
73 
74             adapter.add(TestListItem.newTest(this, R.string.nfc_hce_single_non_payment_emulator,
75                     SingleNonPaymentEmulatorActivity.class.getName(),
76                     new Intent(this, SingleNonPaymentEmulatorActivity.class), null));
77 
78             adapter.add(TestListItem.newTest(this, R.string.nfc_hce_dual_non_payment_emulator,
79                     DualNonPaymentEmulatorActivity.class.getName(),
80                     new Intent(this, DualNonPaymentEmulatorActivity.class), null));
81 
82             adapter.add(TestListItem.newTest(this, R.string.nfc_hce_conflicting_non_payment_emulator,
83                     ConflictingNonPaymentEmulatorActivity.class.getName(),
84                     new Intent(this, ConflictingNonPaymentEmulatorActivity.class), null));
85 
86             adapter.add(TestListItem.newTest(this, R.string.nfc_hce_foreground_non_payment_emulator,
87                     ForegroundNonPaymentEmulatorActivity.class.getName(),
88                     new Intent(this, ForegroundNonPaymentEmulatorActivity.class), null));
89 
90             adapter.add(TestListItem.newTest(this, R.string.nfc_hce_throughput_emulator,
91                     ThroughputEmulatorActivity.class.getName(),
92                     new Intent(this, ThroughputEmulatorActivity.class), null));
93 
94             adapter.add(TestListItem.newTest(this, R.string.nfc_hce_tap_test_emulator,
95                     TapTestEmulatorActivity.class.getName(),
96                     new Intent(this, TapTestEmulatorActivity.class), null));
97 
98             adapter.add(TestListItem.newTest(this, R.string.nfc_hce_offhost_service_emulator,
99                     OffHostEmulatorActivity.class.getName(),
100                     new Intent(this, OffHostEmulatorActivity.class), null));
101 
102             adapter.add(TestListItem.newTest(this, R.string.nfc_hce_on_and_offhost_service_emulator,
103                     OnAndOffHostEmulatorActivity.class.getName(),
104                     new Intent(this, OnAndOffHostEmulatorActivity.class), null));
105 
106             if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
107                 adapter.add(TestListItem.newTest(this, R.string.nfc_hce_large_num_aids_emulator,
108                         LargeNumAidsEmulatorActivity.class.getName(),
109                         new Intent(this, LargeNumAidsEmulatorActivity.class), null));
110 
111                 adapter.add(TestListItem.newTest(this, R.string.nfc_hce_payment_dynamic_aids_emulator,
112                         DynamicAidEmulatorActivity.class.getName(),
113                         new Intent(this, DynamicAidEmulatorActivity.class), null));
114 
115                 if (cardEmulation.supportsAidPrefixRegistration()) {
116                     adapter.add(TestListItem.newTest(this, R.string.nfc_hce_payment_prefix_aids_emulator,
117                             PrefixPaymentEmulatorActivity.class.getName(),
118                             new Intent(this, PrefixPaymentEmulatorActivity.class), null));
119 
120                     adapter.add(TestListItem.newTest(this, R.string.nfc_hce_payment_prefix_aids_emulator_2,
121                             PrefixPaymentEmulator2Activity.class.getName(),
122                             new Intent(this, PrefixPaymentEmulator2Activity.class), null));
123 
124                     adapter.add(TestListItem.newTest(this, R.string.nfc_hce_other_prefix_aids_emulator,
125                             DualNonPaymentPrefixEmulatorActivity.class.getName(),
126                             new Intent(this, DualNonPaymentPrefixEmulatorActivity.class), null));
127 
128                     adapter.add(TestListItem.newTest(this, R.string.nfc_hce_other_conflicting_prefix_aids_emulator,
129                             ConflictingNonPaymentPrefixEmulatorActivity.class.getName(),
130                             new Intent(this, ConflictingNonPaymentPrefixEmulatorActivity.class), null));
131                 }
132             }
133         }
134 
135         setTestListAdapter(adapter);
136     }
137 }
138