]> www.average.org Git - YkNeoCR.git/blobdiff - src/org/average/nfcauthcr/NfcCRdispatch.java
begin converting to multiple ops per request
[YkNeoCR.git] / src / org / average / nfcauthcr / NfcCRdispatch.java
index bfacfa988a257a214ee0c09fcec052069e7762bf..25198beff5fdf39e9b1819d673d8822bbe688cc7 100644 (file)
@@ -1,5 +1,8 @@
 package org.average.nfcauthcr;
 
+import java.io.IOException;
+import java.util.ArrayList;
+
 import android.app.Activity;
 import android.app.PendingIntent;
 import android.content.Intent;
@@ -20,30 +23,39 @@ public class NfcCRdispatch {
 
        private Activity activity = null;
        private PendingIntent tagIntent = null;
-       private byte[] challenge;
+       private ArrayList<String> challenge;
 
        NfcCRdispatch(Activity activity) {
                Log.v(TAG, "new NfcCRdispatch, activity=" + activity);
                this.activity = activity;
        }
 
-       public byte[] onNewIntent(Intent intent) {
+       public ArrayList<String> onNewIntent(Intent intent) {
                Log.v(TAG, "NFC Intent arrived");
                Tag tag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);
                if (tag == null) return null;
                IsoDep isoTag = IsoDep.get(tag);
                try {
                        int slot = intent.getIntExtra("yubikey_neo_slot", -1);
+                       isoTag.connect();
                        return YkNeo.doChalResp(isoTag, slot, challenge);
+               } catch (TagLostException e) {
+                       Log.v(TAG, e.getMessage());
+                       Toast.makeText(activity, e.getMessage(),
+                                       Toast.LENGTH_LONG).show();
+               } catch (IOException e) {
+                       Log.v(TAG, e.getMessage());
+                       Toast.makeText(activity, e.getMessage(),
+                                       Toast.LENGTH_LONG).show();
                } catch (CRException e) {
                        Log.v(TAG, e.getMessage());
                        Toast.makeText(activity, e.getMessage(),
                                        Toast.LENGTH_LONG).show();
-                       return null;
                }
+               return null;
        }
 
-       public void onResume(byte[] challenge) {
+       public void onResume(ArrayList<String> challenge) {
                this.challenge = challenge;
                Intent intent = activity.getIntent();
                intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);