summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMick Wollman <mick.wollman@gmail.com>2015-02-18 13:29:09 -0500
committerMick Wollman <mick.wollman@gmail.com>2015-02-18 13:29:09 -0500
commitb2b2233d866f102d3de339afa8ccaf37d3cf2570 (patch)
treedf193eb04eeebc342452e1d2e04aa3b3a496aa37
parente35533df5fa5080e8d1907b075478196beed039f (diff)
parent4ca94352560ef2578c80a58775fb837988769191 (diff)
downloadsmartdevicelink-b2b2233d866f102d3de339afa8ccaf37d3cf2570.tar.gz
Merge branch 'feature/lock_screen_icon_url' into develop
-rw-r--r--src/appMain/sdl_preloaded_pt.json7
-rw-r--r--src/components/application_manager/include/application_manager/message_helper.h10
-rw-r--r--src/components/application_manager/include/application_manager/policies/policy_handler.h1
-rw-r--r--src/components/application_manager/src/commands/mobile/register_app_interface_request.cc4
-rw-r--r--src/components/application_manager/src/message_helper.cc27
-rw-r--r--src/components/application_manager/src/policies/policy_handler.cc5
-rw-r--r--src/components/interfaces/MOBILE_API.xml1
-rw-r--r--src/components/policy/src/policy/include/policy/cache_manager.h7
-rw-r--r--src/components/policy/src/policy/include/policy/cache_manager_interface.h7
-rw-r--r--src/components/policy/src/policy/include/policy/policy_manager.h7
-rw-r--r--src/components/policy/src/policy/include/policy/policy_manager_impl.h1
-rw-r--r--src/components/policy/src/policy/include/policy/pt_representation.h7
-rw-r--r--src/components/policy/src/policy/include/policy/sql_pt_queries.h1
-rw-r--r--src/components/policy/src/policy/include/policy/sql_pt_representation.h2
-rw-r--r--src/components/policy/src/policy/src/cache_manager.cc7
-rw-r--r--src/components/policy/src/policy/src/policy_manager_impl.cc4
-rw-r--r--src/components/policy/src/policy/src/sql_pt_queries.cc5
-rw-r--r--src/components/policy/src/policy/src/sql_pt_representation.cc29
18 files changed, 123 insertions, 9 deletions
diff --git a/src/appMain/sdl_preloaded_pt.json b/src/appMain/sdl_preloaded_pt.json
index 52b7684b0..15e544cbe 100644
--- a/src/appMain/sdl_preloaded_pt.json
+++ b/src/appMain/sdl_preloaded_pt.json
@@ -14,7 +14,10 @@
"endpoints": {
"0x07": {
"default": ["http://policies.telematics.ford.com/api/policies"]
- }
+ },
+ "lock_screen_icon_url": {
+ "default": ["http://i.imgur.com/QwZ9uKG.png"]
+ }
},
"notifications_per_minute_by_priority": {
"EMERGENCY": 60,
@@ -1934,4 +1937,4 @@
}
}
}
-} \ No newline at end of file
+}
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 6bfc36e09..2fc69d816 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 dfc29fe00..1ded00f5f 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 a035e86f2..f62e0d4b8 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 ffde928db..8048b37dd 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 0033743e7..8e73b4bdf 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 7a652bb23..fa0eedbde 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 4783a3979..9004639cd 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 a88ae1a90..e07182a40 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 0bc553b33..3cd295bd9 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 9afb58386..f3c2e3bc1 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 f33c3a081..6aa9bf86d 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 a8a3affd0..80928d2db 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 ce4e4532a..7343c04ef 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 62e96ae0e..332237885 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 a712019c7..d5dd693bc 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 1b7fcdfb6..229656a8b 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 4946284f3..cd8e5dcf0 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()) {