X-Git-Url: http://www.average.org/gitweb/?p=YkNeoCR.git;a=blobdiff_plain;f=src%2Forg%2Faverage%2Fnfcauthcr%2FNfcCRdispatch.java;h=d5342f018fce227d7f2e91ba85f332a46911c1bb;hp=bfacfa988a257a214ee0c09fcec052069e7762bf;hb=edfc8d9f2aad0bd7c0810d9f67a67e3db4b266c0;hpb=08b05b67a65e78e80fb0fffec8855a69a72ebff9 diff --git a/src/org/average/nfcauthcr/NfcCRdispatch.java b/src/org/average/nfcauthcr/NfcCRdispatch.java index bfacfa9..d5342f0 100644 --- a/src/org/average/nfcauthcr/NfcCRdispatch.java +++ b/src/org/average/nfcauthcr/NfcCRdispatch.java @@ -1,4 +1,7 @@ -package org.average.nfcauthcr; +package org.average.ykneocr; + +import java.io.IOException; +import java.util.ArrayList; import android.app.Activity; import android.app.PendingIntent; @@ -11,8 +14,8 @@ import android.nfc.tech.IsoDep; import android.util.Log; import android.widget.Toast; -import org.average.nfcauthcr.YkNeo; -import org.average.nfcauthcr.CRException; +import org.average.ykneocr.YkNeo; +import org.average.ykneocr.CRException; public class NfcCRdispatch { @@ -20,30 +23,39 @@ public class NfcCRdispatch { private Activity activity = null; private PendingIntent tagIntent = null; - private byte[] challenge; + private ArrayList challenge; NfcCRdispatch(Activity activity) { Log.v(TAG, "new NfcCRdispatch, activity=" + activity); this.activity = activity; } - public byte[] onNewIntent(Intent intent) { + public ArrayList 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 challenge) { this.challenge = challenge; Intent intent = activity.getIntent(); intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);