1 /*
2  * Copyright (C) 2016 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.hcef;
18 
19 import android.content.Intent;
20 import android.content.pm.PackageManager;
21 import android.nfc.NfcAdapter;
22 import android.nfc.cardemulation.CardEmulation;
23 import android.os.Bundle;
24 
25 import com.android.cts.verifier.ArrayTestListAdapter;
26 import com.android.cts.verifier.PassFailButtons;
27 import com.android.cts.verifier.R;
28 import com.android.cts.verifier.TestListAdapter.TestListItem;
29 
30 /** Activity that lists all the NFC HCE emulator tests. */
31 public class HceFEmulatorTestActivity extends PassFailButtons.TestListActivity {
32 
33     @Override
onCreate(Bundle savedInstanceState)34     protected void onCreate(Bundle savedInstanceState) {
35         super.onCreate(savedInstanceState);
36         setContentView(R.layout.pass_fail_list);
37         setInfoResources(R.string.nfc_test, R.string.nfc_hce_emulator_test_info, 0);
38         setPassFailButtonClickListeners();
39 
40         ArrayTestListAdapter adapter = new ArrayTestListAdapter(this);
41 
42         NfcAdapter nfcAdapter = NfcAdapter.getDefaultAdapter(this);
43         CardEmulation cardEmulation = CardEmulation.getInstance(nfcAdapter);
44         if (getPackageManager().hasSystemFeature(
45                 PackageManager.FEATURE_NFC_HOST_CARD_EMULATION_NFCF)) {
46             adapter.add(TestListItem.newCategory(this, R.string.nfc_hce_f_emulator_tests));
47 
48             adapter.add(TestListItem.newTest(this, R.string.nfc_hce_f_emulator,
49                     HceFEmulatorActivity.class.getName(),
50                     new Intent(this, HceFEmulatorActivity.class), null));
51         }
52 
53         setTestListAdapter(adapter);
54     }
55 }
56