From 0571ce53451baf7d363703b6e3ac10bc885fc5bc Mon Sep 17 00:00:00 2001 From: Nick Pelly Date: Mon, 14 Nov 2011 14:28:40 -0800 Subject: Add null check to aovid NPE on un-matched close(). Also finish removing NFCEE permission, and fix a couple of style mistakes. Change-Id: I4ec22469990de6661365c281db2e8cfd7ae413b0 --- src/com/android/nfc/NfcService.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/com/android') diff --git a/src/com/android/nfc/NfcService.java b/src/com/android/nfc/NfcService.java index 58a5732..7c1a8e6 100755 --- a/src/com/android/nfc/NfcService.java +++ b/src/com/android/nfc/NfcService.java @@ -1088,7 +1088,7 @@ public class NfcService extends Application implements DeviceHostListener { //TODO: This is incorrect behavior - the close should interrupt pending // operations. However this is not supported by current hardware. - synchronized(NfcService.this) { + synchronized (NfcService.this) { if (!isNfcEnabled()) { throw new IOException("NFC adapter is disabled"); } @@ -1168,7 +1168,11 @@ public class NfcService extends Application implements DeviceHostListener { public Bundle close(String pkg, IBinder b) throws RemoteException { NfcService.this.enforceNfceeAdminPerm(pkg); - b.unlinkToDeath(mOpenEe, 0); + synchronized (this) { + if (mOpenEe != null) { + b.unlinkToDeath(mOpenEe, 0); + } + } Bundle result; try { @@ -1201,7 +1205,7 @@ public class NfcService extends Application implements DeviceHostListener { if (!isNfcEnabled()) { throw new IOException("NFC is not enabled"); } - if (mOpenEe == null){ + if (mOpenEe == null) { throw new IOException("NFC EE is not open"); } if (getCallingPid() != mOpenEe.pid) { -- cgit v1.1