diff options
13 files changed, 147 insertions, 72 deletions
diff --git a/src/components/application_manager/include/application_manager/application_manager_impl.h b/src/components/application_manager/include/application_manager/application_manager_impl.h index 969ec53c41..4b1f8a4601 100644 --- a/src/components/application_manager/include/application_manager/application_manager_impl.h +++ b/src/components/application_manager/include/application_manager/application_manager_impl.h @@ -170,6 +170,7 @@ class ApplicationManagerImpl DataAccessor<ApplicationSet> applications() const OVERRIDE; DataAccessor<AppsWaitRegistrationSet> pending_applications() const OVERRIDE; + DataAccessor<ReregisterWaitList> reregister_applications() const OVERRIDE; ApplicationSharedPtr application(uint32_t app_id) const OVERRIDE; ApplicationSharedPtr active_application() const OVERRIDE; @@ -182,6 +183,8 @@ class ApplicationManagerImpl const std::string& app_name) const OVERRIDE; ApplicationSharedPtr pending_application_by_policy_id( const std::string& policy_app_id) const OVERRIDE; + ApplicationSharedPtr reregister_application_by_policy_id( + const std::string& policy_app_id) const OVERRIDE; std::vector<ApplicationSharedPtr> applications_by_button( uint32_t button) OVERRIDE; @@ -1436,12 +1439,14 @@ class ApplicationManagerImpl ApplicationSet applications_; AppsWaitRegistrationSet apps_to_register_; ForbiddenApps forbidden_applications; + ReregisterWaitList reregister_wait_list_; // Lock for applications list mutable std::shared_ptr<sync_primitives::RecursiveLock> applications_list_lock_ptr_; mutable std::shared_ptr<sync_primitives::Lock> apps_to_register_list_lock_ptr_; + mutable std::shared_ptr<sync_primitives::Lock> reregister_wait_list_lock_ptr_; mutable sync_primitives::Lock subscribed_way_points_apps_lock_; /** @@ -1533,15 +1538,6 @@ class ApplicationManagerImpl std::unique_ptr<app_launch::AppLaunchData> app_launch_dto_; std::unique_ptr<app_launch::AppLaunchCtrl> app_launch_ctrl_; - /** - * @brief ReregisterWaitList is list of applications expected to be - * re-registered after transport switching is complete - */ - typedef std::vector<ApplicationSharedPtr> ReregisterWaitList; - ReregisterWaitList reregister_wait_list_; - - mutable sync_primitives::Lock reregister_wait_list_lock_; - // This is a cache to remember DeviceHandle of secondary transports. Only used // during RegisterApplication(). typedef std::map<int32_t, connection_handler::DeviceHandle> DeviceMap; diff --git a/src/components/application_manager/include/application_manager/command_holder.h b/src/components/application_manager/include/application_manager/command_holder.h index 8cfe5f0889..3f5f657a0e 100644 --- a/src/components/application_manager/include/application_manager/command_holder.h +++ b/src/components/application_manager/include/application_manager/command_holder.h @@ -35,6 +35,7 @@ #include <string> #include "application_manager/application.h" +#include "application_manager/commands/command.h" #include "smart_objects/smart_object.h" namespace application_manager { @@ -59,10 +60,12 @@ class CommandHolder { * internally * @param application Application pointer * @param type Command type + * @param source The source of suspended command * @param command Command */ virtual void Suspend(ApplicationSharedPtr application, CommandType type, + commands::Command::CommandSource source, smart_objects::SmartObjectSPtr command) = 0; /** diff --git a/src/components/application_manager/include/application_manager/command_holder_impl.h b/src/components/application_manager/include/application_manager/command_holder_impl.h index 8867336b3e..530aae47d2 100644 --- a/src/components/application_manager/include/application_manager/command_holder_impl.h +++ b/src/components/application_manager/include/application_manager/command_holder_impl.h @@ -64,10 +64,12 @@ class CommandHolderImpl : public CommandHolder { * @brief Suspend collects command for specific application id internally * @param application Application pointer * @param type Command type + * @param source The source of suspended command * @param command Command */ void Suspend(ApplicationSharedPtr application, CommandType type, + commands::Command::CommandSource source, smart_objects::SmartObjectSPtr command) FINAL; /** @@ -97,9 +99,17 @@ class CommandHolderImpl : public CommandHolder { */ void ResumeMobileCommand(ApplicationSharedPtr application); + /** + * @brief Descriptor of each suspended command containing all necessary + * command info + */ + struct AppCommandInfo { + std::shared_ptr<smart_objects::SmartObject> command_ptr_; + commands::Command::CommandSource command_source_; + }; + using AppCommands = - std::map<ApplicationSharedPtr, - std::vector<std::shared_ptr<smart_objects::SmartObject> > >; + std::map<ApplicationSharedPtr, std::vector<AppCommandInfo> >; ApplicationManager& app_manager_; sync_primitives::Lock commands_lock_; diff --git a/src/components/application_manager/include/application_manager/helpers/application_helper.h b/src/components/application_manager/include/application_manager/helpers/application_helper.h index 18267c9e7f..a7933c2451 100644 --- a/src/components/application_manager/include/application_manager/helpers/application_helper.h +++ b/src/components/application_manager/include/application_manager/helpers/application_helper.h @@ -69,6 +69,19 @@ ApplicationSharedPtr FindPendingApp( return app; } +template <class UnaryPredicate> +ApplicationSharedPtr FindReregisterApp( + DataAccessor<ReregisterWaitList> accessor, UnaryPredicate finder) { + ReregisterWaitList::const_iterator begin = accessor.GetData().begin(); + ReregisterWaitList::const_iterator end = accessor.GetData().end(); + ReregisterWaitList::const_iterator it = std::find_if(begin, end, finder); + if (accessor.GetData().end() == it) { + return ApplicationSharedPtr(); + } + ApplicationSharedPtr app = *it; + return app; +} + /** * Helper function for lookup through applications list and returning all * applications satisfying predicate logic diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_start_stream_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_start_stream_request.cc index e06995f40d..90f7c2d0f1 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_start_stream_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_start_stream_request.cc @@ -64,8 +64,9 @@ NaviStartStreamRequest::NaviStartStreamRequest( } NaviStartStreamRequest::~NaviStartStreamRequest() { - // unsubscribe_from_all_hmi_events() in EventObserver's destructor isn't enough; - // we must unsubscribe before this NaviStartStreamRequest instance is removed + // unsubscribe_from_all_hmi_events() in EventObserver's destructor isn't + // enough; we must unsubscribe before this NaviStartStreamRequest instance is + // removed unsubscribe_from_event(hmi_apis::FunctionID::Navigation_StartStream); } 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 937d9d8a52..14eed6b137 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 @@ -1373,8 +1373,8 @@ bool RegisterAppInterfaceRequest::IsApplicationSwitched() { application_manager_.GetCorrectMobileIDFromMessage(message_); LOG4CXX_DEBUG(logger_, "Looking for application id " << policy_app_id); - - auto app = application_manager_.application(device_id_, policy_app_id); + auto app = + application_manager_.reregister_application_by_policy_id(policy_app_id); if (!app) { LOG4CXX_DEBUG( @@ -1385,11 +1385,12 @@ bool RegisterAppInterfaceRequest::IsApplicationSwitched() { LOG4CXX_DEBUG(logger_, "Application with policy id " << policy_app_id << " is found."); - if (!application_manager_.IsAppInReconnectMode(device_handle_, - policy_app_id)) { - LOG4CXX_DEBUG( - logger_, - "Policy id " << policy_app_id << " is not found in reconnection list."); + + const auto app_device_handle = app->device(); + if (app_device_handle == device_handle_) { + LOG4CXX_DEBUG(logger_, + "Application " << policy_app_id + << " is already registered from this device."); SendResponse(false, mobile_apis::Result::APPLICATION_REGISTERED_ALREADY); return true; } diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/register_app_interface_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/register_app_interface_request_test.cc index ac45e90d8e..636175c56f 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/register_app_interface_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/register_app_interface_request_test.cc @@ -78,6 +78,7 @@ using sdl_rpc_plugin::commands::RegisterAppInterfaceRequest; namespace { const uint32_t kConnectionKey = 1u; const uint32_t kConnectionKey2 = 2u; +const connection_handler::DeviceHandle kDeviceHandle = 3u; const hmi_apis::Common_Language::eType kHmiLanguage = hmi_apis::Common_Language::EN_US; const mobile_apis::Language::eType kMobileLanguage = @@ -304,6 +305,8 @@ TEST_F(RegisterAppInterfaceRequestTest, Run_MinimalData_SUCCESS) { .WillByDefault(DoAll(SetArgPointee<3>(kMacAddress1), Return(0))); MockAppPtr mock_app = CreateBasicMockedApp(); + EXPECT_CALL(app_mngr_, reregister_application_by_policy_id(kAppId1)) + .WillOnce(Return(ApplicationSharedPtr())); EXPECT_CALL(app_mngr_, application(kMacAddress1, kAppId1)) .WillRepeatedly(Return(ApplicationSharedPtr())); @@ -386,6 +389,8 @@ TEST_F(RegisterAppInterfaceRequestTest, .WillByDefault(DoAll(SetArgPointee<3>(kMacAddress1), Return(0))); MockAppPtr mock_app = CreateBasicMockedApp(); + EXPECT_CALL(app_mngr_, reregister_application_by_policy_id(kAppId1)) + .WillOnce(Return(ApplicationSharedPtr())); EXPECT_CALL(app_mngr_, application(kMacAddress1, kAppId1)) .WillRepeatedly(Return(ApplicationSharedPtr())); @@ -484,8 +489,8 @@ TEST_F(RegisterAppInterfaceRequestTest, MockAppPtr mock_app = CreateBasicMockedApp(); app_set_.insert(mock_app); - EXPECT_CALL(app_mngr_, application_by_policy_id(kAppId1)) - .WillRepeatedly(Return(mock_app)); + EXPECT_CALL(app_mngr_, reregister_application_by_policy_id(kAppId1)) + .WillOnce(Return(mock_app)); connection_handler::DeviceHandle device_id = 1; ON_CALL(mock_connection_handler_, @@ -495,11 +500,7 @@ TEST_F(RegisterAppInterfaceRequestTest, ON_CALL(mock_session_observer_, GetDataOnDeviceID(device_id, _, _, _, _)) .WillByDefault(DoAll(SetArgPointee<3>(kMacAddress1), Return(0))); - ON_CALL(app_mngr_, application(kMacAddress1, kAppId1)) - .WillByDefault(Return(mock_app)); - - ON_CALL(app_mngr_, IsAppInReconnectMode(device_id, kAppId1)) - .WillByDefault(Return(true)); + EXPECT_CALL(*mock_app, device()).WillOnce(Return(kDeviceHandle)); EXPECT_CALL(app_mngr_, ProcessReconnection(_, kConnectionKey)); @@ -542,13 +543,9 @@ TEST_F(RegisterAppInterfaceRequestTest, .WillByDefault(DoAll(SetArgPointee<3>(kMacAddress1), Return(0))); MockAppPtr mock_app = CreateBasicMockedApp(); - EXPECT_CALL(app_mngr_, application_by_policy_id(kAppId1)) - .WillRepeatedly(Return(mock_app)); - - EXPECT_CALL(app_mngr_, application(kMacAddress1, kAppId1)) + EXPECT_CALL(app_mngr_, reregister_application_by_policy_id(kAppId1)) .WillOnce(Return(mock_app)); - ON_CALL(app_mngr_, IsAppInReconnectMode(device_id, kAppId1)) - .WillByDefault(Return(true)); + EXPECT_CALL(*mock_app, device()).WillOnce(Return(kDeviceHandle)); EXPECT_CALL(app_mngr_, ProcessReconnection(_, kConnectionKey)); @@ -589,14 +586,9 @@ TEST_F(RegisterAppInterfaceRequestTest, .WillByDefault(DoAll(SetArgPointee<3>(kMacAddress1), Return(0))); MockAppPtr mock_app = CreateBasicMockedApp(); - EXPECT_CALL(app_mngr_, application_by_policy_id(kAppId1)) - .WillRepeatedly(Return(mock_app)); - - EXPECT_CALL(app_mngr_, application(kMacAddress1, kAppId1)) + EXPECT_CALL(app_mngr_, reregister_application_by_policy_id(kAppId1)) .WillOnce(Return(mock_app)); - - EXPECT_CALL(app_mngr_, IsAppInReconnectMode(device_id, kAppId1)) - .WillOnce(Return(true)); + EXPECT_CALL(*mock_app, device()).WillOnce(Return(kDeviceHandle)); EXPECT_CALL(app_mngr_, ProcessReconnection(_, kConnectionKey)); @@ -641,6 +633,8 @@ TEST_F(RegisterAppInterfaceRequestTest, ON_CALL(mock_session_observer_, GetDataOnDeviceID(device_id, _, _, _, _)) .WillByDefault(DoAll(SetArgPointee<3>(kMacAddress1), Return(0))); + EXPECT_CALL(app_mngr_, reregister_application_by_policy_id(kAppId1)) + .WillOnce(Return(ApplicationSharedPtr())); EXPECT_CALL(app_mngr_, application(kMacAddress1, kAppId1)) .WillOnce(Return(mock_app1)); @@ -691,6 +685,8 @@ TEST_F(RegisterAppInterfaceRequestTest, ON_CALL(*mock_app2, mac_address()).WillByDefault(ReturnRef(kMacAddress2)); EXPECT_CALL(app_mngr_, application(kMacAddress2, kAppId1)) .WillRepeatedly(Return(ApplicationSharedPtr())); + EXPECT_CALL(app_mngr_, reregister_application_by_policy_id(kAppId1)) + .WillOnce(Return(ApplicationSharedPtr())); EXPECT_CALL(app_mngr_, application(kConnectionKey2)) .WillOnce(Return(mock_app2)); diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index 652a939e21..e491f09466 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -159,6 +159,7 @@ ApplicationManagerImpl::ApplicationManagerImpl( , applications_list_lock_ptr_( std::make_shared<sync_primitives::RecursiveLock>()) , apps_to_register_list_lock_ptr_(std::make_shared<sync_primitives::Lock>()) + , reregister_wait_list_lock_ptr_(std::make_shared<sync_primitives::Lock>()) , audio_pass_thru_active_(false) , audio_pass_thru_app_id_(0) , driver_distraction_state_(hmi_apis::Common_DriverDistractionState::DD_OFF) @@ -266,6 +267,13 @@ ApplicationManagerImpl::pending_applications() const { return accessor; } +DataAccessor<ReregisterWaitList> +ApplicationManagerImpl::reregister_applications() const { + DataAccessor<ReregisterWaitList> accessor(reregister_wait_list_, + reregister_wait_list_lock_ptr_); + return accessor; +} + ApplicationSharedPtr ApplicationManagerImpl::application( uint32_t app_id) const { AppIdPredicate finder(app_id); @@ -301,6 +309,14 @@ ApplicationSharedPtr ApplicationManagerImpl::pending_application_by_policy_id( return FindPendingApp(accessor, finder); } +ApplicationSharedPtr +ApplicationManagerImpl::reregister_application_by_policy_id( + const std::string& policy_app_id) const { + PolicyAppIdPredicate finder(policy_app_id); + DataAccessor<ReregisterWaitList> accessor = reregister_applications(); + return FindReregisterApp(accessor, finder); +} + bool ActiveAppPredicate(const ApplicationSharedPtr app) { return app ? app->IsFullscreen() : false; } @@ -1554,7 +1570,7 @@ void ApplicationManagerImpl::OnDeviceSwitchingStart( { // During sending of UpdateDeviceList this lock is acquired also so making // it scoped - sync_primitives::AutoLock lock(reregister_wait_list_lock_); + sync_primitives::AutoLock lock(reregister_wait_list_lock_ptr_); for (auto i = reregister_wait_list_.begin(); reregister_wait_list_.end() != i; ++i) { @@ -1594,7 +1610,7 @@ void ApplicationManagerImpl::OnDeviceSwitchingFinish( const std::string& device_uid) { LOG4CXX_AUTO_TRACE(logger_); UNUSED(device_uid); - sync_primitives::AutoLock lock(reregister_wait_list_lock_); + sync_primitives::AutoLock lock(reregister_wait_list_lock_ptr_); const bool unexpected_disonnect = true; const bool is_resuming = true; @@ -3569,7 +3585,7 @@ bool ApplicationManagerImpl::IsAppInReconnectMode( const connection_handler::DeviceHandle& device_id, const std::string& policy_app_id) const { LOG4CXX_AUTO_TRACE(logger_); - sync_primitives::AutoLock lock(reregister_wait_list_lock_); + sync_primitives::AutoLock lock(reregister_wait_list_lock_ptr_); return reregister_wait_list_.end() != std::find_if(reregister_wait_list_.begin(), reregister_wait_list_.end(), @@ -3902,7 +3918,7 @@ void ApplicationManagerImpl::EraseAppFromReconnectionList( } const auto policy_app_id = app->policy_app_id(); - sync_primitives::AutoLock lock(reregister_wait_list_lock_); + sync_primitives::AutoLock lock(reregister_wait_list_lock_ptr_); auto app_it = std::find_if(reregister_wait_list_.begin(), reregister_wait_list_.end(), diff --git a/src/components/application_manager/src/command_holder_impl.cc b/src/components/application_manager/src/command_holder_impl.cc index 87ac50ebd7..1c336ac64f 100644 --- a/src/components/application_manager/src/command_holder_impl.cc +++ b/src/components/application_manager/src/command_holder_impl.cc @@ -43,20 +43,23 @@ CommandHolderImpl::CommandHolderImpl(ApplicationManager& app_manager) void CommandHolderImpl::Suspend( ApplicationSharedPtr application, CommandType type, + commands::Command::CommandSource source, std::shared_ptr<smart_objects::SmartObject> command) { LOG4CXX_AUTO_TRACE(logger_); DCHECK_OR_RETURN_VOID(application); LOG4CXX_DEBUG(logger_, "Suspending command(s) for application: " << application->policy_app_id()); - sync_primitives::AutoLock lock(commands_lock_); + AppCommandInfo info = {command, source}; + + sync_primitives::AutoLock lock(commands_lock_); if (CommandType::kHmiCommand == type) { - app_hmi_commands_[application].push_back(command); + app_hmi_commands_[application].push_back(info); LOG4CXX_DEBUG(logger_, "Suspended HMI command(s): " << app_hmi_commands_.size()); } else { - app_mobile_commands_[application].push_back(command); + app_mobile_commands_[application].push_back(info); LOG4CXX_DEBUG( logger_, "Suspended mobile command(s): " << app_mobile_commands_.size()); @@ -113,8 +116,10 @@ void CommandHolderImpl::ResumeHmiCommand(ApplicationSharedPtr application) { "Resuming HMI command(s): " << app_hmi_commands_.size()); for (auto cmd : app_commands->second) { - (*cmd)[strings::msg_params][strings::app_id] = application->hmi_app_id(); - app_manager_.GetRPCService().ManageHMICommand(cmd); + (*cmd.command_ptr_)[strings::msg_params][strings::app_id] = + application->hmi_app_id(); + app_manager_.GetRPCService().ManageHMICommand(cmd.command_ptr_, + cmd.command_source_); } app_hmi_commands_.erase(app_commands); @@ -132,9 +137,10 @@ void CommandHolderImpl::ResumeMobileCommand(ApplicationSharedPtr application) { "Resuming mobile command(s): " << app_mobile_commands_.size()); for (auto cmd : app_commands->second) { - (*cmd)[strings::params][strings::connection_key] = application->app_id(); - app_manager_.GetRPCService().ManageMobileCommand( - cmd, commands::Command::CommandSource::SOURCE_MOBILE); + (*cmd.command_ptr_)[strings::params][strings::connection_key] = + application->app_id(); + app_manager_.GetRPCService().ManageMobileCommand(cmd.command_ptr_, + cmd.command_source_); } app_mobile_commands_.erase(app_commands); diff --git a/src/components/application_manager/src/rpc_service_impl.cc b/src/components/application_manager/src/rpc_service_impl.cc index e29edd8f59..67538fcaeb 100644 --- a/src/components/application_manager/src/rpc_service_impl.cc +++ b/src/components/application_manager/src/rpc_service_impl.cc @@ -130,7 +130,7 @@ bool RPCServiceImpl::ManageMobileCommand( if (app_ptr && app_manager_.IsAppInReconnectMode(app_ptr->device(), app_ptr->policy_app_id())) { commands_holder_.Suspend( - app_ptr, CommandHolder::CommandType::kMobileCommand, message); + app_ptr, CommandHolder::CommandType::kMobileCommand, source, message); return true; } mobile_apis::FunctionID::eType function_id = @@ -361,7 +361,7 @@ bool RPCServiceImpl::ManageHMICommand(const commands::MessageSharedPtr message, if (app && app_manager_.IsAppInReconnectMode(app->device(), app->policy_app_id())) { commands_holder_.Suspend( - app, CommandHolder::CommandType::kHmiCommand, message); + app, CommandHolder::CommandType::kHmiCommand, source, message); return true; } } diff --git a/src/components/application_manager/test/command_holder_test.cc b/src/components/application_manager/test/command_holder_test.cc index 8a5c639775..acde0bfd86 100644 --- a/src/components/application_manager/test/command_holder_test.cc +++ b/src/components/application_manager/test/command_holder_test.cc @@ -80,8 +80,10 @@ class CommandHolderImplTest : public testing::Test { TEST_F(CommandHolderImplTest, HoldOne_ExpectReleaseOne) { am::CommandHolderImpl cmd_holder(mock_app_manager_); - cmd_holder.Suspend( - mock_app_ptr_, am::CommandHolder::CommandType::kHmiCommand, cmd_ptr_); + cmd_holder.Suspend(mock_app_ptr_, + am::CommandHolder::CommandType::kHmiCommand, + am::commands::Command::CommandSource::SOURCE_HMI, + cmd_ptr_); // Act EXPECT_CALL(mock_rpc_service_, ManageHMICommand(cmd_ptr_, _)); @@ -93,8 +95,10 @@ TEST_F(CommandHolderImplTest, HoldMany_ExpectReleaseSame) { int32_t iterations = 0; do { - cmd_holder.Suspend( - mock_app_ptr_, am::CommandHolder::CommandType::kHmiCommand, cmd_ptr_); + cmd_holder.Suspend(mock_app_ptr_, + am::CommandHolder::CommandType::kHmiCommand, + am::commands::Command::CommandSource::SOURCE_HMI, + cmd_ptr_); ++iterations; } while (iterations < 5); @@ -106,10 +110,14 @@ TEST_F(CommandHolderImplTest, HoldMany_ExpectReleaseSame) { TEST_F(CommandHolderImplTest, Hold_Drop_ExpectNoReleased) { am::CommandHolderImpl cmd_holder(mock_app_manager_); - cmd_holder.Suspend( - mock_app_ptr_, am::CommandHolder::CommandType::kHmiCommand, cmd_ptr_); - cmd_holder.Suspend( - mock_app_ptr_, am::CommandHolder::CommandType::kHmiCommand, cmd_ptr_); + cmd_holder.Suspend(mock_app_ptr_, + am::CommandHolder::CommandType::kHmiCommand, + am::commands::Command::CommandSource::SOURCE_HMI, + cmd_ptr_); + cmd_holder.Suspend(mock_app_ptr_, + am::CommandHolder::CommandType::kHmiCommand, + am::commands::Command::CommandSource::SOURCE_HMI, + cmd_ptr_); // Act cmd_holder.Clear(mock_app_ptr_); @@ -119,10 +127,14 @@ TEST_F(CommandHolderImplTest, Hold_Drop_ExpectNoReleased) { TEST_F(CommandHolderImplTest, Hold_ReleaseAnotherId_ExpectNoReleased) { am::CommandHolderImpl cmd_holder(mock_app_manager_); - cmd_holder.Suspend( - mock_app_ptr_, am::CommandHolder::CommandType::kHmiCommand, cmd_ptr_); - cmd_holder.Suspend( - mock_app_ptr_, am::CommandHolder::CommandType::kHmiCommand, cmd_ptr_); + cmd_holder.Suspend(mock_app_ptr_, + am::CommandHolder::CommandType::kHmiCommand, + am::commands::Command::CommandSource::SOURCE_HMI, + cmd_ptr_); + cmd_holder.Suspend(mock_app_ptr_, + am::CommandHolder::CommandType::kHmiCommand, + am::commands::Command::CommandSource::SOURCE_HMI, + cmd_ptr_); // Act std::shared_ptr<MockApplication> another_app = @@ -137,8 +149,10 @@ TEST_F(CommandHolderImplTest, Hold_DropAnotherId_ExpectReleased) { int32_t iterations = 0; do { - cmd_holder.Suspend( - mock_app_ptr_, am::CommandHolder::CommandType::kHmiCommand, cmd_ptr_); + cmd_holder.Suspend(mock_app_ptr_, + am::CommandHolder::CommandType::kHmiCommand, + am::commands::Command::CommandSource::SOURCE_HMI, + cmd_ptr_); ++iterations; } while (iterations < 3); @@ -155,11 +169,15 @@ TEST_F(CommandHolderImplTest, Hold_DropAnotherId_ExpectReleased) { TEST_F(CommandHolderImplTest, Hold_Mobile_and_HMI_commands_ExpectReleased) { am::CommandHolderImpl cmd_holder(mock_app_manager_); - cmd_holder.Suspend( - mock_app_ptr_, am::CommandHolder::CommandType::kHmiCommand, cmd_ptr_); + cmd_holder.Suspend(mock_app_ptr_, + am::CommandHolder::CommandType::kHmiCommand, + am::commands::Command::CommandSource::SOURCE_HMI, + cmd_ptr_); - cmd_holder.Suspend( - mock_app_ptr_, am::CommandHolder::CommandType::kMobileCommand, cmd_ptr_); + cmd_holder.Suspend(mock_app_ptr_, + am::CommandHolder::CommandType::kMobileCommand, + am::commands::Command::CommandSource::SOURCE_MOBILE, + cmd_ptr_); // Act EXPECT_CALL(mock_rpc_service_, ManageHMICommand(cmd_ptr_, _)); diff --git a/src/components/include/application_manager/application_manager.h b/src/components/include/application_manager/application_manager.h index e4a0417e40..fa2e8941b8 100644 --- a/src/components/include/application_manager/application_manager.h +++ b/src/components/include/application_manager/application_manager.h @@ -120,6 +120,12 @@ typedef std::set<ApplicationSharedPtr, ApplicationsSorter> ApplicationSet; typedef std::set<ApplicationSharedPtr, ApplicationsPolicyAppIdSorter> AppsWaitRegistrationSet; +/** + * @brief ReregisterWaitList is list of applications expected to be + * re-registered after transport switching is complete + */ +typedef std::vector<ApplicationSharedPtr> ReregisterWaitList; + // typedef for Applications list iterator typedef ApplicationSet::iterator ApplicationSetIt; @@ -160,6 +166,7 @@ class ApplicationManager { virtual DataAccessor<ApplicationSet> applications() const = 0; virtual DataAccessor<AppsWaitRegistrationSet> pending_applications() const = 0; + virtual DataAccessor<ReregisterWaitList> reregister_applications() const = 0; virtual ApplicationSharedPtr application(uint32_t app_id) const = 0; virtual ApplicationSharedPtr active_application() const = 0; @@ -181,6 +188,9 @@ class ApplicationManager { virtual ApplicationSharedPtr pending_application_by_policy_id( const std::string& policy_app_id) const = 0; + virtual ApplicationSharedPtr reregister_application_by_policy_id( + const std::string& policy_app_id) const = 0; + virtual AppSharedPtrs applications_by_button(uint32_t button) = 0; virtual AppSharedPtrs applications_with_navi() = 0; diff --git a/src/components/include/test/application_manager/mock_application_manager.h b/src/components/include/test/application_manager/mock_application_manager.h index c05a082e5b..e533228656 100644 --- a/src/components/include/test/application_manager/mock_application_manager.h +++ b/src/components/include/test/application_manager/mock_application_manager.h @@ -80,6 +80,8 @@ class MockApplicationManager : public application_manager::ApplicationManager { MOCK_CONST_METHOD0( pending_applications, DataAccessor<application_manager::AppsWaitRegistrationSet>()); + MOCK_CONST_METHOD0(reregister_applications, + DataAccessor<application_manager::ReregisterWaitList>()); MOCK_CONST_METHOD1( application, application_manager::ApplicationSharedPtr(uint32_t app_id)); MOCK_CONST_METHOD0(active_application, @@ -111,6 +113,9 @@ class MockApplicationManager : public application_manager::ApplicationManager { MOCK_CONST_METHOD1(pending_application_by_policy_id, application_manager::ApplicationSharedPtr( const std::string& policy_app_id)); + MOCK_CONST_METHOD1(reregister_application_by_policy_id, + application_manager::ApplicationSharedPtr( + const std::string& policy_app_id)); MOCK_METHOD1( applications_by_button, std::vector<application_manager::ApplicationSharedPtr>(uint32_t button)); |