summaryrefslogtreecommitdiff
path: root/src/components/application_manager/src/application_manager_impl.cc
diff options
context:
space:
mode:
authorYana Chernysheva <ychernysheva@luxoft.com>2020-10-02 12:31:39 +0300
committerYana Chernysheva <ychernysheva@luxoft.com>2020-10-02 12:31:39 +0300
commit140f0aa5b8f6055c00c241f3d87a96003a076dc8 (patch)
treeef9521763835ea3bd0c3616e53144d382c32eb60 /src/components/application_manager/src/application_manager_impl.cc
parent430a53ff60c340b8ec0eb030ce613cb9750134c7 (diff)
parent18bd4d7ee7d50ff006287b88eb851c8119f1b1fa (diff)
downloadsdl_core-140f0aa5b8f6055c00c241f3d87a96003a076dc8.tar.gz
Merge branch 'release/7.0.0' into fix/move_duplicate_conversion_functions_to_message_helper
Diffstat (limited to 'src/components/application_manager/src/application_manager_impl.cc')
-rw-r--r--src/components/application_manager/src/application_manager_impl.cc70
1 files changed, 33 insertions, 37 deletions
diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc
index 8d4d2c8bec..4a206e19cd 100644
--- a/src/components/application_manager/src/application_manager_impl.cc
+++ b/src/components/application_manager/src/application_manager_impl.cc
@@ -229,7 +229,7 @@ ApplicationManagerImpl::ApplicationManagerImpl(
ApplicationManagerImpl::~ApplicationManagerImpl() {
SDL_LOG_AUTO_TRACE();
- is_stopping_ = true;
+ is_stopping_.store(true);
SendOnSDLClose();
media_manager_ = NULL;
hmi_handler_ = NULL;
@@ -693,9 +693,9 @@ ApplicationSharedPtr ApplicationManagerImpl::RegisterApplication(
bool is_mismatched_cloud_app = false;
if (apps_to_register_.end() == it) {
- DevicePredicate finder(application->device());
+ DevicePredicate device_finder(application->device());
it = std::find_if(
- apps_to_register_.begin(), apps_to_register_.end(), finder);
+ apps_to_register_.begin(), apps_to_register_.end(), device_finder);
bool found = apps_to_register_.end() != it;
is_mismatched_cloud_app = found && (*it)->is_cloud_app() &&
@@ -1218,10 +1218,13 @@ void ApplicationManagerImpl::CreatePendingApplication(
application->set_hybrid_app_preference(hybrid_app_preference_enum);
application->set_cloud_app_certificate(app_properties.certificate);
- sync_primitives::AutoLock lock(apps_to_register_list_lock_ptr_);
- SDL_LOG_DEBUG("apps_to_register_ size before: " << apps_to_register_.size());
- apps_to_register_.insert(application);
- SDL_LOG_DEBUG("apps_to_register_ size after: " << apps_to_register_.size());
+ {
+ sync_primitives::AutoLock lock(apps_to_register_list_lock_ptr_);
+ SDL_LOG_DEBUG(
+ "apps_to_register_ size before: " << apps_to_register_.size());
+ apps_to_register_.insert(application);
+ SDL_LOG_DEBUG("apps_to_register_ size after: " << apps_to_register_.size());
+ }
SendUpdateAppList();
}
@@ -1345,10 +1348,8 @@ void ApplicationManagerImpl::SetPendingApplicationState(
app->app_id(), mobile_apis::Result::INVALID_ENUM, true, true);
app->MarkUnregistered();
- {
- sync_primitives::AutoLock lock(apps_to_register_list_lock_ptr_);
- apps_to_register_.insert(app);
- }
+ sync_primitives::AutoLock lock(apps_to_register_list_lock_ptr_);
+ apps_to_register_.insert(app);
}
void ApplicationManagerImpl::OnConnectionStatusUpdated() {
@@ -1639,11 +1640,14 @@ void ApplicationManagerImpl::SendUpdateAppList() {
(*request)[strings::msg_params][strings::applications] =
SmartObject(SmartType_Array);
- SmartObject& applications =
+ SmartObject& applications_so =
(*request)[strings::msg_params][strings::applications];
- PrepareApplicationListSO(applications_, applications, *this);
- PrepareApplicationListSO(apps_to_register_, applications, *this);
+ const auto applications_list = applications().GetData();
+ PrepareApplicationListSO(applications_list, applications_so, *this);
+
+ const auto pending_apps_list = AppsWaitingForRegistration().GetData();
+ PrepareApplicationListSO(pending_apps_list, applications_so, *this);
rpc_service_->ManageHMICommand(request);
}
@@ -1891,8 +1895,8 @@ bool ApplicationManagerImpl::StartNaviService(
/* Fix: For NaviApp1 Switch to NaviApp2, App1's Endcallback() arrives
later than App2's Startcallback(). Cause streaming issue on HMI.
*/
- sync_primitives::AutoLock lock(applications_list_lock_ptr_);
- for (auto app : applications_) {
+ auto accessor = applications();
+ for (auto app : accessor.GetData()) {
if (!app || (!app->is_navi() && !app->mobile_projection_enabled())) {
SDL_LOG_DEBUG("Continue, Not Navi App Id: " << app->app_id());
continue;
@@ -2534,9 +2538,7 @@ bool ApplicationManagerImpl::Init(
bool ApplicationManagerImpl::Stop() {
SDL_LOG_AUTO_TRACE();
- stopping_application_mng_lock_.Acquire();
- is_stopping_ = true;
- stopping_application_mng_lock_.Release();
+ is_stopping_.store(true);
application_list_update_timer_.Stop();
try {
if (unregister_reason_ ==
@@ -2861,6 +2863,7 @@ void ApplicationManagerImpl::ProcessQueryApp(
CreateApplications(*obj_array, connection_key);
SendUpdateAppList();
+ sync_primitives::AutoLock lock(apps_to_register_list_lock_ptr_);
AppsWaitRegistrationSet::const_iterator it = apps_to_register_.begin();
for (; it != apps_to_register_.end(); ++it) {
const std::string full_icon_path((*it)->app_icon_path());
@@ -2959,9 +2962,7 @@ void ApplicationManagerImpl::SetUnregisterAllApplicationsReason(
void ApplicationManagerImpl::HeadUnitReset(
mobile_api::AppInterfaceUnregisteredReason::eType reason) {
SDL_LOG_AUTO_TRACE();
- stopping_application_mng_lock_.Acquire();
- is_stopping_ = true;
- stopping_application_mng_lock_.Release();
+ is_stopping_.store(true);
switch (reason) {
case mobile_api::AppInterfaceUnregisteredReason::MASTER_RESET: {
SDL_LOG_TRACE("Performing MASTER_RESET");
@@ -3081,11 +3082,11 @@ void ApplicationManagerImpl::UnregisterAllApplications() {
SDL_LOG_DEBUG("Unregister reason " << unregister_reason_);
SetHMICooperating(false);
- bool is_ignition_off = false;
+
using namespace mobile_api::AppInterfaceUnregisteredReason;
using namespace helpers;
- is_ignition_off =
+ bool is_ignition_off =
Compare<eType, EQ, ONE>(unregister_reason_, IGNITION_OFF, INVALID_ENUM);
bool is_unexpected_disconnect = Compare<eType, NEQ, ALL>(
@@ -3297,7 +3298,8 @@ void ApplicationManagerImpl::UnregisterApplication(
plugin_manager_->ForEachPlugin(on_app_unregistered);
request_ctrl_.terminateAppRequests(app_id);
- if (applications_.empty()) {
+ const bool is_applications_list_empty = applications().GetData().empty();
+ if (is_applications_list_empty) {
policy_handler_->StopRetrySequence();
}
return;
@@ -3367,7 +3369,6 @@ mobile_apis::Result::eType ApplicationManagerImpl::CheckPolicyPermissions(
}
bool ApplicationManagerImpl::is_stopping() const {
- sync_primitives::AutoLock lock(stopping_application_mng_lock_);
return is_stopping_;
}
@@ -3844,9 +3845,7 @@ bool ApplicationManagerImpl::ResetVrHelpTitleItems(
}
const std::string& vr_help_title = get_settings().vr_help_title();
- smart_objects::SmartObject so_vr_help_title =
- smart_objects::SmartObject(smart_objects::SmartType_String);
- so_vr_help_title = vr_help_title;
+ smart_objects::SmartObject so_vr_help_title(vr_help_title);
app->reset_vr_help_title();
app->reset_vr_help();
@@ -4103,9 +4102,7 @@ void ApplicationManagerImpl::OnApplicationListUpdateTimer() {
const bool is_new_app_registered = registered_during_timer_execution_;
registered_during_timer_execution_ = false;
- apps_to_register_list_lock_ptr_->Acquire();
- const bool trigger_ptu = apps_size_ != applications_.size();
- apps_to_register_list_lock_ptr_->Release();
+ const bool trigger_ptu = apps_size_ != applications().GetData().size();
if (is_new_app_registered) {
SendUpdateAppList();
@@ -4317,7 +4314,7 @@ void ApplicationManagerImpl::OnUpdateHMIAppType(
std::vector<std::string> hmi_types_from_policy;
smart_objects::SmartObject transform_app_hmi_types(
smart_objects::SmartType_Array);
- bool flag_diffirence_app_hmi_type = false;
+ bool flag_diffirence_app_hmi_type;
DataAccessor<ApplicationSet> accessor(applications());
for (ApplicationSetIt it = accessor.GetData().begin();
it != accessor.GetData().end();
@@ -4326,7 +4323,6 @@ void ApplicationManagerImpl::OnUpdateHMIAppType(
if (it_app_hmi_types_from_policy != app_hmi_types.end() &&
((it_app_hmi_types_from_policy->second).size())) {
- flag_diffirence_app_hmi_type = false;
hmi_types_from_policy = (it_app_hmi_types_from_policy->second);
if (transform_app_hmi_types.length()) {
@@ -4548,7 +4544,6 @@ void ApplicationManagerImpl::SendGetIconUrlNotifications(
continue;
}
- std::string endpoint = app_icon_it->second.endpoint;
bool pending_request = app_icon_it->second.pending_request;
if (pending_request) {
@@ -4879,7 +4874,7 @@ void ApplicationManagerImpl::SetMockMediaManager(
#endif // BUILD_TESTS
struct MobileAppIdPredicate {
std::string policy_app_id_;
- MobileAppIdPredicate(const std::string& policy_app_id)
+ explicit MobileAppIdPredicate(const std::string& policy_app_id)
: policy_app_id_(policy_app_id) {}
bool operator()(const ApplicationSharedPtr app) const {
return app ? policy_app_id_ == app->policy_app_id() : false;
@@ -4888,7 +4883,8 @@ struct MobileAppIdPredicate {
struct TakeDeviceHandle {
public:
- TakeDeviceHandle(const ApplicationManager& app_mngr) : app_mngr_(app_mngr) {}
+ explicit TakeDeviceHandle(const ApplicationManager& app_mngr)
+ : app_mngr_(app_mngr) {}
std::string operator()(ApplicationSharedPtr& app) {
DCHECK_OR_RETURN(app, "");
return MessageHelper::GetDeviceMacAddressForHandle(app->device(),