From ee22baf23dfb71e49945f25c1e4853eef456bb5f Mon Sep 17 00:00:00 2001 From: Jimmy Huang Date: Thu, 11 Dec 2014 11:52:22 -0800 Subject: [PATCH] Fix TC-2051 - Prevents further PBAP transfers The current phoned never close the obex session for pbap sync for call history and contacts, this prevents other clients like syncevolution to start another obex session. This patch will end each session after sync is completed, and will re-create another session when sync is needed, trade off is a little impact on performance. Change-Id: Ie9076dd2ca6f01d0502057217ce129b8e0f38433 Signed-off-by: Jimmy Huang --- packaging/phoned.changes | 3 +++ src/obex.cpp | 43 ++++++++++++++++++++++++------------------- src/phone.cpp | 9 +++++---- 3 files changed, 32 insertions(+), 23 deletions(-) diff --git a/packaging/phoned.changes b/packaging/phoned.changes index d509129..be6a7cc 100644 --- a/packaging/phoned.changes +++ b/packaging/phoned.changes @@ -1,3 +1,6 @@ +* Thu Dec 11 2014 Jimmy Huang accepted/tizen/ivi/20141024.005038-6-g4096c04 +- Fix TC-2051 - Prevents further PBAP transfers + * Wed Oct 29 2014 Jimmy Huang accepted/tizen/ivi/20141024.005038-5-g1cd9a0c - Fixed bug where ModemRemoved signal never handled diff --git a/src/obex.cpp b/src/obex.cpp index b1755b1..3b1dbac 100644 --- a/src/obex.cpp +++ b/src/obex.cpp @@ -167,27 +167,32 @@ void Obex::removeSession(bool notify) { LoggerD("Removing session:" << mSession); - // delete/unref individual contacts - for(auto it=mContacts.begin(); it!=mContacts.end(); ++it) { - EContact *contact = (*it).second; - if(contact) { - // TODO: delete also all its attribs? - g_object_unref(contact); + // Changing the behavior of removeSession so that when notify is set to false, + // we will only close the obex session without destroying cached data, this + // unblocks other clients when accessing obex. + if (notify) { + // delete/unref individual contacts + for(auto it=mContacts.begin(); it!=mContacts.end(); ++it) { + EContact *contact = (*it).second; + if(contact) { + // TODO: delete also all its attribs? + g_object_unref(contact); + } } - } - mContacts.clear(); - mContactsOrder.clear(); - - // delete/unref individual cll history entries - for(auto it=mCallHistory.begin(); it!=mCallHistory.end(); ++it) { - EContact *item = (*it).second; - if(item) { - // TODO: delete also all its attribs? - g_object_unref(item); + mContacts.clear(); + mContactsOrder.clear(); + + // delete/unref individual call history entries + for(auto it=mCallHistory.begin(); it!=mCallHistory.end(); ++it) { + EContact *item = (*it).second; + if(item) { + // TODO: delete also all its attribs? + g_object_unref(item); + } } + mCallHistory.clear(); + mCallHistoryOrder.clear(); } - mCallHistory.clear(); - mCallHistoryOrder.clear(); GError *err = NULL; g_dbus_connection_call_sync( g_bus_get_sync(G_BUS_TYPE_SESSION, NULL, NULL), @@ -828,7 +833,7 @@ void Obex::handleSignal(GDBusConnection *connection, { char *status_str=0; g_variant_get(var, "s", &status_str); - //LoggerD("Status is: " << status_str); + LoggerD("Status is: " << status_str); if(!strcmp(status_str, "complete")) { diff --git a/src/phone.cpp b/src/phone.cpp index b4003a0..6850c26 100644 --- a/src/phone.cpp +++ b/src/phone.cpp @@ -474,6 +474,9 @@ void Phone::callHistoryChanged() { void Phone::pbSynchronizationDone() { LoggerD("PB synchronization DONE"); mPBSynchronized = true; + // remove session after sync is done to prevent blocking other clients + // each sync will now require calling createSession() instead + removeSession(false); } void Phone::handleMethodCall( GDBusConnection *connection, @@ -527,8 +530,7 @@ void Phone::handleMethodCall( GDBusConnection *connection, } else { // the synchronization may be already on-going, but request it anyway - /*Obex::Error err = */phone->syncContacts(); - /*Obex::Error err = */phone->syncCallHistory(); + phone->createSession(phone->mWantedRemoteDevice.c_str()); } } else { @@ -653,8 +655,7 @@ void Phone::handleMethodCall( GDBusConnection *connection, } else if(!strcmp(method_name, "Synchronize")) { LoggerD("Synchronizing data with the phone"); - /*Obex::Error err = */phone->syncContacts(); - /*Obex::Error err = */phone->syncCallHistory(); + phone->createSession(phone->mWantedRemoteDevice.c_str()); g_dbus_method_invocation_return_value(invocation, NULL); } else if(!strcmp(method_name, "GetContacts")) { -- 2.7.4