diff options
author | Martijn Coenen <maco@google.com> | 2013-04-24 09:59:47 -0700 |
---|---|---|
committer | Martijn Coenen <maco@google.com> | 2013-04-24 18:23:00 -0700 |
commit | 7a499e775021bafefbe890d079e2a43f4a54482c (patch) | |
tree | 1c48ea651a28be836ecffe040da808b7706f1dd1 | |
parent | 3e38dca2bc7c7629d7159663d597a1e886d85527 (diff) | |
download | android_packages_apps_Nfc-7a499e775021bafefbe890d079e2a43f4a54482c.tar.gz android_packages_apps_Nfc-7a499e775021bafefbe890d079e2a43f4a54482c.tar.bz2 android_packages_apps_Nfc-7a499e775021bafefbe890d079e2a43f4a54482c.zip |
Avoid P2P/SMX race conditions in NXP stack.
Google Wallet can trigger off field P2P field events
and initiate communication with the SMX. The NXP stack
appears to contain some tricky race conditions around
opening/closing the SMX close to P2P interactions. For now,
do not allow NFCEE access while a P2P link is still active.
Bug: 8552749
Change-Id: I7acae39bc22cebb5d79a484990dcd3fc5f3dad23
-rwxr-xr-x | src/com/android/nfc/NfcService.java | 10 | ||||
-rwxr-xr-x | src/com/android/nfc/P2pLinkManager.java | 10 |
2 files changed, 20 insertions, 0 deletions
diff --git a/src/com/android/nfc/NfcService.java b/src/com/android/nfc/NfcService.java index dc01eafd..306b7066 100755 --- a/src/com/android/nfc/NfcService.java +++ b/src/com/android/nfc/NfcService.java @@ -1392,6 +1392,16 @@ public class NfcService implements DeviceHostListener { if (!isNfcEnabled()) { return EE_ERROR_NFC_DISABLED; } + if (mInProvisionMode) { + // Deny access to the NFCEE as long as the device is being setup + return EE_ERROR_IO; + } + if (mDeviceHost.enablePN544Quirks() && mP2pLinkManager.isLlcpActive()) { + // Don't allow PN544-based devices to open the SE while the LLCP + // link is still up or in a debounce state. This avoids race + // conditions in the NXP stack around P2P/SMX switching. + return EE_ERROR_EXT_FIELD; + } if (mOpenEe != null) { return EE_ERROR_ALREADY_OPEN; } diff --git a/src/com/android/nfc/P2pLinkManager.java b/src/com/android/nfc/P2pLinkManager.java index 4205c7af..29afe95e 100755 --- a/src/com/android/nfc/P2pLinkManager.java +++ b/src/com/android/nfc/P2pLinkManager.java @@ -265,6 +265,16 @@ public class P2pLinkManager implements Handler.Callback, P2pEventListener.Callba } /** + * May be called from any thread. + * @return whether the LLCP link is in an active or debounce state + */ + public boolean isLlcpActive() { + synchronized (this) { + return mLinkState != LINK_STATE_DOWN; + } + } + + /** * Set NDEF callback for sending. * May be called from any thread. * NDEF callbacks may be set at any time (even if NFC is |