Home | History | Annotate | Download | only in hce
      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 android.nfc.NfcAdapter;
     20 import android.nfc.cardemulation.CardEmulation;
     21 import com.android.cts.verifier.ArrayTestListAdapter;
     22 import com.android.cts.verifier.PassFailButtons;
     23 import com.android.cts.verifier.R;
     24 import com.android.cts.verifier.TestListAdapter.TestListItem;
     25 
     26 import android.content.Intent;
     27 import android.content.pm.PackageManager;
     28 import android.os.Bundle;
     29 
     30 /** Activity that lists all the NFC HCE reader tests. */
     31 public class HceReaderTestActivity extends PassFailButtons.TestListActivity {
     32     @Override
     33     protected void onCreate(Bundle savedInstanceState) {
     34         super.onCreate(savedInstanceState);
     35         setContentView(R.layout.pass_fail_list);
     36         setInfoResources(R.string.nfc_test, R.string.nfc_hce_reader_test_info, 0);
     37         setPassFailButtonClickListeners();
     38 
     39         ArrayTestListAdapter adapter = new ArrayTestListAdapter(this);
     40 
     41         if (getPackageManager().hasSystemFeature(PackageManager.FEATURE_NFC_HOST_CARD_EMULATION)) {
     42             adapter.add(TestListItem.newCategory(this, R.string.nfc_hce_reader_tests));
     43             /*
     44              * Only add this test when supported in platform
     45             adapter.add(TestListItem.newTest(this, R.string.nfc_hce_default_route_reader,
     46                     SimpleReaderActivity.class.getName(),
     47                     DefaultRouteEmulatorActivity.buildReaderIntent(this), null));
     48              */
     49 
     50             adapter.add(TestListItem.newTest(this, R.string.nfc_hce_protocol_params_reader,
     51                     ProtocolParamsReaderActivity.class.getName(),
     52                     new Intent(this, ProtocolParamsReaderActivity.class), null));
     53 
     54             adapter.add(TestListItem.newTest(this, R.string.nfc_hce_single_payment_reader,
     55                     SimpleReaderActivity.class.getName(),
     56                     SinglePaymentEmulatorActivity.buildReaderIntent(this), null));
     57 
     58             adapter.add(TestListItem.newTest(this, R.string.nfc_hce_dual_payment_reader,
     59                     SimpleReaderActivity.class.getName(),
     60                     DualPaymentEmulatorActivity.buildReaderIntent(this), null));
     61 
     62             adapter.add(TestListItem.newTest(this, R.string.nfc_hce_change_default_reader,
     63                     SimpleReaderActivity.class.getName(),
     64                     ChangeDefaultEmulatorActivity.buildReaderIntent(this), null));
     65 
     66             adapter.add(TestListItem.newTest(this, R.string.nfc_hce_foreground_payment_reader,
     67                     SimpleReaderActivity.class.getName(),
     68                     ForegroundPaymentEmulatorActivity.buildReaderIntent(this), null));
     69 
     70             adapter.add(TestListItem.newTest(this, R.string.nfc_hce_single_non_payment_reader,
     71                     SimpleReaderActivity.class.getName(),
     72                     SingleNonPaymentEmulatorActivity.buildReaderIntent(this), null));
     73 
     74             adapter.add(TestListItem.newTest(this, R.string.nfc_hce_dual_non_payment_reader,
     75                     SimpleReaderActivity.class.getName(),
     76                     DualNonPaymentEmulatorActivity.buildReaderIntent(this), null));
     77 
     78             adapter.add(TestListItem.newTest(this, R.string.nfc_hce_conflicting_non_payment_reader,
     79                     SimpleReaderActivity.class.getName(),
     80                     ConflictingNonPaymentEmulatorActivity.buildReaderIntent(this), null));
     81 
     82             adapter.add(TestListItem.newTest(this, R.string.nfc_hce_foreground_non_payment_reader,
     83                     SimpleReaderActivity.class.getName(),
     84                     ForegroundNonPaymentEmulatorActivity.buildReaderIntent(this), null));
     85 
     86             adapter.add(TestListItem.newTest(this, R.string.nfc_hce_throughput_reader,
     87                     SimpleReaderActivity.class.getName(),
     88                     ThroughputEmulatorActivity.buildReaderIntent(this), null));
     89 
     90             adapter.add(TestListItem.newTest(this, R.string.nfc_hce_tap_test_reader,
     91                     SimpleReaderActivity.class.getName(),
     92                     TapTestEmulatorActivity.buildReaderIntent(this), null));
     93 
     94             adapter.add(TestListItem.newTest(this, R.string.nfc_hce_offhost_service_reader,
     95                     SimpleReaderActivity.class.getName(),
     96                     OffHostEmulatorActivity.buildReaderIntent(this), null));
     97 
     98             adapter.add(TestListItem.newTest(this, R.string.nfc_hce_on_and_offhost_service_reader,
     99                     SimpleReaderActivity.class.getName(),
    100                     OnAndOffHostEmulatorActivity.buildReaderIntent(this), null));
    101 
    102             adapter.add(TestListItem.newTest(this, R.string.nfc_hce_payment_dynamic_aids_reader,
    103                     SimpleReaderActivity.class.getName(),
    104                     DynamicAidEmulatorActivity.buildReaderIntent(this), null));
    105 
    106             adapter.add(TestListItem.newTest(this, R.string.nfc_hce_large_num_aids_reader,
    107                     SimpleReaderActivity.class.getName(),
    108                     LargeNumAidsEmulatorActivity.buildReaderIntent(this), null));
    109 
    110             NfcAdapter nfcAdapter = NfcAdapter.getDefaultAdapter(this);
    111             CardEmulation cardEmulation = CardEmulation.getInstance(nfcAdapter);
    112             if (cardEmulation.supportsAidPrefixRegistration()) {
    113                 adapter.add(TestListItem.newTest(this, R.string.nfc_hce_payment_prefix_aids_reader,
    114                         SimpleReaderActivity.class.getName(),
    115                         PrefixPaymentEmulatorActivity.buildReaderIntent(this), null));
    116 
    117                 adapter.add(TestListItem.newTest(this, R.string.nfc_hce_payment_prefix_aids_reader_2,
    118                         SimpleReaderActivity.class.getName(),
    119                         PrefixPaymentEmulator2Activity.buildReaderIntent(this), null));
    120 
    121                 adapter.add(TestListItem.newTest(this, R.string.nfc_hce_other_prefix_aids_reader,
    122                         SimpleReaderActivity.class.getName(),
    123                         DualNonPaymentPrefixEmulatorActivity.buildReaderIntent(this), null));
    124 
    125                 adapter.add(TestListItem.newTest(this, R.string.nfc_hce_other_conflicting_prefix_aids_reader,
    126                         SimpleReaderActivity.class.getName(),
    127                         ConflictingNonPaymentPrefixEmulatorActivity.buildReaderIntent(this), null));
    128             }
    129         }
    130 
    131         setTestListAdapter(adapter);
    132     }
    133 }
    134