1 package com.android.cts.verifier.nfc.hce;
2 
3 import android.content.ComponentName;
4 import android.content.Context;
5 import android.content.Intent;
6 import android.os.Bundle;
7 
8 import com.android.cts.verifier.R;
9 import com.android.cts.verifier.nfc.NfcDialogs;
10 
11 public class ForegroundNonPaymentEmulatorActivity extends BaseEmulatorActivity {
12     @Override
onCreate(Bundle savedInstanceState)13     protected void onCreate(Bundle savedInstanceState) {
14         super.onCreate(savedInstanceState);
15         setContentView(R.layout.pass_fail_text);
16         setPassFailButtonClickListeners();
17         getPassButton().setEnabled(false);
18     }
19 
20     @Override
onResume()21     protected void onResume() {
22         super.onResume();
23         setupServices(this, TransportService1.COMPONENT, TransportService2.COMPONENT);
24     }
25 
26     @Override
onPause()27     protected void onPause() {
28         super.onPause();
29         mCardEmulation.unsetPreferredService(this);
30     }
31 
32     @Override
onServicesSetup(boolean result)33     void onServicesSetup(boolean result) {
34         // Tell NFC service we prefer TransportService2
35         mCardEmulation.setPreferredService(this, TransportService2.COMPONENT);
36         NfcDialogs.createHceTapReaderDialog(this,
37                 getString(R.string.nfc_hce_foreground_non_payment_help)).show();
38     }
39 
buildReaderIntent(Context context)40     public static Intent buildReaderIntent(Context context) {
41         Intent readerIntent = new Intent(context, SimpleReaderActivity.class);
42         readerIntent.putExtra(SimpleReaderActivity.EXTRA_APDUS,
43                 TransportService2.APDU_COMMAND_SEQUENCE);
44         readerIntent.putExtra(SimpleReaderActivity.EXTRA_RESPONSES,
45                 TransportService2.APDU_RESPOND_SEQUENCE);
46         readerIntent.putExtra(SimpleReaderActivity.EXTRA_LABEL,
47                 context.getString(R.string.nfc_hce_foreground_non_payment_reader));
48         return readerIntent;
49     }
50 
51     @Override
onApduSequenceComplete(ComponentName component, long duration)52     void onApduSequenceComplete(ComponentName component, long duration) {
53         if (component.equals(TransportService2.COMPONENT)) {
54             getPassButton().setEnabled(true);
55         }
56     }
57 
58 }
59