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.nfc.cardemulation.CardEmulation; 7 import android.os.Bundle; 8 9 import com.android.cts.verifier.R; 10 import com.android.cts.verifier.nfc.NfcDialogs; 11 12 import java.util.ArrayList; 13 14 public class DynamicAidEmulatorActivity extends BaseEmulatorActivity { 15 16 @Override onCreate(Bundle savedInstanceState)17 protected void onCreate(Bundle savedInstanceState) { 18 super.onCreate(savedInstanceState); 19 setContentView(R.layout.pass_fail_text); 20 setPassFailButtonClickListeners(); 21 getPassButton().setEnabled(false); 22 setupServices(this, PaymentServiceDynamicAids.COMPONENT); 23 } 24 25 26 @Override onResume()27 protected void onResume() { 28 super.onResume(); 29 } 30 31 32 @Override onServicesSetup(boolean result)33 void onServicesSetup(boolean result) { 34 ArrayList<String> paymentAids = new ArrayList<String>(); 35 paymentAids.add(HceUtils.PPSE_AID); 36 paymentAids.add(HceUtils.VISA_AID); 37 // Register a different set of AIDs for the foreground 38 mCardEmulation.registerAidsForService(PaymentServiceDynamicAids.COMPONENT, 39 CardEmulation.CATEGORY_PAYMENT, paymentAids); 40 // Now make sure it's default 41 if (makePaymentDefault(PaymentServiceDynamicAids.COMPONENT, 42 R.string.nfc_hce_change_preinstalled_wallet)) { 43 // Wait for callback 44 } else { 45 NfcDialogs.createHceTapReaderDialog(this, getString(R.string.nfc_hce_payment_dynamic_aids_help)).show(); 46 } 47 } 48 49 @Override onPaymentDefaultResult(ComponentName component, boolean success)50 void onPaymentDefaultResult(ComponentName component, boolean success) { 51 if (success) { 52 NfcDialogs.createHceTapReaderDialog(this, getString(R.string.nfc_hce_payment_dynamic_aids_help)).show(); 53 } 54 } 55 56 @Override onApduSequenceComplete(ComponentName component, long duration)57 void onApduSequenceComplete(ComponentName component, long duration) { 58 if (component.equals(PaymentServiceDynamicAids.COMPONENT)) { 59 getPassButton().setEnabled(true); 60 } 61 } 62 buildReaderIntent(Context context)63 public static Intent buildReaderIntent(Context context) { 64 Intent readerIntent = new Intent(context, SimpleReaderActivity.class); 65 readerIntent.putExtra(SimpleReaderActivity.EXTRA_APDUS, 66 PaymentServiceDynamicAids.APDU_COMMAND_SEQUENCE); 67 readerIntent.putExtra(SimpleReaderActivity.EXTRA_RESPONSES, 68 PaymentServiceDynamicAids.APDU_RESPOND_SEQUENCE); 69 readerIntent.putExtra(SimpleReaderActivity.EXTRA_LABEL, 70 context.getString(R.string.nfc_hce_payment_dynamic_aids_reader)); 71 return readerIntent; 72 } 73 } 74