diff options
author | Anatoly Leshin <ALeshin@luxoft.com> | 2014-09-16 14:25:18 +0400 |
---|---|---|
committer | Anatoly Leshin <ALeshin@luxoft.com> | 2014-09-16 14:25:18 +0400 |
commit | 104955c05f385d285881fba1ac090056cad4691b (patch) | |
tree | 7cba1a7c97120be19cac7e6d8ede6e82d3c79368 | |
parent | b8efa209e0207dc834338b4742edfdd089e651bf (diff) | |
parent | 88a16dd2b2605389d2e85f815c5e9edcfb9360dd (diff) | |
download | sdl_core-104955c05f385d285881fba1ac090056cad4691b.tar.gz |
Not a subject for review
Merge branch 'develop' into APPLINK-9151_ProtocolIndexing
13 files changed, 240 insertions, 120 deletions
diff --git a/src/components/application_manager/src/usage_statistics.cc b/src/components/application_manager/src/usage_statistics.cc index 47d493b171..ece6dbdfcb 100644 --- a/src/components/application_manager/src/usage_statistics.cc +++ b/src/components/application_manager/src/usage_statistics.cc @@ -1,4 +1,4 @@ -/** +/** * Copyright (c) 2014, Ford Motor Company * All rights reserved. * @@ -88,8 +88,7 @@ void UsageStatistics::RecordHmiStateChanged(HMILevel::eType new_hmi_level) { next_stopwatch = SECONDS_HMI_NONE; break; default: - NOTREACHED() - ; + NOTREACHED(); } time_in_hmi_state_.Switch(next_stopwatch); } 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 69aa2796ad..f7cc13fd9a 100644 --- a/src/components/policy/src/policy/include/policy/cache_manager.h +++ b/src/components/policy/src/policy/include/policy/cache_manager.h @@ -1,4 +1,4 @@ -/* +/* * Copyright (c) 2014, Ford Motor Company * All rights reserved. * @@ -39,6 +39,7 @@ #include "policy/pt_representation.h" #include "policy/pt_ext_representation.h" #include "utils/lock.h" +#include "usage_statistics/statistics_manager.h" namespace policy { class CacheManager { @@ -394,14 +395,15 @@ public: * Increments global counter * @param type type of counter */ - void Increment(const std::string& type); + void Increment(usage_statistics::GlobalCounterId type); /** * Increments counter of application * @param app_id id application * @param type type of counter */ - void Increment(const std::string& app_id, const std::string& type) const; + void Increment(const std::string& app_id, + usage_statistics::AppCounterId type) const; /** * Sets value of application information @@ -409,7 +411,8 @@ public: * @param type type of information * @param value value of information */ - void Set(const std::string& app_id, const std::string& type, + void Set(const std::string& app_id, + usage_statistics::AppInfoId type, const std::string& value) const; /** @@ -418,7 +421,8 @@ public: * @param type type of stopwatch * @param seconds value for adding in seconds */ - void Add(const std::string& app_id, const std::string& type, + void Add(const std::string& app_id, + usage_statistics::AppStopwatchId type, int seconds) const; /** diff --git a/src/components/policy/src/policy/include/policy/pt_ext_representation.h b/src/components/policy/src/policy/include/policy/pt_ext_representation.h index e4da0563f4..2ed5ef8c49 100644 --- a/src/components/policy/src/policy/include/policy/pt_ext_representation.h +++ b/src/components/policy/src/policy/include/policy/pt_ext_representation.h @@ -1,4 +1,4 @@ -/* +/* Copyright (c) 2013, Ford Motor Company All rights reserved. diff --git a/src/components/policy/src/policy/include/policy/sql_pt_ext_representation.h b/src/components/policy/src/policy/include/policy/sql_pt_ext_representation.h index 3360828dda..8280955432 100644 --- a/src/components/policy/src/policy/include/policy/sql_pt_ext_representation.h +++ b/src/components/policy/src/policy/include/policy/sql_pt_ext_representation.h @@ -1,4 +1,4 @@ -/* +/* Copyright (c) 2013, Ford Motor Company All rights reserved. diff --git a/src/components/policy/src/policy/src/cache_manager.cc b/src/components/policy/src/policy/src/cache_manager.cc index cd427dc1e8..3300461d17 100644 --- a/src/components/policy/src/policy/src/cache_manager.cc +++ b/src/components/policy/src/policy/src/cache_manager.cc @@ -1,4 +1,4 @@ -/* +/* * Copyright (c) 2014, Ford Motor Company * All rights reserved. * @@ -247,6 +247,7 @@ bool CacheManager::ApplyUpdate(const policy_table::Table& update_pt) { void CacheManager::Backup() { LOG4CXX_TRACE_ENTER(logger_); + sync_primitives::AutoLock auto_lock(cache_lock_); if (backup_.valid()) { backup_->Save(*pt_); backup_->SaveUpdateRequired(update_required); @@ -886,34 +887,108 @@ bool CacheManager::CleanupUnpairedDevices(const DeviceIds &device_ids) { return true; } -void CacheManager::Increment(const std::string &type) { +void CacheManager::Increment(usage_statistics::GlobalCounterId type) { #ifdef EXTENDED_POLICY - // TODO: think about it. - if (0 == type.compare("count_of_iap_buffer_full")) { - *pt_->policy_table.usage_and_error_counts->count_of_iap_buffer_full = 1; - } else if (0 == type.compare("count_sync_out_of_memory")) { - *pt_->policy_table.usage_and_error_counts->count_sync_out_of_memory = 1; - } else if (0 == type.compare("count_of_sync_reboots")) { - *pt_->policy_table.usage_and_error_counts->count_of_sync_reboots = 1; + switch (type) { + case usage_statistics::IAP_BUFFER_FULL: + ++(*pt_->policy_table.usage_and_error_counts->count_of_iap_buffer_full); + break; + case usage_statistics::SYNC_OUT_OF_MEMORY: + ++(*pt_->policy_table.usage_and_error_counts->count_sync_out_of_memory); + break; + case usage_statistics::SYNC_REBOOTS: + ++(*pt_->policy_table.usage_and_error_counts->count_of_sync_reboots); + break; + default: + LOG4CXX_INFO(logger_, "Type global counter is unknown"); + return; } #endif // EXTENDED_POLICY } void CacheManager::Increment(const std::string &app_id, - const std::string &type) const { - + usage_statistics::AppCounterId type) const { + switch (type) { + case usage_statistics::USER_SELECTIONS: + ++(*pt_->policy_table.usage_and_error_counts->app_level)[app_id]. + count_of_user_selections; + break; + case usage_statistics::REJECTIONS_SYNC_OUT_OF_MEMORY: + ++(*pt_->policy_table.usage_and_error_counts->app_level)[app_id]. + count_of_rejections_sync_out_of_memory; + break; + case usage_statistics::REJECTIONS_NICKNAME_MISMATCH: + ++(*pt_->policy_table.usage_and_error_counts->app_level)[app_id]. + count_of_rejections_nickname_mismatch; + break; + case usage_statistics::REJECTIONS_DUPLICATE_NAME: + ++(*pt_->policy_table.usage_and_error_counts->app_level)[app_id]. + count_of_rejections_duplicate_name; + break; + case usage_statistics::REJECTED_RPC_CALLS: + ++(*pt_->policy_table.usage_and_error_counts->app_level)[app_id]. + count_of_rejected_rpc_calls; + break; + case usage_statistics::RPCS_IN_HMI_NONE: + ++(*pt_->policy_table.usage_and_error_counts->app_level)[app_id]. + count_of_rpcs_sent_in_hmi_none; + break; + case usage_statistics::REMOVALS_MISBEHAVED: + ++(*pt_->policy_table.usage_and_error_counts->app_level)[app_id]. + count_of_removals_for_bad_behavior; + break; + case usage_statistics::RUN_ATTEMPTS_WHILE_REVOKED: + ++(*pt_->policy_table.usage_and_error_counts->app_level)[app_id]. + count_of_run_attempts_while_revoked; + break; + default: + LOG4CXX_INFO(logger_, "Type app counter is unknown"); + return; + } } void CacheManager::Set(const std::string &app_id, - const std::string &type, + usage_statistics::AppInfoId type, const std::string &value) const { - + switch (type) { + case usage_statistics::LANGUAGE_GUI: + (*pt_->policy_table.usage_and_error_counts->app_level)[app_id]. + app_registration_language_gui = value; + break; + case usage_statistics::LANGUAGE_VUI: + (*pt_->policy_table.usage_and_error_counts->app_level)[app_id]. + app_registration_language_vui = value; + break; + default: + LOG4CXX_INFO(logger_, "Type app info is unknown"); + return; + } } void CacheManager::Add(const std::string &app_id, - const std::string &type, + usage_statistics::AppStopwatchId type, int seconds) const { - + switch (type) { + case usage_statistics::SECONDS_HMI_FULL: + (*pt_->policy_table.usage_and_error_counts->app_level)[app_id]. + minutes_in_hmi_full += seconds; + break; + case usage_statistics::SECONDS_HMI_LIMITED: + (*pt_->policy_table.usage_and_error_counts->app_level)[app_id]. + minutes_in_hmi_limited += seconds; + break; + case usage_statistics::SECONDS_HMI_BACKGROUND: + (*pt_->policy_table.usage_and_error_counts->app_level)[app_id]. + minutes_in_hmi_background += seconds;; + break; + case usage_statistics::SECONDS_HMI_NONE: + (*pt_->policy_table.usage_and_error_counts->app_level)[app_id]. + minutes_in_hmi_none += seconds;; + break; + default: + LOG4CXX_INFO(logger_, "Type app stopwatch is unknown"); + return; + } } void CacheManager::CopyInternalParams(const std::string &from, 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 3ea0cea5b3..c83d6006d8 100644 --- a/src/components/policy/src/policy/src/policy_manager_impl.cc +++ b/src/components/policy/src/policy/src/policy_manager_impl.cc @@ -1,4 +1,4 @@ -/* +/* Copyright (c) 2013, Ford Motor Company All rights reserved. @@ -1010,112 +1010,39 @@ void PolicyManagerImpl::PTUpdatedAt(int kilometers, int days_after_epoch) { } void PolicyManagerImpl::Increment(usage_statistics::GlobalCounterId type) { - std::string counter; - switch (type) { - case usage_statistics::IAP_BUFFER_FULL: - counter = "count_of_iap_buffer_full"; - break; - case usage_statistics::SYNC_OUT_OF_MEMORY: - counter = "count_sync_out_of_memory"; - break; - case usage_statistics::SYNC_REBOOTS: - counter = "count_of_sync_reboots"; - break; - default: - LOG4CXX_INFO(logger_, "Type global counter is unknown"); - return; - } + LOG4CXX_INFO(logger_, "Increment without app id" ); + sync_primitives::AutoLock locker(statistics_lock_); #ifdef EXTENDED_POLICY - cache.Increment(counter); + cache.Increment(type); #endif } void PolicyManagerImpl::Increment(const std::string& app_id, usage_statistics::AppCounterId type) { - std::string counter; - switch (type) { - case usage_statistics::USER_SELECTIONS: - counter = "count_of_user_selections"; - break; - case usage_statistics::REJECTIONS_SYNC_OUT_OF_MEMORY: - counter = "count_of_rejections_sync_out_of_memory"; - break; - case usage_statistics::REJECTIONS_NICKNAME_MISMATCH: - counter = "count_of_rejections_nickname_mismatch"; - break; - case usage_statistics::REJECTIONS_DUPLICATE_NAME: - counter = "count_of_rejections_duplicate_name"; - break; - case usage_statistics::REJECTED_RPC_CALLS: - counter = "count_of_rejected_rpcs_calls"; - break; - case usage_statistics::RPCS_IN_HMI_NONE: - counter = "count_of_rpcs_sent_in_hmi_none"; - break; - case usage_statistics::REMOVALS_MISBEHAVED: - counter = "count_of_removals_for_bad_behavior"; - break; - case usage_statistics::RUN_ATTEMPTS_WHILE_REVOKED: - counter = "count_of_run_attempts_while_revoked"; - break; - default: - LOG4CXX_INFO(logger_, "Type app counter is unknown"); - return; - } -#ifdef EXTENDED_POLICY + LOG4CXX_INFO(logger_, "Increment " << app_id); sync_primitives::AutoLock locker(statistics_lock_); - cache.Increment(app_id, counter); +#ifdef EXTENDED_POLICY + cache.Increment(app_id, type); #endif } void PolicyManagerImpl::Set(const std::string& app_id, usage_statistics::AppInfoId type, const std::string& value) { - std::string info; - switch (type) { - case usage_statistics::LANGUAGE_GUI: - info = "app_registration_language_gui"; - break; - case usage_statistics::LANGUAGE_VUI: - info = "app_registration_language_vui"; - break; - default: - LOG4CXX_INFO(logger_, "Type app info is unknown"); - return; - } - -#ifdef EXTENDED_POLICY + LOG4CXX_INFO(logger_, "Set " << app_id); sync_primitives::AutoLock locker(statistics_lock_); - cache.Set(app_id, info, value); +#ifdef EXTENDED_POLICY + cache.Set(app_id, type, value); #endif } void PolicyManagerImpl::Add(const std::string& app_id, usage_statistics::AppStopwatchId type, int32_t timespan_seconds) { -#ifdef EXTENDED_POLICY - std::string stopwatch; - switch (type) { - // TODO(KKolodiy): rename fields in database - case usage_statistics::SECONDS_HMI_FULL: - stopwatch = "minutes_in_hmi_full"; - break; - case usage_statistics::SECONDS_HMI_LIMITED: - stopwatch = "minutes_in_hmi_limited"; - break; - case usage_statistics::SECONDS_HMI_BACKGROUND: - stopwatch = "minutes_in_hmi_background"; - break; - case usage_statistics::SECONDS_HMI_NONE: - stopwatch = "minutes_in_hmi_none"; - break; - default: - LOG4CXX_INFO(logger_, "Type app stopwatch is unknown"); - return; - } - + LOG4CXX_INFO(logger_, "Add " << app_id); sync_primitives::AutoLock locker(statistics_lock_); - cache.Add(app_id, stopwatch, timespan_seconds); +#ifdef EXTENDED_POLICY + cache.Add(app_id, type, timespan_seconds); #endif } diff --git a/src/components/policy/src/policy/src/sql_pt_ext_representation.cc b/src/components/policy/src/policy/src/sql_pt_ext_representation.cc index 272b209367..c764ea3832 100644 --- a/src/components/policy/src/policy/src/sql_pt_ext_representation.cc +++ b/src/components/policy/src/policy/src/sql_pt_ext_representation.cc @@ -1,4 +1,4 @@ -/* +/* Copyright (c) 2013, Ford Motor Company All rights reserved. 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 0c7c290971..1b7fcdfb6f 100644 --- a/src/components/policy/src/policy/src/sql_pt_queries.cc +++ b/src/components/policy/src/policy/src/sql_pt_queries.cc @@ -1,4 +1,4 @@ -/* +/* Copyright (c) 2013, " Ford Motor Company All rights reserved. @@ -499,7 +499,15 @@ const std::string kInsertDeviceData = "INSERT OR IGNORE INTO `device` (`id`) VALUES (?)"; const std::string kInsertAppLevel = - "INSERT INTO `app_level` (`application_id`) VALUES (?)"; + "INSERT INTO `app_level` (`application_id`, `minutes_in_hmi_full`," + "`minutes_in_hmi_limited` ,`minutes_in_hmi_background`," + "`minutes_in_hmi_none`,`count_of_user_selections`," + "`count_of_rejections_sync_out_of_memory`," + "`count_of_rejections_nickname_mismatch`," + "`count_of_rejections_duplicate_name`,`count_of_rejected_rpcs_calls`," + "`count_of_rpcs_sent_in_hmi_none`,`count_of_removals_for_bad_behavior`," + "`count_of_run_attempts_while_revoked`,`app_registration_language_gui`," + "`app_registration_language_vui`) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; const std::string kDeleteSecondsBetweenRetries = "DELETE FROM `seconds_between_retry`"; 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 2f75c62b8c..a80f2eda2e 100644 --- a/src/components/policy/src/policy/src/sql_pt_representation.cc +++ b/src/components/policy/src/policy/src/sql_pt_representation.cc @@ -1,4 +1,4 @@ -/* +/* Copyright (c) 2013, Ford Motor Company All rights reserved. @@ -1166,12 +1166,25 @@ bool SQLPTRepresentation::SaveUsageAndErrorCounts( const policy_table::AppLevels& app_levels = *counts.app_level; for (it = app_levels.begin(); it != app_levels.end(); ++it) { query.Bind(0, it->first); + query.Bind(1, it->second.minutes_in_hmi_full); + query.Bind(2, it->second.minutes_in_hmi_limited); + query.Bind(3, it->second.minutes_in_hmi_background); + query.Bind(4, it->second.minutes_in_hmi_none); + query.Bind(5, it->second.count_of_user_selections); + query.Bind(6, it->second.count_of_rejections_sync_out_of_memory); + query.Bind(7, it->second.count_of_rejections_nickname_mismatch); + query.Bind(8, it->second.count_of_rejections_duplicate_name); + query.Bind(9, it->second.count_of_rejected_rpc_calls); + query.Bind(10, it->second.count_of_rpcs_sent_in_hmi_none); + query.Bind(11, it->second.count_of_removals_for_bad_behavior); + query.Bind(12, it->second.count_of_run_attempts_while_revoked); + query.Bind(13, it->second.app_registration_language_gui); + query.Bind(14, it->second.app_registration_language_vui); if (!query.Exec()) { LOG4CXX_WARN(logger_, "Incorrect insert into app level."); return false; } } - return true; } diff --git a/src/components/policy/src/policy/usage_statistics/include/usage_statistics/statistics_manager.h b/src/components/policy/src/policy/usage_statistics/include/usage_statistics/statistics_manager.h index 49a0274d50..64a7b24b19 100644 --- a/src/components/policy/src/policy/usage_statistics/include/usage_statistics/statistics_manager.h +++ b/src/components/policy/src/policy/usage_statistics/include/usage_statistics/statistics_manager.h @@ -1,4 +1,4 @@ -/* +/* Copyright (c) 2013, Ford Motor Company All rights reserved. @@ -77,6 +77,86 @@ class StatisticsManager { virtual void Add(const std::string& app_id, AppStopwatchId type, int32_t timespan_seconds) = 0; + + static std::string EnumToStdString(GlobalCounterId global_counter_id) { + std::string counter; + switch (global_counter_id) { + case usage_statistics::IAP_BUFFER_FULL: + counter = "count_of_iap_buffer_full"; + break; + case usage_statistics::SYNC_OUT_OF_MEMORY: + counter = "count_sync_out_of_memory"; + break; + case usage_statistics::SYNC_REBOOTS: + counter = "count_of_sync_reboots"; + break; + } + return counter; + } + + static std::string EnumToStdString(AppInfoId app_info_id) { + std::string info; + switch (app_info_id) { + case usage_statistics::LANGUAGE_GUI: + info = "app_registration_language_gui"; + break; + case usage_statistics::LANGUAGE_VUI: + info = "app_registration_language_vui"; + break; + } + return info; + } + + static std::string EnumToStdString(AppStopwatchId app_stop_watch_id) { + std::string stopwatch; + switch (app_stop_watch_id) { + // TODO(KKolodiy): rename fields in database + case usage_statistics::SECONDS_HMI_FULL: + stopwatch = "minutes_in_hmi_full"; + break; + case usage_statistics::SECONDS_HMI_LIMITED: + stopwatch = "minutes_in_hmi_limited"; + break; + case usage_statistics::SECONDS_HMI_BACKGROUND: + stopwatch = "minutes_in_hmi_background"; + break; + case usage_statistics::SECONDS_HMI_NONE: + stopwatch = "minutes_in_hmi_none"; + break; + } + return stopwatch; + } + + static std::string EnumToStdString(AppCounterId app_counter_id) { + std::string counter; + switch (app_counter_id) { + case usage_statistics::USER_SELECTIONS: + counter = "count_of_user_selections"; + break; + case usage_statistics::REJECTIONS_SYNC_OUT_OF_MEMORY: + counter = "count_of_rejections_sync_out_of_memory"; + break; + case usage_statistics::REJECTIONS_NICKNAME_MISMATCH: + counter = "count_of_rejections_nickname_mismatch"; + break; + case usage_statistics::REJECTIONS_DUPLICATE_NAME: + counter = "count_of_rejections_duplicate_name"; + break; + case usage_statistics::REJECTED_RPC_CALLS: + counter = "count_of_rejected_rpcs_calls"; + break; + case usage_statistics::RPCS_IN_HMI_NONE: + counter = "count_of_rpcs_sent_in_hmi_none"; + break; + case usage_statistics::REMOVALS_MISBEHAVED: + counter = "count_of_removals_for_bad_behavior"; + break; + case usage_statistics::RUN_ATTEMPTS_WHILE_REVOKED: + counter = "count_of_run_attempts_while_revoked"; + break; + } + return counter; + } }; } // namespace usage_statistics diff --git a/src/components/policy/test/policy/src/test_sql_pt_ext_representation.cc b/src/components/policy/test/policy/src/test_sql_pt_ext_representation.cc index 53dc8f8582..c0dabe2753 100644 --- a/src/components/policy/test/policy/src/test_sql_pt_ext_representation.cc +++ b/src/components/policy/test/policy/src/test_sql_pt_ext_representation.cc @@ -1,4 +1,4 @@ -/* Copyright (c) 2013, Ford Motor Company +/* Copyright (c) 2013, Ford Motor Company * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/src/components/rpc_base/include/rpc_base/rpc_base.h b/src/components/rpc_base/include/rpc_base/rpc_base.h index 1935f7cbd4..56b099d9e9 100644 --- a/src/components/rpc_base/include/rpc_base/rpc_base.h +++ b/src/components/rpc_base/include/rpc_base/rpc_base.h @@ -1,4 +1,4 @@ -/** +/** * Copyright (c) 2014, Ford Motor Company * All rights reserved. * @@ -187,6 +187,8 @@ class Integer : public PrimitiveType { explicit Integer(dbus::MessageReader* reader); Integer(const Json::Value* value, IntType def_value); Integer& operator=(IntType new_val); + Integer& operator++(); + Integer& operator+=(int value); operator IntType() const; Json::Value ToJsonValue() const; void ToDbusWriter(dbus::MessageWriter* writer) const; diff --git a/src/components/rpc_base/include/rpc_base/rpc_base_inl.h b/src/components/rpc_base/include/rpc_base/rpc_base_inl.h index da47074248..4373f0ea26 100644 --- a/src/components/rpc_base/include/rpc_base/rpc_base_inl.h +++ b/src/components/rpc_base/include/rpc_base/rpc_base_inl.h @@ -1,4 +1,4 @@ -/** +/** * Copyright (c) 2014, Ford Motor Company * All rights reserved. * @@ -185,6 +185,18 @@ Integer<T, minval, maxval>& Integer<T, minval, maxval>::operator=(IntType new_va } template<typename T, T minval, T maxval> +Integer<T, minval, maxval>& Integer<T, minval, maxval>::operator++() { + ++value_; + return *this; +} + +template<typename T, T minval, T maxval> +Integer<T, minval, maxval>& Integer<T, minval, maxval>::operator+=(int value) { + value_ += value; + return *this; +} + +template<typename T, T minval, T maxval> Integer<T, minval, maxval>::operator IntType() const { return value_; } |