From c415d195de2036d35e354fcf94cb0a53eb1eef3c Mon Sep 17 00:00:00 2001 From: "taekeun.kang" Date: Wed, 30 Nov 2016 16:47:02 +0900 Subject: [PATCH 01/16] [Common] fix bug in tools.cc - missing '}' Change-Id: I493872f648b6adab262deb826034cad19a277f07 Signed-off-by: taekeun.kang --- src/common/tools.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/src/common/tools.cc b/src/common/tools.cc index d961c50..21f5064 100644 --- a/src/common/tools.cc +++ b/src/common/tools.cc @@ -150,6 +150,7 @@ class AccessControlImpl { LoggerD("Enter"); return true; + } }; #elif PRIVILEGE_USE_CYNARA -- 2.7.4 From e028ded95c6dbf43fca09ed8c52177c6770b7a43 Mon Sep 17 00:00:00 2001 From: "jk.pu" Date: Wed, 30 Nov 2016 17:37:39 +0900 Subject: [PATCH 02/16] [version] 1.53 Change-Id: I5000310f64d0911926fd8659157ed6914e81d3de Signed-off-by: jk.pu --- packaging/webapi-plugins.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/webapi-plugins.spec b/packaging/webapi-plugins.spec index 361b04c..ae2935a 100644 --- a/packaging/webapi-plugins.spec +++ b/packaging/webapi-plugins.spec @@ -10,7 +10,7 @@ %define crosswalk_extensions_path %{_libdir}/%{crosswalk_extensions} Name: webapi-plugins -Version: 1.52 +Version: 1.53 Release: 0 License: Apache-2.0 and BSD-3-Clause and MIT Group: Development/Libraries -- 2.7.4 From e44ca5565b8f6c4b26be05ab5c55413c96ed57f7 Mon Sep 17 00:00:00 2001 From: Lukasz Bardeli Date: Wed, 30 Nov 2016 15:41:29 +0100 Subject: [PATCH 03/16] [Convergance] change call successCallbackin AppCommunicationClientService.disconnect() [Verification] Code compiles without error Change-Id: I8dd051670f0477bdd88fbb2f40ff66b579801e6c Signed-off-by: Lukasz Bardeli --- src/convergence/convergence_api.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/convergence/convergence_api.js b/src/convergence/convergence_api.js index 81718f5..9e362c5 100644 --- a/src/convergence/convergence_api.js +++ b/src/convergence/convergence_api.js @@ -1001,14 +1001,12 @@ AppCommunicationClientService.prototype.connect = function(successCallback, erro { name: 'successCallback', type: types_.FUNCTION, - //values: ConnectSuccessCallback, optional: false, nullable: false }, { name: 'errorCallback', type: types_.FUNCTION, - //values: ErrorCallback, optional: true, nullable: true } @@ -1061,6 +1059,8 @@ AppCommunicationClientService.prototype.disconnect = function(successCallback, e }, function(result) { if (native_.isFailure(result)) { native_.callIfPossible(errorCallback, native_.getErrorObject(result)); + } else { + native_.callIfPossible(successCallback, this); } }); @@ -1069,8 +1069,6 @@ AppCommunicationClientService.prototype.disconnect = function(successCallback, e } else { updateWithInternalData({ connectionState: ConnectionState.NOT_CONNECTED }, this); } - - native_.callIfPossible(successCallback, this); }; function ChannelInfo(uri_, id_) { -- 2.7.4 From 506bb2a7f439d7693a2fd3fd1061ade15d78c300 Mon Sep 17 00:00:00 2001 From: Hyunjin Park Date: Thu, 1 Dec 2016 16:43:02 +0900 Subject: [PATCH 04/16] [convergence] remove warning due to missing return value [verification] no warning is confirmed on log Change-Id: I90317218f07f03798177adca859a299a1561bd74 --- src/convergence/convergence_utils.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/convergence/convergence_utils.cc b/src/convergence/convergence_utils.cc index bfc67b0..bbe9a7c 100644 --- a/src/convergence/convergence_utils.cc +++ b/src/convergence/convergence_utils.cc @@ -95,6 +95,8 @@ common::TizenResult ConvergenceUtils::ConvertConvergenceError(int error) { // return common::InvalidStateError(error); return common::AbortError(error); } + + return common::TizenSuccess(); } } // namespace convergence -- 2.7.4 From dbdfea4552571ab586883fb5645dc16b624015c7 Mon Sep 17 00:00:00 2001 From: "jk.pu" Date: Mon, 5 Dec 2016 18:22:15 +0900 Subject: [PATCH 05/16] [iotcon]add oring connectivity convert for find function Change-Id: I9d90c1d53eda3270f49f9357edc34541ad58ceb1 Signed-off-by: jk.pu --- src/iotcon/iotcon_instance.cc | 6 +++--- src/iotcon/iotcon_utils.cc | 21 +++++++++++++++++++++ src/iotcon/iotcon_utils.h | 1 + 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/src/iotcon/iotcon_instance.cc b/src/iotcon/iotcon_instance.cc index 27e56c3..1166063 100644 --- a/src/iotcon/iotcon_instance.cc +++ b/src/iotcon/iotcon_instance.cc @@ -1267,7 +1267,7 @@ common::TizenResult IotconInstance::ClientFindResource(const picojson::object& a }; CHECK_EXIST(args, kConnectivityType); - iotcon_connectivity_type_e connectivity_type = IotconUtils::ToConnectivityType( + int connectivity_type = IotconUtils::ToConnectivityType2( args.find(kConnectivityType)->second.get()); long long id = GetId(args); @@ -1431,7 +1431,7 @@ common::TizenResult IotconInstance::ClientFindDeviceInfo(const picojson::object& CHECK_EXIST(args, kConnectivityType); std::string con_type = args.find(kConnectivityType)->second.get(); - iotcon_connectivity_type_e con_type_e = IotconUtils::ToConnectivityType(con_type); + int con_type_e = IotconUtils::ToConnectivityType2(con_type); long long id = GetId(args); auto response = [this, id](const common::TizenResult& res, const picojson::value& v) { @@ -1528,7 +1528,7 @@ common::TizenResult IotconInstance::ClientFindPlatformInfo(const picojson::objec CHECK_EXIST(args, kConnectivityType); std::string con_type = args.find(kConnectivityType)->second.get(); - iotcon_connectivity_type_e con_type_e = IotconUtils::ToConnectivityType(con_type); + int con_type_e = IotconUtils::ToConnectivityType2(con_type); long long id = GetId(args); auto response = [this, id](const common::TizenResult& res, const picojson::value& v) { diff --git a/src/iotcon/iotcon_utils.cc b/src/iotcon/iotcon_utils.cc index 311590e..c94661f 100644 --- a/src/iotcon/iotcon_utils.cc +++ b/src/iotcon/iotcon_utils.cc @@ -2078,6 +2078,27 @@ iotcon_connectivity_type_e IotconUtils::ToConnectivityType(const std::string& e) IOTCON_CONNECTIVITY_TYPE_E } +int IotconUtils::ToConnectivityType2(const std::string& connectivity_type) { + ScopeLogger(); + int ret = IOTCON_CONNECTIVITY_ALL; + if (connectivity_type == "IP") { + ret = IOTCON_CONNECTIVITY_IP; + } else if (connectivity_type == "PREFER_UDP") { + ret = IOTCON_CONNECTIVITY_IP|IOTCON_CONNECTIVITY_PREFER_UDP; + } else if (connectivity_type == "PREFER_TCP") { + ret = IOTCON_CONNECTIVITY_IP|IOTCON_CONNECTIVITY_PREFER_TCP; + } else if (connectivity_type == "IPV4_ONLY") { + ret = IOTCON_CONNECTIVITY_IP|IOTCON_CONNECTIVITY_IPV4_ONLY|IOTCON_CONNECTIVITY_PREFER_UDP; + } else if (connectivity_type == "IPV6_ONLY") { + ret = IOTCON_CONNECTIVITY_IP|IOTCON_CONNECTIVITY_IPV6_ONLY|IOTCON_CONNECTIVITY_PREFER_UDP; + } else { + ret = IOTCON_CONNECTIVITY_ALL; + } + + LoggerD("ToConnectivityType2: %s ,%d", connectivity_type.c_str(), ret); + return ret; +} + iotcon_observe_policy_e IotconUtils::ToObservePolicy(const std::string& e) { ScopeLogger(); diff --git a/src/iotcon/iotcon_utils.h b/src/iotcon/iotcon_utils.h index e6a1505..9252e9a 100644 --- a/src/iotcon/iotcon_utils.h +++ b/src/iotcon/iotcon_utils.h @@ -218,6 +218,7 @@ class IotconUtils { static std::string FromResponseResultType(iotcon_response_result_e e); static iotcon_connectivity_type_e ToConnectivityType(const std::string& e); + static int ToConnectivityType2(const std::string& e); static iotcon_observe_policy_e ToObservePolicy(const std::string& e); static iotcon_qos_e ToQos(const std::string& e); static iotcon_response_result_e ToResponseResult(const std::string& e); -- 2.7.4 From 01f1db235be92988e0912a0b810117c856ca3e0d Mon Sep 17 00:00:00 2001 From: Szymon Jastrzebski Date: Mon, 5 Dec 2016 10:24:25 +0100 Subject: [PATCH 06/16] [Bluetooth] Fixed memory leak [Verification] TCT test passed Change-Id: I5f790d94aca1a2767f7d3596afece3759362eeb5 Signed-off-by: Szymon Jastrzebski --- src/bluetooth/bluetooth_adapter.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/src/bluetooth/bluetooth_adapter.cc b/src/bluetooth/bluetooth_adapter.cc index 396211d..dd30661 100755 --- a/src/bluetooth/bluetooth_adapter.cc +++ b/src/bluetooth/bluetooth_adapter.cc @@ -736,6 +736,7 @@ void BluetoothAdapter::SetVisible(const picojson::value& data, picojson::object& } else { *p_ret = LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "app control setVisible failed"); } + free(result); }, t_param); if (err != APP_CONTROL_ERROR_NONE) { -- 2.7.4 From 1e63ac5796ac957c07b6445577b053dca2fb1617 Mon Sep 17 00:00:00 2001 From: Piotr Kosko Date: Thu, 1 Dec 2016 12:19:11 +0100 Subject: [PATCH 07/16] [Convergence] Reporting error while disconnect fails Change-Id: I0c75536ffa79d89f1fd999646256195a5b33000c Signed-off-by: Piotr Kosko --- src/convergence/convergence_api.js | 14 +++++++------- .../convergence_app_communication_service.cc | 19 ++++++++++++++++--- .../convergence_remote_app_control_service.cc | 18 ++++++++++++++++-- 3 files changed, 39 insertions(+), 12 deletions(-) diff --git a/src/convergence/convergence_api.js b/src/convergence/convergence_api.js index 9e362c5..615b81c 100644 --- a/src/convergence/convergence_api.js +++ b/src/convergence/convergence_api.js @@ -421,21 +421,21 @@ RemoteAppControlService.prototype.disconnect = function(successCallback, errorCa throw new WebAPIException(WebAPIException.INVALID_STATE_ERR, 'Service is not connected yet.'); } + var that = this; var result = native_.call('RemoteAppControlService_disconnect', { deviceId: this._deviceId }, function(result) { if (native_.isFailure(result)) { native_.callIfPossible(errorCallback, native_.getErrorObject(result)); + } else { + updateWithInternalData({ connectionState: ConnectionState.NOT_CONNECTED }, that); + native_.callIfPossible(successCallback, that); } }); if (native_.isFailure(result)) { throw native_.getErrorObject(result); - } else { - updateWithInternalData({ connectionState: ConnectionState.NOT_CONNECTED }, this); } - - native_.callIfPossible(successCallback, this); }; RemoteAppControlService.prototype.start = function() { @@ -1054,20 +1054,20 @@ AppCommunicationClientService.prototype.disconnect = function(successCallback, e if (this.connectionState != ConnectionState.CONNECTED) throw new WebAPIException(WebAPIException.INVALID_STATE_ERR, 'Service is not connected yet.'); + var that = this; var result = native_.call('AppCommunicationClientService_disconnect', { deviceId: this._deviceId }, function(result) { if (native_.isFailure(result)) { native_.callIfPossible(errorCallback, native_.getErrorObject(result)); } else { - native_.callIfPossible(successCallback, this); + updateWithInternalData({ connectionState: ConnectionState.NOT_CONNECTED }, that); + native_.callIfPossible(successCallback, that); } }); if (native_.isFailure(result)) { throw native_.getErrorObject(result); - } else { - updateWithInternalData({ connectionState: ConnectionState.NOT_CONNECTED }, this); } }; diff --git a/src/convergence/convergence_app_communication_service.cc b/src/convergence/convergence_app_communication_service.cc index 42ce200..4272e4e 100644 --- a/src/convergence/convergence_app_communication_service.cc +++ b/src/convergence/convergence_app_communication_service.cc @@ -467,14 +467,27 @@ common::TizenResult ConvergenceAppCommunicationClientService::Disconnect() { if (!service) return LogAndCreateTizenError(AbortError, "Service is NULL"); - const int error = conv_service_disconnect(service); + int error = conv_service_disconnect(service); if (CONV_ERROR_NONE != error) { - // TODO: Handle error trace_conv_error(error, __LINE__, "conv_service_disconnect"); return LogAndCreateTizenError(AbortError, "conv_service_disconnect [fail]"); } - return TizenSuccess(); + conv_service_connection_state_e state = CONV_SERVICE_CONNECTION_STATE_NONE; + error = conv_service_get_connection_state(service, &state); + if (CONV_ERROR_NONE != error) { + LoggerE("Error gathering state [%d] : %s", error, get_error_message(error)); + return LogAndCreateTizenError(AbortError, "Error gathering state"); + } else { + LoggerD("state: %d" , state); + + } + if (CONV_SERVICE_CONNECTION_STATE_NOT_CONNECTED == state) { + return TizenSuccess(); + } else { + LoggerE("Service is still connected, reporting error"); + return LogAndCreateTizenError(AbortError, "Disconnecting failed."); + } } diff --git a/src/convergence/convergence_remote_app_control_service.cc b/src/convergence/convergence_remote_app_control_service.cc index 201b26d..bd9612b 100644 --- a/src/convergence/convergence_remote_app_control_service.cc +++ b/src/convergence/convergence_remote_app_control_service.cc @@ -123,7 +123,7 @@ TizenResult ConvergenceRemoteAppControlService::Disconnect() { return LogAndCreateTizenError(AbortError, "Service with specified type does not exist"); } - const int error = conv_service_disconnect(service); + int error = conv_service_disconnect(service); if (CONV_ERROR_NONE != error) { return LogAndCreateTizenError(AbortError, "conv_service_disconnect [Fail]"); } else { @@ -132,7 +132,21 @@ TizenResult ConvergenceRemoteAppControlService::Disconnect() { LoggerI("Disconnected from the remote service"); } - return TizenSuccess(); + conv_service_connection_state_e state = CONV_SERVICE_CONNECTION_STATE_NONE; + error = conv_service_get_connection_state(service, &state); + if (CONV_ERROR_NONE != error) { + LoggerE("Error gathering state [%d] : %s", error, get_error_message(error)); + return LogAndCreateTizenError(AbortError, "Error gathering state"); + } else { + LoggerD("state: %d" , state); + + } + if (CONV_SERVICE_CONNECTION_STATE_NOT_CONNECTED == state) { + return TizenSuccess(); + } else { + LoggerE("Service is still connected, reporting error"); + return LogAndCreateTizenError(AbortError, "Disconnecting failed."); + } } TizenResult ConvergenceRemoteAppControlService::Start(const bool reply, const int cur_listener_id) { -- 2.7.4 From a721e535e74883a56e8ce39498ed4798d2036942 Mon Sep 17 00:00:00 2001 From: Tomasz Marciniak Date: Fri, 2 Dec 2016 16:31:24 +0900 Subject: [PATCH 08/16] [Convergence] Fix for launch() and launchAppControl() [Verification] Code compiles. Application on remote device can be launched, resulut is received and passed to JS layer. Application does not crash now. Change-Id: I45345a302a0601895bda5593700c80be3c877b95 Signed-off-by: Tomasz Marciniak --- src/convergence/convergence_api.js | 29 +++++-- src/convergence/convergence_instance.cc | 8 +- .../convergence_remote_app_control_service.cc | 89 ++++++++++++++++------ .../convergence_remote_app_control_service.h | 4 +- src/convergence/convergence_utils.h | 7 +- 5 files changed, 95 insertions(+), 42 deletions(-) diff --git a/src/convergence/convergence_api.js b/src/convergence/convergence_api.js index 615b81c..708fbc0 100644 --- a/src/convergence/convergence_api.js +++ b/src/convergence/convergence_api.js @@ -302,8 +302,18 @@ native_.addListener('REMOTE_APP_CONTROL_SERVICE_LISTENER', function(result) { native_.callIfPossible(s._connectCallback, s); break; case 'onPublish': - native_.callIfPossible(s._remoteAppControlCallback, - result.payload); + var remote_func = result.remote_function; + if ('launch' === remote_func) { + native_.callIfPossible(s._remoteAppControlCallback); + } else if ('launchAppControl' === remote_func) { + var callback = result.callback_result; + var d = undefined; + if ('onsuccess' === callback) { + d = result.reply ? new tizen.ApplicationControlData('reply', [result.reply]) : null; + } + + native_.callIfPossible(s._remoteAppControlCallback[callback], d); + } break; case 'onStart': native_.callIfPossible(s._startCallback, s); @@ -542,11 +552,8 @@ RemoteAppControlService.prototype.launch = function(appId, successCallback, erro this._remoteAppControlCallback = successCallback; convergenceServices[lid] = this; - var needReply = !(successCallback == null); - var result = native_.call('RemoteAppControlService_launch', { appId: args.appId, - reply: needReply, deviceId: this._deviceId, curListenerId: lid }, function(result) { @@ -579,22 +586,30 @@ RemoteAppControlService.prototype.launchAppControl = function() { type: types_.FUNCTION, optional: true, nullable: true + }, { + name: 'replyCallback', + type : types_.LISTENER, + values : ['onsuccess', 'onfailure'], + optional: true, + nullable: true }]); var lid = this._serviceId; - this._remoteAppControlCallback = args.successCallback; + this._remoteAppControlCallback = args.replyCallback; convergenceServices[lid] = this; var callArgs = {}; callArgs.appControl = args.appControl; callArgs.appId = args.appId ? args.appId : ""; - callArgs.reply = !!args.successCallback; + callArgs.reply = !!args.replyCallback; callArgs.deviceId = this._deviceId; callArgs.curListenerId = lid; var callback = function(result) { if (native_.isFailure(result)) { native_.callIfPossible(args.errorCallback, native_.getErrorObject(result)); + } else { + native_.callIfPossible(args.successCallback); } }; diff --git a/src/convergence/convergence_instance.cc b/src/convergence/convergence_instance.cc index cd14512..622d850 100644 --- a/src/convergence/convergence_instance.cc +++ b/src/convergence/convergence_instance.cc @@ -343,7 +343,6 @@ common::TizenResult ConvergenceInstance::RemoteAppControlServiceLaunch(const pic CHECK_EXIST(args, kJSArgumentDeviceId); CHECK_EXIST(args, kJSArgumentAppId); - CHECK_EXIST(args, kJSArgumentReply); CHECK_EXIST(args, kJSCurrentListenerId); auto launch = [this, args](const common::AsyncToken& token) -> void { @@ -362,7 +361,6 @@ common::TizenResult ConvergenceInstance::RemoteAppControlServiceLaunch(const pic } else { result = service->Launch( ConvergenceUtils::GetArg(args, kJSArgumentAppId).to_str().c_str(), - static_cast(ConvergenceUtils::GetArg(args, kJSArgumentReply).get()), static_cast(ConvergenceUtils::GetArg(args, kJSCurrentListenerId).get())); } @@ -411,11 +409,7 @@ common::TizenResult ConvergenceInstance::RemoteAppControlServiceLaunchAppControl static_cast(ConvergenceUtils::GetArg(args, kJSCurrentListenerId).get())); } - //only in case of failure call callback - //other cases are handled by conv_service_listener_cb() - if (!result) { - this->Post(token, result); - } + this->Post(token, result); }; std::thread(launch_app_control, token).detach(); diff --git a/src/convergence/convergence_remote_app_control_service.cc b/src/convergence/convergence_remote_app_control_service.cc index bd9612b..f652523 100644 --- a/src/convergence/convergence_remote_app_control_service.cc +++ b/src/convergence/convergence_remote_app_control_service.cc @@ -32,6 +32,11 @@ namespace convergence { namespace { static const char* kAppControl = "app_control"; static const char* kReply = "reply"; +static const char* kCbResult = "callback_result"; +static const char* kRemoteFunc = "remote_function"; + +static const std::string kLaunch = "launch"; +static const std::string kLaunchAppControl = "launchAppControl"; } // namespace using common::TizenResult; @@ -215,20 +220,41 @@ void ConvergenceRemoteAppControlService::ServiceListenerCb(conv_service_h servic } picojson::object param; - param["payload"] = picojson::value("TODO"); - - // TODO parse the payload and fill the param - const std::string result_type = ConvergencePayloadArray::ExtractPayloadString(result, kServiceResultType.c_str()); param[kServiceResultType] = picojson::value(result_type); - if (CONV_ERROR_NONE == error) { - param[kServiceListenerStatus] = picojson::value(kServiceListenerStatusOk); - callbackParam->plugin_->ReplyAsync(kRemoteAppControlListenerCallback, - callbackParam->callback_id_, - true, - param); + //onPublish are triggered by launch() and launchAppControl() methods + if (kServiceResultTypeOnPublish == result_type) { + param[kRemoteFunc] = picojson::value(callbackParam->remote_method_); + //there is no information which method caused callback execution + //so it is needed to provide such information via callbackParam + if (kLaunchAppControl == callbackParam->remote_method_) { + const std::string app_control_result = ConvergencePayloadArray::ExtractPayloadString(result, kServiceReplyControlResult.c_str()); + if ("0" == app_control_result) { + const std::string app_control_reply = ConvergencePayloadArray::ExtractPayloadString(result, kServiceReplyResult.c_str()); + + param[kCbResult] = picojson::value("onsuccess"); + param[kReply] = picojson::value(app_control_reply); + } else { + param[kCbResult] = picojson::value("onfailure"); + } + } + + //in case of launch() method there is no information received if it finished + //with success or error, so we assume optimistic success + param[kServiceListenerStatus] = picojson::value(kServiceListenerStatusOk); + callbackParam->plugin_->ReplyAsync(kRemoteAppControlListenerCallback, + callbackParam->callback_id_, + true, + param); + } else { + param[kServiceListenerStatus] = picojson::value(kServiceListenerStatusOk); + callbackParam->plugin_->ReplyAsync(kRemoteAppControlListenerCallback, + callbackParam->callback_id_, + true, + param); + } } else { // Error occurred during connection param[kServiceListenerStatus] = picojson::value(kServiceListenerStatusError); @@ -240,7 +266,7 @@ void ConvergenceRemoteAppControlService::ServiceListenerCb(conv_service_h servic } } -void ConvergenceRemoteAppControlService::UpdateListener(const int cur_listener_id) { +void ConvergenceRemoteAppControlService::UpdateListener(const int cur_listener_id, std::string remote_method) { ScopeLogger(); conv_service_h service_handle = FindServiceHandle(); @@ -250,6 +276,7 @@ void ConvergenceRemoteAppControlService::UpdateListener(const int cur_listener_i } CallbackParam *param = new CallbackParam(convergence_plugin_, cur_listener_id); + param->remote_method_ = remote_method; const int error = conv_service_set_listener_cb(service_handle, ServiceListenerCb, param); if (CONV_ERROR_NONE != error) { @@ -263,7 +290,7 @@ void ConvergenceRemoteAppControlService::UpdateListener(const int cur_listener_i } } -TizenResult ConvergenceRemoteAppControlService::Launch(const char *appId, bool reply, const int cur_listener_id) { +TizenResult ConvergenceRemoteAppControlService::Launch(const char *appId, const int cur_listener_id) { ScopeLogger(); if (!started_) { @@ -273,12 +300,21 @@ TizenResult ConvergenceRemoteAppControlService::Launch(const char *appId, bool r conv_payload_h payload = nullptr; app_control_h app_control = nullptr; + //regarding to native team app_control can be released + //after setting it in payload handle, unfortunately + //when it is done here or in triggered callback or even + //if they are kept in vector and released in + //~ConvergenceRemoteAppControlService() application crashes. + //it seems that ownership is taken over somewhere and + //handle is released. We need to wait for convergence + //native team answer. Now app_control_destroy is commented SCOPE_EXIT { if (payload) { conv_payload_destroy(payload); } if (app_control) { - app_control_destroy(app_control); + //uncomment below line when issue will be explained + //app_control_destroy(app_control); } }; @@ -292,6 +328,7 @@ TizenResult ConvergenceRemoteAppControlService::Launch(const char *appId, bool r return LogAndCreateTizenError(AbortError, "Failed to create payload handle"); } + ret = app_control_create(&app_control); if (APP_CONTROL_ERROR_NONE != ret) { return LogAndCreateTizenError(AbortError, "Failed to create app control handle"); @@ -312,17 +349,12 @@ TizenResult ConvergenceRemoteAppControlService::Launch(const char *appId, bool r return LogAndCreateTizenError(AbortError, "Failed to set app control in payload"); } - if (reply) { - ret = conv_payload_set_string(payload, kReply, "1"); - if (CONV_ERROR_NONE != ret) { - return LogAndCreateTizenError(AbortError, "Failed to set string in payload"); - } - } + //if the 'reply' was set callback was not triggered because + //D2D-CONV-MANAGER received error IOTCON_ERROR_INVALID_PARAMETER -22 + //RemoteAppControlServiceProvider.cpp: __on_response(741) > iotcon_response_get_result() Fail(-22) // Update listener: assign it if it is not yet assigned - if (reply) { - UpdateListener(cur_listener_id); - } + UpdateListener(cur_listener_id, "launch"); // Sending app control on the remote device ret = conv_service_publish(service_handle, nullptr, payload); @@ -348,12 +380,21 @@ TizenResult ConvergenceRemoteAppControlService::LaunchAppControl(const picojson: conv_payload_h payload = nullptr; app_control_h app_control = nullptr; + //regarding to native team app_control can be released + //after setting it in payload handle, unfortunately + //when it is done here or in triggered callback or even + //if they are kept in vector and released in + //~ConvergenceRemoteAppControlService() application crashes. + //it seems that ownership is taken over somewhere and + //handle is released. We need to wait for convergence + //native team answer. Now app_control_destroy is commented SCOPE_EXIT { if (payload) { conv_payload_destroy(payload); } if (app_control) { - app_control_destroy(app_control); + //uncomment below line when issue will be explained + //app_control_destroy(app_control); } }; @@ -457,7 +498,7 @@ TizenResult ConvergenceRemoteAppControlService::LaunchAppControl(const picojson: // Update listener: assign it if it is not yet assigned if (reply) { - UpdateListener(cur_listener_id); + UpdateListener(cur_listener_id, "launchAppControl"); } // Sending app control on the remote device diff --git a/src/convergence/convergence_remote_app_control_service.h b/src/convergence/convergence_remote_app_control_service.h index a43294f..bf1de55 100644 --- a/src/convergence/convergence_remote_app_control_service.h +++ b/src/convergence/convergence_remote_app_control_service.h @@ -45,7 +45,7 @@ class ConvergenceRemoteAppControlService : public ConvergenceService { common::TizenResult Disconnect(); common::TizenResult Start(const bool reply, const int cur_listener_id); common::TizenResult Stop(const bool reply, const int cur_listener_id); - common::TizenResult Launch(const char *appId, bool reply, const int cur_listener_id); + common::TizenResult Launch(const char *appId, const int cur_listener_id); common::TizenResult LaunchAppControl(const picojson::object& jsonAppControl, const char *appId, bool reply, @@ -54,7 +54,7 @@ class ConvergenceRemoteAppControlService : public ConvergenceService { common::TizenResult ApplicationControlDataToServiceExtraData( const picojson::object& app_control_data, app_control_h app_control); - void UpdateListener(const int cur_listener_id); + void UpdateListener(const int cur_listener_id, std::string remote_method = ""); static void ServiceConnectedCb(conv_service_h service_handle, conv_error_e error, conv_payload_h result, void* user_data); static void ServiceListenerCb(conv_service_h service_handle, diff --git a/src/convergence/convergence_utils.h b/src/convergence/convergence_utils.h index ab4570e..50e0490 100644 --- a/src/convergence/convergence_utils.h +++ b/src/convergence/convergence_utils.h @@ -38,6 +38,8 @@ class ConvergenceInstance; namespace { // Service result type static const std::string kServiceResultType = "result_type"; +static const std::string kServiceReplyResult = "app_control_reply"; +static const std::string kServiceReplyControlResult = "app_control_result"; static const std::string kServiceResultTypeOnStart = "onStart"; static const std::string kServiceResultTypeOnStop = "onStop"; static const std::string kServiceResultTypeOnConnect = "onConnect"; @@ -61,10 +63,11 @@ static const std::string kServiceListenerError = "error"; } // namespace struct CallbackParam { - CallbackParam(ConvergenceInstance *plg, int cbId) - : plugin_(plg), callback_id_(cbId) {} + CallbackParam(ConvergenceInstance *plg, int cbId) + : plugin_(plg), callback_id_(cbId), remote_method_() {} ConvergenceInstance *plugin_; int callback_id_; + std::string remote_method_; }; -- 2.7.4 From fa7e3ee6dbda59eaec352eeed8fb82dc2e721400 Mon Sep 17 00:00:00 2001 From: Tomasz Marciniak Date: Fri, 2 Dec 2016 19:20:04 +0900 Subject: [PATCH 09/16] [Convergence] Return InvalidValuesError if id is empty. [Verification] Code compiles. Proper error is returned in error callback. Change-Id: I55c6c7fbb786022bdbe882bd9ee99cae0654242b Signed-off-by: Tomasz Marciniak --- src/convergence/convergence_instance.cc | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/convergence/convergence_instance.cc b/src/convergence/convergence_instance.cc index 622d850..4ad3807 100644 --- a/src/convergence/convergence_instance.cc +++ b/src/convergence/convergence_instance.cc @@ -359,9 +359,12 @@ common::TizenResult ConvergenceInstance::RemoteAppControlServiceLaunch(const pic result = LogAndCreateTizenError(AbortError, "Can not find the service type = 1", ("Can not find the service type = 1")); } else { - result = service->Launch( - ConvergenceUtils::GetArg(args, kJSArgumentAppId).to_str().c_str(), - static_cast(ConvergenceUtils::GetArg(args, kJSCurrentListenerId).get())); + std::string id = ConvergenceUtils::GetArg(args, kJSArgumentAppId).to_str(); + if (id.empty()) { + result = LogAndCreateTizenError(InvalidValuesError, "Invalid app id", ("Invalid app id")); + } else { + result = service->Launch(id.c_str(), static_cast(ConvergenceUtils::GetArg(args, kJSCurrentListenerId).get())); + } } //only in case of failure call callback -- 2.7.4 From 78dc7d8010d0e9377de12c9f085beeeabe5339ae Mon Sep 17 00:00:00 2001 From: Piotr Kosko Date: Fri, 2 Dec 2016 14:40:35 +0100 Subject: [PATCH 10/16] [Convergence] Fixed clientInfo in callback of start method [Feature] Fixed filling clientInfo when calling start callback of client service (both for service found on other device with startDiscovery and for local service created with constructor) Change-Id: If2d0e1808df46a8e41415a98e680c86ed0bedf59 Signed-off-by: Piotr Kosko --- src/convergence/convergence_api.js | 3 +- .../convergence_app_communication_service.cc | 59 ++++++++++++++-------- .../convergence_app_communication_service.h | 2 +- src/convergence/convergence_client_info.cc | 2 +- src/convergence/convergence_utils.h | 16 +++++- 5 files changed, 55 insertions(+), 27 deletions(-) diff --git a/src/convergence/convergence_api.js b/src/convergence/convergence_api.js index 708fbc0..3d4650d 100644 --- a/src/convergence/convergence_api.js +++ b/src/convergence/convergence_api.js @@ -714,8 +714,9 @@ native_.addListener('APP_COMMUNICATION_SERVICE_LISTENER', function(result) { native_.callIfPossible(s._connectCallback, s); break; case 'onStart': + var clientInfo = (result.clientInfo ? new ClientInfo(result.clientInfo) : null); native_.callIfPossible(s._startCallback, - new ChannelInfo(result.channel.uri, result.channel.id), null); + new ChannelInfo(result.channel.uri, result.channel.id), clientInfo); break; case 'onPublish': native_.callIfPossible(s._sendCallback, diff --git a/src/convergence/convergence_app_communication_service.cc b/src/convergence/convergence_app_communication_service.cc index 4272e4e..2b71890 100644 --- a/src/convergence/convergence_app_communication_service.cc +++ b/src/convergence/convergence_app_communication_service.cc @@ -37,6 +37,7 @@ using common::TizenSuccess; namespace { static const std::string kChannel = "channel"; +static const std::string kClientInfo = "clientInfo"; } // namespace ConvergenceAppCommunicationService::ConvergenceAppCommunicationService() @@ -72,7 +73,7 @@ common::TizenResult ConvergenceAppCommunicationService::Start( return LogAndCreateTizenError(AbortError, "Service with specified type does not exist"); } - UpdateListener(cur_listener_id); + UpdateListener(cur_listener_id, REMOTE_SERVICE_START); const int error = conv_service_start(service_handle, channel->GetHandle(), nullptr); if (CONV_ERROR_NONE != error) { @@ -185,8 +186,11 @@ void ConvergenceAppCommunicationService::ServiceListenerCb(conv_service_h servic param[kChannel] = ConvergenceChannel::ToJson(channel_handle); param[kServiceResultType] = picojson::value(result_type); - if ((kServiceResultTypeOnStart == result_type) - || (kServiceResultTypeOnPublish == result_type) + if (kServiceResultTypeOnStart == result_type) { + if (callbackParam->client_info_) { + param[kClientInfo] = callbackParam->client_info_->ToJson(); + } + } else if ((kServiceResultTypeOnPublish == result_type) || (kServiceResultTypeOnStop == result_type)) { // The service doesn't send any callback with thie response } else if (kServiceResultTypeOnMessage == result_type) { @@ -194,10 +198,20 @@ void ConvergenceAppCommunicationService::ServiceListenerCb(conv_service_h servic ConvergencePayloadArray::ExtractPayloadString(result, "from")); // Define the string as a constant param[kPayload] = ConvergencePayloadArray::ToJson(result); } else if (kServiceResultTypeOnConnect == result_type) { - //param["clientInfo"] = ConvergenceClientInfo(result).ToJson(); - //callbackParam->plugin_->ReplyAsync(kAppCommunicationClientServiceConnectCallback, - // callbackParam->callback_id_, true, param); - return; + // just filling client_info_ member in CallbackParam + if (!callbackParam->client_info_) { + callbackParam->client_info_ = new ConvergenceClientInfo(result); + } + if (LOCAL_SERVICE_START != callbackParam->type_) { + // for non-local services just set clientInfo and not trigger callback + return; + } else { + // but trigger this callback for local services and pretend that this is onStart signal + param[kServiceResultType] = picojson::value(kServiceResultTypeOnStart); + if (callbackParam->client_info_) { + param[kClientInfo] = callbackParam->client_info_->ToJson(); + } + } } else if (kServiceResultTypeOnClientConnect == result_type) { // TODO the service doesn't send any callback with thie response return; // TODO @@ -217,7 +231,8 @@ void ConvergenceAppCommunicationService::ServiceListenerCb(conv_service_h servic callbackParam->callback_id_, true, param); } -void ConvergenceAppCommunicationService::UpdateListener(const int cur_listener_id) { +void ConvergenceAppCommunicationService::UpdateListener(const int cur_listener_id, + ServiceRequestType type) { ScopeLogger(); // TODO make sure that callback is not called twice for the same listener @@ -255,7 +270,7 @@ void ConvergenceAppCommunicationService::UpdateListener(const int cur_listener_i free(sver); } - CallbackParam *param = new CallbackParam(convergence_plugin_, cur_listener_id); + CallbackParam *param = new CallbackParam(convergence_plugin_, cur_listener_id, type); const int error = conv_service_set_listener_cb(service_handle, ServiceListenerCb, param); if (CONV_ERROR_NONE != error) { @@ -348,24 +363,24 @@ common::TizenResult ConvergenceAppCommunicationServerService::Start( const int cur_listener_id) { ScopeLogger(); + LoggerI("Starting service [0x%x] with handle [0x%x]", this, service_handle_); + std::unique_ptr ch_ptr(channel); // auto release memory in case of error - /* By implementation, the local App Communication Service doesn't send - * the callback confirming that the Start is successful. - * So we are sending this callback manually - */ - picojson::object param; - param[kServiceListenerStatus] = picojson::value(kServiceListenerStatusOk); + conv_service_h service_handle = FindServiceHandle(); + if (!service_handle) { + return LogAndCreateTizenError(AbortError, "Service with specified type does not exist"); + } - param[kChannel] = ConvergenceChannel::ToJson(channel->GetHandle()); // Define string as constant - param[kServiceResultType] = picojson::value(kServiceResultTypeOnStart); + UpdateListener(cur_listener_id, LOCAL_SERVICE_START); - common::TizenResult result = ConvergenceAppCommunicationService::Start(channel, cur_listener_id); - if (!result) { - return result; + const int error = conv_service_start(service_handle, channel->GetHandle(), nullptr); + if (CONV_ERROR_NONE != error) { + return LogAndCreateTizenError(AbortError, "conv_service_start [fail]"); } - convergence_plugin_->ReplyAsync(kAppCommunicationListenerCallback, cur_listener_id, true, param); - return result; + opened_channels.push_back(ch_ptr.release()); + + return TizenSuccess(); } common::TizenResult ConvergenceAppCommunicationServerService::Stop( diff --git a/src/convergence/convergence_app_communication_service.h b/src/convergence/convergence_app_communication_service.h index 3821886..10ec5d9 100644 --- a/src/convergence/convergence_app_communication_service.h +++ b/src/convergence/convergence_app_communication_service.h @@ -55,12 +55,12 @@ class ConvergenceAppCommunicationService : public ConvergenceService { common::TizenResult SetListener(const int cur_listener_id); common::TizenResult RemoveListener(); private: - void UpdateListener(const int cur_listener_id); static void ServiceListenerCb(conv_service_h service_handle, conv_channel_h channel_handle, conv_error_e error, conv_payload_h result, void* user_data); protected: + void UpdateListener(const int cur_listener_id, ServiceRequestType type = UNKNOWN_REQUEST_TYPE); std::vector callback_param_gc_; }; diff --git a/src/convergence/convergence_client_info.cc b/src/convergence/convergence_client_info.cc index 6dece11..b75c2e7 100644 --- a/src/convergence/convergence_client_info.cc +++ b/src/convergence/convergence_client_info.cc @@ -76,7 +76,7 @@ picojson::value ConvergenceClientInfo::ToJson() const { ScopeLogger(); picojson::object clientInfo; clientInfo["isHost"] = picojson::value(static_cast(isHost_)); - clientInfo["connectionTime"] = picojson::value(static_cast(connectionTime_)); + clientInfo["connectTime"] = picojson::value(static_cast(connectionTime_)); clientInfo["clientId"] = picojson::value(clientId_); return picojson::value(clientInfo); } diff --git a/src/convergence/convergence_utils.h b/src/convergence/convergence_utils.h index 50e0490..2d17d8a 100644 --- a/src/convergence/convergence_utils.h +++ b/src/convergence/convergence_utils.h @@ -24,6 +24,7 @@ #include #include "common/tizen_result.h" +#include "convergence_client_info.h" namespace extension { namespace convergence { @@ -62,12 +63,23 @@ static const std::string kServiceListenerStatusError = "listener_error"; static const std::string kServiceListenerError = "error"; } // namespace +enum ServiceRequestType { + LOCAL_SERVICE_START, + REMOTE_SERVICE_START, + UNKNOWN_REQUEST_TYPE +}; + struct CallbackParam { - CallbackParam(ConvergenceInstance *plg, int cbId) - : plugin_(plg), callback_id_(cbId), remote_method_() {} + CallbackParam(ConvergenceInstance *plg, int cbId, ServiceRequestType type = UNKNOWN_REQUEST_TYPE) + : plugin_(plg), callback_id_(cbId), remote_method_(), client_info_(nullptr), type_(type) {} + ~CallbackParam() { + delete client_info_; + } ConvergenceInstance *plugin_; int callback_id_; std::string remote_method_; + ConvergenceClientInfo* client_info_; + ServiceRequestType type_; }; -- 2.7.4 From e2e5253d2777610781b3361dcfa8c7026b319815 Mon Sep 17 00:00:00 2001 From: Tomasz Marciniak Date: Sun, 4 Dec 2016 18:50:20 +0900 Subject: [PATCH 11/16] [Convergence] Set discoveryStarted to false in error callback. [Verification] Code compiles. Change-Id: I05aa3c04f5dfe2232495c08c35c15921f37747a6 Signed-off-by: Tomasz Marciniak --- src/convergence/convergence_api.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/convergence/convergence_api.js b/src/convergence/convergence_api.js index 3d4650d..8abc3c2 100644 --- a/src/convergence/convergence_api.js +++ b/src/convergence/convergence_api.js @@ -135,9 +135,6 @@ ConvergenceManager.prototype.startDiscovery = function(successCallback, errorCallback, timeout) { console.log('Entered ConvergenceManager.startDiscovery()'); - if (discoveryStarted) - throw new WebAPIException(WebAPIException.INVALID_STATE_ERR, 'Discovery has been started.'); - var args = validator_.validateArgs(arguments, [ {name: 'successCallback', type: types_.LISTENER, values: ['onfound', 'onfinished' ]}, {name: 'errorCallback', type: types_.FUNCTION, optional: true, nullable: true}, @@ -145,8 +142,9 @@ ConvergenceManager.prototype.startDiscovery = function(successCallback, ]); // Indicate, that discovery procedure is on - if (discoveryStarted === true) + if (discoveryStarted === true) { throw new WebAPIException(WebAPIException.INVALID_STATE_ERR, 'Discovery has already started.'); + } discoveryStarted = true; @@ -225,6 +223,7 @@ ConvergenceManager.prototype.startDiscovery = function(successCallback, }, function(result) { if (native_.isFailure(result)) { native_.callIfPossible(errorCallback, native_.getErrorObject(result)); + discoveryStarted = false; } }); -- 2.7.4 From eb584c2707a7eea94fd7ffea254edd2356655777 Mon Sep 17 00:00:00 2001 From: "jk.pu" Date: Tue, 6 Dec 2016 16:01:24 +0900 Subject: [PATCH 12/16] [messaging] fix savace 2.2 defect. remove unreachable code. Change-Id: I6face2a23275b1e9798a0d07b97905b660258f16 Signed-off-by: jk.pu --- src/messaging/messaging_database_manager.cc | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/messaging/messaging_database_manager.cc b/src/messaging/messaging_database_manager.cc index 55f7da2..793ea10 100755 --- a/src/messaging/messaging_database_manager.cc +++ b/src/messaging/messaging_database_manager.cc @@ -687,13 +687,7 @@ PlatformResult MessagingDatabaseManager::addFilters(AbstractFilterPtr filter, // Service type query if (MessageType::SMS == msg_type || MessageType::MMS == msg_type) { - if (UNDEFINED != msg_type) { sql_query << attribute_map["type"].sql_name << " = " << msg_type << " AND "; - } else { - return LogAndCreateResult( - ErrorCode::UNKNOWN_ERR, "The service type is incorrect.", - ("The service type is incorrect - %d", msg_type)); - } } if(filter) { -- 2.7.4 From 32058695f14106f7bc01a0de8d86f006b89043eb Mon Sep 17 00:00:00 2001 From: Hyunjin Park Date: Tue, 6 Dec 2016 16:31:39 +0900 Subject: [PATCH 13/16] [version] 1.54 Change-Id: Ia70f62133d7fe89936f0fd91e0354713cf69ea96 --- packaging/webapi-plugins.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/webapi-plugins.spec b/packaging/webapi-plugins.spec index ae2935a..d269237 100644 --- a/packaging/webapi-plugins.spec +++ b/packaging/webapi-plugins.spec @@ -10,7 +10,7 @@ %define crosswalk_extensions_path %{_libdir}/%{crosswalk_extensions} Name: webapi-plugins -Version: 1.53 +Version: 1.54 Release: 0 License: Apache-2.0 and BSD-3-Clause and MIT Group: Development/Libraries -- 2.7.4 From 619fbda30ad2fbb6c772b9f3226b099e21dc1453 Mon Sep 17 00:00:00 2001 From: Tomasz Marciniak Date: Wed, 7 Dec 2016 20:45:27 +0900 Subject: [PATCH 14/16] [Convergence] Uncomment app_control_destroy() and remove JS logs. [Verification] Code compiles. There is no crash on 20161206 image. Change-Id: Ia50579d2db56b88efe449dc8475b179b6b45870b Signed-off-by: Tomasz Marciniak --- src/convergence/convergence_api.js | 81 ++-------------------- .../convergence_remote_app_control_service.cc | 28 +------- 2 files changed, 9 insertions(+), 100 deletions(-) diff --git a/src/convergence/convergence_api.js b/src/convergence/convergence_api.js index 8abc3c2..d8c1baf 100644 --- a/src/convergence/convergence_api.js +++ b/src/convergence/convergence_api.js @@ -90,8 +90,7 @@ function getServiceConnectionStateName(connectionStateNumber) { case 2: return ConnectionState.CONNECTING; default: - console.log('ERROR: Unknown connection state'); - return 'UNKNOWN'; // TODO throw exception + return 'UNKNOWN'; } } @@ -133,7 +132,6 @@ function ConvergenceManager() { ConvergenceManager.prototype.startDiscovery = function(successCallback, errorCallback, timeout) { - console.log('Entered ConvergenceManager.startDiscovery()'); var args = validator_.validateArgs(arguments, [ {name: 'successCallback', type: types_.LISTENER, values: ['onfound', 'onfinished' ]}, @@ -152,7 +150,6 @@ ConvergenceManager.prototype.startDiscovery = function(successCallback, convergenceDevices = []; native_.addListener('CONVERGENCE_DISCOVERY_LISTENER', function(result) { - console.log('Entered discovery listener'); if (native_.isFailure(result)) { native_.callIfPossible(errorCallback, native_.getErrorObject(result)); @@ -161,11 +158,9 @@ ConvergenceManager.prototype.startDiscovery = function(successCallback, // Prepare service array if (!result || !result.device || !result.device.services) { - console.log('INVALID device info obtained from Native API'); // TODO throw exception return; } - console.log('Service number: ' + result.device.services.length); var services = []; var id = result.device.id; for (var i = 0; i < result.device.services.length; ++i) { @@ -176,9 +171,6 @@ ConvergenceManager.prototype.startDiscovery = function(successCallback, } else if (service_data.serviceType == 1) { // Remote App Control s = new RemoteAppControlService(); } else { - // Error: unknown service type - // TODO throw exception - console.log('UNKNOWN SERVICE TYPE: ' + service_data.serviceType); continue; } @@ -212,7 +204,7 @@ ConvergenceManager.prototype.startDiscovery = function(successCallback, convergenceDevices = []; } else { - console.log('UNKNOWN discovery state exception'); // TODO throw exception + console.log('UNKNOWN discovery state exception'); } } }); @@ -234,8 +226,6 @@ ConvergenceManager.prototype.startDiscovery = function(successCallback, }; ConvergenceManager.prototype.stopDiscovery = function() { - console.log('Entered ConvergenceManager.stopDiscovery()'); - if (discoveryStarted === false) throw new WebAPIException(WebAPIException.INVALID_STATE_ERR, 'Discovery has not started yet.'); @@ -247,8 +237,6 @@ ConvergenceManager.prototype.stopDiscovery = function() { }; function Service(connectionState_, type_) { - console.log('Entered Service.constructor()'); - var connectionState = connectionState_; Object.defineProperties(this, { @@ -274,18 +262,10 @@ function Service(connectionState_, type_) { native_.addListener('REMOTE_APP_CONTROL_SERVICE_LISTENER', function(result) { if (native_.isFailure(result)) { //native_.callIfPossible(errorCallback, native_.getErrorObject(result)); - console.log('Error in REMOTE_APP_CONTROL_SERVICE_LISTENER'); } else { - - console.log(''); - console.log('REMOTE_APP_CONTROL_SERVICE_LISTENER invoked with data'); - console.log(JSON.stringify(result)); - console.log(''); - // Invoke corresponding callback var lid = result.curListenerId; if (!lid || !convergenceServices.hasOwnProperty(lid)) { - console.log('ERROR: Remote App Ctrl listener is not registered [' + lid + ']'); return; // Something is wrong: listener MUST be there } var s = convergenceServices[lid]; @@ -321,15 +301,12 @@ native_.addListener('REMOTE_APP_CONTROL_SERVICE_LISTENER', function(result) { native_.callIfPossible(s._stopCallback, null); break; default: - console.log('Ignoring result type: [' + result_type + ']'); break; } } }); function RemoteAppControlService() { - console.log('Entered RemoteAppControlService.constructor()'); - validator_.isConstructorCall(this, RemoteAppControlService); // The device id is needed for getting the valid service handle on the @@ -371,8 +348,6 @@ RemoteAppControlService.prototype = new Service(); RemoteAppControlService.prototype.constructor = RemoteAppControlService; RemoteAppControlService.prototype.connect = function(successCallback, errorCallback) { - console.log('Entered RemoteAppControlService.connect()'); - var args = validator_.validateArgs(arguments, [ { name: 'successCallback', @@ -409,8 +384,6 @@ RemoteAppControlService.prototype.connect = function(successCallback, errorCallb }; RemoteAppControlService.prototype.disconnect = function(successCallback, errorCallback) { - console.log('Entered RemoteAppControlService.disconnect()'); - var args = validator_.validateArgs(arguments, [ { name: 'successCallback', @@ -460,7 +433,6 @@ RemoteAppControlService.prototype.start = function() { nullable: true }]); - if (this.connectionState === ConnectionState.NOT_CONNECTED) { throw new WebAPIException(WebAPIException.INVALID_STATE_ERR, 'Service is not connected yet.'); } @@ -521,7 +493,6 @@ RemoteAppControlService.prototype.stop = function() { }; RemoteAppControlService.prototype.launch = function(appId, successCallback, errorCallback) { - console.log('Entered RemoteAppControlService.launch()'); var args = validator_.validateArgs(arguments, [ { name: 'appId', @@ -619,8 +590,6 @@ RemoteAppControlService.prototype.launchAppControl = function() { }; function AppCommunicationService(connectionState_, type_) { - console.log('Entered AppCommunicationService.constructor()'); - Service.call(this, connectionState_, type_); // The device id is needed for getting the valid service handle on the // native layer @@ -671,8 +640,6 @@ function AppCommunicationService(connectionState_, type_) { } }); - // TODO add callbacks in runtime instead of constructor - // Registering the service in the table of issued services convergenceServices[this._serviceId] = this; } @@ -682,22 +649,12 @@ AppCommunicationService.prototype.constructor = AppCommunicationService; native_.addListener('APP_COMMUNICATION_SERVICE_LISTENER', function(result) { - console.log('On App Communication Service Success Callback'); - if (native_.isFailure(result)) { - console.log('ERROR in APP_COMMUNICATION_SERVICE_LISTENER'); //native_.callIfPossible(errorCallback, native_.getErrorObject(result)); } else { - - console.log(''); - console.log('APP_COMMUNICATION_SERVICE_LISTENER invoked with data'); - console.log(JSON.stringify(result)); - console.log(''); - // Invoke corresponding callback var lid = result.curListenerId; if (!lid || !convergenceServices.hasOwnProperty(lid)) { - console.log('ERROR: App Comm listener is not registered [' + lid + ']'); return; // Something is wrong: listener MUST be there } var s = convergenceServices[lid]; @@ -745,15 +702,12 @@ native_.addListener('APP_COMMUNICATION_SERVICE_LISTENER', function(result) { } break; default: - console.log('Ignoring result type: [' + result_type + ']'); break; } } }); AppCommunicationService.prototype.start = function(channel, successCallback, errorCallback) { - console.log('Entered AppCommunicationService.start()'); - var args = validator_.validateArgs(arguments, [ { name: 'channel', @@ -796,8 +750,6 @@ AppCommunicationService.prototype.start = function(channel, successCallback, err }; AppCommunicationService.prototype.stop = function(channel, successCallback, errorCallback) { - console.log('Entered AppCommunicationService.stop()'); - var args = validator_.validateArgs(arguments, [ { name: 'channel', @@ -843,8 +795,6 @@ AppCommunicationService.prototype.stop = function(channel, successCallback, erro }; AppCommunicationService.prototype.send = function(channel, payload, successCallback, errorCallback) { - console.log('Entered AppCommunicationService.send()'); - var args = validator_.validateArgs(arguments, [ { name: 'channel', @@ -935,21 +885,14 @@ AppCommunicationService.prototype.getClientList = function() { }; AppCommunicationService.prototype.setListener = function(listenerCallback) { - console.log('Entered AppCommunicationService.setListener()'); var args = validator_.validateArgs(arguments, [ {name: 'listenerCallback', type: types_.FUNCTION} ]); var lid = this._serviceId; - // TODO in fact, it should be even the list of callbacks instead of - // the single callback this._listenerCallback = listenerCallback; convergenceServices[lid] = this; - console.log(''); - console.log('AppCommunicationServiceCommandListeners ADDED [' + lid + ']'); - console.log(''); - var result = native_.callSync('AppCommunicationService_setListener', { deviceId: this._deviceId, curListenerId: lid @@ -958,34 +901,29 @@ AppCommunicationService.prototype.setListener = function(listenerCallback) { if (native_.isFailure(result)) throw native_.getErrorObject(result); - return args.curListenerId; // TODO return proper index of listener + return args.curListenerId; }; AppCommunicationService.prototype.unsetListener = function(id) { - console.log('Entered AppCommunicationService.unsetListener()'); var args = validator_.validateArgs(arguments, [ {name: 'id', type: types_.LONG, optional: false} ]); var result = native_.callSync('AppCommunicationService_unsetListener', { deviceId: this._deviceId - //curListenerId: id // not needed in below layers }); if (native_.isFailure(result)) throw native_.getErrorObject(result); var lid = this._serviceId; - if (this._listenerCallback) {// TODO extend this to manage the list of callbacks - //delete this._listenerCallback; + if (this._listenerCallback) { this._listenerCallback = null; } convergenceServices[lid] = this; }; function AppCommunicationServerService() { - console.log('Entered AppCommunicationServerService.constructor()'); - validator_.isConstructorCall(this, AppCommunicationServerService); AppCommunicationService.call(this, ConnectionState.NOT_CONNECTED, ServiceType.APP_COMM_SERVER); @@ -999,8 +937,6 @@ AppCommunicationServerService.prototype = new AppCommunicationService(); AppCommunicationServerService.prototype.constructor = AppCommunicationServerService; function AppCommunicationClientService() { - console.log('Entered AppCommunicationClientService.constructor()'); - validator_.isConstructorCall(this, AppCommunicationClientService); AppCommunicationService.call(this, ConnectionState.NOT_CONNECTED, ServiceType.APP_COMM_CLIENT); @@ -1010,8 +946,6 @@ AppCommunicationClientService.prototype = new AppCommunicationService(); AppCommunicationClientService.prototype.constructor = AppCommunicationClientService; AppCommunicationClientService.prototype.connect = function(successCallback, errorCallback) { - console.log('Entered AppCommunicationClientService.connect()'); - var args = validator_.validateArgs(arguments, [ { name: 'successCallback', @@ -1048,26 +982,23 @@ AppCommunicationClientService.prototype.connect = function(successCallback, erro }; AppCommunicationClientService.prototype.disconnect = function(successCallback, errorCallback) { - console.log('Entered AppCommunicationClientService.disconnect()'); - var args = validator_.validateArgs(arguments, [ { name: 'successCallback', type: types_.FUNCTION, - //values: ConnectSuccessCallback, optional: true, nullable: true }, { name: 'errorCallback', type: types_.FUNCTION, - //values: ErrorCallback, optional: true, nullable: true } ]); - if (this.connectionState != ConnectionState.CONNECTED) + if (this.connectionState != ConnectionState.CONNECTED) { throw new WebAPIException(WebAPIException.INVALID_STATE_ERR, 'Service is not connected yet.'); + } var that = this; var result = native_.call('AppCommunicationClientService_disconnect', { diff --git a/src/convergence/convergence_remote_app_control_service.cc b/src/convergence/convergence_remote_app_control_service.cc index f652523..d10a370 100644 --- a/src/convergence/convergence_remote_app_control_service.cc +++ b/src/convergence/convergence_remote_app_control_service.cc @@ -300,21 +300,12 @@ TizenResult ConvergenceRemoteAppControlService::Launch(const char *appId, const conv_payload_h payload = nullptr; app_control_h app_control = nullptr; - //regarding to native team app_control can be released - //after setting it in payload handle, unfortunately - //when it is done here or in triggered callback or even - //if they are kept in vector and released in - //~ConvergenceRemoteAppControlService() application crashes. - //it seems that ownership is taken over somewhere and - //handle is released. We need to wait for convergence - //native team answer. Now app_control_destroy is commented SCOPE_EXIT { if (payload) { conv_payload_destroy(payload); } if (app_control) { - //uncomment below line when issue will be explained - //app_control_destroy(app_control); + app_control_destroy(app_control); } }; @@ -349,12 +340,8 @@ TizenResult ConvergenceRemoteAppControlService::Launch(const char *appId, const return LogAndCreateTizenError(AbortError, "Failed to set app control in payload"); } - //if the 'reply' was set callback was not triggered because - //D2D-CONV-MANAGER received error IOTCON_ERROR_INVALID_PARAMETER -22 - //RemoteAppControlServiceProvider.cpp: __on_response(741) > iotcon_response_get_result() Fail(-22) - // Update listener: assign it if it is not yet assigned - UpdateListener(cur_listener_id, "launch"); + UpdateListener(cur_listener_id, "launch"); // Sending app control on the remote device ret = conv_service_publish(service_handle, nullptr, payload); @@ -380,21 +367,12 @@ TizenResult ConvergenceRemoteAppControlService::LaunchAppControl(const picojson: conv_payload_h payload = nullptr; app_control_h app_control = nullptr; - //regarding to native team app_control can be released - //after setting it in payload handle, unfortunately - //when it is done here or in triggered callback or even - //if they are kept in vector and released in - //~ConvergenceRemoteAppControlService() application crashes. - //it seems that ownership is taken over somewhere and - //handle is released. We need to wait for convergence - //native team answer. Now app_control_destroy is commented SCOPE_EXIT { if (payload) { conv_payload_destroy(payload); } if (app_control) { - //uncomment below line when issue will be explained - //app_control_destroy(app_control); + app_control_destroy(app_control); } }; -- 2.7.4 From 053690e116cbbac4ef98402980c98ff05adbe5a9 Mon Sep 17 00:00:00 2001 From: Hyunjin Park Date: Wed, 7 Dec 2016 20:57:03 +0900 Subject: [PATCH 15/16] [package] fix issue of web TCT - cause : native API is changed not to throw invalid parameter in no db case. - solution : add code to check package db [verification] test result of Web TCT is 100% pass rate. Change-Id: If2b1c1aa9a83f5df8dee725e2015963d24da4c48 --- src/package/package_instance.cc | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/src/package/package_instance.cc b/src/package/package_instance.cc index 8125076..3a24edb 100644 --- a/src/package/package_instance.cc +++ b/src/package/package_instance.cc @@ -366,22 +366,31 @@ void PackageInstance::PackageManagerUninstall( return; } - int request_id = 0; - int ret = package_manager_request_uninstall(request_, id.c_str(), &request_id); + package_info_h pkg_info; + int ret = package_manager_get_package_info(id.c_str(), &pkg_info); if ( ret != PACKAGE_MANAGER_ERROR_NONE ) { - if ( ret == PACKAGE_MANAGER_ERROR_INVALID_PARAMETER ) { - LoggerE("The package is not found at the specified location"); - InvokeErrorCallbackAsync(callback_id, - NotFoundException( - "The package is not found at the specified location")); + if ( ret == PACKAGE_MANAGER_ERROR_NO_SUCH_PACKAGE ) { + LoggerE("The package is not found at the specified location"); + InvokeErrorCallbackAsync(callback_id, + NotFoundException( + "The package is not found at the specified location")); } else { - LoggerE("Failed to uninstall package: %d (%s)", ret, get_error_message(ret)); - InvokeErrorCallbackAsync(callback_id, UnknownException( - "It is not allowed to install the package by the platform or " \ - "any other platform error occurs")); + LoggerE("Failed to get package info: %d (%s)", ret, get_error_message(ret)); + InvokeErrorCallbackAsync(callback_id, UnknownException( + "It is not allowed to get package information by the platform or " \ + "any other platform error occurs")); } } else { - RegisterCallback(request_id, callback_id); + int request_id = 0; + int ret = package_manager_request_uninstall(request_, id.c_str(), &request_id); + if ( ret != PACKAGE_MANAGER_ERROR_NONE ) { + LoggerE("Failed to uninstall package: %d (%s)", ret, get_error_message(ret)); + InvokeErrorCallbackAsync(callback_id, UnknownException( + "It is not allowed to install the package by the platform or " \ + "any other platform error occurs")); + } else { + RegisterCallback(request_id, callback_id); + } } ReportSuccess(out); -- 2.7.4 From 5fbbeb7d9a5ad5ddfa881ca71534cd8671cd3358 Mon Sep 17 00:00:00 2001 From: Hyunjin Park Date: Thu, 8 Dec 2016 15:17:16 +0900 Subject: [PATCH 16/16] [nbs] fix svace issue WGID 158431 - MEMORY_LEAK.STRDUP [verification] test result of web TCT is 100% passed. Change-Id: I1806e9e7da2e9285f9eea2ae5c9d4ad70427ead4 --- src/networkbearerselection/networkbearerselection_manager.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/networkbearerselection/networkbearerselection_manager.cc b/src/networkbearerselection/networkbearerselection_manager.cc index 1c4903b..34b23e1 100644 --- a/src/networkbearerselection/networkbearerselection_manager.cc +++ b/src/networkbearerselection/networkbearerselection_manager.cc @@ -268,6 +268,10 @@ void NetworkBearerSelectionManager::requestRouteToHost( if (connection_profile_get_name(profileHandle, ¤tProfileName_c) != CONNECTION_ERROR_NONE) { LoggerE("Fail to get current profile name"); + if (currentProfileName_c != nullptr) { + free(currentProfileName_c); + currentProfileName_c = nullptr; + } makeErrorCallback(domain_name, kPlatformError); return; } -- 2.7.4