]> www.average.org Git - YkNeoCR.git/blobdiff - src/org/average/nfcauthcr/Check.java
cleanup workflow
[YkNeoCR.git] / src / org / average / nfcauthcr / Check.java
index c3738f7fc4f80dbe2c799925d522beaa0ea62153..f65ae1ba034536692c5ba0be8c216e329bac146f 100644 (file)
@@ -14,6 +14,7 @@ import android.util.Log;
 import android.widget.Toast;
 
 import org.average.nfcauthcr.YkNeo;
+import org.average.nfcauthcr.CRException;
 
 public class Check extends Activity {
 
@@ -61,12 +62,16 @@ 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();
        }
@@ -96,13 +101,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},