Merge "Set a configurable flag for tag dispatch failed toast"
diff --git a/res/values/config.xml b/res/values/config.xml
index f5585dd..c5354c2 100644
--- a/res/values/config.xml
+++ b/res/values/config.xml
@@ -3,6 +3,7 @@
     <string name="bluetooth_package" translatable="false">com.android.bluetooth</string>
     <bool name="enable_nfc_url_open_dialog">false</bool>
     <bool name="enable_auto_play">true</bool>
+    <bool name="enable_notify_dispatch_failed">false</bool>
 
     <!-- List of SKUs where Secure NFC functionality is supported -->
     <string-array name="config_skuSupportsSecureNfc" translatable="false" />
diff --git a/src/com/android/nfc/NfcService.java b/src/com/android/nfc/NfcService.java
index 601e867..c5026b0 100644
--- a/src/com/android/nfc/NfcService.java
+++ b/src/com/android/nfc/NfcService.java
@@ -2676,7 +2676,8 @@
                 int dispatchResult = mNfcDispatcher.dispatchTag(tag);
                 if (dispatchResult == NfcDispatcher.DISPATCH_FAIL && !mInProvisionMode) {
                     unregisterObject(tagEndpoint.getHandle());
-                    if (mScreenState == ScreenStateHelper.SCREEN_STATE_ON_UNLOCKED) {
+                    if (mScreenState == ScreenStateHelper.SCREEN_STATE_ON_UNLOCKED &&
+                        mContext.getResources().getBoolean(R.bool.enable_notify_dispatch_failed)) {
                         if (mToast != null) {
                             if (mToast.getView().isShown()) mToast.cancel();
                         }