summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsniukalov <sniukalov@luxoft.com>2019-06-26 09:54:43 +0300
committersniukalov <sniukalov@luxoft.com>2019-08-14 14:59:40 +0300
commit952dfe04bc48c01cfdde183783b4610da83728c3 (patch)
tree65ef8163682aadbbbafe8adfdfa2f5d5e99bd3d2
parent99533fc65d29134ef032d81a55b414e11f49ba5b (diff)
downloadsdl_core-952dfe04bc48c01cfdde183783b4610da83728c3.tar.gz
Adjustment application_manager for multiple devices.
-rw-r--r--src/components/application_manager/include/application_manager/application_manager_impl.h41
-rw-r--r--src/components/application_manager/src/application_manager_impl.cc48
-rw-r--r--src/components/application_manager/src/rpc_service_impl.cc6
-rw-r--r--src/components/include/application_manager/application_manager.h29
4 files changed, 85 insertions, 39 deletions
diff --git a/src/components/application_manager/include/application_manager/application_manager_impl.h b/src/components/application_manager/include/application_manager/application_manager_impl.h
index c34affbf13..b8de08b7b6 100644
--- a/src/components/application_manager/include/application_manager/application_manager_impl.h
+++ b/src/components/application_manager/include/application_manager/application_manager_impl.h
@@ -517,32 +517,6 @@ class ApplicationManagerImpl
bool IsApplicationForbidden(uint32_t connection_key,
const std::string& mobile_app_id);
- struct ApplicationsAppIdSorter {
- bool operator()(const ApplicationSharedPtr lhs,
- const ApplicationSharedPtr rhs) {
- return lhs->app_id() < rhs->app_id();
- }
- };
-
- struct ApplicationsMobileAppIdSorter {
- bool operator()(const ApplicationSharedPtr lhs,
- const ApplicationSharedPtr rhs) {
- if (lhs->policy_app_id() == rhs->policy_app_id()) {
- return lhs->device() < rhs->device();
- }
- return lhs->policy_app_id() < rhs->policy_app_id();
- }
- };
-
- // typedef for Applications list
- typedef std::set<ApplicationSharedPtr, ApplicationsAppIdSorter> ApplictionSet;
-
- // typedef for Applications list iterator
- typedef ApplictionSet::iterator ApplictionSetIt;
-
- // typedef for Applications list const iterator
- typedef ApplictionSet::const_iterator ApplictionSetConstIt;
-
/**
* @brief Notification from PolicyHandler about PTU.
* Compares AppHMIType between saved in app and received from PTU. If they are
@@ -1062,13 +1036,26 @@ class ApplicationManagerImpl
const connection_handler::DeviceHandle handle) const OVERRIDE;
/**
+ * DEPRECATED
+ * @brief IsAppInReconnectMode check if application belongs to session
+ * affected by transport switching at the moment by checking internal
+ * waiting list prepared on switching start
+ * @param policy_app_id Application id
+ * @return True if application is in the waiting list, otherwise - false
+ */
+ DEPRECATED bool IsAppInReconnectMode(
+ const std::string& policy_app_id) const FINAL;
+
+ /**
* @brief IsAppInReconnectMode check if application belongs to session
* affected by transport switching at the moment by checking internal
* waiting list prepared on switching start
+ * @param device_id device identifier
* @param policy_app_id Application id
* @return True if application is in the waiting list, otherwise - false
*/
- bool IsAppInReconnectMode(const std::string& policy_app_id) const FINAL;
+ bool IsAppInReconnectMode(const connection_handler::DeviceHandle& device_id,
+ const std::string& policy_app_id) const FINAL;
bool IsStopping() const OVERRIDE {
return is_stopping_;
diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc
index 317ad2933f..bf59b03bb3 100644
--- a/src/components/application_manager/src/application_manager_impl.cc
+++ b/src/components/application_manager/src/application_manager_impl.cc
@@ -121,6 +121,7 @@ bool device_id_comparator(const std::string& device_id,
}
/**
+ * DEPRECATED
* @brief policy_app_id_comparator is predicate to compare policy application
* ids
* @param policy_app_id Policy id of application
@@ -133,6 +134,28 @@ bool policy_app_id_comparator(const std::string& policy_app_id,
return app->policy_app_id() == policy_app_id;
}
+/**
+ * @brief PolicyAppIdComparator is struct predicate to compare policy
+ * application ids & device
+ * @param device_handle of application
+ * @param id of application
+ * @return True if policy id & device_handle of application matches to policy id
+ * & device_handle passed
+ */
+struct PolicyAppIdComparator {
+ PolicyAppIdComparator(const connection_handler::DeviceHandle& device_handle,
+ const std::string& policy_app_id)
+ : device_handle_(device_handle), policy_app_id_(policy_app_id) {}
+ bool operator()(const ApplicationSharedPtr app) const {
+ return app && app->device() == device_handle_ &&
+ app->policy_app_id() == policy_app_id_;
+ }
+
+ private:
+ const connection_handler::DeviceHandle& device_handle_;
+ const std::string& policy_app_id_;
+};
+
uint32_t ApplicationManagerImpl::mobile_corelation_id_ = 0;
uint32_t ApplicationManagerImpl::corelation_id_ = 0;
const uint32_t ApplicationManagerImpl::max_corelation_id_ = UINT_MAX;
@@ -1943,7 +1966,7 @@ void ApplicationManagerImpl::OnServiceEndedCallback(
return;
}
- if (IsAppInReconnectMode(app->policy_app_id())) {
+ if (IsAppInReconnectMode(app->device(), app->policy_app_id())) {
LOG4CXX_DEBUG(logger_,
"Application is in reconnection list and won't be closed.");
return;
@@ -2533,7 +2556,7 @@ void ApplicationManagerImpl::CreateApplications(SmartArray& obj_array,
connection_handler::DeviceHandle device_id = 0;
if (-1 == connection_handler().get_session_observer().GetDataOnSessionKey(
- connection_key, NULL, NULL, &device_id)) {
+ connection_key, nullptr, nullptr, &device_id)) {
LOG4CXX_ERROR(logger_,
"Failed to create application: no connection info.");
continue;
@@ -2541,7 +2564,7 @@ void ApplicationManagerImpl::CreateApplications(SmartArray& obj_array,
std::string device_mac;
connection_handler().get_session_observer().GetDataOnDeviceID(
- device_id, NULL, NULL, &device_mac, NULL);
+ device_id, nullptr, nullptr, &device_mac, nullptr);
const uint32_t hmi_app_id =
resume_controller().IsApplicationSaved(policy_app_id, device_mac)
@@ -3524,6 +3547,17 @@ bool ApplicationManagerImpl::IsAppInReconnectMode(
policy_app_id));
}
+bool ApplicationManagerImpl::IsAppInReconnectMode(
+ const connection_handler::DeviceHandle& device_id,
+ const std::string& policy_app_id) const {
+ LOG4CXX_AUTO_TRACE(logger_);
+ sync_primitives::AutoLock lock(reregister_wait_list_lock_);
+ return reregister_wait_list_.end() !=
+ std::find_if(reregister_wait_list_.begin(),
+ reregister_wait_list_.end(),
+ PolicyAppIdComparator(device_id, policy_app_id));
+}
+
policy::DeviceConsent ApplicationManagerImpl::GetUserConsentForDevice(
const std::string& device_id) const {
return GetPolicyHandler().GetUserConsentForDevice(device_id);
@@ -3846,10 +3880,10 @@ void ApplicationManagerImpl::EraseAppFromReconnectionList(
const auto policy_app_id = app->policy_app_id();
sync_primitives::AutoLock lock(reregister_wait_list_lock_);
- auto app_it = std::find_if(
- reregister_wait_list_.begin(),
- reregister_wait_list_.end(),
- std::bind1st(std::ptr_fun(&policy_app_id_comparator), policy_app_id));
+ auto app_it =
+ std::find_if(reregister_wait_list_.begin(),
+ reregister_wait_list_.end(),
+ PolicyAppIdComparator(app->device(), policy_app_id));
if (reregister_wait_list_.end() != app_it) {
reregister_wait_list_.erase(app_it);
}
diff --git a/src/components/application_manager/src/rpc_service_impl.cc b/src/components/application_manager/src/rpc_service_impl.cc
index b5cae1c126..fef5ef0163 100644
--- a/src/components/application_manager/src/rpc_service_impl.cc
+++ b/src/components/application_manager/src/rpc_service_impl.cc
@@ -82,7 +82,8 @@ bool RPCServiceImpl::ManageMobileCommand(
(*message)[strings::params][strings::connection_key].asUInt());
auto app_ptr = app_manager_.application(connection_key);
- if (app_ptr && app_manager_.IsAppInReconnectMode(app_ptr->policy_app_id())) {
+ if (app_ptr && app_manager_.IsAppInReconnectMode(app_ptr->device(),
+ app_ptr->policy_app_id())) {
commands_holder_.Suspend(
app_ptr, CommandHolder::CommandType::kMobileCommand, message);
return true;
@@ -296,7 +297,8 @@ bool RPCServiceImpl::ManageHMICommand(const commands::MessageSharedPtr message,
(*message)[strings::msg_params][strings::app_id].asUInt();
auto app = app_manager_.application(static_cast<uint32_t>(connection_key));
- if (app && app_manager_.IsAppInReconnectMode(app->policy_app_id())) {
+ if (app && app_manager_.IsAppInReconnectMode(app->device(),
+ app->policy_app_id())) {
commands_holder_.Suspend(
app, CommandHolder::CommandType::kHmiCommand, message);
return true;
diff --git a/src/components/include/application_manager/application_manager.h b/src/components/include/application_manager/application_manager.h
index 521eadf48e..219da72563 100644
--- a/src/components/include/application_manager/application_manager.h
+++ b/src/components/include/application_manager/application_manager.h
@@ -94,12 +94,21 @@ class StateControllerImpl;
struct CommandParametersPermissions;
using policy::RPCParams;
typedef std::vector<ApplicationSharedPtr> AppSharedPtrs;
-struct ApplicationsAppIdSorter {
+struct DEPRECATED ApplicationsAppIdSorter {
bool operator()(const ApplicationSharedPtr lhs,
const ApplicationSharedPtr rhs) const {
return lhs->app_id() < rhs->app_id();
}
};
+struct ApplicationsSorter {
+ bool operator()(const ApplicationSharedPtr lhs,
+ const ApplicationSharedPtr rhs) const {
+ if (lhs->app_id() == rhs->app_id()) {
+ return lhs->device() < rhs->device();
+ }
+ return lhs->app_id() < rhs->app_id();
+ }
+};
struct ApplicationsPolicyAppIdSorter {
bool operator()(const ApplicationSharedPtr lhs,
const ApplicationSharedPtr rhs) {
@@ -110,7 +119,7 @@ struct ApplicationsPolicyAppIdSorter {
}
};
-typedef std::set<ApplicationSharedPtr, ApplicationsAppIdSorter> ApplicationSet;
+typedef std::set<ApplicationSharedPtr, ApplicationsSorter> ApplicationSet;
typedef std::set<ApplicationSharedPtr, ApplicationsPolicyAppIdSorter>
AppsWaitRegistrationSet;
@@ -633,13 +642,27 @@ class ApplicationManager {
uint32_t connection_key, const std::string& policy_app_id) const = 0;
/**
+ * DEPRECATED
* @brief IsAppInReconnectMode check if application belongs to session
* affected by transport switching at the moment
* @param policy_app_id Application id
* @return True if application is registered within session being switched,
* otherwise - false
*/
- virtual bool IsAppInReconnectMode(const std::string& policy_app_id) const = 0;
+ DEPRECATED virtual bool IsAppInReconnectMode(
+ const std::string& policy_app_id) const = 0;
+
+ /**
+ * @brief IsAppInReconnectMode check if application belongs to session
+ * affected by transport switching at the moment
+ * @param device_id device indentifier
+ * @param policy_app_id Application id
+ * @return True if application is registered within session being switched,
+ * otherwise - false
+ */
+ virtual bool IsAppInReconnectMode(
+ const connection_handler::DeviceHandle& device_id,
+ const std::string& policy_app_id) const = 0;
virtual resumption::ResumeCtrl& resume_controller() = 0;