Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds lock screen icon URL field to policy table. #28

Merged
merged 2 commits into from
Feb 18, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/appMain/sdl_preloaded_pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -1934,4 +1937,4 @@
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,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
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
27 changes: 27 additions & 0 deletions src/components/application_manager/src/message_helper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
1 change: 1 addition & 0 deletions src/components/interfaces/MOBILE_API.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
7 changes: 7 additions & 0 deletions src/components/policy/src/policy/src/cache_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions src/components/policy/src/policy/src/policy_manager_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
5 changes: 4 additions & 1 deletion src/components/policy/src/policy/src/sql_pt_queries.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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` "
Expand Down Expand Up @@ -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 (?, ?, ?)";
Expand Down
29 changes: 24 additions & 5 deletions src/components/policy/src/policy/src/sql_pt_representation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down Expand Up @@ -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()) {
Expand Down