Don't IPC for every onPause() in NfcActivityManager.

The NfcService now contains additional code to make sure
that the registered NDEF callback corresponds to the package
running in the foreground. This allows us to stop calling
the NfcService on every onPause() to register the NDEF callback,
as NfcService itself will now detect that the app is no longer
in the foreground, and won't call the callback.

Bug: 5199662
Change-Id: Ibd0d21f8c7b76346238305a6684967263cb7d7e0
diff --git a/core/java/android/nfc/NfcActivityManager.java b/core/java/android/nfc/NfcActivityManager.java
index 53b41d5..7c3123f 100644
--- a/core/java/android/nfc/NfcActivityManager.java
+++ b/core/java/android/nfc/NfcActivityManager.java
@@ -197,7 +197,7 @@
             isResumed = state.resumed;
         }
         if (isResumed) {
-            requestNfcServiceCallback(true);
+            requestNfcServiceCallback();
         }
     }
 
@@ -211,7 +211,7 @@
             isResumed = state.resumed;
         }
         if (isResumed) {
-            requestNfcServiceCallback(true);
+            requestNfcServiceCallback();
         }
     }
 
@@ -223,7 +223,7 @@
             isResumed = state.resumed;
         }
         if (isResumed) {
-            requestNfcServiceCallback(true);
+            requestNfcServiceCallback();
         }
     }
 
@@ -236,7 +236,7 @@
             isResumed = state.resumed;
         }
         if (isResumed) {
-            requestNfcServiceCallback(true);
+            requestNfcServiceCallback();
         }
     }
 
@@ -249,18 +249,17 @@
             isResumed = state.resumed;
         }
         if (isResumed) {
-            requestNfcServiceCallback(true);
+            requestNfcServiceCallback();
         }
     }
 
     /**
      * Request or unrequest NFC service callbacks for NDEF push.
      * Makes IPC call - do not hold lock.
-     * TODO: Do not do IPC on every onPause/onResume
      */
-    void requestNfcServiceCallback(boolean request) {
+    void requestNfcServiceCallback() {
         try {
-            NfcAdapter.sService.setNdefPushCallback(request ? this : null);
+            NfcAdapter.sService.setNdefPushCallback(this);
         } catch (RemoteException e) {
             mAdapter.attemptDeadServiceRecovery(e);
         }
@@ -355,7 +354,7 @@
             if (state == null) return;
             state.resumed = true;
         }
-        requestNfcServiceCallback(true);
+        requestNfcServiceCallback();
     }
 
     /** Callback from Activity life-cycle, on main thread */
@@ -367,7 +366,6 @@
             if (state == null) return;
             state.resumed = false;
         }
-        requestNfcServiceCallback(false);
     }
 
     /** Callback from Activity life-cycle, on main thread */