summaryrefslogtreecommitdiff
path: root/src/components/application_manager/rpc_plugins/sdl_rpc_plugin
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/application_manager/rpc_plugins/sdl_rpc_plugin')
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/update_device_list_request.h19
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/register_app_interface_request.h6
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/update_device_list_request.cc40
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc18
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/update_device_list_request_test.cc41
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/register_app_interface_request_test.cc21
6 files changed, 28 insertions, 117 deletions
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/update_device_list_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/update_device_list_request.h
index db4f265a9f..ed89bc73ec 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/update_device_list_request.h
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/update_device_list_request.h
@@ -46,8 +46,7 @@ namespace commands {
/**
* @brief UpdateDeviceListRequest command class
**/
-class UpdateDeviceListRequest : public app_mngr::commands::RequestToHMI,
- public app_mngr::event_engine::EventObserver {
+class UpdateDeviceListRequest : public app_mngr::commands::RequestToHMI {
public:
/**
* @brief UpdateDeviceListRequest class constructor
@@ -70,23 +69,7 @@ class UpdateDeviceListRequest : public app_mngr::commands::RequestToHMI,
**/
virtual void Run();
- /**
- * @brief Interface method that is called whenever new event received
- * Need to observe OnHMIReady event, to send UpdateDeviceListRequest
- * when HMI will be ready
- * @param event The received event
- */
- virtual void on_event(const app_mngr::event_engine::Event& event);
-
- /**
- * @brief Need to stop execution StopMethod if HMI did not started
- */
- virtual bool CleanUp();
-
private:
- sync_primitives::Lock wait_hmi_lock;
- sync_primitives::ConditionalVariable termination_condition_;
-
DISALLOW_COPY_AND_ASSIGN(UpdateDeviceListRequest);
};
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/register_app_interface_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/register_app_interface_request.h
index fae8f5eeb7..ae52caf0f7 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/register_app_interface_request.h
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/register_app_interface_request.h
@@ -261,12 +261,6 @@ class RegisterAppInterfaceRequest
const smart_objects::SmartObject& message);
/**
- * @brief WaitForHMIIsReady blocking function. Waits for HMI be ready for
- * requests processing
- */
- void WaitForHMIIsReady();
-
- /**
* @brief FillApplicationParams set app application attributes from the RAI
* request
* @param application applicaiton to fill params
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/update_device_list_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/update_device_list_request.cc
index c8aa295645..4d055564de 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/update_device_list_request.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/update_device_list_request.cc
@@ -53,51 +53,27 @@ UpdateDeviceListRequest::UpdateDeviceListRequest(
application_manager,
rpc_service,
hmi_capabilities,
- policy_handle)
- , EventObserver(application_manager_.event_dispatcher()) {}
+ policy_handle) {}
UpdateDeviceListRequest::~UpdateDeviceListRequest() {}
void UpdateDeviceListRequest::Run() {
SDL_LOG_AUTO_TRACE();
- sync_primitives::AutoLock auto_lock(wait_hmi_lock);
// Fix problem with SDL and HMI HTML. This problem is not actual for HMI PASA.
// Flag conditional compilation for specific customer is used in order to
// exclude
// hit code to RTC
- if (true == application_manager_.get_settings().launch_hmi()) {
- if (!application_manager_.IsHMICooperating()) {
- SDL_LOG_INFO("Wait for HMI Cooperation");
- subscribe_on_event(hmi_apis::FunctionID::BasicCommunication_OnReady);
- termination_condition_.Wait(auto_lock);
- SDL_LOG_DEBUG("HMI Cooperation OK");
+ if (application_manager_.get_settings().launch_hmi()) {
+ SDL_LOG_INFO("Wait for HMI Cooperation");
+ if (!application_manager_.WaitForHmiIsReady()) {
+ SDL_LOG_ERROR("HMI is not ready");
+ return;
}
- }
-
- SendRequest();
-}
-void UpdateDeviceListRequest::on_event(const event_engine::Event& event) {
- SDL_LOG_AUTO_TRACE();
- sync_primitives::AutoLock auto_lock(wait_hmi_lock);
- switch (event.id()) {
- case hmi_apis::FunctionID::BasicCommunication_OnReady: {
- SDL_LOG_INFO("received OnReady");
- unsubscribe_from_event(hmi_apis::FunctionID::BasicCommunication_OnReady);
- termination_condition_.Broadcast();
- break;
- };
- default: {
- SDL_LOG_ERROR("Unknown event " << event.id());
- break;
- };
+ SDL_LOG_DEBUG("HMI Cooperation is OK");
}
-}
-bool UpdateDeviceListRequest::CleanUp() {
- sync_primitives::AutoLock auto_lock(wait_hmi_lock);
- termination_condition_.Broadcast();
- return true;
+ SendRequest();
}
} // namespace commands
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 6ac830c378..920805be7c 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
@@ -159,18 +159,6 @@ uint32_t RegisterAppInterfaceRequest::default_timeout() const {
return 0;
}
-void RegisterAppInterfaceRequest::WaitForHMIIsReady() {
- while (!application_manager_.IsStopping() &&
- !application_manager_.IsHMICooperating()) {
- SDL_LOG_DEBUG("Waiting for the HMI... conn_key="
- << connection_key() << ", correlation_id=" << correlation_id()
- << ", default_timeout=" << default_timeout()
- << ", thread=" << pthread_self());
- sleep(1);
- // TODO(DK): timer_->StartWait(1);
- }
-}
-
void RegisterAppInterfaceRequest::FillApplicationParams(
ApplicationSharedPtr application) {
SDL_LOG_AUTO_TRACE();
@@ -488,10 +476,8 @@ void RegisterAppInterfaceRequest::Run() {
SDL_LOG_AUTO_TRACE();
SDL_LOG_DEBUG("Connection key is " << connection_key());
- WaitForHMIIsReady();
-
- if (application_manager_.IsStopping()) {
- SDL_LOG_WARN("The ApplicationManager is stopping!");
+ if (!application_manager_.WaitForHmiIsReady()) {
+ SDL_LOG_WARN("Failed to wait for HMI readiness");
return;
}
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/update_device_list_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/update_device_list_request_test.cc
index 31c03a7ed5..9760462d05 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/update_device_list_request_test.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/update_device_list_request_test.cc
@@ -92,10 +92,6 @@ class UpdateDeviceListRequestTest
TEST_F(UpdateDeviceListRequestTest, RUN_LaunchHMIReturnsFalse) {
MessageSharedPtr command_msg = CreateCommandMsg();
- EXPECT_CALL(app_mngr_, event_dispatcher())
- .WillOnce(ReturnRef(mock_event_dispatcher_));
- EXPECT_CALL(mock_event_dispatcher_, remove_observer(_));
-
UpdateDeviceListRequestPtr command(
CreateCommand<UpdateDeviceListRequest>(command_msg));
@@ -103,7 +99,7 @@ TEST_F(UpdateDeviceListRequestTest, RUN_LaunchHMIReturnsFalse) {
EXPECT_CALL(settings_, launch_hmi()).WillOnce(Return(false));
- EXPECT_CALL(app_mngr_, IsHMICooperating()).Times(0);
+ EXPECT_CALL(app_mngr_, WaitForHmiIsReady()).Times(0);
EXPECT_CALL(mock_rpc_service_, SendMessageToHMI(command_msg));
command->Run();
@@ -114,13 +110,9 @@ TEST_F(UpdateDeviceListRequestTest, RUN_LaunchHMIReturnsFalse) {
CommandImpl::protocol_version_);
}
-TEST_F(UpdateDeviceListRequestTest, RUN_HMICooperatingReturnsTrue_SUCCESSS) {
+TEST_F(UpdateDeviceListRequestTest, RUN_HMICooperatingReturnsTrue_SUCCESS) {
MessageSharedPtr command_msg = CreateCommandMsg();
- EXPECT_CALL(app_mngr_, event_dispatcher())
- .WillOnce(ReturnRef(mock_event_dispatcher_));
- EXPECT_CALL(mock_event_dispatcher_, remove_observer(_));
-
UpdateDeviceListRequestPtr command(
CreateCommand<UpdateDeviceListRequest>(command_msg));
@@ -128,7 +120,7 @@ TEST_F(UpdateDeviceListRequestTest, RUN_HMICooperatingReturnsTrue_SUCCESSS) {
EXPECT_CALL(settings_, launch_hmi()).WillOnce(Return(true));
- EXPECT_CALL(app_mngr_, IsHMICooperating()).WillOnce(Return(true));
+ EXPECT_CALL(app_mngr_, WaitForHmiIsReady()).WillOnce(Return(true));
EXPECT_CALL(mock_rpc_service_, SendMessageToHMI(command_msg));
command->Run();
@@ -139,29 +131,20 @@ TEST_F(UpdateDeviceListRequestTest, RUN_HMICooperatingReturnsTrue_SUCCESSS) {
CommandImpl::protocol_version_);
}
-TEST_F(UpdateDeviceListRequestTest, OnEvent_WrongEventId_UNSUCCESS) {
- Event event(Event::EventID::INVALID_ENUM);
-
- EXPECT_CALL(app_mngr_, event_dispatcher())
- .WillOnce(ReturnRef(mock_event_dispatcher_));
- EXPECT_CALL(mock_event_dispatcher_, remove_observer(_));
-
- UpdateDeviceListRequestPtr command(CreateCommand<UpdateDeviceListRequest>());
+TEST_F(UpdateDeviceListRequestTest, RUN_HMICooperatingReturnsFalse_UNSUCCESS) {
+ MessageSharedPtr command_msg = CreateCommandMsg();
- command->on_event(event);
-}
+ UpdateDeviceListRequestPtr command(
+ CreateCommand<UpdateDeviceListRequest>(command_msg));
-TEST_F(UpdateDeviceListRequestTest, OnEvent_SUCCESS) {
- Event event(Event::EventID::BasicCommunication_OnReady);
+ EXPECT_CALL(app_mngr_, get_settings()).WillOnce(ReturnRef(settings_));
- EXPECT_CALL(app_mngr_, event_dispatcher())
- .WillOnce(ReturnRef(mock_event_dispatcher_));
- EXPECT_CALL(mock_event_dispatcher_, remove_observer(_, _));
- EXPECT_CALL(mock_event_dispatcher_, remove_observer(_));
+ EXPECT_CALL(settings_, launch_hmi()).WillOnce(Return(true));
- UpdateDeviceListRequestPtr command(CreateCommand<UpdateDeviceListRequest>());
+ EXPECT_CALL(app_mngr_, WaitForHmiIsReady()).WillOnce(Return(false));
+ EXPECT_CALL(mock_rpc_service_, SendMessageToHMI(_)).Times(0);
- command->on_event(event);
+ command->Run();
}
} // namespace update_device_list_request
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 fab648fc95..4572a6d907 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
@@ -198,7 +198,7 @@ class RegisterAppInterfaceRequestTest
void InitGetters() {
ON_CALL(app_mngr_, GetCorrectMobileIDFromMessage(msg_))
.WillByDefault(Return(kAppId1));
- ON_CALL(app_mngr_, IsHMICooperating()).WillByDefault(Return(true));
+ ON_CALL(app_mngr_, WaitForHmiIsReady()).WillByDefault(Return(true));
ON_CALL(app_mngr_, resume_controller())
.WillByDefault(ReturnRef(mock_resume_crt_));
ON_CALL(app_mngr_, connection_handler())
@@ -416,11 +416,7 @@ TEST_F(RegisterAppInterfaceRequestTest, DefaultTimeout_CheckIfZero_SUCCESS) {
TEST_F(RegisterAppInterfaceRequestTest, Run_MinimalData_SUCCESS) {
InitBasicMessage();
(*msg_)[am::strings::msg_params][am::strings::hash_id] = kAppId1;
- EXPECT_CALL(app_mngr_, IsStopping())
- .WillOnce(Return(false))
- .WillOnce(Return(true))
- .WillOnce(Return(false));
- ON_CALL(app_mngr_, IsHMICooperating()).WillByDefault(Return(false));
+ EXPECT_CALL(app_mngr_, WaitForHmiIsReady()).WillOnce(Return(true));
EXPECT_CALL(app_mngr_, IsApplicationForbidden(_, _)).WillOnce(Return(false));
ON_CALL(mock_connection_handler_,
@@ -504,11 +500,7 @@ TEST_F(RegisterAppInterfaceRequestTest,
Run_HmiInterfacesStateAvailable_SUCCESS) {
InitBasicMessage();
- EXPECT_CALL(app_mngr_, IsStopping())
- .WillOnce(Return(false))
- .WillOnce(Return(true))
- .WillOnce(Return(false));
- ON_CALL(app_mngr_, IsHMICooperating()).WillByDefault(Return(false));
+ ON_CALL(app_mngr_, WaitForHmiIsReady()).WillByDefault(Return(true));
EXPECT_CALL(app_mngr_, IsApplicationForbidden(_, _)).WillOnce(Return(false));
ON_CALL(mock_connection_handler_,
@@ -808,11 +800,8 @@ TEST_F(RegisterAppInterfaceRequestTest,
InitBasicMessage();
(*msg_)[am::strings::params][am::strings::connection_key] = kConnectionKey2;
- EXPECT_CALL(app_mngr_, IsStopping())
- .WillOnce(Return(false))
- .WillOnce(Return(true))
- .WillOnce(Return(false));
- ON_CALL(app_mngr_, IsHMICooperating()).WillByDefault(Return(false));
+
+ ON_CALL(app_mngr_, WaitForHmiIsReady()).WillByDefault(Return(true));
EXPECT_CALL(app_mngr_, IsApplicationForbidden(kConnectionKey2, kAppId1))
.WillOnce(Return(false));