diff options
author | Jacob Keeler <jacob.keeler@livioradio.com> | 2019-02-27 15:10:32 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-02-27 15:10:32 -0500 |
commit | eba1f131162fdcb2be3164d98c39eab56d37b7dc (patch) | |
tree | 05994a814133a2a16adb592b241f2f0209ef74ee | |
parent | c8e6559e24781da9d20824f77ef5d231dfb60b54 (diff) | |
parent | c6ef3733102cfb91d691b1b04487a0a1a2d3b1c3 (diff) | |
download | sdl_core-eba1f131162fdcb2be3164d98c39eab56d37b7dc.tar.gz |
Merge pull request #2826 from smartdevicelink/feature/app_services_ini_behavior
Add logic for `HMIOriginID` and `EmbeddedServices` ini params
5 files changed, 75 insertions, 12 deletions
diff --git a/src/components/application_manager/include/application_manager/app_service_manager.h b/src/components/application_manager/include/application_manager/app_service_manager.h index 09cf1fdc7b..5a345e60fb 100644 --- a/src/components/application_manager/include/application_manager/app_service_manager.h +++ b/src/components/application_manager/include/application_manager/app_service_manager.h @@ -58,6 +58,8 @@ class ApplicationManager; */ class AppServiceManager { public: + const std::string kEmbeddedService = "EMBEDDED_SERVICE"; + /** * @brief Class constructor * @param app_manager @@ -158,9 +160,6 @@ class AppServiceManager { bool UpdateNavigationCapabilities(smart_objects::SmartObject& out_params); private: - void GetProviderFromService(const AppService& service, - ApplicationSharedPtr& app, - bool& hmi_service); ApplicationManager& app_manager_; resumption::LastState& last_state_; std::map<std::string, AppService> published_services_; @@ -169,6 +168,12 @@ class AppServiceManager { const smart_objects::SmartObject& service_record, const mobile_apis::ServiceUpdateReason::eType update_reason, smart_objects::SmartObject& msg_params); + void GetProviderFromService(const AppService& service, + ApplicationSharedPtr& app, + bool& hmi_service); + std::pair<std::string, AppService> FindServiceByPolicyAppID( + std::string policy_app_id, std::string type); + std::string GetPolicyAppID(AppService service); }; } // namespace application_manager diff --git a/src/components/application_manager/include/application_manager/smart_object_keys.h b/src/components/application_manager/include/application_manager/smart_object_keys.h index 205b57b603..78f336fb64 100644 --- a/src/components/application_manager/include/application_manager/smart_object_keys.h +++ b/src/components/application_manager/include/application_manager/smart_object_keys.h @@ -326,6 +326,7 @@ extern const char* updated_app_service_record; extern const char* service_records; extern const char* activate; extern const char* set_as_default; +extern const char* origin_app; // resuming extern const char* application_commands; diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_perform_app_service_interaction_request_from_hmi.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_perform_app_service_interaction_request_from_hmi.cc index 8f52268f19..c384e73d33 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_perform_app_service_interaction_request_from_hmi.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_perform_app_service_interaction_request_from_hmi.cc @@ -57,6 +57,25 @@ void ASPerformAppServiceInteractionRequestFromHMI::Run() { LOG4CXX_AUTO_TRACE(logger_); smart_objects::SmartObject& msg_params = (*message_)[strings::msg_params]; + std::string hmi_origin_id = + application_manager_.get_settings().hmi_origin_id(); + if (!msg_params.keyExists(strings::origin_app)) { + if (hmi_origin_id.empty()) { + smart_objects::SmartObject response_params; + response_params[strings::info] = + "No HMI origin ID to use for interaction passthrough"; + SendResponse( + false, + correlation_id(), + hmi_apis::FunctionID::AppService_PerformAppServiceInteraction, + hmi_apis::Common_Result::INVALID_DATA, + &response_params, + application_manager::commands::Command::SOURCE_SDL_TO_HMI); + return; + } + msg_params[strings::origin_app] = hmi_origin_id; + } + std::string service_id = msg_params[strings::service_id].asString(); auto service = application_manager_.GetAppServiceManager().FindServiceByID(service_id); diff --git a/src/components/application_manager/src/app_service_manager.cc b/src/components/application_manager/src/app_service_manager.cc index e9acac0e05..ed9120ad19 100644 --- a/src/components/application_manager/src/app_service_manager.cc +++ b/src/components/application_manager/src/app_service_manager.cc @@ -88,10 +88,21 @@ smart_objects::SmartObject AppServiceManager::PublishAppService( app_service.record = service_record; std::string service_type = manifest[strings::service_type].asString(); - Json::Value& dictionary = last_state_.get_dictionary(); - app_service.default_service = - (dictionary[kAppServiceSection][kDefaults][service_type].asString() == - manifest[strings::service_name].asString()); + + std::string default_app_id = DefaultServiceByType(service_type); + if (default_app_id.empty() && !mobile_service) { + auto embedded_services = app_manager_.get_settings().embedded_services(); + for (auto it = embedded_services.begin(); it != embedded_services.end(); + ++it) { + if (*it == service_type) { + Json::Value& dictionary = last_state_.get_dictionary(); + dictionary[kAppServiceSection][kDefaults][service_type] = + kEmbeddedService; + default_app_id = kEmbeddedService; + } + } + } + app_service.default_service = GetPolicyAppID(app_service) == default_app_id; published_services_.insert( std::pair<std::string, AppService>(service_id, app_service)); @@ -239,9 +250,10 @@ bool AppServiceManager::SetDefaultService(const std::string service_id) { std::string service_type = service.record[strings::service_manifest][strings::service_type] .asString(); - std::string default_service_name = DefaultServiceByType(service_type); - if (!default_service_name.empty()) { - auto default_service = FindServiceByName(default_service_name); + std::string default_app_id = DefaultServiceByType(service_type); + if (!default_app_id.empty()) { + auto default_service = + FindServiceByPolicyAppID(default_app_id, service_type); if (!default_service.first.empty()) { default_service.second.default_service = false; } @@ -250,8 +262,7 @@ bool AppServiceManager::SetDefaultService(const std::string service_id) { Json::Value& dictionary = last_state_.get_dictionary(); dictionary[kAppServiceSection][kDefaults][service_type] = - service.record[strings::service_manifest][strings::service_name] - .asString(); + GetPolicyAppID(service); return true; } @@ -406,6 +417,24 @@ std::pair<std::string, AppService> AppServiceManager::FindServiceByName( return std::make_pair(std::string(), empty); } +std::pair<std::string, AppService> AppServiceManager::FindServiceByPolicyAppID( + std::string policy_app_id, std::string type) { + LOG4CXX_AUTO_TRACE(logger_); + for (auto it = published_services_.begin(); it != published_services_.end(); + ++it) { + if (it->second.record[strings::service_manifest][strings::service_type] + .asString() != type) { + continue; + } + + if (policy_app_id == GetPolicyAppID(it->second)) { + return *it; + } + } + AppService empty; + return std::make_pair(std::string(), empty); +} + std::pair<std::string, AppService> AppServiceManager::FindServiceByID( std::string service_id) { LOG4CXX_AUTO_TRACE(logger_); @@ -440,6 +469,14 @@ void AppServiceManager::SetServicePublished(const std::string service_id, it->second.record[strings::service_published] = service_published; } +std::string AppServiceManager::GetPolicyAppID(AppService service) { + if (service.mobile_service) { + auto app = app_manager_.application(service.connection_key); + return app ? app->policy_app_id() : std::string(); + } + return kEmbeddedService; +} + bool AppServiceManager::UpdateNavigationCapabilities( smart_objects::SmartObject& out_params) { LOG4CXX_AUTO_TRACE(logger_); diff --git a/src/components/application_manager/src/smart_object_keys.cc b/src/components/application_manager/src/smart_object_keys.cc index 953df3dbd6..45829a4d2a 100644 --- a/src/components/application_manager/src/smart_object_keys.cc +++ b/src/components/application_manager/src/smart_object_keys.cc @@ -293,6 +293,7 @@ const char* updated_app_service_record = "updatedAppServiceRecord"; const char* service_records = "serviceRecords"; const char* activate = "activate"; const char* set_as_default = "setAsDefault"; +const char* origin_app = "originApp"; // resuming const char* application_commands = "applicationCommands"; |