Verify setForegroundDispatch caller is in foreground.
Bug: 28300969
Change-Id: Icadfe70cd06f921badd266e7a4efbae15a8c206a
diff --git a/src/com/android/nfc/NfcService.java b/src/com/android/nfc/NfcService.java
index b822afe..d62ec03 100755
--- a/src/com/android/nfc/NfcService.java
+++ b/src/com/android/nfc/NfcService.java
@@ -805,7 +805,10 @@
public void setForegroundDispatch(PendingIntent intent,
IntentFilter[] filters, TechListParcel techListsParcel) {
NfcPermissions.enforceUserPermissions(mContext);
-
+ if (!mForegroundUtils.isInForeground(Binder.getCallingUid())) {
+ Log.e(TAG, "setForegroundDispatch: Caller not in foreground.");
+ return;
+ }
// Short-cut the disable path
if (intent == null && filters == null && techListsParcel == null) {
mNfcDispatcher.setForegroundDispatch(null, null, null);
@@ -935,6 +938,10 @@
@Override
public void setReaderMode(IBinder binder, IAppCallback callback, int flags, Bundle extras)
throws RemoteException {
+ if (!mForegroundUtils.isInForeground(Binder.getCallingUid())) {
+ Log.e(TAG, "setReaderMode: Caller not in foreground.");
+ return;
+ }
synchronized (NfcService.this) {
if (!isNfcEnabled()) {
Log.e(TAG, "setReaderMode() called while NFC is not enabled.");