summaryrefslogtreecommitdiff
path: root/src/components/application_manager/src/application_manager_impl.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/application_manager/src/application_manager_impl.cc')
-rw-r--r--src/components/application_manager/src/application_manager_impl.cc99
1 files changed, 67 insertions, 32 deletions
diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc
index 8044e8b6cd..6187a6daba 100644
--- a/src/components/application_manager/src/application_manager_impl.cc
+++ b/src/components/application_manager/src/application_manager_impl.cc
@@ -295,13 +295,6 @@ ApplicationSharedPtr ApplicationManagerImpl::application_by_policy_id(
return FindApp(accessor, finder);
}
-ApplicationSharedPtr ApplicationManagerImpl::application_by_name(
- const std::string& app_name) const {
- AppNamePredicate finder(app_name);
- DataAccessor<ApplicationSet> accessor = applications();
- return FindApp(accessor, finder);
-}
-
ApplicationSharedPtr ApplicationManagerImpl::pending_application_by_policy_id(
const std::string& policy_app_id) const {
PolicyAppIdPredicate finder(policy_app_id);
@@ -309,6 +302,13 @@ ApplicationSharedPtr ApplicationManagerImpl::pending_application_by_policy_id(
return FindPendingApp(accessor, finder);
}
+ApplicationSharedPtr ApplicationManagerImpl::application_by_name(
+ const std::string& app_name) const {
+ AppNamePredicate finder(app_name);
+ DataAccessor<ApplicationSet> accessor = applications();
+ return FindApp(accessor, finder);
+}
+
ApplicationSharedPtr
ApplicationManagerImpl::reregister_application_by_policy_id(
const std::string& policy_app_id) const {
@@ -327,6 +327,20 @@ ApplicationSharedPtr ApplicationManagerImpl::active_application() const {
return FindApp(accessor, ActiveAppPredicate);
}
+bool FullOrLimitedAppPredicate(const ApplicationSharedPtr app) {
+ return app ? app->IsFullscreen() ||
+ app->hmi_level(
+ mobile_api::PredefinedWindows::DEFAULT_WINDOW) ==
+ mobile_api::HMILevel::HMI_LIMITED
+ : false;
+}
+
+ApplicationSharedPtr ApplicationManagerImpl::get_full_or_limited_application()
+ const {
+ DataAccessor<ApplicationSet> accessor = applications();
+ return FindApp(accessor, FullOrLimitedAppPredicate);
+}
+
bool LimitedAppPredicate(const ApplicationSharedPtr app) {
return app ? app->hmi_level(mobile_api::PredefinedWindows::DEFAULT_WINDOW) ==
mobile_api::HMILevel::HMI_LIMITED
@@ -406,6 +420,13 @@ ApplicationManagerImpl::applications_by_button(uint32_t button) {
return FindAllApps(accessor, finder);
}
+std::vector<ApplicationSharedPtr> ApplicationManagerImpl::applications_by_name(
+ const std::string& app_name) const {
+ AppNamePredicate finder(app_name);
+ DataAccessor<ApplicationSet> accessor = applications();
+ return FindAllApps(accessor, finder);
+}
+
struct IsApplication {
IsApplication(connection_handler::DeviceHandle device_handle,
const std::string& policy_app_id)
@@ -434,12 +455,6 @@ void ApplicationManagerImpl::OnApplicationRegistered(ApplicationSharedPtr app) {
sync_primitives::AutoLock lock(applications_list_lock_ptr_);
const mobile_apis::HMILevel::eType default_level = GetDefaultHmiLevel(app);
state_ctrl_.OnApplicationRegistered(app, default_level);
-
- std::function<void(plugin_manager::RPCPlugin&)> on_app_registered =
- [app](plugin_manager::RPCPlugin& plugin) {
- plugin.OnApplicationEvent(plugin_manager::kApplicationRegistered, app);
- };
- plugin_manager_->ForEachPlugin(on_app_registered);
}
void ApplicationManagerImpl::OnApplicationSwitched(ApplicationSharedPtr app) {
@@ -729,14 +744,7 @@ ApplicationSharedPtr ApplicationManagerImpl::RegisterApplication(
// Timer will be started after hmi level resumption.
resume_controller().OnAppRegistrationStart(policy_app_id, device_mac);
- // Add application to registered app list and set appropriate mark.
- // Lock has to be released before adding app to policy DB to avoid possible
- // deadlock with simultaneous PTU processing
- applications_list_lock_ptr_->Acquire();
- application->MarkRegistered();
- applications_.insert(application);
- apps_size_ = applications_.size();
- applications_list_lock_ptr_->Release();
+ AddAppToRegisteredAppList(application);
// Update cloud app information, in case any pending apps are unable to be
// registered due to a mobile app taking precedence
@@ -1025,15 +1033,23 @@ void ApplicationManagerImpl::RefreshCloudAppInformation() {
} else if (mobile_apis::HybridAppPreference::MOBILE ==
hybrid_app_preference) {
auto nickname_it = nicknames.begin();
+ bool duplicate_found = false;
for (; nickname_it != nicknames.end(); ++nickname_it) {
- auto app = application_by_name(*nickname_it);
- if (app.use_count() != 0) {
- LOG4CXX_ERROR(
- logger_,
- "Mobile app already registered for cloud app: " << *nickname_it);
- continue;
+ auto apps = applications_by_name(*nickname_it);
+ for (auto app : apps) {
+ if (app.use_count() != 0 && !app->is_cloud_app()) {
+ LOG4CXX_ERROR(logger_,
+ "Mobile app already registered for cloud app: "
+ << *nickname_it);
+ duplicate_found = true;
+ break;
+ }
}
}
+
+ if (duplicate_found) {
+ continue;
+ }
}
pending_device_map_.insert(
@@ -3129,13 +3145,10 @@ void ApplicationManagerImpl::UnregisterApplication(
"There is no more SDL4 apps with device handle: " << handle);
RemoveAppsWaitingForRegistration(handle);
- RefreshCloudAppInformation();
- SendUpdateAppList();
- } else if (app_to_remove->is_cloud_app()) {
- RefreshCloudAppInformation();
- SendUpdateAppList();
}
}
+ RefreshCloudAppInformation();
+ SendUpdateAppList();
}
commands_holder_->Clear(app_to_remove);
@@ -4176,6 +4189,28 @@ ApplicationManagerImpl::SupportedSDLVersion() const {
get_settings().max_supported_protocol_version());
}
+void ApplicationManagerImpl::AddAppToRegisteredAppList(
+ const ApplicationSharedPtr application) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ DCHECK_OR_RETURN_VOID(application);
+ sync_primitives::AutoLock lock(applications_list_lock_ptr_);
+
+ // Add application to registered app list and set appropriate mark.
+ application->MarkRegistered();
+ applications_.insert(application);
+ LOG4CXX_DEBUG(
+ logger_,
+ "App with app_id: " << application->app_id()
+ << " has been added to registered applications list");
+ apps_size_ = static_cast<uint32_t>(applications_.size());
+}
+
+void ApplicationManagerImpl::ApplyFunctorForEachPlugin(
+ std::function<void(plugin_manager::RPCPlugin&)> functor) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ plugin_manager_->ForEachPlugin(functor);
+}
+
event_engine::EventDispatcher& ApplicationManagerImpl::event_dispatcher() {
return event_dispatcher_;
}