diff options
author | Andrey Oleynik <AOleynik@luxoft.com> | 2014-09-17 14:00:24 +0300 |
---|---|---|
committer | Andrey Oleynik <AOleynik@luxoft.com> | 2014-09-17 14:00:24 +0300 |
commit | 08125ce885f75d7d0482972204a182cd2d4a5fda (patch) | |
tree | 5f0498d01710cbb19d954a42bfe8efc7c462839b | |
parent | 43918dfda825c91778dfb945aedfd322b3ae1afa (diff) | |
download | sdl_core-08125ce885f75d7d0482972204a182cd2d4a5fda.tar.gz |
APPLINK-9263. Fixed PTS/PTU initialization.
4 files changed, 129 insertions, 35 deletions
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 b31ab99093..d81343500d 100644 --- a/src/components/policy/src/policy/include/policy/cache_manager.h +++ b/src/components/policy/src/policy/include/policy/cache_manager.h @@ -177,7 +177,7 @@ public: * device_info, statistics, excluding user messages * @return Generated structure for obtaining Json string. */ - virtual utils::SharedPtr<policy_table::Table> GenerateSnapshot() const; + virtual utils::SharedPtr<policy_table::Table> GenerateSnapshot(); /** * Applies policy table to the current table @@ -533,7 +533,6 @@ public: void Backup(); private: - std::string currentDateTime(); struct AppHMITypeToString { std::string operator()(rpc::Enum<policy_table::AppHMIType> value) { @@ -547,15 +546,19 @@ private: void FillAppSpecificData(); bool AppExists(const std::string& app_id) const; long int GenerateHash(const std::string& str_to_hash); - void CopyInternalParams(const std::string &from, const std::string& to); - utils::SharedPtr<policy_table::Table> pt_; - long ConvertSecondsToMinute(int seconds); + /** + * @brief Checks snapshot initialization and initializes to default values, if + * necessary + */ + void CheckSnapshotInitialization(); + +private: + utils::SharedPtr<policy_table::Table> pt_; utils::SharedPtr<PTRepresentation> backup_; utils::SharedPtr<PTExtRepresentation> ex_backup_; - bool update_required; std::map<std::string, bool> is_revoked_; std::map<std::string, bool> is_default_; diff --git a/src/components/policy/src/policy/policy_table/table_struct_ext/types.cc b/src/components/policy/src/policy/policy_table/table_struct_ext/types.cc index b508420880..b1cbc5a828 100644 --- a/src/components/policy/src/policy/policy_table/table_struct_ext/types.cc +++ b/src/components/policy/src/policy/policy_table/table_struct_ext/types.cc @@ -47,7 +47,7 @@ ApplicationParams::ApplicationParams(const Json::Value* value__) keep_context(impl::ValueMember(value__, "keep_context")), steal_focus(impl::ValueMember(value__, "steal_focus")), memory_kb(impl::ValueMember(value__, "memory_kb"), 0), - heart_beat_timeout_ms(impl::ValueMember(value__, "heart_beat_timeout_ms"), 0), + heart_beat_timeout_ms(impl::ValueMember(value__, "heart_beat_timeout_ms")), certificate(impl::ValueMember(value__, "certificate"), "not_specified") { } Json::Value ApplicationParams::ToJsonValue() const { @@ -343,9 +343,9 @@ ModuleConfig::ModuleConfig(const Json::Value* value__) seconds_between_retries(impl::ValueMember(value__, "seconds_between_retries")), endpoints(impl::ValueMember(value__, "endpoints")), notifications_per_minute_by_priority(impl::ValueMember(value__, "notifications_per_minute_by_priority")), - vehicle_make(impl::ValueMember(value__, "vehicle_make"), "not_specified"), - vehicle_model(impl::ValueMember(value__, "vehicle_model"), "not_specified"), - vehicle_year(impl::ValueMember(value__, "vehicle_year"), "none") { + vehicle_make(impl::ValueMember(value__, "vehicle_make")), + vehicle_model(impl::ValueMember(value__, "vehicle_model")), + vehicle_year(impl::ValueMember(value__, "vehicle_year")) { } Json::Value ModuleConfig::ToJsonValue() const { @@ -770,8 +770,8 @@ ModuleMeta::ModuleMeta(const Json::Value* value__) ccpu_version(impl::ValueMember(value__, "ccpu_version")), language(impl::ValueMember(value__, "language")), wers_country_code(impl::ValueMember(value__, "wers_country_code")), - pt_exchanged_at_odometer_x(impl::ValueMember(value__, "pt_exchanged_at_odometer_x"), 0), - pt_exchanged_x_days_after_epoch(impl::ValueMember(value__, "pt_exchanged_x_days_after_epoch"), 0), + pt_exchanged_at_odometer_x(impl::ValueMember(value__, "pt_exchanged_at_odometer_x")), + pt_exchanged_x_days_after_epoch(impl::ValueMember(value__, "pt_exchanged_x_days_after_epoch")), ignition_cycles_since_last_exchange(impl::ValueMember(value__, "ignition_cycles_since_last_exchange")), vin(impl::ValueMember(value__, "vin")) { } @@ -912,20 +912,20 @@ AppLevel::~AppLevel() { } AppLevel::AppLevel(const Json::Value* value__) : CompositeType(InitHelper(value__, &Json::Value::isObject)), - minutes_in_hmi_full(impl::ValueMember(value__, "minutes_in_hmi_full"), 0), - app_registration_language_gui(impl::ValueMember(value__, "app_registration_language_gui"), "not_specified"), - app_registration_language_vui(impl::ValueMember(value__, "app_registration_language_vui"), "not_specified"), - minutes_in_hmi_limited(impl::ValueMember(value__, "minutes_in_hmi_limited"), 0), - minutes_in_hmi_background(impl::ValueMember(value__, "minutes_in_hmi_background"), 0), - minutes_in_hmi_none(impl::ValueMember(value__, "minutes_in_hmi_none"), 0), - count_of_user_selections(impl::ValueMember(value__, "count_of_user_selections"), 0), - count_of_rejections_sync_out_of_memory(impl::ValueMember(value__, "count_of_rejections_sync_out_of_memory"), 0), - count_of_rejections_nickname_mismatch(impl::ValueMember(value__, "count_of_rejections_nickname_mismatch"), 0), - count_of_rejections_duplicate_name(impl::ValueMember(value__, "count_of_rejections_duplicate_name"), 0), - count_of_rejected_rpc_calls(impl::ValueMember(value__, "count_of_rejected_rpc_calls"), 0), - count_of_rpcs_sent_in_hmi_none(impl::ValueMember(value__, "count_of_rpcs_sent_in_hmi_none"), 0), - count_of_removals_for_bad_behavior(impl::ValueMember(value__, "count_of_removals_for_bad_behavior"), 0), - count_of_run_attempts_while_revoked(impl::ValueMember(value__, "count_of_run_attempts_while_revoked"), 0) { + minutes_in_hmi_full(impl::ValueMember(value__, "minutes_in_hmi_full")), + app_registration_language_gui(impl::ValueMember(value__, "app_registration_language_gui")), + app_registration_language_vui(impl::ValueMember(value__, "app_registration_language_vui")), + minutes_in_hmi_limited(impl::ValueMember(value__, "minutes_in_hmi_limited")), + minutes_in_hmi_background(impl::ValueMember(value__, "minutes_in_hmi_background")), + minutes_in_hmi_none(impl::ValueMember(value__, "minutes_in_hmi_none")), + count_of_user_selections(impl::ValueMember(value__, "count_of_user_selections")), + count_of_rejections_sync_out_of_memory(impl::ValueMember(value__, "count_of_rejections_sync_out_of_memory")), + count_of_rejections_nickname_mismatch(impl::ValueMember(value__, "count_of_rejections_nickname_mismatch")), + count_of_rejections_duplicate_name(impl::ValueMember(value__, "count_of_rejections_duplicate_name")), + count_of_rejected_rpc_calls(impl::ValueMember(value__, "count_of_rejected_rpc_calls")), + count_of_rpcs_sent_in_hmi_none(impl::ValueMember(value__, "count_of_rpcs_sent_in_hmi_none")), + count_of_removals_for_bad_behavior(impl::ValueMember(value__, "count_of_removals_for_bad_behavior")), + count_of_run_attempts_while_revoked(impl::ValueMember(value__, "count_of_run_attempts_while_revoked")) { } Json::Value AppLevel::ToJsonValue() const { Json::Value result__(Json::objectValue); @@ -1125,9 +1125,9 @@ UsageAndErrorCounts::~UsageAndErrorCounts() { } UsageAndErrorCounts::UsageAndErrorCounts(const Json::Value* value__) : CompositeType(InitHelper(value__, &Json::Value::isObject)), - count_of_iap_buffer_full(impl::ValueMember(value__, "count_of_iap_buffer_full"), 0), - count_sync_out_of_memory(impl::ValueMember(value__, "count_sync_out_of_memory"), 0), - count_of_sync_reboots(impl::ValueMember(value__, "count_of_sync_reboots"), 0), + count_of_iap_buffer_full(impl::ValueMember(value__, "count_of_iap_buffer_full")), + count_sync_out_of_memory(impl::ValueMember(value__, "count_sync_out_of_memory")), + count_of_sync_reboots(impl::ValueMember(value__, "count_of_sync_reboots")), app_level(impl::ValueMember(value__, "app_level")) { } Json::Value UsageAndErrorCounts::ToJsonValue() const { diff --git a/src/components/policy/src/policy/src/cache_manager.cc b/src/components/policy/src/policy/src/cache_manager.cc index a71cd57579..d944a1ce8b 100644 --- a/src/components/policy/src/policy/src/cache_manager.cc +++ b/src/components/policy/src/policy/src/cache_manager.cc @@ -764,8 +764,102 @@ bool CacheManager::GetPriority(const std::string &policy_app_id, return app_id_exists; } +void CacheManager::CheckSnapshotInitialization() +{ + *(pt_->policy_table.module_config.preloaded_pt) = false; + + rpc::Optional<policy_table::ModuleMeta>& module_meta = + pt_->policy_table.module_meta; + if (!module_meta->pt_exchanged_at_odometer_x->is_initialized()) { + *(module_meta->pt_exchanged_at_odometer_x) = 0; + } + + if (!module_meta->pt_exchanged_x_days_after_epoch->is_initialized()) { + *(module_meta->pt_exchanged_x_days_after_epoch) = 0; + } + + rpc::Optional<policy_table::UsageAndErrorCounts>& usage_and_error_counts = + pt_->policy_table.usage_and_error_counts; + if (!usage_and_error_counts->count_of_iap_buffer_full->is_initialized()) { + *(usage_and_error_counts->count_of_iap_buffer_full) = 0; + } + + if (!usage_and_error_counts->count_of_sync_reboots->is_initialized()) { + *(usage_and_error_counts->count_of_sync_reboots) = 0; + } + + if (!usage_and_error_counts->count_sync_out_of_memory->is_initialized()) { + *(usage_and_error_counts->count_sync_out_of_memory) = 0; + } + + if (usage_and_error_counts->app_level->is_initialized()) { + policy_table::AppLevels::iterator it = + usage_and_error_counts->app_level->begin(); + policy_table::AppLevels::const_iterator it_end = + usage_and_error_counts->app_level->end(); + for (;it != it_end; ++it) { + if (!(*it).second.minutes_in_hmi_full.is_initialized()) { + (*it).second.minutes_in_hmi_full = 0; + } + + if (!(*it).second.app_registration_language_gui.is_initialized()) { + (*it).second.app_registration_language_gui = "unknown"; + } + + if (!(*it).second.app_registration_language_vui.is_initialized()) { + (*it).second.app_registration_language_vui = "unknown"; + } + + if (!(*it).second.minutes_in_hmi_limited.is_initialized()) { + (*it).second.minutes_in_hmi_limited = 0; + } + + if (!(*it).second.minutes_in_hmi_background.is_initialized()) { + (*it).second.minutes_in_hmi_background = 0; + } + + if (!(*it).second.minutes_in_hmi_none.is_initialized()) { + (*it).second.minutes_in_hmi_none = 0; + } + + if (!(*it).second.count_of_user_selections.is_initialized()) { + (*it).second.count_of_user_selections = 0; + } + + if (!(*it).second.count_of_rejections_sync_out_of_memory.is_initialized()) { + (*it).second.count_of_rejections_sync_out_of_memory = 0; + } + + if (!(*it).second.count_of_rejections_nickname_mismatch.is_initialized()) { + (*it).second.count_of_rejections_nickname_mismatch = 0; + } + + if (!(*it).second.count_of_rejections_duplicate_name.is_initialized()) { + (*it).second.count_of_rejections_duplicate_name = 0; + } + + if (!(*it).second.count_of_rejected_rpc_calls.is_initialized()) { + (*it).second.count_of_rejected_rpc_calls = 0; + } + + if (!(*it).second.count_of_rpcs_sent_in_hmi_none.is_initialized()) { + (*it).second.count_of_rpcs_sent_in_hmi_none = 0; + } + + if (!(*it).second.count_of_removals_for_bad_behavior.is_initialized()) { + (*it).second.count_of_removals_for_bad_behavior = 0; + } + + if (!(*it).second.count_of_run_attempts_while_revoked.is_initialized()) { + (*it).second.count_of_run_attempts_while_revoked = 0; + } + } + } +} + utils::SharedPtr<policy_table::Table> -CacheManager::GenerateSnapshot() const { +CacheManager::GenerateSnapshot() { + CheckSnapshotInitialization(); return pt_; } 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 c83d6006d8..2c0d4bbc48 100644 --- a/src/components/policy/src/policy/src/policy_manager_impl.cc +++ b/src/components/policy/src/policy/src/policy_manager_impl.cc @@ -296,21 +296,18 @@ BinaryMessageSptr PolicyManagerImpl::RequestPTUpdate() { return NULL; } - // Temporary workaround - *(policy_table_snapshot->policy_table.module_config.preloaded_pt) = false; - #ifdef EXTENDED_POLICY cache.UnpairedDevicesList(unpaired_device_ids_); #endif // EXTENDED_POLICY policy_table_snapshot->SetPolicyTableType(policy_table::PT_SNAPSHOT); - /*if (false == policy_table_snapshot->is_valid()) { + if (false == policy_table_snapshot->is_valid()) { LOG4CXX_INFO( logger_, "Policy snappshot is not valid"); rpc::ValidationReport report("policy_table"); policy_table_snapshot->ReportErrors(&report); LOG4CXX_INFO(logger_, "Errors: " << rpc::PrettyFormat(report)); - }*/ + } Json::Value value = policy_table_snapshot->ToJsonValue(); Json::FastWriter writer; |