X-Git-Url: http://www.average.org/gitweb/?p=YkNeoCR.git;a=blobdiff_plain;f=src%2Forg%2Faverage%2Fnfcauthcr%2FCheck.java;h=6b6ec4f568f79e043ea47cef0888432bb38257b4;hp=c3738f7fc4f80dbe2c799925d522beaa0ea62153;hb=bb4b51c880cf9a1942151bf1dd8977e3a8e0ccf6;hpb=a0d60dab1717e69b6d853eb91d0065fe378e3c28 diff --git a/src/org/average/nfcauthcr/Check.java b/src/org/average/nfcauthcr/Check.java index c3738f7..6b6ec4f 100644 --- a/src/org/average/nfcauthcr/Check.java +++ b/src/org/average/nfcauthcr/Check.java @@ -14,12 +14,12 @@ import android.util.Log; import android.widget.Toast; import org.average.nfcauthcr.YkNeo; +import org.average.nfcauthcr.CRException; public class Check extends Activity { private final String TAG = getClass().getName(); - private AlertDialog swipeDialog; private PendingIntent tagIntent; @Override @@ -29,14 +29,8 @@ public class Check extends Activity { Intent intent = getIntent(); setResult(RESULT_CANCELED); - if (swipeDialog != null) { - swipeDialog.dismiss(); - swipeDialog = null; - } int slot = intent.getIntExtra("slot", -1); if (slot > 0) { - swipeDialog = makeDialog(); - swipeDialog.show(); enableDispatch(slot); } } @@ -46,10 +40,6 @@ public class Check extends Activity { super.onPause(); Log.v(TAG, "Finished the work"); - if(swipeDialog != null) { - swipeDialog.dismiss(); - swipeDialog = null; - } disableDispatch(); } @@ -61,28 +51,40 @@ public class Check extends Activity { Tag tag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG); if (tag == null) return; IsoDep isoTag = IsoDep.get(tag); - byte[] response = YkNeo.doChallengeYubiKey( + try { + byte[] response = YkNeo.doChallengeYubiKey( isoTag, slot, challenge); - if (response != null) { Intent data = getIntent(); data.putExtra("response", response); setResult(RESULT_OK, data); + } catch (CRException e) { + Log.v(TAG, e.getMessage()); + Toast.makeText(this, e.getMessage(), + Toast.LENGTH_LONG).show(); } finish(); } - private AlertDialog makeDialog() { - AlertDialog.Builder builder = new AlertDialog.Builder(this); - builder.setTitle(R.string.challenging); - builder.setMessage(R.string.swipe); - builder.setOnCancelListener( - new DialogInterface.OnCancelListener() { - public void onCancel(DialogInterface dialog) { - finish(); - } - }); - return builder.create(); - } +/* + + + + + + + + + + + + android.nfc.tech.IsoDep + + + +*/ private void enableDispatch(int slot) { Intent intent = getIntent(); @@ -96,13 +98,11 @@ public class Check extends Activity { Toast.makeText(this, R.string.no_nfc, Toast.LENGTH_LONG).show(); finish(); - return; } if (! adapter.isEnabled()) { Toast.makeText(this, R.string.nfc_disabled, Toast.LENGTH_LONG).show(); finish(); - return; } adapter.enableForegroundDispatch( this, tagIntent, new IntentFilter[] {iso},