diff options
Diffstat (limited to 'src/components')
17 files changed, 118 insertions, 7 deletions
diff --git a/src/components/application_manager/include/application_manager/message_helper.h b/src/components/application_manager/include/application_manager/message_helper.h index 6bfc36e093..2fc69d8162 100644 --- a/src/components/application_manager/include/application_manager/message_helper.h +++ b/src/components/application_manager/include/application_manager/message_helper.h @@ -102,6 +102,16 @@ class MessageHelper { static smart_objects::SmartObject* GetHashUpdateNotification(const uint32_t app_id); /** + * @brief Create OnSystemRequest notification for lock screen icon url + */ + static smart_objects::SmartObject* GetLockScreenIconUrlNotification(const uint32_t connection_key); + + /** + * @brief Send the OnSystemRequest notification for lock screen icon url to the mobile device + */ + static void SendLockScreenIconUrlNotification(const uint32_t connection_key); + + /** * @brief Sends to mobile HashUpdateNotification */ static void SendHashUpdateNotification(const uint32_t app_id); diff --git a/src/components/application_manager/include/application_manager/policies/policy_handler.h b/src/components/application_manager/include/application_manager/policies/policy_handler.h index dfc29fe00a..1ded00f5f7 100644 --- a/src/components/application_manager/include/application_manager/policies/policy_handler.h +++ b/src/components/application_manager/include/application_manager/policies/policy_handler.h @@ -86,6 +86,7 @@ class PolicyHandler : StringArray* nicknames = NULL, StringArray* app_hmi_types = NULL); EndpointUrls GetUpdateUrls(int service_type); + std::string GetLockScreenIconUrl() const; void ResetRetrySequence(); int NextRetryTimeout(); int TimeoutExchange(); 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 a035e86f2d..f62e0d4b84 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 @@ -281,6 +281,10 @@ void RegisterAppInterfaceRequest::Run() { device_info); SendRegisterAppInterfaceResponseToMobile(); + + MessageHelper::SendLockScreenIconUrlNotification( + (*message_)[strings::params][strings::connection_key].asInt()); + policy::PolicyHandler::instance()->PTExchangeAtRegistration(mobile_app_id); } } diff --git a/src/components/application_manager/src/message_helper.cc b/src/components/application_manager/src/message_helper.cc index ffde928db6..8048b37dda 100644 --- a/src/components/application_manager/src/message_helper.cc +++ b/src/components/application_manager/src/message_helper.cc @@ -383,6 +383,33 @@ smart_objects::SmartObject* MessageHelper::GetHashUpdateNotification( return message; } +smart_objects::SmartObject* MessageHelper::GetLockScreenIconUrlNotification(const uint32_t connection_key) { + ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application(connection_key); + DCHECK(app.get()); + + smart_objects::SmartObject* message = new smart_objects::SmartObject(smart_objects::SmartType_Map); + (*message)[strings::params][strings::function_id] = mobile_apis::FunctionID::OnSystemRequestID; + (*message)[strings::params][strings::connection_key] = connection_key; + (*message)[strings::params][strings::message_type] = mobile_apis::messageType::notification; + (*message)[strings::params][strings::protocol_type] = commands::CommandImpl::mobile_protocol_type_; + (*message)[strings::params][strings::protocol_version] = commands::CommandImpl::protocol_version_; + + (*message)[strings::msg_params][strings::request_type] = mobile_apis::RequestType::LOCK_SCREEN_ICON_URL; + + (*message)[strings::msg_params][strings::url] = policy::PolicyHandler::instance()->GetLockScreenIconUrl(); + + + return message; +} + +void MessageHelper::SendLockScreenIconUrlNotification(const uint32_t connection_key) { + LOG4CXX_INFO(logger_, "SendLockScreenIconUrlNotification"); + + smart_objects::SmartObject* so = GetLockScreenIconUrlNotification(connection_key); + PrintSmartObject(*so); + DCHECK(ApplicationManagerImpl::instance()->ManageMobileCommand(so)); +} + void MessageHelper::SendHashUpdateNotification(const uint32_t app_id) { LOG4CXX_INFO(logger_, "SendHashUpdateNotification"); diff --git a/src/components/application_manager/src/policies/policy_handler.cc b/src/components/application_manager/src/policies/policy_handler.cc index 0033743e75..8e73b4bdf4 100644 --- a/src/components/application_manager/src/policies/policy_handler.cc +++ b/src/components/application_manager/src/policies/policy_handler.cc @@ -1177,6 +1177,11 @@ EndpointUrls PolicyHandler::GetUpdateUrls(int service_type) { return policy_manager_->GetUpdateUrls(service_type); } +std::string PolicyHandler::GetLockScreenIconUrl() const { + POLICY_LIB_CHECK(std::string("")); + return policy_manager_->GetLockScreenIconUrl(); +} + void PolicyHandler::ResetRetrySequence() { POLICY_LIB_CHECK_VOID(); policy_manager_->ResetRetrySequence(); diff --git a/src/components/interfaces/MOBILE_API.xml b/src/components/interfaces/MOBILE_API.xml index 7a652bb233..fa0eedbde7 100644 --- a/src/components/interfaces/MOBILE_API.xml +++ b/src/components/interfaces/MOBILE_API.xml @@ -2100,6 +2100,7 @@ <element name="AUTH_CHALLENGE" /> <element name="AUTH_ACK" /> <element name="PROPRIETARY" /> + <element name="LOCK_SCREEN_ICON_URL" /> </enum> <enum name="AppHMIType"> diff --git a/src/components/policy/src/policy/include/policy/cache_manager.h b/src/components/policy/src/policy/include/policy/cache_manager.h index 4783a39791..9004639cdf 100644 --- a/src/components/policy/src/policy/include/policy/cache_manager.h +++ b/src/components/policy/src/policy/include/policy/cache_manager.h @@ -152,6 +152,13 @@ class CacheManager : public CacheManagerInterface { virtual EndpointUrls GetUpdateUrls(int service_type); /** + * @brief GetLockScreenIcon allows to obtain lock screen icon url; + * + * @return url which point to the resourse where lock screen icon could be obtained. + */ + virtual std::string GetLockScreenIconUrl() const; + + /** * @brief Get allowed number of notifications * depending on application priority. * @param priority Priority of application diff --git a/src/components/policy/src/policy/include/policy/cache_manager_interface.h b/src/components/policy/src/policy/include/policy/cache_manager_interface.h index a88ae1a901..e07182a409 100644 --- a/src/components/policy/src/policy/include/policy/cache_manager_interface.h +++ b/src/components/policy/src/policy/include/policy/cache_manager_interface.h @@ -152,6 +152,13 @@ class CacheManagerInterface { virtual EndpointUrls GetUpdateUrls(int service_type) = 0; /** + * @brief GetLockScreenIcon allows to obtain lock screen icon url; + * + * @return url which point to the resourse where lock screen icon could be obtained. + */ + virtual std::string GetLockScreenIconUrl() const = 0; + + /** * @brief Get allowed number of notifications * depending on application priority. * @param priority Priority of application diff --git a/src/components/policy/src/policy/include/policy/policy_manager.h b/src/components/policy/src/policy/include/policy/policy_manager.h index 0bc553b33a..3cd295bd95 100644 --- a/src/components/policy/src/policy/include/policy/policy_manager.h +++ b/src/components/policy/src/policy/include/policy/policy_manager.h @@ -80,6 +80,13 @@ class PolicyManager : public usage_statistics::StatisticsManager { virtual std::string GetUpdateUrl(int service_type) = 0; /** + * @brief GetLockScreenIcon allows to obtain lock screen icon url; + * + * @return url which point to the resourse where lock screen icon could be obtained. + */ + virtual std::string GetLockScreenIconUrl() const = 0; + + /** * @brief Gets all URLs for sending PTS to from PT itself. * @param service_type Service specifies user of URL * @return vector of urls diff --git a/src/components/policy/src/policy/include/policy/policy_manager_impl.h b/src/components/policy/src/policy/include/policy/policy_manager_impl.h index 9afb58386f..f3c2e3bc18 100644 --- a/src/components/policy/src/policy/include/policy/policy_manager_impl.h +++ b/src/components/policy/src/policy/include/policy/policy_manager_impl.h @@ -61,6 +61,7 @@ class PolicyManagerImpl : public PolicyManager { virtual bool ResetPT(const std::string& file_name); virtual std::string GetUpdateUrl(int service_type); virtual EndpointUrls GetUpdateUrls(int service_type); + virtual std::string GetLockScreenIconUrl() const; virtual BinaryMessageSptr RequestPTUpdate(); virtual void CheckPermissions(const PTString& app_id, const PTString& hmi_level, diff --git a/src/components/policy/src/policy/include/policy/pt_representation.h b/src/components/policy/src/policy/include/policy/pt_representation.h index f33c3a0811..6aa9bf86d0 100644 --- a/src/components/policy/src/policy/include/policy/pt_representation.h +++ b/src/components/policy/src/policy/include/policy/pt_representation.h @@ -167,6 +167,13 @@ class PTRepresentation { virtual EndpointUrls GetUpdateUrls(int service_type) = 0; /** + * @brief GetLockScreenIcon allows to obtain lock screen icon url; + * + * @return url which point to the resourse where lock screen icon could be obtained. + */ + virtual std::string GetLockScreenIconUrl() const = 0; + + /** * @brief Get allowed number of notifications * depending on application priority. * @param priority Priority of application diff --git a/src/components/policy/src/policy/include/policy/sql_pt_queries.h b/src/components/policy/src/policy/include/policy/sql_pt_queries.h index a8a3affd0b..80928d2dbd 100644 --- a/src/components/policy/src/policy/include/policy/sql_pt_queries.h +++ b/src/components/policy/src/policy/include/policy/sql_pt_queries.h @@ -49,6 +49,7 @@ extern const std::string kSelectPreloaded; extern const std::string kIsFirstRun; extern const std::string kSetNotFirstRun; extern const std::string kSelectEndpoint; +extern const std::string kSelectLockScreenIcon; extern const std::string kSelectModuleConfig; extern const std::string kSelectEndpoints; extern const std::string kSelectNotificationsPerMin; diff --git a/src/components/policy/src/policy/include/policy/sql_pt_representation.h b/src/components/policy/src/policy/include/policy/sql_pt_representation.h index ce4e4532ab..7343c04ef8 100644 --- a/src/components/policy/src/policy/include/policy/sql_pt_representation.h +++ b/src/components/policy/src/policy/include/policy/sql_pt_representation.h @@ -73,7 +73,7 @@ class SQLPTRepresentation : public virtual PTRepresentation { const std::vector<std::string>& msg_codes, const std::string& language); virtual EndpointUrls GetUpdateUrls(int service_type); - + virtual std::string GetLockScreenIconUrl() const; virtual int GetNotificationsNumber(const std::string& priority); virtual bool GetPriority(const std::string& policy_app_id, std::string* priority); diff --git a/src/components/policy/src/policy/src/cache_manager.cc b/src/components/policy/src/policy/src/cache_manager.cc index 62e96ae0ec..3322378857 100644 --- a/src/components/policy/src/policy/src/cache_manager.cc +++ b/src/components/policy/src/policy/src/cache_manager.cc @@ -538,6 +538,13 @@ EndpointUrls CacheManager::GetUpdateUrls(int service_type) { return result; } +std::string CacheManager::GetLockScreenIconUrl() const { + if (backup_) { + return backup_->GetLockScreenIconUrl(); + } + return std::string (""); +} + int CacheManager::GetNotificationsNumber(const std::string &priority) { CACHE_MANAGER_CHECK(0); typedef rpc::policy_table_interface_base::NumberOfNotificationsPerMinute NNPM; diff --git a/src/components/policy/src/policy/src/policy_manager_impl.cc b/src/components/policy/src/policy/src/policy_manager_impl.cc index a712019c7c..d5dd693bc3 100644 --- a/src/components/policy/src/policy/src/policy_manager_impl.cc +++ b/src/components/policy/src/policy/src/policy_manager_impl.cc @@ -269,6 +269,10 @@ EndpointUrls PolicyManagerImpl::GetUpdateUrls(int service_type) { return cache_->GetUpdateUrls(service_type); } +std::string PolicyManagerImpl::GetLockScreenIconUrl() const { + return cache_->GetLockScreenIconUrl(); +} + BinaryMessageSptr PolicyManagerImpl::RequestPTUpdate() { LOG4CXX_INFO(logger_, "Creating PT Snapshot"); utils::SharedPtr<policy_table::Table> policy_table_snapshot = diff --git a/src/components/policy/src/policy/src/sql_pt_queries.cc b/src/components/policy/src/policy/src/sql_pt_queries.cc index 1b7fcdfb6f..229656a8b2 100644 --- a/src/components/policy/src/policy/src/sql_pt_queries.cc +++ b/src/components/policy/src/policy/src/sql_pt_queries.cc @@ -279,7 +279,7 @@ const std::string kCreateSchema = "CREATE INDEX IF NOT EXISTS `consent_group.fk_consent_group_functional_group1_idx` " " ON `consent_group`(`functional_group_id`); " "CREATE TABLE IF NOT EXISTS `endpoint`( " - " `service` INTEGER NOT NULL, " + " `service` VARCHAR(100) NOT NULL, " " `url` VARCHAR(100) NOT NULL, " " `application_id` VARCHAR(45) NOT NULL, " " CONSTRAINT `fk_endpoint_application1` " @@ -439,6 +439,9 @@ const std::string kSetNotFirstRun = const std::string kSelectEndpoint = "SELECT `url`, `application_id` FROM `endpoint` WHERE `service` = ? "; +const std::string kSelectLockScreenIcon = + "SELECT `url` FROM `endpoint` WHERE `service` = ? AND `application_id` = ?"; + const std::string kInsertFunctionalGroup = "INSERT INTO `functional_group` (`id`, `name`, `user_consent_prompt`) " " VALUES (?, ?, ?)"; diff --git a/src/components/policy/src/policy/src/sql_pt_representation.cc b/src/components/policy/src/policy/src/sql_pt_representation.cc index 4946284f3c..cd8e5dcf06 100644 --- a/src/components/policy/src/policy/src/sql_pt_representation.cc +++ b/src/components/policy/src/policy/src/sql_pt_representation.cc @@ -249,6 +249,29 @@ EndpointUrls SQLPTRepresentation::GetUpdateUrls(int service_type) { return ret; } +std::string SQLPTRepresentation::GetLockScreenIconUrl() const { + dbms::SQLQuery query(db()); + std::string ret; + if (query.Prepare(sql_pt::kSelectLockScreenIcon)) { + query.Bind(0, std::string("lock_screen_icon_url")); + query.Bind(1, std::string("default")); + + if(!query.Exec()) { + LOG4CXX_WARN(logger_, "Incorrect select from notifications by priority."); + return ret; + } + + if (!query.IsNull(0)) { + ret = query.GetString(0); + } + + } else { + LOG4CXX_WARN(logger_, "Invalid select endpoints statement."); + } + return ret; +} + + int SQLPTRepresentation::GetNotificationsNumber(const std::string& priority) { LOG4CXX_INFO(logger_, "GetNotificationsNumber"); dbms::SQLQuery query(db()); @@ -958,11 +981,7 @@ bool SQLPTRepresentation::SaveServiceEndpoints( const policy_table::URL& urls = app_it->second; policy_table::URL::const_iterator url_it; for (url_it = urls.begin(); url_it != urls.end(); ++url_it) { - std::stringstream temp_stream(it->first); - int service; - temp_stream.seekg(3); - temp_stream >> service; - query.Bind(0, service); + query.Bind(0, it->first); query.Bind(1, *url_it); query.Bind(2, app_it->first); if (!query.Exec() || !query.Reset()) { |