From ba895122ff2418a2f2e00d83cd62ac2eb975b880 Mon Sep 17 00:00:00 2001 From: Souleymane DIALLO Date: Wed, 15 May 2024 11:44:30 +0200 Subject: [PATCH 1/5] fix: remove deprecated Beam functionalities from Android 14 --- README.md | 4 - build.gradle | 0 .../nfc/plugin/NfcPlugin.java | 189 ++---------------- 3 files changed, 21 insertions(+), 172 deletions(-) create mode 100644 build.gradle diff --git a/README.md b/README.md index 4df50fb7..950b358a 100644 --- a/README.md +++ b/README.md @@ -452,7 +452,6 @@ Function `nfc.share` writes an NdefMessage via peer-to-peer. This should appear ### Supported Platforms -- Android - Windows - BlackBerry 7 - BlackBerry 10 @@ -481,7 +480,6 @@ Function `nfc.unshare` stops sharing data via peer-to-peer. ### Supported Platforms -- Android - Windows - BlackBerry 7 - BlackBerry 10 @@ -538,7 +536,6 @@ This is Android only, but it should be possible to add implementations for other ### Supported Platforms -- Android ## nfc.stopHandover @@ -557,7 +554,6 @@ Function `nfc.stopHandover` stops sharing data via peer-to-peer. ### Supported Platforms -- Android ## nfc.showSettings diff --git a/build.gradle b/build.gradle new file mode 100644 index 00000000..e69de29b diff --git a/src/android/src/com/chariotsolutions/nfc/plugin/NfcPlugin.java b/src/android/src/com/chariotsolutions/nfc/plugin/NfcPlugin.java index e8256d83..132dedd6 100644 --- a/src/android/src/com/chariotsolutions/nfc/plugin/NfcPlugin.java +++ b/src/android/src/com/chariotsolutions/nfc/plugin/NfcPlugin.java @@ -20,12 +20,10 @@ import android.content.Intent; import android.content.IntentFilter; import android.content.IntentFilter.MalformedMimeTypeException; -import android.net.Uri; import android.nfc.FormatException; import android.nfc.NdefMessage; import android.nfc.NdefRecord; import android.nfc.NfcAdapter; -import android.nfc.NfcEvent; import android.nfc.Tag; import android.nfc.TagLostException; import android.nfc.tech.Ndef; @@ -35,7 +33,7 @@ import android.os.Parcelable; import android.util.Log; -public class NfcPlugin extends CordovaPlugin implements NfcAdapter.OnNdefPushCompleteCallback { +public class NfcPlugin extends CordovaPlugin { private static final String REGISTER_MIME_TYPE = "registerMimeType"; private static final String REMOVE_MIME_TYPE = "removeMimeType"; private static final String REGISTER_NDEF = "registerNdef"; @@ -46,10 +44,6 @@ public class NfcPlugin extends CordovaPlugin implements NfcAdapter.OnNdefPushCom private static final String WRITE_TAG = "writeTag"; private static final String MAKE_READ_ONLY = "makeReadOnly"; private static final String ERASE_TAG = "eraseTag"; - private static final String SHARE_TAG = "shareTag"; - private static final String UNSHARE_TAG = "unshareTag"; - private static final String HANDOVER = "handover"; // Android Beam - private static final String STOP_HANDOVER = "stopHandover"; private static final String ENABLED = "enabled"; private static final String INIT = "init"; private static final String SHOW_SETTINGS = "showSettings"; @@ -74,21 +68,17 @@ public class NfcPlugin extends CordovaPlugin implements NfcAdapter.OnNdefPushCom private static final String STATUS_NFC_OK = "NFC_OK"; private static final String STATUS_NO_NFC = "NO_NFC"; private static final String STATUS_NFC_DISABLED = "NFC_DISABLED"; - private static final String STATUS_NDEF_PUSH_DISABLED = "NDEF_PUSH_DISABLED"; private static final String TAG = "NfcPlugin"; private final List intentFilters = new ArrayList<>(); private final ArrayList techLists = new ArrayList<>(); - private NdefMessage p2pMessage = null; private PendingIntent pendingIntent = null; private Intent savedIntent = null; private CallbackContext readerModeCallback; private CallbackContext channelCallback; - private CallbackContext shareTagCallback; - private CallbackContext handoverCallback; @Override public boolean execute(String action, JSONArray data, CallbackContext callbackContext) throws JSONException { @@ -155,19 +145,8 @@ public boolean execute(String action, JSONArray data, CallbackContext callbackCo } else if (action.equalsIgnoreCase(ERASE_TAG)) { eraseTag(callbackContext); - } else if (action.equalsIgnoreCase(SHARE_TAG)) { - shareTag(data, callbackContext); - - } else if (action.equalsIgnoreCase(UNSHARE_TAG)) { - unshareTag(callbackContext); - - } else if (action.equalsIgnoreCase(HANDOVER)) { - handover(data, callbackContext); - - } else if (action.equalsIgnoreCase(STOP_HANDOVER)) { - stopHandover(callbackContext); - - } else if (action.equalsIgnoreCase(INIT)) { + } + else if (action.equalsIgnoreCase(INIT)) { init(callbackContext); } else if (action.equalsIgnoreCase(ENABLED)) { @@ -289,13 +268,6 @@ private void removeNdef(CallbackContext callbackContext) { callbackContext.success(); } - private void unshareTag(CallbackContext callbackContext) { - p2pMessage = null; - stopNdefPush(); - shareTagCallback = null; - callbackContext.success(); - } - private void init(CallbackContext callbackContext) { Log.d(TAG, "Enabling plugin " + getIntent()); @@ -438,35 +410,6 @@ private void makeReadOnly(final CallbackContext callbackContext) { }); } - private void shareTag(JSONArray data, CallbackContext callbackContext) throws JSONException { - NdefRecord[] records = Util.jsonToNdefRecords(data.getString(0)); - this.p2pMessage = new NdefMessage(records); - - startNdefPush(callbackContext); - } - - // setBeamPushUris - // Every Uri you provide must have either scheme 'file' or scheme 'content'. - // Note that this takes priority over setNdefPush - // - // See http://developer.android.com/reference/android/nfc/NfcAdapter.html#setBeamPushUris(android.net.Uri[],%20android.app.Activity) - private void handover(JSONArray data, CallbackContext callbackContext) throws JSONException { - - Uri[] uri = new Uri[data.length()]; - - for (int i = 0; i < data.length(); i++) { - uri[i] = Uri.parse(data.getString(i)); - } - - startNdefBeam(callbackContext, uri); - } - - private void stopHandover(CallbackContext callbackContext) { - stopNdefBeam(); - handoverCallback = null; - callbackContext.success(); - } - private void showSettings(CallbackContext callbackContext) { if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN) { Intent intent = new Intent(android.provider.Settings.ACTION_NFC_SETTINGS); @@ -546,9 +489,6 @@ private void startNfc() { nfcAdapter.enableForegroundDispatch(getActivity(), getPendingIntent(), intentFilters, techLists); } - if (p2pMessage != null) { - nfcAdapter.setNdefPushMessage(p2pMessage, getActivity()); - } } catch (IllegalStateException e) { // issue 110 - user exits app with home button while nfc is initializing Log.w(TAG, "Illegal State Exception starting NFC. Assuming application is terminating."); @@ -575,77 +515,6 @@ private void stopNfc() { }); } - private void startNdefBeam(final CallbackContext callbackContext, final Uri[] uris) { - getActivity().runOnUiThread(() -> { - - NfcAdapter nfcAdapter = NfcAdapter.getDefaultAdapter(getActivity()); - - if (nfcAdapter == null) { - callbackContext.error(STATUS_NO_NFC); - } else if (!nfcAdapter.isNdefPushEnabled()) { - callbackContext.error(STATUS_NDEF_PUSH_DISABLED); - } else { - nfcAdapter.setOnNdefPushCompleteCallback(NfcPlugin.this, getActivity()); - try { - nfcAdapter.setBeamPushUris(uris, getActivity()); - - PluginResult result = new PluginResult(PluginResult.Status.NO_RESULT); - result.setKeepCallback(true); - handoverCallback = callbackContext; - callbackContext.sendPluginResult(result); - - } catch (IllegalArgumentException e) { - callbackContext.error(e.getMessage()); - } - } - }); - } - - private void startNdefPush(final CallbackContext callbackContext) { - getActivity().runOnUiThread(() -> { - - NfcAdapter nfcAdapter = NfcAdapter.getDefaultAdapter(getActivity()); - - if (nfcAdapter == null) { - callbackContext.error(STATUS_NO_NFC); - } else if (!nfcAdapter.isNdefPushEnabled()) { - callbackContext.error(STATUS_NDEF_PUSH_DISABLED); - } else { - nfcAdapter.setNdefPushMessage(p2pMessage, getActivity()); - nfcAdapter.setOnNdefPushCompleteCallback(NfcPlugin.this, getActivity()); - - PluginResult result = new PluginResult(PluginResult.Status.NO_RESULT); - result.setKeepCallback(true); - shareTagCallback = callbackContext; - callbackContext.sendPluginResult(result); - } - }); - } - - private void stopNdefPush() { - getActivity().runOnUiThread(() -> { - - NfcAdapter nfcAdapter = NfcAdapter.getDefaultAdapter(getActivity()); - - if (nfcAdapter != null) { - nfcAdapter.setNdefPushMessage(null, getActivity()); - } - - }); - } - - private void stopNdefBeam() { - getActivity().runOnUiThread(() -> { - - NfcAdapter nfcAdapter = NfcAdapter.getDefaultAdapter(getActivity()); - - if (nfcAdapter != null) { - nfcAdapter.setBeamPushUris(null, getActivity()); - } - - }); - } - private void addToTechList(String[] techs) { techLists.add(techs); } @@ -790,7 +659,7 @@ private boolean recycledIntent() { // TODO this is a kludge, find real solution int flags = getIntent().getFlags(); if ((flags & Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY) == Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY) { - Log.i(TAG, "Launched from history, killing recycled intent"); + LOG.i(TAG, "Launched from history, killing recycled intent"); setIntent(new Intent()); return true; } @@ -799,7 +668,7 @@ private boolean recycledIntent() { // TODO this is a kludge, find real solution @Override public void onPause(boolean multitasking) { - Log.d(TAG, "onPause " + getIntent()); + LOG.d(TAG, "onPause " + getIntent()); super.onPause(multitasking); if (multitasking) { // nfc can't run in background @@ -809,14 +678,14 @@ public void onPause(boolean multitasking) { @Override public void onResume(boolean multitasking) { - Log.d(TAG, "onResume " + getIntent()); + LOG.d(TAG, "onResume " + getIntent()); super.onResume(multitasking); startNfc(); } @Override public void onNewIntent(Intent intent) { - Log.d(TAG, "onNewIntent " + intent); + LOG.d(TAG, "onNewIntent " + intent); super.onNewIntent(intent); setIntent(intent); savedIntent = intent; @@ -835,22 +704,6 @@ private void setIntent(Intent intent) { getActivity().setIntent(intent); } - @Override - public void onNdefPushComplete(NfcEvent event) { - - // handover (beam) take precedence over share tag (ndef push) - if (handoverCallback != null) { - PluginResult result = new PluginResult(PluginResult.Status.OK, "Beamed Message to Peer"); - result.setKeepCallback(true); - handoverCallback.sendPluginResult(result); - } else if (shareTagCallback != null) { - PluginResult result = new PluginResult(PluginResult.Status.OK, "Shared Message with Peer"); - result.setKeepCallback(true); - shareTagCallback.sendPluginResult(result); - } - - } - /** * Enable I/O operations to the tag from this TagTechnology object. * * @@ -869,7 +722,7 @@ private void connect(final String tech, final int timeout, final CallbackContext } if (tag == null) { - Log.e(TAG, "No Tag"); + LOG.e(TAG, "No Tag"); callbackContext.error("No Tag"); return; } @@ -891,7 +744,7 @@ private void connect(final String tech, final int timeout, final CallbackContext } catch(NoSuchMethodException e) { // Some technologies do not support this, so just ignore. } catch(JSONException e) { - Log.e(TAG, "Error serializing JSON", e); + LOG.e(TAG, "Error serializing JSON", e); } } @@ -905,21 +758,21 @@ private void connect(final String tech, final int timeout, final CallbackContext callbackContext.success(resultObject); } catch (IOException ex) { - Log.e(TAG, "Tag connection failed", ex); + LOG.e(TAG, "Tag connection failed", ex); callbackContext.error("Tag connection failed"); // Users should never get these reflection errors } catch (ClassNotFoundException e) { - Log.e(TAG, e.getMessage(), e); + LOG.e(TAG, e.getMessage(), e); callbackContext.error(e.getMessage()); } catch (NoSuchMethodException e) { - Log.e(TAG, e.getMessage(), e); + LOG.e(TAG, e.getMessage(), e); callbackContext.error(e.getMessage()); } catch (IllegalAccessException e) { - Log.e(TAG, e.getMessage(), e); + LOG.e(TAG, e.getMessage(), e); callbackContext.error(e.getMessage()); } catch (InvocationTargetException e) { - Log.e(TAG, e.getMessage(), e); + LOG.e(TAG, e.getMessage(), e); callbackContext.error(e.getMessage()); } }); @@ -961,7 +814,7 @@ private void close(CallbackContext callbackContext) { } } catch (IOException ex) { - Log.e(TAG, "Error closing nfc connection", ex); + LOG.e(TAG, "Error closing nfc connection", ex); callbackContext.error("Error closing nfc connection " + ex.getLocalizedMessage()); } }); @@ -977,12 +830,12 @@ private void transceive(final byte[] data, final CallbackContext callbackContext cordova.getThreadPool().execute(() -> { try { if (tagTechnology == null) { - Log.e(TAG, "No Tech"); + LOG.e(TAG, "No Tech"); callbackContext.error("No Tech"); return; } if (!tagTechnology.isConnected()) { - Log.e(TAG, "Not connected"); + LOG.e(TAG, "Not connected"); callbackContext.error("Not connected"); return; } @@ -996,17 +849,17 @@ private void transceive(final byte[] data, final CallbackContext callbackContext } catch (NoSuchMethodException e) { String error = "TagTechnology " + tagTechnologyClass.getName() + " does not have a transceive function"; - Log.e(TAG, error, e); + LOG.e(TAG, error, e); callbackContext.error(error); } catch (NullPointerException e) { // This can happen if the tag has been closed while we're still working with it from the thread pool. - Log.e(TAG, e.getMessage(), e); + LOG.e(TAG, e.getMessage(), e); callbackContext.error(e.getMessage()); } catch (IllegalAccessException e) { - Log.e(TAG, e.getMessage(), e); + LOG.e(TAG, e.getMessage(), e); callbackContext.error(e.getMessage()); } catch (InvocationTargetException e) { - Log.e(TAG, e.getMessage(), e); + LOG.e(TAG, e.getMessage(), e); Throwable cause = e.getCause(); callbackContext.error(cause.getMessage()); } From cba6938bf85e1864a3ea544af958bbae0bcc5769 Mon Sep 17 00:00:00 2001 From: Souleymane DIALLO Date: Wed, 15 May 2024 16:07:05 +0200 Subject: [PATCH 2/5] refactor: remove unused Android-specific functions nfc.handover and nfc.stopHandover from README and phonegap-nfc.js --- README.md | 50 ------------------- .../nfc/plugin/NfcPlugin.java | 37 +++++++------- www/phonegap-nfc.js | 12 ----- 3 files changed, 18 insertions(+), 81 deletions(-) diff --git a/README.md b/README.md index 950b358a..37f0d6e5 100644 --- a/README.md +++ b/README.md @@ -87,8 +87,6 @@ Writing NFC tags on iOS uses the same [nfc.write](#nfcwrite) function as other p - [nfc.share](#nfcshare) - [nfc.unshare](#nfcunshare) - [nfc.erase](#nfcerase) -- [nfc.handover](#nfchandover) -- [nfc.stopHandover](#nfcstophandover) - [nfc.enabled](#nfcenabled) - [nfc.showSettings](#nfcshowsettings) - [~~nfc.beginSession~~](#nfcbeginsession) @@ -506,54 +504,6 @@ This method *must* be called from within an NDEF Event Handler. - Android - BlackBerry 7 -## nfc.handover - -Send a file to another device via NFC handover. - - var uri = "content://media/external/audio/media/175"; - nfc.handover(uri, [onSuccess], [onFailure]); - - - var uris = [ - "content://media/external/audio/media/175", - "content://media/external/audio/media/176", - "content://media/external/audio/media/348" - ]; - nfc.handover(uris, [onSuccess], [onFailure]); - - -### Parameters - -- __uri__: A URI as a String, or an *array* of URIs. -- __onSuccess__: (Optional) The callback that is called when the message is pushed. -- __onFailure__: (Optional) The callback that is called if there was an error. - -### Description - -Function `nfc.handover` shares files to a NFC peer using handover. Files are sent by specifying a file:// or context:// URI or a list of URIs. The file transfer is initiated with NFC but the transfer is completed with over Bluetooth or WiFi which is handled by a NFC handover request. The Android code is responsible for building the handover NFC Message. - -This is Android only, but it should be possible to add implementations for other platforms. - -### Supported Platforms - - -## nfc.stopHandover - -Stop sharing NDEF data via NFC handover. - - nfc.stopHandover([onSuccess], [onFailure]); - -### Parameters - -- __onSuccess__: (Optional) The callback that is called when sharing stops. -- __onFailure__: (Optional) The callback that is called if there was an error. - -### Description - -Function `nfc.stopHandover` stops sharing data via peer-to-peer. - -### Supported Platforms - ## nfc.showSettings diff --git a/src/android/src/com/chariotsolutions/nfc/plugin/NfcPlugin.java b/src/android/src/com/chariotsolutions/nfc/plugin/NfcPlugin.java index 132dedd6..1d2464de 100644 --- a/src/android/src/com/chariotsolutions/nfc/plugin/NfcPlugin.java +++ b/src/android/src/com/chariotsolutions/nfc/plugin/NfcPlugin.java @@ -145,8 +145,7 @@ public boolean execute(String action, JSONArray data, CallbackContext callbackCo } else if (action.equalsIgnoreCase(ERASE_TAG)) { eraseTag(callbackContext); - } - else if (action.equalsIgnoreCase(INIT)) { + } else if (action.equalsIgnoreCase(INIT)) { init(callbackContext); } else if (action.equalsIgnoreCase(ENABLED)) { @@ -659,7 +658,7 @@ private boolean recycledIntent() { // TODO this is a kludge, find real solution int flags = getIntent().getFlags(); if ((flags & Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY) == Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY) { - LOG.i(TAG, "Launched from history, killing recycled intent"); + Log.i(TAG, "Launched from history, killing recycled intent"); setIntent(new Intent()); return true; } @@ -668,7 +667,7 @@ private boolean recycledIntent() { // TODO this is a kludge, find real solution @Override public void onPause(boolean multitasking) { - LOG.d(TAG, "onPause " + getIntent()); + Log.d(TAG, "onPause " + getIntent()); super.onPause(multitasking); if (multitasking) { // nfc can't run in background @@ -678,14 +677,14 @@ public void onPause(boolean multitasking) { @Override public void onResume(boolean multitasking) { - LOG.d(TAG, "onResume " + getIntent()); + Log.d(TAG, "onResume " + getIntent()); super.onResume(multitasking); startNfc(); } @Override public void onNewIntent(Intent intent) { - LOG.d(TAG, "onNewIntent " + intent); + Log.d(TAG, "onNewIntent " + intent); super.onNewIntent(intent); setIntent(intent); savedIntent = intent; @@ -722,7 +721,7 @@ private void connect(final String tech, final int timeout, final CallbackContext } if (tag == null) { - LOG.e(TAG, "No Tag"); + Log.e(TAG, "No Tag"); callbackContext.error("No Tag"); return; } @@ -744,7 +743,7 @@ private void connect(final String tech, final int timeout, final CallbackContext } catch(NoSuchMethodException e) { // Some technologies do not support this, so just ignore. } catch(JSONException e) { - LOG.e(TAG, "Error serializing JSON", e); + Log.e(TAG, "Error serializing JSON", e); } } @@ -763,16 +762,16 @@ private void connect(final String tech, final int timeout, final CallbackContext // Users should never get these reflection errors } catch (ClassNotFoundException e) { - LOG.e(TAG, e.getMessage(), e); + Log.e(TAG, e.getMessage(), e); callbackContext.error(e.getMessage()); } catch (NoSuchMethodException e) { - LOG.e(TAG, e.getMessage(), e); + Log.e(TAG, e.getMessage(), e); callbackContext.error(e.getMessage()); } catch (IllegalAccessException e) { - LOG.e(TAG, e.getMessage(), e); + Log.e(TAG, e.getMessage(), e); callbackContext.error(e.getMessage()); } catch (InvocationTargetException e) { - LOG.e(TAG, e.getMessage(), e); + Log.e(TAG, e.getMessage(), e); callbackContext.error(e.getMessage()); } }); @@ -814,7 +813,7 @@ private void close(CallbackContext callbackContext) { } } catch (IOException ex) { - LOG.e(TAG, "Error closing nfc connection", ex); + Log.e(TAG, "Error closing nfc connection", ex); callbackContext.error("Error closing nfc connection " + ex.getLocalizedMessage()); } }); @@ -830,12 +829,12 @@ private void transceive(final byte[] data, final CallbackContext callbackContext cordova.getThreadPool().execute(() -> { try { if (tagTechnology == null) { - LOG.e(TAG, "No Tech"); + Log.e(TAG, "No Tech"); callbackContext.error("No Tech"); return; } if (!tagTechnology.isConnected()) { - LOG.e(TAG, "Not connected"); + Log.e(TAG, "Not connected"); callbackContext.error("Not connected"); return; } @@ -849,17 +848,17 @@ private void transceive(final byte[] data, final CallbackContext callbackContext } catch (NoSuchMethodException e) { String error = "TagTechnology " + tagTechnologyClass.getName() + " does not have a transceive function"; - LOG.e(TAG, error, e); + Log.e(TAG, error, e); callbackContext.error(error); } catch (NullPointerException e) { // This can happen if the tag has been closed while we're still working with it from the thread pool. - LOG.e(TAG, e.getMessage(), e); + Log.e(TAG, e.getMessage(), e); callbackContext.error(e.getMessage()); } catch (IllegalAccessException e) { - LOG.e(TAG, e.getMessage(), e); + Log.e(TAG, e.getMessage(), e); callbackContext.error(e.getMessage()); } catch (InvocationTargetException e) { - LOG.e(TAG, e.getMessage(), e); + Log.e(TAG, e.getMessage(), e); Throwable cause = e.getCause(); callbackContext.error(cause.getMessage()); } diff --git a/www/phonegap-nfc.js b/www/phonegap-nfc.js index 7349bb7a..d6051b7c 100644 --- a/www/phonegap-nfc.js +++ b/www/phonegap-nfc.js @@ -461,18 +461,6 @@ var nfc = { cordova.exec(win, fail, "NfcPlugin", "unshareTag", []); }, - handover: function (uris, win, fail) { - // if we get a single URI, wrap it in an array - if (!Array.isArray(uris)) { - uris = [ uris ]; - } - cordova.exec(win, fail, "NfcPlugin", "handover", uris); - }, - - stopHandover: function (win, fail) { - cordova.exec(win, fail, "NfcPlugin", "stopHandover", []); - }, - erase: function (win, fail) { cordova.exec(win, fail, "NfcPlugin", "eraseTag", [[]]); }, From 9abf51a04927a155c9ed4465f61f1aed875dd5be Mon Sep 17 00:00:00 2001 From: Souleymane DIALLO Date: Wed, 15 May 2024 16:44:50 +0200 Subject: [PATCH 3/5] refactor: remane LOG to Log in NfcPlugin.java --- src/android/src/com/chariotsolutions/nfc/plugin/NfcPlugin.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/android/src/com/chariotsolutions/nfc/plugin/NfcPlugin.java b/src/android/src/com/chariotsolutions/nfc/plugin/NfcPlugin.java index 1d2464de..588f2a5e 100644 --- a/src/android/src/com/chariotsolutions/nfc/plugin/NfcPlugin.java +++ b/src/android/src/com/chariotsolutions/nfc/plugin/NfcPlugin.java @@ -757,7 +757,7 @@ private void connect(final String tech, final int timeout, final CallbackContext callbackContext.success(resultObject); } catch (IOException ex) { - LOG.e(TAG, "Tag connection failed", ex); + Log.e(TAG, "Tag connection failed", ex); callbackContext.error("Tag connection failed"); // Users should never get these reflection errors From a7fa359b23a8eca06adbad5d64bf1808092c3d27 Mon Sep 17 00:00:00 2001 From: Souleymane DIALLO Date: Fri, 17 May 2024 10:23:43 +0200 Subject: [PATCH 4/5] fix: fix requires FLAG_MUTABLE when creating a PendingIntent --- .../src/com/chariotsolutions/nfc/plugin/NfcPlugin.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/android/src/com/chariotsolutions/nfc/plugin/NfcPlugin.java b/src/android/src/com/chariotsolutions/nfc/plugin/NfcPlugin.java index 588f2a5e..3c3b2f30 100644 --- a/src/android/src/com/chariotsolutions/nfc/plugin/NfcPlugin.java +++ b/src/android/src/com/chariotsolutions/nfc/plugin/NfcPlugin.java @@ -425,7 +425,10 @@ private void createPendingIntent() { Activity activity = getActivity(); Intent intent = new Intent(activity, activity.getClass()); intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP); - pendingIntent = PendingIntent.getActivity(activity, 0, intent, 0); + pendingIntent = PendingIntent.getActivity( + activity, 0, intent, + android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.S ? PendingIntent.FLAG_MUTABLE : 0 + ); } } From 9f2edab130c8a31855a8b5d61bda88b0fdbd8f40 Mon Sep 17 00:00:00 2001 From: Souleymane DIALLO Date: Fri, 17 May 2024 10:48:41 +0200 Subject: [PATCH 5/5] Revert "fix: fix requires FLAG_MUTABLE when creating a PendingIntent" This reverts commit a7fa359b23a8eca06adbad5d64bf1808092c3d27. --- .../src/com/chariotsolutions/nfc/plugin/NfcPlugin.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/android/src/com/chariotsolutions/nfc/plugin/NfcPlugin.java b/src/android/src/com/chariotsolutions/nfc/plugin/NfcPlugin.java index 3c3b2f30..588f2a5e 100644 --- a/src/android/src/com/chariotsolutions/nfc/plugin/NfcPlugin.java +++ b/src/android/src/com/chariotsolutions/nfc/plugin/NfcPlugin.java @@ -425,10 +425,7 @@ private void createPendingIntent() { Activity activity = getActivity(); Intent intent = new Intent(activity, activity.getClass()); intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP); - pendingIntent = PendingIntent.getActivity( - activity, 0, intent, - android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.S ? PendingIntent.FLAG_MUTABLE : 0 - ); + pendingIntent = PendingIntent.getActivity(activity, 0, intent, 0); } }