1 package com.android.cts.verifier.nfc.hce; 2 3 import android.annotation.TargetApi; 4 import android.content.ComponentName; 5 import android.content.Context; 6 import android.content.Intent; 7 import android.os.Bundle; 8 import com.android.cts.verifier.R; 9 import com.android.cts.verifier.nfc.NfcDialogs; 10 11 @TargetApi(19) 12 public class SinglePaymentEmulatorActivity extends BaseEmulatorActivity { 13 @Override onCreate(Bundle savedInstanceState)14 protected void onCreate(Bundle savedInstanceState) { 15 super.onCreate(savedInstanceState); 16 setContentView(R.layout.pass_fail_text); 17 setPassFailButtonClickListeners(); 18 getPassButton().setEnabled(false); 19 setupServices(this, PaymentService1.COMPONENT); 20 } 21 22 @Override onResume()23 protected void onResume() { 24 super.onResume(); 25 } 26 27 @Override onServicesSetup(boolean result)28 void onServicesSetup(boolean result) { 29 // Verify HCE service 1 is the default 30 if (makePaymentDefault(PaymentService1.COMPONENT, 31 R.string.nfc_hce_change_preinstalled_wallet)) { 32 // Wait for callback 33 } else { 34 NfcDialogs.createHceTapReaderDialog(this, null).show(); 35 } 36 } 37 38 @Override onPaymentDefaultResult(ComponentName component, boolean success)39 void onPaymentDefaultResult(ComponentName component, boolean success) { 40 if (success) { 41 NfcDialogs.createHceTapReaderDialog(this, null).show(); 42 } 43 } 44 buildReaderIntent(Context context)45 public static Intent buildReaderIntent(Context context) { 46 Intent readerIntent = new Intent(context, SimpleReaderActivity.class); 47 readerIntent.putExtra(SimpleReaderActivity.EXTRA_APDUS, 48 PaymentService1.APDU_COMMAND_SEQUENCE); 49 readerIntent.putExtra(SimpleReaderActivity.EXTRA_RESPONSES, 50 PaymentService1.APDU_RESPOND_SEQUENCE); 51 readerIntent.putExtra(SimpleReaderActivity.EXTRA_LABEL, 52 context.getString(R.string.nfc_hce_single_payment_reader)); 53 return readerIntent; 54 } 55 56 @Override onApduSequenceComplete(ComponentName component, long duration)57 void onApduSequenceComplete(ComponentName component, long duration) { 58 if (component.equals(PaymentService1.COMPONENT)) { 59 getPassButton().setEnabled(true); 60 } 61 } 62 } 63