From 704c06d7640c58dc6d1dac3686dc5f754bad01c5 Mon Sep 17 00:00:00 2001 From: Yussuf Khalil Date: Mon, 16 Jul 2018 21:17:25 +0200 Subject: [PATCH] Use less precise intent filter for listening for NFC YubiKeys 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 --- app/src/main/java/net/pp3345/ykdroid/ConnectionManager.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/net/pp3345/ykdroid/ConnectionManager.java b/app/src/main/java/net/pp3345/ykdroid/ConnectionManager.java index e2138a4..2928377 100644 --- a/app/src/main/java/net/pp3345/ykdroid/ConnectionManager.java +++ b/app/src/main/java/net/pp3345/ykdroid/ConnectionManager.java @@ -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; } @@ -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) {