summaryrefslogtreecommitdiff
path: root/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc
diff options
context:
space:
mode:
authorIgor Gapchuk (GitHub) <41586842+IGapchuk@users.noreply.github.com>2019-11-21 21:18:07 +0200
committerJackLivio <jack@livio.io>2019-11-21 14:18:07 -0500
commit974819078a7e2fe75e7efab242f7ff5a130d5654 (patch)
treeee2910014d83a2fd975daae21dd2346e294f0a6f /src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc
parent4427ceb58cb91db60150a76f825f3719b8ea76d8 (diff)
downloadsdl_core-974819078a7e2fe75e7efab242f7ff5a130d5654.tar.gz
Fix SDL crash during application registration (#3115)
* Add the new ApplicationEvent. Add the new ApplicationEvent (kRCStatusChanged) for informing RcRPCPlugin that OnRCStatus notification should be sent. Split adding RcExtension to application and sending OnRCStatus notification to the separate actions. * Fix SDL crash during application registration. There is an issue when SDL crashes during registration second application in the time when already exists a registered other one application. In the current implementation ApplicationManager during application registering by the ApplicationManager::RegisterApplication method creates a new instance of the application and adds it to the collection of all registered applications. This method calls in the RegisterAppInterfaceRequest, but all needed extensions will be added only by the ApplicationManager::OnApplicationRegistered method during sending RegisterAppInterface Response to the mobile. According to the described behavior could appear case when a first application is registered successfully and all needed application extensions are successfully added too. The second application starts the registration process in someone thread, but in the other one thread, SDL receives PolicyEvent::kApplicationPolicyUpdated event and tries to unsubscribe all applications from removed in policy table Vehicle Data Items. All actions go on in the next sequence: Precondition: The first application is successfully registered and all needed extensions are added. The first thread: 1. The Mobile device sends RegisterAppInterfaceRequest RPC to the SDL for registration of the second application. 2. SDL receives the RegisterAppInterfaceRequest and calls method Run. Within method RegisterAppInterfaceRequest::Run ApplicationManager runs 3. the method RegisterApplication. The second thread: 4. The SDL receives the PolicyEvent::kApplicationPolicyUpdated event and forwards the event to each plugin for processing it. 5. VehicleInfoPlugin tries to unsubscribe all registered applications from removed in policy table Vehicle Data Items. The plugin finds the first application and unsubscribes it from all removed Vehicle Data Items. The plugin finds the second application and doesn't find any extensions for the application and crashes on the DCHECK with an uninitialized pointer to the extension.
Diffstat (limited to 'src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc')
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc
index 14a94fd1a2..b9ac00aef4 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc
@@ -43,6 +43,7 @@
#include "application_manager/application_manager.h"
#include "application_manager/helpers/application_helper.h"
#include "application_manager/message_helper.h"
+#include "application_manager/plugin_manager/plugin_keys.h"
#include "application_manager/policies/policy_handler.h"
#include "application_manager/policies/policy_handler_interface.h"
#include "application_manager/resumption/resume_ctrl.h"
@@ -458,6 +459,12 @@ void RegisterAppInterfaceRequest::Run() {
}
}
+ auto on_app_registered = [application](plugin_manager::RPCPlugin& plugin) {
+ plugin.OnApplicationEvent(plugin_manager::kApplicationRegistered,
+ application);
+ };
+ application_manager_.ApplyFunctorForEachPlugin(on_app_registered);
+
if (msg_params.keyExists(strings::day_color_scheme)) {
application->set_day_color_scheme(msg_params[strings::day_color_scheme]);
}
@@ -875,6 +882,12 @@ void RegisterAppInterfaceRequest::SendRegisterAppInterfaceResponseToMobile(
// Default HMI level should be set before any permissions validation, since it
// relies on HMI level.
application_manager_.OnApplicationRegistered(application);
+
+ auto send_rc_status = [application](plugin_manager::RPCPlugin& plugin) {
+ plugin.OnApplicationEvent(plugin_manager::kRCStatusChanged, application);
+ };
+ application_manager_.ApplyFunctorForEachPlugin(send_rc_status);
+
SendOnAppRegisteredNotificationToHMI(
application, resumption, need_restore_vr);
(*notify_upd_manager)();