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 ThroughputEmulatorActivity extends BaseEmulatorActivity { 15 TextView mTextView; 16 17 @Override onCreate(Bundle savedInstanceState)18 protected void onCreate(Bundle savedInstanceState) { 19 super.onCreate(savedInstanceState); 20 setContentView(R.layout.pass_fail_text); 21 setPassFailButtonClickListeners(); 22 getPassButton().setEnabled(false); 23 mTextView = (TextView) findViewById(R.id.text); 24 setupServices(this, ThroughputService.COMPONENT); 25 } 26 27 @Override onResume()28 protected void onResume() { 29 super.onResume(); 30 } 31 32 @Override onServicesSetup(boolean result)33 void onServicesSetup(boolean result) { 34 NfcDialogs.createHceTapReaderDialog(this, 35 getString(R.string.nfc_hce_throughput_emulator_help)).show(); 36 } 37 buildReaderIntent(Context context)38 public static Intent buildReaderIntent(Context context) { 39 Intent readerIntent = new Intent(context, SimpleReaderActivity.class); 40 readerIntent.putExtra(SimpleReaderActivity.EXTRA_APDUS, 41 ThroughputService.APDU_COMMAND_SEQUENCE); 42 readerIntent.putExtra(SimpleReaderActivity.EXTRA_RESPONSES, 43 ThroughputService.APDU_RESPOND_SEQUENCE); 44 readerIntent.putExtra(SimpleReaderActivity.EXTRA_LABEL, 45 context.getString(R.string.nfc_hce_throughput_reader)); 46 return readerIntent; 47 } 48 49 @Override onApduSequenceComplete(ComponentName component, long duration)50 void onApduSequenceComplete(ComponentName component, long duration) { 51 if (component.equals(ThroughputService.COMPONENT)) { 52 long timePerApdu = duration / ThroughputService.APDU_COMMAND_SEQUENCE.length; 53 if (duration < 1000) { 54 mTextView.setText("PASS. Total duration: " + Long.toString(duration) + " ms " + 55 "( " + Long.toString(timePerApdu) + " ms per APDU roundtrip)."); 56 getPassButton().setEnabled(true); 57 } else { 58 mTextView.setText("FAIL. Total duration: " + Long.toString(duration) + " ms " + 59 "(" + Long.toString(timePerApdu) + " ms per APDU roundtrip)." + 60 " Require <= 60ms per APDU roundtrip."); 61 } 62 } 63 } 64 } 65