summaryrefslogtreecommitdiff
path: root/src/components/application_manager/rpc_plugins
diff options
context:
space:
mode:
authorjacobkeeler <jacob.keeler@livioradio.com>2019-03-05 14:32:47 -0500
committerjacobkeeler <jacob.keeler@livioradio.com>2019-03-05 14:37:21 -0500
commit3d3178c0d78dc2c0c1f515bb955eadff78a83e59 (patch)
treefa43e2e94d01dffecefd39b8d2224fce4e637210 /src/components/application_manager/rpc_plugins
parent7083c88030f15af77dc9a1c9a40a8a5bf73d8c73 (diff)
downloadsdl_core-3d3178c0d78dc2c0c1f515bb955eadff78a83e59.tar.gz
Handle hybrid app preference
If both a cloud app and mobile app attempt to register with the same name, the hybrid app preference of the cloud app is used to determine which app should be registered
Diffstat (limited to 'src/components/application_manager/rpc_plugins')
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/register_app_interface_request.h3
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc56
2 files changed, 48 insertions, 11 deletions
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/register_app_interface_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/register_app_interface_request.h
index f8be896996..a6bfdec209 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/register_app_interface_request.h
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/register_app_interface_request.h
@@ -148,7 +148,8 @@ class RegisterAppInterfaceRequest
* return SUCCESS if there is no coincidence of app.name/TTS/VR synonyms,
* otherwise appropriate error code returns
*/
- mobile_apis::Result::eType CheckCoincidence();
+ mobile_apis::Result::eType CheckCoincidence(
+ app_mngr::ApplicationSharedPtr& app);
/*
* @brief Predicate for using with CheckCoincidence method to compare with VR
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc
index 6317d9b068..e4540fe888 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc
@@ -281,17 +281,49 @@ void RegisterAppInterfaceRequest::Run() {
return;
}
- mobile_apis::Result::eType coincidence_result = CheckCoincidence();
+ ApplicationSharedPtr duplicate_app;
+ mobile_apis::Result::eType coincidence_result =
+ CheckCoincidence(duplicate_app);
+
+ if (mobile_apis::Result::DUPLICATE_NAME == coincidence_result) {
+ bool error_response = true;
+ if (duplicate_app->is_cloud_app()) {
+ if (duplicate_app->hybrid_app_preference() ==
+ mobile_apis::HybridAppPreference::MOBILE) {
+ // Unregister cloud application and allow mobile application to register
+ // in it's place
+ application_manager_.UnregisterApplication(
+ duplicate_app->app_id(), mobile_apis::Result::USER_DISALLOWED);
+ error_response = false;
+ }
+ } else {
+ ApplicationSharedPtr cloud_app =
+ application_manager_.pending_application_by_policy_id(policy_app_id);
+ // If the duplicate name was not because of a mobile/cloud app pair, go
+ // through the normal process for handling duplicate names
+ if (cloud_app.use_count() == 0 || !cloud_app->is_cloud_app()) {
+ usage_statistics::AppCounter count_of_rejections_duplicate_name(
+ GetPolicyHandler().GetStatisticManager(),
+ policy_app_id,
+ usage_statistics::REJECTIONS_DUPLICATE_NAME);
+ ++count_of_rejections_duplicate_name;
+ } else if (cloud_app->hybrid_app_preference() ==
+ mobile_apis::HybridAppPreference::CLOUD) {
+ // Unregister mobile application and allow cloud application to
+ // register in it's place
+ application_manager_.UnregisterApplication(
+ duplicate_app->app_id(), mobile_apis::Result::USER_DISALLOWED);
+ error_response = false;
+ }
+ }
- if (mobile_apis::Result::SUCCESS != coincidence_result) {
- LOG4CXX_ERROR(logger_, "Coincidence check failed.");
- if (mobile_apis::Result::DUPLICATE_NAME == coincidence_result) {
- usage_statistics::AppCounter count_of_rejections_duplicate_name(
- GetPolicyHandler().GetStatisticManager(),
- policy_app_id,
- usage_statistics::REJECTIONS_DUPLICATE_NAME);
- ++count_of_rejections_duplicate_name;
+ if (error_response) {
+ LOG4CXX_ERROR(logger_, "Coincidence check failed.");
+ SendResponse(false, coincidence_result);
+ return;
}
+ } else if (mobile_apis::Result::SUCCESS != coincidence_result) {
+ LOG4CXX_ERROR(logger_, "Coincidence check failed.");
SendResponse(false, coincidence_result);
return;
}
@@ -922,7 +954,8 @@ void RegisterAppInterfaceRequest::SendOnAppRegisteredNotificationToHMI(
DCHECK(rpc_service_.ManageHMICommand(notification));
}
-mobile_apis::Result::eType RegisterAppInterfaceRequest::CheckCoincidence() {
+mobile_apis::Result::eType RegisterAppInterfaceRequest::CheckCoincidence(
+ ApplicationSharedPtr& out_app) {
LOG4CXX_AUTO_TRACE(logger_);
const smart_objects::SmartObject& msg_params =
(*message_)[strings::msg_params];
@@ -938,6 +971,7 @@ mobile_apis::Result::eType RegisterAppInterfaceRequest::CheckCoincidence() {
const custom_str::CustomString& cur_name = (*it)->name();
if (app_name.CompareIgnoreCase(cur_name)) {
LOG4CXX_ERROR(logger_, "Application name is known already.");
+ out_app = *it;
return mobile_apis::Result::DUPLICATE_NAME;
}
@@ -949,6 +983,7 @@ mobile_apis::Result::eType RegisterAppInterfaceRequest::CheckCoincidence() {
if (0 != std::count_if(curr_vr->begin(), curr_vr->end(), v)) {
LOG4CXX_ERROR(logger_, "Application name is known already.");
+ out_app = *it;
return mobile_apis::Result::DUPLICATE_NAME;
}
}
@@ -961,6 +996,7 @@ mobile_apis::Result::eType RegisterAppInterfaceRequest::CheckCoincidence() {
CoincidencePredicateVR v(cur_name);
if (0 != std::count_if(new_vr->begin(), new_vr->end(), v)) {
LOG4CXX_ERROR(logger_, "vr_synonyms duplicated with app_name .");
+ out_app = *it;
return mobile_apis::Result::DUPLICATE_NAME;
}
} // end vr check