Merge "Broadcast LLCP events in debug builds." into jb-mr2-dev
diff --git a/src/com/android/nfc/NfcService.java b/src/com/android/nfc/NfcService.java
index f6ca3b5..6ed07fd 100755
--- a/src/com/android/nfc/NfcService.java
+++ b/src/com/android/nfc/NfcService.java
@@ -56,6 +56,7 @@
 import android.nfc.tech.TagTechnology;
 import android.os.AsyncTask;
 import android.os.Binder;
+import android.os.Build;
 import android.os.Bundle;
 import android.os.Handler;
 import android.os.IBinder;
@@ -175,6 +176,12 @@
         "com.android.nfc_extras.action.AID_SELECTED";
     public static final String EXTRA_AID = "com.android.nfc_extras.extra.AID";
 
+    public static final String ACTION_LLCP_UP =
+            "com.android.nfc.action.LLCP_UP";
+
+    public static final String ACTION_LLCP_DOWN =
+            "com.android.nfc.action.LLCP_DOWN";
+
     public static final String ACTION_APDU_RECEIVED =
         "com.android.nfc_extras.action.APDU_RECEIVED";
     public static final String EXTRA_APDU_BYTES =
@@ -237,6 +244,7 @@
     NfcAdapterExtrasService mExtrasService;
     boolean mIsAirplaneSensitive;
     boolean mIsAirplaneToggleable;
+    boolean mIsDebugBuild;
     NfceeAccessControl mNfceeAccessControl;
 
     private NfcDispatcher mNfcDispatcher;
@@ -394,6 +402,8 @@
         mState = NfcAdapter.STATE_OFF;
         mIsNdefPushEnabled = mPrefs.getBoolean(PREF_NDEF_PUSH_ON, NDEF_PUSH_ON_DEFAULT);
 
+        mIsDebugBuild = "userdebug".equals(Build.TYPE) || "eng".equals(Build.TYPE);
+
         mPowerManager = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE);
 
         mRoutingWakeLock = mPowerManager.newWakeLock(
@@ -1884,10 +1894,18 @@
                     break;
 
                 case MSG_LLCP_LINK_ACTIVATION:
+                    if (mIsDebugBuild) {
+                        Intent actIntent = new Intent(ACTION_LLCP_UP);
+                        mContext.sendBroadcast(actIntent);
+                    }
                     llcpActivated((NfcDepEndpoint) msg.obj);
                     break;
 
                 case MSG_LLCP_LINK_DEACTIVATED:
+                    if (mIsDebugBuild) {
+                        Intent deactIntent = new Intent(ACTION_LLCP_DOWN);
+                        mContext.sendBroadcast(deactIntent);
+                    }
                     NfcDepEndpoint device = (NfcDepEndpoint) msg.obj;
                     boolean needsDisconnect = false;