diff options
author | Andrey Oleynik <AOleynik@luxoft.com> | 2014-09-13 17:40:45 +0300 |
---|---|---|
committer | Andrey Oleynik <AOleynik@luxoft.com> | 2014-09-13 17:40:45 +0300 |
commit | a625974534bbeaa3429f449a1277a2645504dc40 (patch) | |
tree | 4f55fe539efdc566e8b5db076530bc855ff4617f | |
parent | 7ad1dc9abde2a821d82f0a9b3cd68de5cd30fe6f (diff) | |
download | sdl_core-a625974534bbeaa3429f449a1277a2645504dc40.tar.gz |
APPLINK-9232. Fixed adding new app after registration.
3 files changed, 21 insertions, 3 deletions
diff --git a/src/components/application_manager/src/commands/mobile/register_app_interface_request.cc b/src/components/application_manager/src/commands/mobile/register_app_interface_request.cc index c5507ebb08..8f0f7581f7 100644 --- a/src/components/application_manager/src/commands/mobile/register_app_interface_request.cc +++ b/src/components/application_manager/src/commands/mobile/register_app_interface_request.cc @@ -282,9 +282,6 @@ void RegisterAppInterfaceRequest::Run() { SendRegisterAppInterfaceResponseToMobile(); - // Add registered application to the policy db. - policy::PolicyHandler::instance()-> - AddApplication(msg_params[strings::app_id].asString()); // Ensure that device has consents to start policy update procedure. // In case when device has no consent, EnsureDeviceConsented will send // OnSDLConsentNeeded and will start PTU in OnAllowSDLFunctionality. diff --git a/src/components/application_manager/src/commands/mobile/register_app_interface_response.cc b/src/components/application_manager/src/commands/mobile/register_app_interface_response.cc index 011f4f2aeb..d7e7df3083 100644 --- a/src/components/application_manager/src/commands/mobile/register_app_interface_response.cc +++ b/src/components/application_manager/src/commands/mobile/register_app_interface_response.cc @@ -33,6 +33,8 @@ #include "application_manager/commands/mobile/register_app_interface_response.h" #include "interfaces/MOBILE_API.h" +#include "application_manager/policies/policy_handler.h" +#include "application_manager/application_manager_impl.h" namespace application_manager { @@ -54,6 +56,18 @@ void RegisterAppInterfaceResponse::Run() { } SendResponse(success, result_code, last_message); + + // Add registered application to the policy db right after response sent to + // mobile to be able to check all other API according to app permissions + uint32_t connection_key = + (*message_)[strings::params][strings::connection_key].asUInt(); + application_manager::ApplicationConstSharedPtr app = + application_manager::ApplicationManagerImpl::instance()-> + application(connection_key); + if (app.valid()) { + policy::PolicyHandler::instance()-> + AddApplication(app->mobile_app_id()->asString()); + } } } // namespace commands diff --git a/src/components/policy/src/policy/src/cache_manager.cc b/src/components/policy/src/policy/src/cache_manager.cc index 3f4a8aac85..cd427dc1e8 100644 --- a/src/components/policy/src/policy/src/cache_manager.cc +++ b/src/components/policy/src/policy/src/cache_manager.cc @@ -498,6 +498,13 @@ void CacheManager::CheckPermissions(const PTString &app_id, return; } + if (pt_->policy_table.app_policies.end() == + pt_->policy_table.app_policies.find(app_id)) { + LOG4CXX_ERROR(logger_, "Application id " << app_id + << " was not found in policy DB."); + return; + } + policy_table::Strings::const_iterator app_groups_iter = pt_->policy_table.app_policies[app_id].groups.begin(); |