return early if cannot init adapter master
authorEugene Crosser <crosser@average.org>
Fri, 10 May 2013 13:59:39 +0000 (17:59 +0400)
committerEugene Crosser <crosser@average.org>
Fri, 10 May 2013 13:59:39 +0000 (17:59 +0400)
res/values/strings.xml
src/org/average/nfcauthcr/NfcCRdispatch.java
src/org/average/nfcauthcr/QueryCrToken.java

index 83cb008ef2b061bbb9d92bb4d5664a9dd8c38773..15432f66bbbbae224fe7d6417561dc820ba83651 100644 (file)
@@ -2,23 +2,21 @@
 <resources>
        <string name="app_name">YkNeo CR</string>
        <string name="info"><![CDATA[
-<center>
 <h1>Challenge-Response Provider</h1>
 <h2>using Yubico\'s <em>Yubikey Neo</em> NFC token</h2>
-</center>
 <p>
-You need to set up a slot in the <em>Neo</em> to use with CHAL-HMAC
+This application does not do anything itself, it provides a way for other
+applications to use the NFC token for encryption and authentication purposes.
+</p>
+<p>
+You need to configure one of the slots in the <em>Neo</em> to run in CHAL-HMAC
 mode, like this:
 </p>
 <pre>
   ykpersonalize -2 -ochal-resp -ochal-hmac -ohmac-lt64 -oserial-api-visible
 </pre>
 <p>
-This application does not do anything itself, it provides a way for other
-applications to use the NFC token for encryption and authentication purposes.
-</p>
-<p>
-The slot number used for the above command must be selected below:
+The slot number that was used in the above command must be selected below:
 </p>
        ]]>
        </string>
index d5342f018fce227d7f2e91ba85f332a46911c1bb..3216ef642a3b1dc126ec316a95036c9a3fee66e3 100644 (file)
@@ -55,7 +55,7 @@ public class NfcCRdispatch {
                return null;
        }
 
-       public void onResume(ArrayList<String> challenge) {
+       public boolean onResume(ArrayList<String> challenge) {
                this.challenge = challenge;
                Intent intent = activity.getIntent();
                intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
@@ -68,16 +68,17 @@ public class NfcCRdispatch {
                if (adapter == null) {
                        Toast.makeText(activity, R.string.no_nfc,
                                                Toast.LENGTH_LONG).show();
-                       return;
+                       return false;
                }
                if (!adapter.isEnabled()) {
                        Toast.makeText(activity, R.string.nfc_disabled,
                                                Toast.LENGTH_LONG).show();
-                       return;
+                       return false;
                }
                adapter.enableForegroundDispatch(activity, tagIntent,
                                        new IntentFilter[] {iso},
                                        new String[][] {techs});
+               return true;
        }
 
        public void onPause() {
index 68a8d0e9762e1a04d71a7e948c7d7f56cd5eb749..f8565c975ee86ab9e96c5fd48e7d388085e9b3cf 100644 (file)
@@ -64,7 +64,10 @@ public class QueryCrToken extends Activity {
                                intent.getStringArrayListExtra("challenge");
                intent.putExtra("yubikey_neo_slot", slot);
                if (challenge != null) {
-                       dispatch.onResume(challenge);
+                       if (!dispatch.onResume(challenge)) {
+                               Log.e(TAG, "Failed to enable fg dispatch");
+                               finish();
+                       }
                } else {
                        Log.e(TAG, "Challenge missing in the Intent");
                        finish();