summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShobhitAd <adlakhashobhit@gmail.com>2020-09-17 13:57:25 -0400
committerShobhitAd <adlakhashobhit@gmail.com>2020-09-17 13:57:25 -0400
commit83ae6548f65454a784554fbff5823d12af519e7b (patch)
tree5b4b6b4ecca82364b7cae3ffdbbd92b2bbbf1885
parent6b72fbf8dab880467e2278e0bfdbda0b855b3b97 (diff)
downloadsdl_core-83ae6548f65454a784554fbff5823d12af519e7b.tar.gz
Address review comments
-rw-r--r--src/components/application_manager/include/application_manager/state_controller_impl.h3
-rw-r--r--src/components/application_manager/src/state_controller_impl.cc42
2 files changed, 27 insertions, 18 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 745bcd03fd..210ddf9720 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
@@ -431,7 +431,8 @@ class StateControllerImpl : public event_engine::EventObserver,
typedef std::list<WindowStatePair> WindowStatePairs;
std::map<uint32_t, WindowStatePairs> postponed_app_widgets_;
- std::unordered_set<uint32_t> pending_hmistatus_notification_apps_;
+ std::unordered_set<uint32_t> apps_with_pending_hmistatus_notification_;
+ mutable sync_primitives::Lock apps_with_pending_hmistatus_notification_lock_;
ApplicationManager& app_mngr_;
};
} // namespace application_manager
diff --git a/src/components/application_manager/src/state_controller_impl.cc b/src/components/application_manager/src/state_controller_impl.cc
index 47876f9bb6..7c9b7b5ffc 100644
--- a/src/components/application_manager/src/state_controller_impl.cc
+++ b/src/components/application_manager/src/state_controller_impl.cc
@@ -730,21 +730,25 @@ void StateControllerImpl::on_event(const event_engine::MobileEvent& event) {
SDL_LOG_WARN("Application doesn't exist");
return;
}
+ {
+ sync_primitives::AutoLock autolock(
+ apps_with_pending_hmistatus_notification_lock_);
+
+ auto it = apps_with_pending_hmistatus_notification_.find(app->app_id());
+ if (it == apps_with_pending_hmistatus_notification_.end()) {
+ SDL_LOG_WARN("Application does not have a pending OnHMIStatus");
+ return;
+ }
- auto it = pending_hmistatus_notification_apps_.find(app->app_id());
- if (it == pending_hmistatus_notification_apps_.end()) {
- SDL_LOG_WARN("Application does not have a pending OnHMIStatus");
- return;
- }
- auto notification = MessageHelper::CreateHMIStatusNotification(app, 0);
- app_mngr_.GetRPCService().ManageMobileCommand(
- notification, commands::Command::SOURCE_SDL);
+ auto notification = MessageHelper::CreateHMIStatusNotification(app, 0);
+ app_mngr_.GetRPCService().ManageMobileCommand(
+ notification, commands::Command::SOURCE_SDL);
- pending_hmistatus_notification_apps_.erase(app->app_id());
- if (pending_hmistatus_notification_apps_.empty()) {
- unsubscribe_from_event(FunctionID::RegisterAppInterfaceID);
+ apps_with_pending_hmistatus_notification_.erase(app->app_id());
+ if (apps_with_pending_hmistatus_notification_.empty()) {
+ unsubscribe_from_event(FunctionID::RegisterAppInterfaceID);
+ }
}
-
} break;
default:
@@ -866,8 +870,8 @@ void StateControllerImpl::ActivateDefaultWindow(ApplicationSharedPtr app) {
SetRegularState(app, window_id, hmi_level, audio_state, video_state, false);
- // After main window activation, streaming state should be updated for another
- // windows of the app
+ // After main window activation, streaming state should be updated for
+ // another windows of the app
HmiStatePtr new_state =
app->RegularHmiState(PredefinedWindows::DEFAULT_WINDOW);
UpdateAppWindowsStreamingState(app, new_state);
@@ -920,7 +924,11 @@ void StateControllerImpl::OnStateChanged(ApplicationSharedPtr app,
"Application "
<< app->app_id()
<< " not ready to receive OnHMIStatus. Delaying notification");
- pending_hmistatus_notification_apps_.insert(app->app_id());
+ {
+ sync_primitives::AutoLock autolock(
+ apps_with_pending_hmistatus_notification_lock_);
+ apps_with_pending_hmistatus_notification_.insert(app->app_id());
+ }
subscribe_on_event(mobile_apis::FunctionID::RegisterAppInterfaceID);
}
if (mobile_apis::PredefinedWindows::DEFAULT_WINDOW != window_id) {
@@ -1265,8 +1273,8 @@ void StateControllerImpl::OnAppDeactivated(
return;
}
- // TODO(AOleynik): Need to delete DeactivateReason and modify OnAppDeactivated
- // when HMI will support that, otherwise won't be testable
+ // TODO(AOleynik): Need to delete DeactivateReason and modify
+ // OnAppDeactivated when HMI will support that, otherwise won't be testable
DeactivateApp(app, window_id);
}