diff options
author | Alexander <akutsan@luxoft.com> | 2018-12-17 17:52:33 +0000 |
---|---|---|
committer | igapchuck <igapchuck@luxoft.com> | 2019-07-24 10:26:36 +0300 |
commit | cba71653afd3ee68ae97b47505391db821aaac8d (patch) | |
tree | 360de9d9552fe598b155959d9aa63317368cf47f | |
parent | e7af1061be064f983f64a837f665d3d4d51c601c (diff) | |
download | sdl_core-cba71653afd3ee68ae97b47505391db821aaac8d.tar.gz |
Add lock_screen_dismissal_enabled to Policy databse
Removed debug logs
8 files changed, 64 insertions, 13 deletions
diff --git a/src/components/policy/policy_external/include/policy/policy_table/types.h b/src/components/policy/policy_external/include/policy/policy_table/types.h index 994fd86579..8795e2690f 100644 --- a/src/components/policy/policy_external/include/policy/policy_table/types.h +++ b/src/components/policy/policy_external/include/policy/policy_table/types.h @@ -364,6 +364,7 @@ struct ModuleConfig : CompositeType { Optional<String<0, 65535> > certificate; Optional<Boolean> preloaded_pt; Optional<Boolean> full_app_id_supported; + Optional<Boolean> lock_screen_dismissal_enabled; public: ModuleConfig(); diff --git a/src/components/policy/policy_external/src/policy_table/types.cc b/src/components/policy/policy_external/src/policy_table/types.cc index ca3f8a1648..d39b3f7623 100644 --- a/src/components/policy/policy_external/src/policy_table/types.cc +++ b/src/components/policy/policy_external/src/policy_table/types.cc @@ -788,8 +788,9 @@ ModuleConfig::ModuleConfig(const Json::Value* value__) , preloaded_date(impl::ValueMember(value__, "preloaded_date")) , certificate(impl::ValueMember(value__, "certificate")) , preloaded_pt(impl::ValueMember(value__, "preloaded_pt")) - , full_app_id_supported( - impl::ValueMember(value__, "full_app_id_supported")) {} + , full_app_id_supported(impl::ValueMember(value__, "full_app_id_supported")) + , lock_screen_dismissal_enabled( + impl::ValueMember(value__, "lock_screen_dismissal_enabled")) {} void ModuleConfig::SafeCopyFrom(const ModuleConfig& from) { exchange_after_x_days = from.exchange_after_x_days; @@ -801,6 +802,7 @@ void ModuleConfig::SafeCopyFrom(const ModuleConfig& from) { endpoints = from.endpoints; notifications_per_minute_by_priority = from.notifications_per_minute_by_priority; + lock_screen_dismissal_enabled = from.lock_screen_dismissal_enabled; certificate.assign_if_valid(from.certificate); vehicle_make.assign_if_valid(from.vehicle_make); @@ -834,6 +836,9 @@ Json::Value ModuleConfig::ToJsonValue() const { impl::WriteJsonField("vehicle_year", vehicle_year, &result__); impl::WriteJsonField("certificate", certificate, &result__); impl::WriteJsonField("preloaded_date", preloaded_date, &result__); + impl::WriteJsonField("lock_screen_dismissal_enabled", + lock_screen_dismissal_enabled, + &result__); return result__; } @@ -883,6 +888,9 @@ bool ModuleConfig::is_valid() const { if (!preloaded_date.is_valid()) { return false; } + if (!lock_screen_dismissal_enabled.is_valid()) { + return false; + } return Validate(); } @@ -925,6 +933,9 @@ bool ModuleConfig::struct_empty() const { if (notifications_per_minute_by_priority.is_initialized()) { return false; } + if (lock_screen_dismissal_enabled.is_initialized()) { + return false; + } if (vehicle_make.is_initialized()) { return false; } @@ -979,6 +990,10 @@ void ModuleConfig::ReportErrors(rpc::ValidationReport* report__) const { notifications_per_minute_by_priority.ReportErrors( &report__->ReportSubobject("notifications_per_minute_by_priority")); } + if (!lock_screen_dismissal_enabled.is_valid()) { + lock_screen_dismissal_enabled.ReportErrors( + &report__->ReportSubobject("lock_screen_dismissal_enabled")); + } if (!vehicle_make.is_valid()) { vehicle_make.ReportErrors(&report__->ReportSubobject("vehicle_make")); } @@ -1037,6 +1052,7 @@ void ModuleConfig::SetPolicyTableType(PolicyTableType pt_type) { seconds_between_retries.SetPolicyTableType(pt_type); endpoints.SetPolicyTableType(pt_type); notifications_per_minute_by_priority.SetPolicyTableType(pt_type); + lock_screen_dismissal_enabled.SetPolicyTableType(pt_type); vehicle_make.SetPolicyTableType(pt_type); vehicle_model.SetPolicyTableType(pt_type); vehicle_year.SetPolicyTableType(pt_type); diff --git a/src/components/policy/policy_external/src/sql_pt_queries.cc b/src/components/policy/policy_external/src/sql_pt_queries.cc index f4cac214a5..5592fdecd8 100644 --- a/src/components/policy/policy_external/src/sql_pt_queries.cc +++ b/src/components/policy/policy_external/src/sql_pt_queries.cc @@ -76,7 +76,8 @@ const std::string kCreateSchema = " `vehicle_model` VARCHAR(45), " " `vehicle_year` VARCHAR(4), " " `preloaded_date` VARCHAR (10), " - " `certificate` VARCHAR (45) " + " `certificate` VARCHAR (45), " + " `lock_screen_dismissal_enabled` BOOL" "); " "CREATE TABLE IF NOT EXISTS `functional_group`( " " `id` INTEGER PRIMARY KEY NOT NULL, " @@ -459,7 +460,7 @@ const std::string kInsertInitData = " VALUES (0, 0, 0, 0); " "INSERT OR IGNORE INTO `module_config` (`preloaded_pt`, `is_first_run`," " `exchange_after_x_ignition_cycles`, `exchange_after_x_kilometers`, " - " `exchange_after_x_days`, `timeout_after_x_seconds`) " + " `exchange_after_x_days`, `timeout_after_x_seconds`)" " VALUES(1, 0, 0, 0, 0, 0); " "INSERT OR IGNORE INTO `priority`(`value`) VALUES ('EMERGENCY'); " "INSERT OR IGNORE INTO `priority`(`value`) VALUES ('NAVIGATION'); " @@ -734,7 +735,7 @@ const std::string kUpdateModuleConfig = " `exchange_after_x_kilometers` = ?, `exchange_after_x_days` = ?, " " `timeout_after_x_seconds` = ?, `vehicle_make` = ?, " " `vehicle_model` = ?, `vehicle_year` = ?, `preloaded_date` = ?, " - " `certificate` = ? "; + " `certificate` = ?, lock_screen_dismissal_enabled = ?"; const std::string kInsertEndpoint = "INSERT INTO `endpoint` (`service`, `url`, `application_id`) " @@ -785,7 +786,8 @@ const std::string kSelectModuleConfig = "SELECT `preloaded_pt`, `exchange_after_x_ignition_cycles`, " " `exchange_after_x_kilometers`, `exchange_after_x_days`, " " `timeout_after_x_seconds`, `vehicle_make`," - " `vehicle_model`, `vehicle_year`, `preloaded_date`, `certificate` " + " `vehicle_model`, `vehicle_year`, `preloaded_date`, `certificate`, " + " `lock_screen_dismissal_enabled` " " FROM `module_config`"; const std::string kSelectEndpoints = diff --git a/src/components/policy/policy_external/src/sql_pt_representation.cc b/src/components/policy/policy_external/src/sql_pt_representation.cc index 1bb0cf0fa1..d5950f9d42 100644 --- a/src/components/policy/policy_external/src/sql_pt_representation.cc +++ b/src/components/policy/policy_external/src/sql_pt_representation.cc @@ -552,6 +552,9 @@ void SQLPTRepresentation::GatherModuleConfig( *config->vehicle_year = query.GetString(7); *config->preloaded_date = query.GetString(8); *config->certificate = query.GetString(9); + if (!query.IsNull(10)) { + *config->lock_screen_dismissal_enabled = query.GetBoolean(10); + } } utils::dbms::SQLQuery endpoints(db()); @@ -1412,6 +1415,10 @@ bool SQLPTRepresentation::SaveModuleConfig( config.certificate.is_initialized() ? query.Bind(9, *(config.certificate)) : query.Bind(9); + config.lock_screen_dismissal_enabled.is_initialized() + ? query.Bind(10, *(config.lock_screen_dismissal_enabled)) + : query.Bind(10); + if (!query.Exec()) { LOG4CXX_WARN(logger_, "Incorrect update module config"); return false; diff --git a/src/components/policy/policy_regular/include/policy/policy_table/types.h b/src/components/policy/policy_regular/include/policy/policy_table/types.h index e41069a86c..c2a8f901ad 100644 --- a/src/components/policy/policy_regular/include/policy/policy_table/types.h +++ b/src/components/policy/policy_regular/include/policy/policy_table/types.h @@ -302,6 +302,7 @@ struct ModuleConfig : CompositeType { Optional<String<4, 4> > vehicle_year; Optional<String<0, 10> > preloaded_date; Optional<String<0, 65535> > certificate; + Optional<Boolean> lock_screen_dismissal_enabled; public: ModuleConfig(); diff --git a/src/components/policy/policy_regular/src/policy_table/types.cc b/src/components/policy/policy_regular/src/policy_table/types.cc index bdf1329dee..7fdfde996c 100644 --- a/src/components/policy/policy_regular/src/policy_table/types.cc +++ b/src/components/policy/policy_regular/src/policy_table/types.cc @@ -678,7 +678,9 @@ ModuleConfig::ModuleConfig(const Json::Value* value__) , vehicle_model(impl::ValueMember(value__, "vehicle_model")) , vehicle_year(impl::ValueMember(value__, "vehicle_year")) , preloaded_date(impl::ValueMember(value__, "preloaded_date")) - , certificate(impl::ValueMember(value__, "certificate")) {} + , certificate(impl::ValueMember(value__, "certificate")) + , lock_screen_dismissal_enabled( + impl::ValueMember(value__, "lock_screen_dismissal_enabled")) {} void ModuleConfig::SafeCopyFrom(const ModuleConfig& from) { // device_certificates = from.device_certificates; // According to the @@ -692,6 +694,8 @@ void ModuleConfig::SafeCopyFrom(const ModuleConfig& from) { notifications_per_minute_by_priority = from.notifications_per_minute_by_priority; + lock_screen_dismissal_enabled = from.lock_screen_dismissal_enabled; + vehicle_make.assign_if_valid(from.vehicle_make); vehicle_model.assign_if_valid(from.vehicle_model); vehicle_year.assign_if_valid(from.vehicle_year); @@ -723,6 +727,9 @@ Json::Value ModuleConfig::ToJsonValue() const { impl::WriteJsonField("vehicle_year", vehicle_year, &result__); impl::WriteJsonField("certificate", certificate, &result__); impl::WriteJsonField("preloaded_date", preloaded_date, &result__); + impl::WriteJsonField("lock_screen_dismissal_enabled", + lock_screen_dismissal_enabled, + &result__); return result__; } @@ -754,6 +761,9 @@ bool ModuleConfig::is_valid() const { if (!notifications_per_minute_by_priority.is_valid()) { return false; } + if (!lock_screen_dismissal_enabled.is_valid()) { + return false; + } if (!vehicle_make.is_valid()) { return false; } @@ -808,6 +818,9 @@ bool ModuleConfig::struct_empty() const { if (notifications_per_minute_by_priority.is_initialized()) { return false; } + if (lock_screen_dismissal_enabled.is_initialized()) { + return false; + } if (vehicle_make.is_initialized()) { return false; } @@ -863,6 +876,10 @@ void ModuleConfig::ReportErrors(rpc::ValidationReport* report__) const { notifications_per_minute_by_priority.ReportErrors( &report__->ReportSubobject("notifications_per_minute_by_priority")); } + if (!lock_screen_dismissal_enabled.is_valid()) { + lock_screen_dismissal_enabled.ReportErrors( + &report__->ReportSubobject("lock_screen_dismissal_enabled")); + } if (!vehicle_make.is_valid()) { vehicle_make.ReportErrors(&report__->ReportSubobject("vehicle_make")); } @@ -902,6 +919,7 @@ void ModuleConfig::SetPolicyTableType(PolicyTableType pt_type) { seconds_between_retries.SetPolicyTableType(pt_type); endpoints.SetPolicyTableType(pt_type); notifications_per_minute_by_priority.SetPolicyTableType(pt_type); + lock_screen_dismissal_enabled.SetPolicyTableType(pt_type); vehicle_make.SetPolicyTableType(pt_type); vehicle_model.SetPolicyTableType(pt_type); vehicle_year.SetPolicyTableType(pt_type); diff --git a/src/components/policy/policy_regular/src/sql_pt_queries.cc b/src/components/policy/policy_regular/src/sql_pt_queries.cc index a97b0ab153..ab57ab989f 100644 --- a/src/components/policy/policy_regular/src/sql_pt_queries.cc +++ b/src/components/policy/policy_regular/src/sql_pt_queries.cc @@ -71,7 +71,8 @@ const std::string kCreateSchema = " `certificate` TEXT, " " `vehicle_make` VARCHAR(45), " " `vehicle_model` VARCHAR(45), " - " `vehicle_year` VARCHAR(4) " + " `vehicle_year` VARCHAR(4), " + " `lock_screen_dismissal_enabled` BOOL" "); " "CREATE TABLE IF NOT EXISTS `functional_group`( " " `id` INTEGER PRIMARY KEY NOT NULL, " @@ -419,7 +420,7 @@ const std::string kInsertInitData = " VALUES (0, 0, 0, 0); " "INSERT OR IGNORE INTO `module_config` (`preloaded_pt`, `is_first_run`," " `exchange_after_x_ignition_cycles`, `exchange_after_x_kilometers`, " - " `exchange_after_x_days`, `timeout_after_x_seconds`) " + " `exchange_after_x_days`, `timeout_after_x_seconds`)" " VALUES(1, 0, 0, 0, 0, 0); " "INSERT OR IGNORE INTO `priority`(`value`) VALUES ('EMERGENCY'); " "INSERT OR IGNORE INTO `priority`(`value`) VALUES ('NAVIGATION'); " @@ -682,7 +683,8 @@ const std::string kUpdateModuleConfig = " `exchange_after_x_ignition_cycles` = ?," " `exchange_after_x_kilometers` = ?, `exchange_after_x_days` = ?, " " `timeout_after_x_seconds` = ?, `certificate` = ?, `vehicle_make` = ?, " - " `vehicle_model` = ?, `vehicle_year` = ? "; + " `vehicle_model` = ?, `vehicle_year` = ?, lock_screen_dismissal_enabled " + "= ?"; const std::string kInsertEndpoint = "INSERT INTO `endpoint` (`service`, `url`, `application_id`) " @@ -722,7 +724,7 @@ const std::string kSelectModuleConfig = "SELECT `preloaded_pt`, `exchange_after_x_ignition_cycles`, " " `exchange_after_x_kilometers`, `exchange_after_x_days`, " " `timeout_after_x_seconds`, `certificate`, `vehicle_make`," - " `vehicle_model`, `vehicle_year` " + " `vehicle_model`, `vehicle_year` ,`lock_screen_dismissal_enabled`" " FROM `module_config`"; const std::string kSelectEndpoints = @@ -907,6 +909,5 @@ const std::string kSaveModuleMeta = "`ignition_cycles_since_last_exchange` = ? "; const std::string kSelectModuleMeta = "SELECT* FROM `module_meta`"; - } // namespace sql_pt } // namespace policy diff --git a/src/components/policy/policy_regular/src/sql_pt_representation.cc b/src/components/policy/policy_regular/src/sql_pt_representation.cc index 20ba9ec651..bcd3322b0d 100644 --- a/src/components/policy/policy_regular/src/sql_pt_representation.cc +++ b/src/components/policy/policy_regular/src/sql_pt_representation.cc @@ -525,7 +525,9 @@ void SQLPTRepresentation::GatherModuleConfig( *config->vehicle_make = query.GetString(6); *config->vehicle_model = query.GetString(7); *config->vehicle_year = query.GetString(8); - *config->preloaded_date = query.GetString(9); + if (!query.IsNull(9)) { + *config->lock_screen_dismissal_enabled = query.GetBoolean(9); + } } utils::dbms::SQLQuery endpoints(db()); @@ -1365,6 +1367,9 @@ bool SQLPTRepresentation::SaveModuleConfig( : query.Bind(7); config.vehicle_year.is_initialized() ? query.Bind(8, *(config.vehicle_year)) : query.Bind(8); + config.lock_screen_dismissal_enabled.is_initialized() + ? query.Bind(9, *(config.lock_screen_dismissal_enabled)) + : query.Bind(9); if (!query.Exec()) { LOG4CXX_WARN(logger_, "Incorrect update module config"); return false; |