summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlha Vorobiova (GitHub) <86727408+OlhaVorobiova@users.noreply.github.com>2022-06-21 02:40:00 +0200
committerGitHub <noreply@github.com>2022-06-20 20:40:00 -0400
commit546e0528e7847ef4adb148d01813faf51c57cbed (patch)
treebb93b93ead89445eba3844744f811caa1b9d72da
parentba3e91d409312da7ebe8c352fcfba12b120927dc (diff)
downloadsdl_core-546e0528e7847ef4adb148d01813faf51c57cbed.tar.gz
Move subscribe_on_event before sending BCActivateAppRequest (#3915)
-rw-r--r--src/components/application_manager/include/application_manager/state_controller_impl.h7
-rw-r--r--src/components/application_manager/src/state_controller_impl.cc34
-rw-r--r--src/components/application_manager/test/state_controller/state_controller_test.cc6
3 files changed, 23 insertions, 24 deletions
diff --git a/src/components/application_manager/include/application_manager/state_controller_impl.h b/src/components/application_manager/include/application_manager/state_controller_impl.h
index 6845851f97..e0200f55af 100644
--- a/src/components/application_manager/include/application_manager/state_controller_impl.h
+++ b/src/components/application_manager/include/application_manager/state_controller_impl.h
@@ -136,9 +136,10 @@ class StateControllerImpl : public event_engine::EventObserver,
PostponedActivationController& GetPostponedActivationController() OVERRIDE;
private:
- int64_t RequestHMIStateChange(ApplicationConstSharedPtr app,
- hmi_apis::Common_HMILevel::eType level,
- bool send_policy_priority);
+ void RequestHMIStateChange(ApplicationConstSharedPtr app,
+ HmiStatePtr resolved_state,
+ hmi_apis::Common_HMILevel::eType level,
+ bool send_policy_priority);
/**
* @brief The HmiLevelConflictResolver struct
diff --git a/src/components/application_manager/src/state_controller_impl.cc b/src/components/application_manager/src/state_controller_impl.cc
index 28146a1adc..9880edb4a1 100644
--- a/src/components/application_manager/src/state_controller_impl.cc
+++ b/src/components/application_manager/src/state_controller_impl.cc
@@ -112,20 +112,7 @@ void StateControllerImpl::SetRegularState(ApplicationSharedPtr app,
resolved_state->hmi_level());
if (request_hmi_state_change) {
- const int64_t result = RequestHMIStateChange(app, hmi_level, true);
- if (-1 != result) {
- const uint32_t corr_id = static_cast<uint32_t>(result);
-
- subscribe_on_event(
- hmi_apis::FunctionID::BasicCommunication_CloseApplication, corr_id);
- subscribe_on_event(hmi_apis::FunctionID::BasicCommunication_ActivateApp,
- corr_id);
-
- waiting_for_response_[app->app_id()] = resolved_state;
- app_mngr_.set_application_id(corr_id, app->hmi_app_id());
- return;
- }
- SDL_LOG_ERROR("Unable to send BC.ActivateApp");
+ RequestHMIStateChange(app, resolved_state, hmi_level, true);
return;
}
ApplyRegularState(app, window_id, resolved_state);
@@ -1104,8 +1091,9 @@ void StateControllerImpl::OnAppWindowAdded(
OnStateChanged(app, window_id, initial_state, new_state);
}
-int64_t StateControllerImpl::RequestHMIStateChange(
+void StateControllerImpl::RequestHMIStateChange(
ApplicationConstSharedPtr app,
+ HmiStatePtr resolved_state,
hmi_apis::Common_HMILevel::eType level,
bool send_policy_priority) {
SDL_LOG_AUTO_TRACE();
@@ -1122,15 +1110,21 @@ int64_t StateControllerImpl::RequestHMIStateChange(
}
if (!request) {
SDL_LOG_ERROR("Unable to create request");
- return -1;
+ return;
}
+
+ const uint32_t corr_id =
+ (*request)[strings::params][strings::correlation_id].asUInt();
+ subscribe_on_event(hmi_apis::FunctionID::BasicCommunication_CloseApplication,
+ corr_id);
+ subscribe_on_event(hmi_apis::FunctionID::BasicCommunication_ActivateApp,
+ corr_id);
+ waiting_for_response_[app->app_id()] = resolved_state;
+ app_mngr_.set_application_id(corr_id, app->hmi_app_id());
+
if (!app_mngr_.GetRPCService().ManageHMICommand(request)) {
SDL_LOG_ERROR("Unable to send request");
- return -1;
}
- const uint32_t corr_id =
- (*request)[strings::params][strings::correlation_id].asUInt();
- return static_cast<int64_t>(corr_id);
}
void StateControllerImpl::ApplyPostponedStateForApp(ApplicationSharedPtr app) {
diff --git a/src/components/application_manager/test/state_controller/state_controller_test.cc b/src/components/application_manager/test/state_controller/state_controller_test.cc
index b6ec4fc8ef..f255223136 100644
--- a/src/components/application_manager/test/state_controller/state_controller_test.cc
+++ b/src/components/application_manager/test/state_controller/state_controller_test.cc
@@ -3654,7 +3654,11 @@ TEST_F(StateControllerImplTest,
static_cast<hmi_apis::Common_HMILevel::eType>(new_state->hmi_level()),
kCorrID);
- smart_objects::SmartObjectSPtr bc_activate_app_request;
+ smart_objects::SmartObjectSPtr bc_activate_app_request =
+ std::make_shared<smart_objects::SmartObject>();
+ (*bc_activate_app_request)[am::strings::params][am::strings::correlation_id] =
+ kCorrID;
+
EXPECT_CALL(message_helper_mock_, GetBCActivateAppRequestToHMI(_, _, _, _, _))
.WillOnce(Return(bc_activate_app_request));
EXPECT_CALL(*simple_app_ptr_, SetRegularState(_, _)).Times(0);