diff options
Diffstat (limited to 'src/components/policy/policy_external/src/policy_manager_impl.cc')
-rw-r--r-- | src/components/policy/policy_external/src/policy_manager_impl.cc | 81 |
1 files changed, 41 insertions, 40 deletions
diff --git a/src/components/policy/policy_external/src/policy_manager_impl.cc b/src/components/policy/policy_external/src/policy_manager_impl.cc index 433a7a6bca..c7d814e56e 100644 --- a/src/components/policy/policy_external/src/policy_manager_impl.cc +++ b/src/components/policy/policy_external/src/policy_manager_impl.cc @@ -49,12 +49,9 @@ #include "policy/cache_manager.h" #include "policy/update_status_manager.h" #include "config_profile/profile.h" -#include "utils/make_shared.h" -#ifdef SDL_REMOTE_CONTROL #include "policy/access_remote.h" #include "policy/access_remote_impl.h" -#endif // SDL_REMOTE_CONTROL policy::PolicyManager* CreateManager() { return new policy::PolicyManagerImpl(); @@ -216,47 +213,41 @@ PolicyManagerImpl::PolicyManagerImpl() : PolicyManager() , listener_(NULL) , cache_(new CacheManager) -#ifdef SDL_REMOTE_CONTROL - , access_remote_(new AccessRemoteImpl( - CacheManagerInterfaceSPtr::static_pointer_cast<CacheManager>(cache_))) -#endif // SDL_REMOTE_CONTROL + , access_remote_( + new AccessRemoteImpl(std::static_pointer_cast<CacheManager>(cache_))) , retry_sequence_timeout_(60) , retry_sequence_index_(0) , ignition_check(true) - , retry_sequence_url_(0, 0, "") { -} + , retry_sequence_url_(0, 0, "") {} PolicyManagerImpl::PolicyManagerImpl(bool in_memory) : PolicyManager() , listener_(NULL) , cache_(new CacheManager(in_memory)) -#ifdef SDL_REMOTE_CONTROL - , access_remote_(new AccessRemoteImpl( - CacheManagerInterfaceSPtr::static_pointer_cast<CacheManager>(cache_))) -#endif // SDL_REMOTE_CONTROL + , access_remote_( + new AccessRemoteImpl(std::static_pointer_cast<CacheManager>(cache_))) , retry_sequence_timeout_(60) , retry_sequence_index_(0) , ignition_check(true) , retry_sequence_url_(0, 0, "") , wrong_ptu_update_received_(false) , send_on_update_sent_out_(false) - , trigger_ptu_(false) { -} + , trigger_ptu_(false) {} void PolicyManagerImpl::set_listener(PolicyListener* listener) { listener_ = listener; update_status_manager_.set_listener(listener); } -utils::SharedPtr<policy_table::Table> PolicyManagerImpl::Parse( +std::shared_ptr<policy_table::Table> PolicyManagerImpl::Parse( const BinaryMessage& pt_content) { std::string json(pt_content.begin(), pt_content.end()); Json::Value value; Json::Reader reader; if (reader.parse(json.c_str(), value)) { - return new policy_table::Table(&value); + return std::make_shared<policy_table::Table>(&value); } else { - return utils::SharedPtr<policy_table::Table>(); + return std::make_shared<policy_table::Table>(); } } @@ -288,7 +279,7 @@ bool PolicyManagerImpl::LoadPT(const std::string& file, "PTU content is: " << std::string(pt_content.begin(), pt_content.end())); // Parse message into table struct - utils::SharedPtr<policy_table::Table> pt_update = Parse(pt_content); + std::shared_ptr<policy_table::Table> pt_update = Parse(pt_content); if (!pt_update) { LOG4CXX_WARN(logger_, "Parsed table pointer is NULL."); update_status_manager_.OnWrongUpdateReceived(); @@ -310,7 +301,7 @@ bool PolicyManagerImpl::LoadPT(const std::string& file, sync_primitives::AutoLock lock(apps_registration_lock_); // Get current DB data, since it could be updated during awaiting of PTU - utils::SharedPtr<policy_table::Table> policy_table_snapshot = + std::shared_ptr<policy_table::Table> policy_table_snapshot = cache_->GenerateSnapshot(); if (!policy_table_snapshot) { LOG4CXX_ERROR( @@ -372,8 +363,8 @@ bool PolicyManagerImpl::LoadPT(const std::string& file, } CheckAppPolicyResults PolicyManagerImpl::CheckPermissionsChanges( - const utils::SharedPtr<policy_table::Table> pt_update, - const utils::SharedPtr<policy_table::Table> snapshot) { + const std::shared_ptr<policy_table::Table> pt_update, + const std::shared_ptr<policy_table::Table> snapshot) { LOG4CXX_INFO(logger_, "Checking incoming permissions."); // Replace predefined policies with its actual setting, e.g. "123":"default" @@ -477,7 +468,7 @@ void PolicyManagerImpl::GetUpdateUrls(const uint32_t service_type, void PolicyManagerImpl::RequestPTUpdate() { LOG4CXX_AUTO_TRACE(logger_); - utils::SharedPtr<policy_table::Table> policy_table_snapshot = + std::shared_ptr<policy_table::Table> policy_table_snapshot = cache_->GenerateSnapshot(); if (!policy_table_snapshot) { LOG4CXX_ERROR(logger_, "Failed to create snapshot of policy table"); @@ -563,6 +554,25 @@ const std::vector<std::string> PolicyManagerImpl::GetAppRequestTypes( return request_types; } +RequestType::State PolicyManagerImpl::GetAppRequestTypesState( + const std::string& policy_app_id) const { + LOG4CXX_AUTO_TRACE(logger_); + return cache_->GetAppRequestTypesState(policy_app_id); +} + +RequestSubType::State PolicyManagerImpl::GetAppRequestSubTypesState( + const std::string& policy_app_id) const { + LOG4CXX_AUTO_TRACE(logger_); + return cache_->GetAppRequestSubTypesState(policy_app_id); +} + +const std::vector<std::string> PolicyManagerImpl::GetAppRequestSubTypes( + const std::string& policy_app_id) const { + std::vector<std::string> request_subtypes; + cache_->GetAppRequestSubTypes(policy_app_id, request_subtypes); + return request_subtypes; +} + const VehicleInfo PolicyManagerImpl::GetVehicleInfo() const { return cache_->GetVehicleInfo(); } @@ -773,13 +783,11 @@ void PolicyManagerImpl::SendNotificationOnPermissionsUpdated( LOG4CXX_INFO(logger_, "Send notification for application_id:" << application_id); -#ifdef SDL_REMOTE_CONTROL const ApplicationOnDevice who = {device_id, application_id}; if (access_remote_->IsAppRemoteControl(who)) { listener()->OnPermissionsUpdated(application_id, notification_data); return; } -#endif // SDL_REMOTE_CONTROL std::string default_hmi; GetDefaultHmi(application_id, &default_hmi); @@ -1268,7 +1276,7 @@ bool PolicyManagerImpl::ExceededIgnitionCycles() { } bool PolicyManagerImpl::IsPTValid( - utils::SharedPtr<policy_table::Table> policy_table, + std::shared_ptr<policy_table::Table> policy_table, policy_table::PolicyTableType type) const { policy_table->SetPolicyTableType(type); if (!policy_table->is_valid()) { @@ -1359,7 +1367,7 @@ void PolicyManagerImpl::SendPermissionsToApp( Permissions notification_data; // Need to get rid of this call - utils::SharedPtr<policy_table::Table> policy_table_snapshot = + std::shared_ptr<policy_table::Table> policy_table_snapshot = cache_->GenerateSnapshot(); PrepareNotificationData( @@ -1488,7 +1496,7 @@ void PolicyManagerImpl::CalculateGroupsConsentFromExternalConsent( bool PolicyManagerImpl::ExceededDays() { LOG4CXX_AUTO_TRACE(logger_); - TimevalStruct current_time = date_time::DateTime::getCurrentTime(); + date_time::TimeDuration current_time = date_time::getCurrentTime(); const int kSecondsInDay = 60 * 60 * 24; const int days = current_time.tv_sec / kSecondsInDay; @@ -1767,16 +1775,11 @@ StatusNotifier PolicyManagerImpl::AddApplication( sync_primitives::AutoLock lock(apps_registration_lock_); if (IsNewApplication(application_id)) { AddNewApplication(application_id, device_consent); - return utils::MakeShared<CallStatusChange>(update_status_manager_, - device_consent); + return std::make_shared<CallStatusChange>(update_status_manager_, + device_consent); } else { PromoteExistedApplication(application_id, device_consent); - if (helpers::in_range(hmi_types, policy_table::AHT_NAVIGATION) && - !HasCertificate()) { - LOG4CXX_DEBUG(logger_, "Certificate does not exist, scheduling update."); - update_status_manager_.ScheduleUpdate(); - } - return utils::MakeShared<utils::CallNothing>(); + return std::make_shared<utils::CallNothing>(); } } @@ -1906,7 +1909,7 @@ void PolicyManagerImpl::SaveUpdateStatusRequired(bool is_update_needed) { void PolicyManagerImpl::set_cache_manager( CacheManagerInterface* cache_manager) { - cache_ = cache_manager; + cache_ = std::shared_ptr<CacheManagerInterface>(cache_manager); } std::ostream& operator<<(std::ostream& output, @@ -1919,7 +1922,6 @@ std::ostream& operator<<(std::ostream& output, return output; } -#ifdef SDL_REMOTE_CONTROL void PolicyManagerImpl::SetDefaultHmiTypes(const std::string& application_id, const std::vector<int>& hmi_types) { LOG4CXX_INFO(logger_, "SetDefaultHmiTypes"); @@ -2022,9 +2024,8 @@ bool PolicyManagerImpl::GetModuleTypes( } void PolicyManagerImpl::set_access_remote( - utils::SharedPtr<AccessRemote> access_remote) { + std::shared_ptr<AccessRemote> access_remote) { access_remote_ = access_remote; } -#endif // SDL_REMOTE_CONTROL } // namespace policy |