Fix peer-to-peer server register error if RF discovery is started.
If RF discovery is started, discovery should be temporarily stopped before deregister peer-to-peer server
Change-Id: I42c826454f050e09b3d673b89560a8c7bed728d7
diff --git a/nci/jni/NativeNfcManager.cpp b/nci/jni/NativeNfcManager.cpp
index 36e89c0..0e9252a 100755
--- a/nci/jni/NativeNfcManager.cpp
+++ b/nci/jni/NativeNfcManager.cpp
@@ -95,6 +95,7 @@
void doStartupConfig ();
void startStopPolling (bool isStartPolling);
void startRfDiscovery (bool isStart);
+ bool isDiscoveryStarted ();
}
@@ -1727,6 +1728,21 @@
/*******************************************************************************
**
+** Function: isDiscoveryStarted
+**
+** Description: Indicates whether the discovery is started.
+**
+** Returns: True if discovery is started
+**
+*******************************************************************************/
+bool isDiscoveryStarted ()
+{
+ return sRfEnabled;
+}
+
+
+/*******************************************************************************
+**
** Function: doStartupConfig
**
** Description: Configure the NFC controller.
diff --git a/nci/jni/PeerToPeer.cpp b/nci/jni/PeerToPeer.cpp
index 17d252c..da4cf30 100644
--- a/nci/jni/PeerToPeer.cpp
+++ b/nci/jni/PeerToPeer.cpp
@@ -40,6 +40,8 @@
{
extern void nativeNfcTag_registerNdefTypeHandler ();
extern void nativeNfcTag_deregisterNdefTypeHandler ();
+ extern void startRfDiscovery (bool isStart);
+ extern bool isDiscoveryStarted ();
}
@@ -475,6 +477,7 @@
ALOGD ("%s: enter; JNI handle: %u", fn, jniHandle);
tNFA_STATUS nfaStat = NFA_STATUS_FAILED;
sp<P2pServer> pSrv = NULL;
+ bool isPollingTempStopped = false;
mMutex.lock();
if ((pSrv = findServerLocked (jniHandle)) == NULL)
@@ -484,6 +487,11 @@
return (false);
}
mMutex.unlock();
+ if (isDiscoveryStarted ())
+ {
+ isPollingTempStopped = true;
+ startRfDiscovery (false);
+ }
{
// Server does not call NFA_P2pDisconnect(), so unblock the accept()
@@ -499,6 +507,11 @@
removeServer (jniHandle);
+ if (isPollingTempStopped)
+ {
+ startRfDiscovery (true);
+ }
+
ALOGD ("%s: exit", fn);
return true;
}