summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--jni/com_android_nfc_NativeP2pDevice.cpp6
-rwxr-xr-xsrc/com/android/nfc/NfcService.java4
2 files changed, 7 insertions, 3 deletions
diff --git a/jni/com_android_nfc_NativeP2pDevice.cpp b/jni/com_android_nfc_NativeP2pDevice.cpp
index fc2692b..fd9af3e 100644
--- a/jni/com_android_nfc_NativeP2pDevice.cpp
+++ b/jni/com_android_nfc_NativeP2pDevice.cpp
@@ -145,7 +145,6 @@ static jboolean com_android_nfc_NativeP2pDevice_doConnect(JNIEnv *e, jobject o)
if(status != NFCSTATUS_PENDING)
{
LOGE("phLibNfc_RemoteDev_Connect(P2P) returned 0x%04x[%s]", status, nfc_jni_get_status_name(status));
- nfc_jni_restart_discovery_locked(nfc_jni_get_nat_ext(e));
goto clean_and_return;
}
TRACE("phLibNfc_RemoteDev_Connect(P2P) returned 0x%04x[%s]", status, nfc_jni_get_status_name(status));
@@ -185,6 +184,11 @@ static jboolean com_android_nfc_NativeP2pDevice_doConnect(JNIEnv *e, jobject o)
result = JNI_TRUE;
clean_and_return:
+ if (result != JNI_TRUE)
+ {
+ /* Restart the polling loop if the connection failed */
+ nfc_jni_restart_discovery_locked(nfc_jni_get_nat_ext(e));
+ }
nfc_cb_data_deinit(&cb_data);
CONCURRENCY_UNLOCK();
return result;
diff --git a/src/com/android/nfc/NfcService.java b/src/com/android/nfc/NfcService.java
index 9dd8436..d91c41c 100755
--- a/src/com/android/nfc/NfcService.java
+++ b/src/com/android/nfc/NfcService.java
@@ -2377,8 +2377,8 @@ public class NfcService extends Application {
device.doDisconnect();
}
} else {
- if (DBG) Log.d(TAG, "Cannot connect remote Target. Restart polling loop.");
- device.doDisconnect();
+ if (DBG) Log.d(TAG, "Cannot connect remote Target. Polling loop restarted...");
+ /* The polling loop should have been restarted in failing doConnect */
}
} else if (device.getMode() == NativeP2pDevice.MODE_P2P_INITIATOR) {