summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnaud Ferir <arnaud.ferir@trusted-logic.com>2011-01-19 19:10:00 +0100
committerJeff Hamilton <jham@android.com>2011-01-24 12:07:59 -0600
commit7f5487be0414b1f92b41cc5f7b0b7db846d9b1c9 (patch)
tree8fae2471697700b04a4f466e375c840d407794d2
parent2436ffe91853535fad87b7a8e03d8883bae20f20 (diff)
downloadpackages_apps_nfc-7f5487be0414b1f92b41cc5f7b0b7db846d9b1c9.zip
packages_apps_nfc-7f5487be0414b1f92b41cc5f7b0b7db846d9b1c9.tar.gz
packages_apps_nfc-7f5487be0414b1f92b41cc5f7b0b7db846d9b1c9.tar.bz2
Do not disconnect P2P target if connect failed.
If the P2P target connect failed, the P2P target disconnect cannot be done. However the polling loop must be restarted. This is already done in JNI layer by the failing connect itself. Change-Id: I1c3323e4c038c8133e7b6e16b3a238c050427cfc
-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) {