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 DualNonPaymentPrefixEmulatorActivity extends BaseEmulatorActivity { 15 @Override onCreate(Bundle savedInstanceState)16 protected void onCreate(Bundle savedInstanceState) { 17 super.onCreate(savedInstanceState); 18 setContentView(R.layout.pass_fail_text); 19 setPassFailButtonClickListeners(); 20 getPassButton().setEnabled(false); 21 setupServices(this, PrefixTransportService1.COMPONENT, PrefixAccessService.COMPONENT); 22 } 23 24 @Override onResume()25 protected void onResume() { 26 super.onResume(); 27 } 28 29 @Override onServicesSetup(boolean result)30 void onServicesSetup(boolean result) { 31 // Do dynamic AID registration 32 ArrayList<String> service1_aids = new ArrayList<String>(); 33 service1_aids.add(HceUtils.TRANSPORT_PREFIX_AID + "*"); 34 ArrayList<String> service2_aids = new ArrayList<String>(); 35 service2_aids.add(HceUtils.ACCESS_PREFIX_AID + "*"); 36 mCardEmulation.registerAidsForService(PrefixTransportService1.COMPONENT, CardEmulation.CATEGORY_OTHER, service1_aids); 37 mCardEmulation.registerAidsForService(PrefixAccessService.COMPONENT, CardEmulation.CATEGORY_OTHER, service2_aids); 38 NfcDialogs.createHceTapReaderDialog(this, getString(R.string.nfc_hce_other_prefix_aids_help)).show(); 39 } 40 buildReaderIntent(Context context)41 public static Intent buildReaderIntent(Context context) { 42 Intent readerIntent = new Intent(context, SimpleReaderActivity.class); 43 // Combine command/response APDU arrays 44 CommandApdu[] commandSequences = new CommandApdu[PrefixTransportService1.APDU_COMMAND_SEQUENCE.length + 45 PrefixAccessService.APDU_COMMAND_SEQUENCE.length]; 46 System.arraycopy(PrefixTransportService1.APDU_COMMAND_SEQUENCE, 0, commandSequences, 0, 47 PrefixTransportService1.APDU_COMMAND_SEQUENCE.length); 48 System.arraycopy(PrefixAccessService.APDU_COMMAND_SEQUENCE, 0, commandSequences, 49 PrefixTransportService1.APDU_COMMAND_SEQUENCE.length, 50 PrefixAccessService.APDU_COMMAND_SEQUENCE.length); 51 52 String[] responseSequences = new String[PrefixTransportService1.APDU_RESPOND_SEQUENCE.length + 53 PrefixAccessService.APDU_RESPOND_SEQUENCE.length]; 54 System.arraycopy(PrefixTransportService1.APDU_RESPOND_SEQUENCE, 0, responseSequences, 0, 55 PrefixTransportService1.APDU_RESPOND_SEQUENCE.length); 56 System.arraycopy(PrefixAccessService.APDU_RESPOND_SEQUENCE, 0, responseSequences, 57 PrefixTransportService1.APDU_RESPOND_SEQUENCE.length, 58 PrefixAccessService.APDU_RESPOND_SEQUENCE.length); 59 60 readerIntent.putExtra(SimpleReaderActivity.EXTRA_APDUS, commandSequences); 61 readerIntent.putExtra(SimpleReaderActivity.EXTRA_RESPONSES, responseSequences); 62 readerIntent.putExtra(SimpleReaderActivity.EXTRA_LABEL, 63 context.getString(R.string.nfc_hce_other_prefix_aids_reader)); 64 return readerIntent; 65 } 66 67 @Override onApduSequenceComplete(ComponentName component, long duration)68 void onApduSequenceComplete(ComponentName component, long duration) { 69 if (component.equals(PrefixAccessService.COMPONENT)) { 70 getPassButton().setEnabled(true); 71 } 72 } 73 }