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 android.widget.TextView; 9 10 import com.android.cts.verifier.R; 11 import com.android.cts.verifier.nfc.NfcDialogs; 12 13 @TargetApi(19) 14 public class TapTestEmulatorActivity extends BaseEmulatorActivity { 15 TextView mTextView; 16 int mNumTaps; 17 18 @Override onCreate(Bundle savedInstanceState)19 protected void onCreate(Bundle savedInstanceState) { 20 super.onCreate(savedInstanceState); 21 setContentView(R.layout.pass_fail_text); 22 setPassFailButtonClickListeners(); 23 getPassButton().setEnabled(false); 24 mTextView = (TextView) findViewById(R.id.text); 25 setupServices(this, TransportService1.COMPONENT); 26 } 27 28 @Override onResume()29 protected void onResume() { 30 super.onResume(); 31 mNumTaps = 0; 32 mTextView.setText("Number of successful taps: 0/50."); 33 } 34 35 @Override onServicesSetup(boolean result)36 void onServicesSetup(boolean result) { 37 NfcDialogs.createHceTapReaderDialog(this, 38 getString(R.string.nfc_hce_tap_test_emulator_help)).show(); 39 } 40 buildReaderIntent(Context context)41 public static Intent buildReaderIntent(Context context) { 42 Intent readerIntent = new Intent(context, SimpleReaderActivity.class); 43 readerIntent.putExtra(SimpleReaderActivity.EXTRA_APDUS, 44 TransportService1.APDU_COMMAND_SEQUENCE); 45 readerIntent.putExtra(SimpleReaderActivity.EXTRA_RESPONSES, 46 TransportService1.APDU_RESPOND_SEQUENCE); 47 readerIntent.putExtra(SimpleReaderActivity.EXTRA_LABEL, 48 context.getString(R.string.nfc_hce_tap_test_reader)); 49 return readerIntent; 50 } 51 52 @Override onApduSequenceComplete(ComponentName component, long duration)53 void onApduSequenceComplete(ComponentName component, long duration) { 54 if (component.equals(TransportService1.COMPONENT)) { 55 mNumTaps++; 56 if (mNumTaps <= 50) { 57 mTextView.setText("Number of successful taps: " + Integer.toString(mNumTaps) + 58 "/50."); 59 } 60 if (mNumTaps >= 50) { 61 getPassButton().setEnabled(true); 62 } 63 } 64 } 65 } 66