From: Jaehong Jo Date: Thu, 10 Dec 2015 07:03:25 +0000 (+0900) Subject: Fixed EDR problem related to BT on/off for Android. X-Git-Tag: 1.2.0+RC1~697 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=496109dc5edc7d0baeb9193acb782b5176a5d30a;p=platform%2Fupstream%2Fiotivity.git Fixed EDR problem related to BT on/off for Android. When BT turn off, call Stop EDR Server, and when BT turn on, call Start EDR Server. Change-Id: Ife12956568fd631140209472912d3e0fef62f13d Signed-off-by: Jaehong Jo Reviewed-on: https://gerrit.iotivity.org/gerrit/4487 Tested-by: jenkins-iotivity Reviewed-by: jihwan seo Reviewed-by: Jon A. Cruz --- diff --git a/resource/csdk/connectivity/src/bt_edr_adapter/android/caedrnwmonitor.c b/resource/csdk/connectivity/src/bt_edr_adapter/android/caedrnwmonitor.c index 37c5a11..de187d8 100644 --- a/resource/csdk/connectivity/src/bt_edr_adapter/android/caedrnwmonitor.c +++ b/resource/csdk/connectivity/src/bt_edr_adapter/android/caedrnwmonitor.c @@ -127,7 +127,7 @@ Java_org_iotivity_ca_CaEdrInterface_caEdrStateChangedCallback(JNIEnv *env, jobje if (NULL == g_networkChangeCb) { - OIC_LOG(DEBUG, TAG, "gNetworkChangeCb is null"); + OIC_LOG(DEBUG, TAG, "g_networkChangeCb is null"); return; } @@ -158,14 +158,23 @@ Java_org_iotivity_ca_CaEdrInterface_caEdrStateChangedCallback(JNIEnv *env, jobje if (state_on == status) { CANetworkStatus_t newStatus = CA_INTERFACE_UP; + + CAResult_t res = CAEDRStartUnicastServer(false); + if (CA_STATUS_OK != res) + { + OIC_LOG(ERROR, TAG, "CAEDRStartUnicastServer failed"); + return; + } CAEDRServerStartAcceptThread(); g_networkChangeCb(newStatus); } else if (state_off == status) { CANetworkStatus_t newStatus = CA_INTERFACE_DOWN; + CAEDRServerStop(); + CAEDRNativeSocketCloseToAll(env); + CAEDRNativeRemoveAllDeviceState(); CAEDRNativeRemoveAllDeviceSocket(env); - CAEDRNativeRemoveAllDeviceState(env); g_networkChangeCb(newStatus); } } diff --git a/resource/csdk/connectivity/src/bt_edr_adapter/android/caedrserver.c b/resource/csdk/connectivity/src/bt_edr_adapter/android/caedrserver.c index 8bac747..a330d40 100644 --- a/resource/csdk/connectivity/src/bt_edr_adapter/android/caedrserver.c +++ b/resource/csdk/connectivity/src/bt_edr_adapter/android/caedrserver.c @@ -154,6 +154,10 @@ static void CAReceiveHandler(void *data) CAAdapterReceiveThreadContext_t *ctx = (CAAdapterReceiveThreadContext_t *) data; + ca_mutex_lock(g_mutexUnicastServer); + g_stopUnicast = false; + ca_mutex_unlock(g_mutexUnicastServer); + while (true != *(ctx->stopFlag)) { // if new socket object is added in socket list after below logic is ran. @@ -706,6 +710,7 @@ CAResult_t CAEDRNativeReadData(JNIEnv *env, uint32_t id, CAAdapterServerType_t t // remove socket to list CAEDRNativeRemoveDeviceSocket(env, jni_obj_socket); + CAEDRNativeRemoveDevice(address); (*env)->ReleaseStringUTFChars(env, jni_str_address, address); (*env)->DeleteLocalRef(env, jni_str_address); @@ -718,7 +723,6 @@ CAResult_t CAEDRNativeReadData(JNIEnv *env, uint32_t id, CAAdapterServerType_t t if (!jni_cid_BTsocket) { (*env)->DeleteLocalRef(env, jni_str_address); - OIC_LOG(ERROR, TAG, "[EDR][Native] btReadData: jni_cid_BTsocket is null"); return CA_STATUS_FAILED; }