• 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.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 import android.os.SystemProperties;
31 
32 /** Activity that lists all the NFC HCE emulator tests. */
33 public class HceEmulatorTestActivity extends PassFailButtons.TestListActivity {
34 
35     @Override
onCreate(Bundle savedInstanceState)36     protected void onCreate(Bundle savedInstanceState) {
37         super.onCreate(savedInstanceState);
38         setContentView(R.layout.pass_fail_list);
39         setInfoResources(R.string.nfc_test, R.string.nfc_hce_emulator_test_info, 0);
40         setPassFailButtonClickListeners();
41 
42         ArrayTestListAdapter adapter = new ArrayTestListAdapter(this);
43 
44         NfcAdapter nfcAdapter = NfcAdapter.getDefaultAdapter(this);
45         CardEmulation cardEmulation = CardEmulation.getInstance(nfcAdapter);
46         if (getPackageManager().hasSystemFeature(PackageManager.FEATURE_NFC_HOST_CARD_EMULATION)) {
47             adapter.add(TestListItem.newCategory(this, R.string.nfc_hce_emulator_tests));
48 
49             /*
50              * Only add this test when supported in platform
51             adapter.add(TestListItem.newTest(this, R.string.nfc_hce_default_route_emulator,
52                     DefaultRouteEmulatorActivity.class.getName(),
53                     new Intent(this, DefaultRouteEmulatorActivity.class), null));
54             */
55             adapter.add(TestListItem.newTest(this, R.string.nfc_hce_protocol_params_emulator,
56                     ProtocolParamsEmulatorActivity.class.getName(),
57                     new Intent(this, ProtocolParamsEmulatorActivity.class), null));
58 
59             adapter.add(TestListItem.newTest(this, R.string.nfc_hce_single_payment_emulator,
60                     SinglePaymentEmulatorActivity.class.getName(),
61                     new Intent(this, SinglePaymentEmulatorActivity.class), null));
62 
63             adapter.add(TestListItem.newTest(this, R.string.nfc_hce_dual_payment_emulator,
64                     DualPaymentEmulatorActivity.class.getName(),
65                     new Intent(this, DualPaymentEmulatorActivity.class), null));
66 
67             adapter.add(TestListItem.newTest(this, R.string.nfc_hce_change_default_emulator,
68                     ChangeDefaultEmulatorActivity.class.getName(),
69                     new Intent(this, ChangeDefaultEmulatorActivity.class), null));
70 
71             adapter.add(TestListItem.newTest(this, R.string.nfc_hce_foreground_payment_emulator,
72                     ForegroundPaymentEmulatorActivity.class.getName(),
73                     new Intent(this, ForegroundPaymentEmulatorActivity.class), null));
74 
75             adapter.add(TestListItem.newTest(this, R.string.nfc_hce_single_non_payment_emulator,
76                     SingleNonPaymentEmulatorActivity.class.getName(),
77                     new Intent(this, SingleNonPaymentEmulatorActivity.class), null));
78 
79             adapter.add(TestListItem.newTest(this, R.string.nfc_hce_dual_non_payment_emulator,
80                     DualNonPaymentEmulatorActivity.class.getName(),
81                     new Intent(this, DualNonPaymentEmulatorActivity.class), null));
82 
83             adapter.add(TestListItem.newTest(this, R.string.nfc_hce_conflicting_non_payment_emulator,
84                     ConflictingNonPaymentEmulatorActivity.class.getName(),
85                     new Intent(this, ConflictingNonPaymentEmulatorActivity.class), null));
86 
87             adapter.add(TestListItem.newTest(this, R.string.nfc_hce_foreground_non_payment_emulator,
88                     ForegroundNonPaymentEmulatorActivity.class.getName(),
89                     new Intent(this, ForegroundNonPaymentEmulatorActivity.class), null));
90 
91             adapter.add(TestListItem.newTest(this, R.string.nfc_hce_throughput_emulator,
92                     ThroughputEmulatorActivity.class.getName(),
93                     new Intent(this, ThroughputEmulatorActivity.class), null));
94 
95             adapter.add(TestListItem.newTest(this, R.string.nfc_hce_tap_test_emulator,
96                     TapTestEmulatorActivity.class.getName(),
97                     new Intent(this, TapTestEmulatorActivity.class), null));
98 
99             adapter.add(TestListItem.newTest(this, R.string.nfc_hce_offhost_service_emulator,
100                     OffHostEmulatorActivity.class.getName(),
101                     new Intent(this, OffHostEmulatorActivity.class), null));
102 
103             adapter.add(TestListItem.newTest(this, R.string.nfc_hce_on_and_offhost_service_emulator,
104                     OnAndOffHostEmulatorActivity.class.getName(),
105                     new Intent(this, OnAndOffHostEmulatorActivity.class), null));
106 
107             if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
108                 adapter.add(TestListItem.newTest(this, R.string.nfc_hce_large_num_aids_emulator,
109                         LargeNumAidsEmulatorActivity.class.getName(),
110                         new Intent(this, LargeNumAidsEmulatorActivity.class), null));
111 
112                 adapter.add(TestListItem.newTest(this, R.string.nfc_hce_payment_dynamic_aids_emulator,
113                         DynamicAidEmulatorActivity.class.getName(),
114                         new Intent(this, DynamicAidEmulatorActivity.class), null));
115 
116                 if (cardEmulation.supportsAidPrefixRegistration()) {
117                     adapter.add(TestListItem.newTest(this, R.string.nfc_hce_payment_prefix_aids_emulator,
118                             PrefixPaymentEmulatorActivity.class.getName(),
119                             new Intent(this, PrefixPaymentEmulatorActivity.class), null));
120 
121                     adapter.add(TestListItem.newTest(this, R.string.nfc_hce_payment_prefix_aids_emulator_2,
122                             PrefixPaymentEmulator2Activity.class.getName(),
123                             new Intent(this, PrefixPaymentEmulator2Activity.class), null));
124 
125                     adapter.add(TestListItem.newTest(this, R.string.nfc_hce_other_prefix_aids_emulator,
126                             DualNonPaymentPrefixEmulatorActivity.class.getName(),
127                             new Intent(this, DualNonPaymentPrefixEmulatorActivity.class), null));
128 
129                     adapter.add(TestListItem.newTest(this, R.string.nfc_hce_other_conflicting_prefix_aids_emulator,
130                             ConflictingNonPaymentPrefixEmulatorActivity.class.getName(),
131                             new Intent(this, ConflictingNonPaymentPrefixEmulatorActivity.class), null));
132                 }
133             }
134 
135             int firstSdk =
136                     SystemProperties.getInt("ro.product.first_api_level", Build.VERSION_CODES.S);
137             if (firstSdk >= Build.VERSION_CODES.S) {
138                 adapter.add(TestListItem.newTest(this, R.string.nfc_screen_on_only_offhost_emulator,
139                         ScreenOnOnlyOffHostEmulatorActivity.class.getName(),
140                         new Intent(this, ScreenOnOnlyOffHostEmulatorActivity.class), null));
141 
142                 adapter.add(TestListItem.newTest(this, R.string.nfc_screen_off_hce_payment_emulator,
143                         ScreenOffPaymentEmulatorActivity.class.getName(),
144                         new Intent(this, ScreenOffPaymentEmulatorActivity.class), null));
145             }
146         }
147 
148         setTestListAdapter(adapter);
149     }
150 }
151