Skip to content

Commit

Permalink
Use less precise intent filter for listening for NFC YubiKeys
Browse files Browse the repository at this point in the history
It seems that the previous method doesn't work properly on some devices or not with every YubiKey. This new approach doesn't strictly verify that the NFC tag is actually a YubiKey and will allow to use any ISO 14443-4 tag. Let's just hope that the user won't confuse his credit card for a YubiKey.

Fixes #2
  • Loading branch information
pp3345 committed Jul 16, 2018
1 parent 3f38214 commit 704c06d
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions app/src/main/java/net/pp3345/ykdroid/ConnectionManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,11 @@ public void onActivityResumed(final Activity activity) {
return;

final IntentFilter filter = new IntentFilter(NfcAdapter.ACTION_NDEF_DISCOVERED);
filter.addDataScheme(NfcYubiKey.YUBIKEY_NEO_NDEF_SCHEME);
filter.addDataAuthority(NfcYubiKey.YUBIKEY_NEO_NDEF_HOST, null);

NfcAdapter.getDefaultAdapter(this.activity).enableForegroundDispatch(this.activity,
PendingIntent.getActivity(this.activity, -1, new Intent(this.activity, this.activity.getClass()), 0),
new IntentFilter[]{filter},
null);
new String[][]{new String[]{IsoDep.class.getName()}});
this.isActivityResumed = true;
}

Expand Down Expand Up @@ -170,7 +168,7 @@ public void onReceive(final Context context, final Intent intent) {
this.unplugReceiver = null;
}
break;
case NfcAdapter.ACTION_NDEF_DISCOVERED:
case NfcAdapter.ACTION_TECH_DISCOVERED:
final IsoDep isoDep = IsoDep.get((Tag) intent.getParcelableExtra(NfcAdapter.EXTRA_TAG));

if (isoDep == null) {
Expand Down

0 comments on commit 704c06d

Please sign in to comment.