am 91e47177: Reconcile with jb-release

* commit '91e471772f1acb4786d95c08f1d296ff8ffe2efb':
diff --git a/src/com/android/nfc/P2pEventManager.java b/src/com/android/nfc/P2pEventManager.java
index c024afc..68f479b 100644
--- a/src/com/android/nfc/P2pEventManager.java
+++ b/src/com/android/nfc/P2pEventManager.java
@@ -51,7 +51,16 @@
                 Context.NOTIFICATION_SERVICE);
 
         mSending = false;
-        mSendUi = new SendUi(context, this);
+        final int uiModeType = mContext.getResources().getConfiguration().uiMode
+                & Configuration.UI_MODE_TYPE_MASK;
+        if (uiModeType == Configuration.UI_MODE_TYPE_APPLIANCE) {
+            // "Appliances" don't intrinsically have a way of confirming this, so we
+            // don't use the UI and just autoconfirm where necessary.
+            // Don't instantiate SendUi or else we'll use memory and never reclaim it.
+            mSendUi = null;
+        } else {
+            mSendUi = new SendUi(context, this);
+        }
     }
 
     @Override
@@ -61,19 +70,17 @@
         mNdefReceived = false;
 
         mVibrator.vibrate(VIBRATION_PATTERN, -1);
-        mSendUi.takeScreenshot();
+        if (mSendUi != null) {
+            mSendUi.takeScreenshot();
+        }
     }
 
     @Override
     public void onP2pSendConfirmationRequested() {
-        final int uiModeType = mContext.getResources().getConfiguration().uiMode
-                & Configuration.UI_MODE_TYPE_MASK;
-        if (uiModeType == Configuration.UI_MODE_TYPE_APPLIANCE) {
-            // "Appliances" don't intrinsically have a way of confirming this, so we
-            // will just auto-confirm.
-            mCallback.onP2pSendConfirmed();
-        } else {
+        if (mSendUi != null) {
             mSendUi.showPreSend();
+        } else {
+            mCallback.onP2pSendConfirmed();
         }
     }
 
@@ -81,7 +88,9 @@
     public void onP2pSendComplete() {
         mNfcService.playSound(NfcService.SOUND_END);
         mVibrator.vibrate(VIBRATION_PATTERN, -1);
-        mSendUi.finish(SendUi.FINISH_SEND_SUCCESS);
+        if (mSendUi != null) {
+            mSendUi.finish(SendUi.FINISH_SEND_SUCCESS);
+        }
         mSending = false;
         mNdefSent = true;
     }
@@ -100,14 +109,16 @@
     public void onP2pReceiveComplete(boolean playSound) {
         mVibrator.vibrate(VIBRATION_PATTERN, -1);
         if (playSound) mNfcService.playSound(NfcService.SOUND_END);
-        // TODO we still don't have a nice receive solution
-        // The sanest solution right now is just to scale back up what we had
-        // and start the new activity. It is not perfect, but at least it is
-        // consistent behavior. All other variants involve making the old
-        // activity screenshot disappear, and then removing the animation
-        // window hoping the new activity has started by then. This just goes
-        // wrong too often and can look weird.
-        mSendUi.finish(SendUi.FINISH_SCALE_UP);
+        if (mSendUi != null) {
+            // TODO we still don't have a nice receive solution
+            // The sanest solution right now is just to scale back up what we had
+            // and start the new activity. It is not perfect, but at least it is
+            // consistent behavior. All other variants involve making the old
+            // activity screenshot disappear, and then removing the animation
+            // window hoping the new activity has started by then. This just goes
+            // wrong too often and can look weird.
+            mSendUi.finish(SendUi.FINISH_SCALE_UP);
+        }
         mNdefReceived = true;
     }
 
@@ -117,7 +128,7 @@
             mNfcService.playSound(NfcService.SOUND_ERROR);
             mSending = false;
         }
-        if (!mNdefSent && !mNdefReceived) {
+        if (!mNdefSent && !mNdefReceived && mSendUi != null) {
             mSendUi.finish(SendUi.FINISH_SCALE_UP);
         }
     }
@@ -125,7 +136,9 @@
     @Override
     public void onSendConfirmed() {
         if (!mSending) {
-            mSendUi.showStartSend();
+            if (mSendUi != null) {
+                mSendUi.showStartSend();
+            }
             mCallback.onP2pSendConfirmed();
         }
         mSending = true;