summaryrefslogtreecommitdiff
path: root/src/components/policy
diff options
context:
space:
mode:
authorAndrii Kalinich (GitHub) <AKalinich@luxoft.com>2018-05-21 14:48:04 +0300
committerGitHub <noreply@github.com>2018-05-21 14:48:04 +0300
commit1f3a2e49b0b0a6254ca6e8b003784b43bd1488d0 (patch)
tree73c3a081a39495647695dee0c6e926a7b38cec17 /src/components/policy
parent6212599da217e95899d63d4b33088082489841bd (diff)
parent44e583faf7cbd3f94fc644960bb71f1636aba4fa (diff)
downloadsdl_core-1f3a2e49b0b0a6254ca6e8b003784b43bd1488d0.tar.gz
Merge pull request #2198 from AKalinich-Luxoft/feature/help_promt_manager
Feature help promt manager
Diffstat (limited to 'src/components/policy')
-rw-r--r--src/components/policy/policy_external/.gitignore6
-rw-r--r--src/components/policy/policy_external/include/policy/cache_manager.h18
-rw-r--r--src/components/policy/policy_external/include/policy/cache_manager_interface.h9
-rw-r--r--src/components/policy/policy_external/include/policy/policy_manager_impl.h3
-rw-r--r--src/components/policy/policy_external/include/policy/policy_types.h4
-rw-r--r--src/components/policy/policy_external/src/cache_manager.cc133
-rw-r--r--src/components/policy/policy_external/src/policy_helper.cc6
-rw-r--r--src/components/policy/policy_external/src/policy_manager_impl.cc66
-rw-r--r--src/components/policy/policy_external/src/sql_pt_queries.cc40
-rw-r--r--src/components/policy/policy_external/src/sql_pt_representation.cc14
-rw-r--r--src/components/policy/policy_external/test/json/PTU.json2
-rw-r--r--src/components/policy/policy_external/test/json/PTU2.json2
-rw-r--r--src/components/policy/policy_external/test/json/PTU3.json2
-rw-r--r--src/components/policy/policy_external/test/json/PTU_default_app.json4
-rw-r--r--src/components/policy/policy_external/test/json/PTU_default_app_app_invalid_values_RequestType_array.json4
-rw-r--r--src/components/policy/policy_external/test/json/PTU_default_app_empty_RequestType_array.json4
-rw-r--r--src/components/policy/policy_external/test/json/PTU_default_app_omitted_RequestType_array.json4
-rw-r--r--src/components/policy/policy_external/test/json/PTU_default_app_one_invalid_value_RequestType_array.json4
-rw-r--r--src/components/policy/policy_external/test/json/PTU_pre_data_consent_app.json4
-rw-r--r--src/components/policy/policy_external/test/json/PTU_pre_data_consent_app_empty_RequestType_array.json4
-rw-r--r--src/components/policy/policy_external/test/json/PTU_pre_data_consent_app_invalid_values_RequestType_array.json4
-rw-r--r--src/components/policy/policy_external/test/json/PTU_pre_data_consent_app_omitted_RequestType_array.json4
-rw-r--r--src/components/policy/policy_external/test/json/PTU_pre_data_consent_app_one_invalid_value_RequestType_array.json4
-rw-r--r--src/components/policy/policy_external/test/json/PTU_with_empty_requestType_array.json4
-rw-r--r--src/components/policy/policy_external/test/json/PTU_with_invalid_requestType_between_correct.json4
-rw-r--r--src/components/policy/policy_external/test/json/PTU_with_one_invalid_requestType.json4
-rw-r--r--src/components/policy/policy_external/test/json/PTU_without_requestType_field.json4
-rw-r--r--src/components/policy/policy_external/test/json/preloadedPT_with_invalid_default_reqestType_between_valid.json2
-rw-r--r--src/components/policy/policy_external/test/json/preloadedPT_with_invalid_default_requestType.json2
-rw-r--r--src/components/policy/policy_external/test/json/preloadedPT_with_several_invalid_default_requestTypes.json2
-rw-r--r--src/components/policy/policy_external/test/json/ptu2_requestType.json6
-rw-r--r--src/components/policy/policy_external/test/json/ptu_requestType.json6
-rw-r--r--src/components/policy/policy_external/test/json/sdl_preloaded_pt.json2
-rw-r--r--src/components/policy/policy_external/test/json/sdl_preloaded_pt1.json4
-rw-r--r--src/components/policy/policy_external/test/json/sdl_preloaded_pt_send_location.json4
-rw-r--r--src/components/policy/policy_external/test/json/sdl_pt_first_update.json4
-rw-r--r--src/components/policy/policy_external/test/json/sdl_pt_second_update.json4
-rw-r--r--src/components/policy/policy_external/test/json/sdl_pt_update.json4
-rw-r--r--src/components/policy/policy_external/test/json/sdl_update_pt_2_groups_have_params.json4
-rw-r--r--src/components/policy/policy_external/test/json/sdl_update_pt_2_groups_no_params_in1.json4
-rw-r--r--src/components/policy/policy_external/test/json/sdl_update_pt_2_groups_no_params_in1_omitted_in2.json4
-rw-r--r--src/components/policy/policy_external/test/json/sdl_update_pt_send_location.json4
-rw-r--r--src/components/policy/policy_external/test/json/sdl_update_pt_send_location_all_params.json4
-rw-r--r--src/components/policy/policy_external/test/json/sdl_update_pt_send_location_no_params.json4
-rw-r--r--src/components/policy/policy_external/test/json/sdl_update_pt_send_location_some_params.json4
-rw-r--r--src/components/policy/policy_external/test/json/valid_sdl_pt_update.json4
-rw-r--r--src/components/policy/policy_external/test/policy_manager_impl_ptu_test.cc3
-rw-r--r--src/components/policy/policy_external/test/policy_manager_impl_test_base.cc6
-rw-r--r--src/components/policy/policy_regular/include/policy/cache_manager.h18
-rw-r--r--src/components/policy/policy_regular/include/policy/cache_manager_interface.h9
-rw-r--r--src/components/policy/policy_regular/include/policy/policy_helper.h3
-rw-r--r--src/components/policy/policy_regular/include/policy/policy_manager_impl.h3
-rw-r--r--src/components/policy/policy_regular/include/policy/policy_table/enums.h1
-rw-r--r--src/components/policy/policy_regular/include/policy/policy_types.h4
-rw-r--r--src/components/policy/policy_regular/src/cache_manager.cc115
-rw-r--r--src/components/policy/policy_regular/src/policy_helper.cc28
-rw-r--r--src/components/policy/policy_regular/src/policy_manager_impl.cc18
-rw-r--r--src/components/policy/policy_regular/src/policy_table/enums.cc8
-rw-r--r--src/components/policy/policy_regular/src/policy_table/types.cc85
-rw-r--r--src/components/policy/policy_regular/src/sql_pt_queries.cc32
-rw-r--r--src/components/policy/policy_regular/src/sql_pt_representation.cc67
-rw-r--r--src/components/policy/policy_regular/test/PTU.json2
-rw-r--r--src/components/policy/policy_regular/test/PTU2.json2
-rw-r--r--src/components/policy/policy_regular/test/PTU3.json2
-rw-r--r--src/components/policy/policy_regular/test/PTU4.json2
-rw-r--r--src/components/policy/policy_regular/test/policy_manager_impl_test.cc2
-rw-r--r--src/components/policy/policy_regular/test/ptu2_requestType.json6
-rw-r--r--src/components/policy/policy_regular/test/ptu_requestType.json6
-rw-r--r--src/components/policy/policy_regular/test/sdl_preloaded_pt.json2
-rw-r--r--src/components/policy/policy_regular/test/sdl_pt_first_update.json4
-rw-r--r--src/components/policy/policy_regular/test/sdl_pt_second_update.json4
-rw-r--r--src/components/policy/policy_regular/test/sdl_pt_update.json4
-rw-r--r--src/components/policy/policy_regular/test/valid_sdl_pt_update.json4
73 files changed, 631 insertions, 242 deletions
diff --git a/src/components/policy/policy_external/.gitignore b/src/components/policy/policy_external/.gitignore
index 3e5fc41721..d67909069a 100644
--- a/src/components/policy/policy_external/.gitignore
+++ b/src/components/policy/policy_external/.gitignore
@@ -54,11 +54,8 @@ test/components/utils/test_Utils
test/test_suit
# libraries
-src/components/qt_hmi/qml_plugins/dbus/libhmi_dbus.so
-src/components/qt_hmi/qml_plugins/hmi_framework/libHmiFramework.so
# install folders
-src/components/qt_hmi/qml_model/com/ford/sdl
# ctags-generated
tags
@@ -70,9 +67,6 @@ moc_*.cpp
*_automoc.cpp
# generated files
-src/components/qt_hmi/qml_plugins/dbus_adapter/qml_dbus.cc
-src/components/qt_hmi/qml_plugins/dbus_adapter/qml_dbus.h
-src/components/qt_hmi/qml_model/hmi_api/*Proxy.qml
# Mac OS Specific
.DS_Store
diff --git a/src/components/policy/policy_external/include/policy/cache_manager.h b/src/components/policy/policy_external/include/policy/cache_manager.h
index 428a9bd2f6..bda456c90a 100644
--- a/src/components/policy/policy_external/include/policy/cache_manager.h
+++ b/src/components/policy/policy_external/include/policy/cache_manager.h
@@ -701,6 +701,15 @@ class CacheManager : public CacheManagerInterface {
const PolicySettings& get_settings() const;
+ /**
+ * @brief OnDeviceSwitching Processes existing policy permissions for devices
+ * switching transport
+ * @param device_id_from Device ID original
+ * @param device_id_to Device ID new
+ */
+ void OnDeviceSwitching(const std::string& device_id_from,
+ const std::string& device_id_to) OVERRIDE;
+
private:
std::string currentDateTime();
struct AppHMITypeToString {
@@ -731,6 +740,13 @@ class CacheManager : public CacheManagerInterface {
*/
void ResetCalculatedPermissionsForDevice(const std::string& device_id);
+ /**
+ * @brief Transform to lower case all non default application names in
+ * applications policies section
+ * @param pt polict rable for update
+ */
+ void MakeLowerCaseAppNames(policy_table::Table& pt) const;
+
void AddCalculatedPermissions(const std::string& device_id,
const std::string& policy_app_id,
const policy::Permissions& permissions);
@@ -748,7 +764,7 @@ class CacheManager : public CacheManagerInterface {
typedef std::set<std::string> UnpairedDevices;
UnpairedDevices is_unpaired_;
- sync_primitives::Lock cache_lock_;
+ mutable sync_primitives::Lock cache_lock_;
sync_primitives::Lock unpaired_lock_;
typedef std::map<std::string, Permissions> AppCalculatedPermissions;
diff --git a/src/components/policy/policy_external/include/policy/cache_manager_interface.h b/src/components/policy/policy_external/include/policy/cache_manager_interface.h
index ae1f8922ba..b9e9f73646 100644
--- a/src/components/policy/policy_external/include/policy/cache_manager_interface.h
+++ b/src/components/policy/policy_external/include/policy/cache_manager_interface.h
@@ -778,6 +778,15 @@ class CacheManagerInterface {
virtual void SetExternalConsentForApp(
const PermissionConsent& permissions) = 0;
+ /**
+ * @brief OnDeviceSwitching Processes existing policy permissions for devices
+ * switching transport
+ * @param device_id_from Device ID original
+ * @param device_id_to Device ID new
+ */
+ virtual void OnDeviceSwitching(const std::string& device_id_from,
+ const std::string& device_id_to) = 0;
+
#ifdef BUILD_TESTS
/**
* @brief GetPT allows to obtain SharedPtr to PT.
diff --git a/src/components/policy/policy_external/include/policy/policy_manager_impl.h b/src/components/policy/policy_external/include/policy/policy_manager_impl.h
index 80ceb06e7e..97a2e60055 100644
--- a/src/components/policy/policy_external/include/policy/policy_manager_impl.h
+++ b/src/components/policy/policy_external/include/policy/policy_manager_impl.h
@@ -559,6 +559,9 @@ class PolicyManagerImpl : public PolicyManager {
*/
void OnAppRegisteredOnMobile(const std::string& application_id) OVERRIDE;
+ void OnDeviceSwitching(const std::string& device_id_from,
+ const std::string& device_id_to) OVERRIDE;
+
/**
* @brief Gets meta information
* @return meta information
diff --git a/src/components/policy/policy_external/include/policy/policy_types.h b/src/components/policy/policy_external/include/policy/policy_types.h
index f57919b6f7..232191cfea 100644
--- a/src/components/policy/policy_external/include/policy/policy_types.h
+++ b/src/components/policy/policy_external/include/policy/policy_types.h
@@ -41,6 +41,8 @@
#include <utility>
#include "utils/shared_ptr.h"
#include "utils/helpers.h"
+#include "transport_manager/common.h"
+
namespace policy {
// TODO(PV): specify errors
@@ -190,7 +192,7 @@ struct DeviceParams {
std::string device_name;
std::string device_mac_address;
std::string device_connection_type;
- uint32_t device_handle;
+ transport_manager::DeviceHandle device_handle;
};
/**
diff --git a/src/components/policy/policy_external/src/cache_manager.cc b/src/components/policy/policy_external/src/cache_manager.cc
index 3a3f3d06a9..5aa39cb2f4 100644
--- a/src/components/policy/policy_external/src/cache_manager.cc
+++ b/src/components/policy/policy_external/src/cache_manager.cc
@@ -252,7 +252,8 @@ CacheManager::CacheManager()
: CacheManagerInterface()
, pt_(new policy_table::Table)
, backup_(new SQLPTExtRepresentation())
- , update_required(false) {
+ , update_required(false)
+ , cache_lock_(true) {
InitBackupThread();
}
@@ -260,7 +261,8 @@ CacheManager::CacheManager(bool in_memory)
: CacheManagerInterface()
, pt_(new policy_table::Table)
, backup_(new SQLPTExtRepresentation(in_memory))
- , update_required(false) {
+ , update_required(false)
+ , cache_lock_(true) {
InitBackupThread();
}
@@ -277,6 +279,7 @@ ConsentPriorityType CacheManager::GetConsentsPriority(
LOG4CXX_AUTO_TRACE(logger_);
ConsentPriorityType prio_type = ConsentPriorityType::kExternalConsentPrio;
CACHE_MANAGER_CHECK(prio_type);
+ sync_primitives::AutoLock auto_lock(cache_lock_);
policy_table::DeviceData::const_iterator dev_params_iter =
pt_->policy_table.device_data->find(device_id);
@@ -304,11 +307,13 @@ ConsentPriorityType CacheManager::GetConsentsPriority(
}
const policy_table::Strings& CacheManager::GetGroups(const PTString& app_id) {
+ sync_primitives::AutoLock auto_lock(cache_lock_);
return pt_->policy_table.app_policies_section.apps[app_id].groups;
}
bool CacheManager::CanAppKeepContext(const std::string& app_id) const {
CACHE_MANAGER_CHECK(false);
+ sync_primitives::AutoLock auto_lock(cache_lock_);
bool result = false;
if (kDeviceId == app_id) {
result = pt_->policy_table.app_policies_section.device.keep_context;
@@ -320,6 +325,7 @@ bool CacheManager::CanAppKeepContext(const std::string& app_id) const {
uint32_t CacheManager::HeartBeatTimeout(const std::string& app_id) const {
CACHE_MANAGER_CHECK(0);
+ sync_primitives::AutoLock auto_lock(cache_lock_);
uint32_t result = 0;
if (!IsApplicationRepresented(app_id)) {
return result;
@@ -336,6 +342,7 @@ uint32_t CacheManager::HeartBeatTimeout(const std::string& app_id) const {
const policy_table::AppHMITypes* CacheManager::GetHMITypes(
const std::string& app_id) {
+ sync_primitives::AutoLock auto_lock(cache_lock_);
const policy_table::ApplicationPolicies& apps =
pt_->policy_table.app_policies_section.apps;
policy_table::ApplicationPolicies::const_iterator i = apps.find(app_id);
@@ -365,6 +372,7 @@ int32_t CacheManager::GenerateHash(const std::string& str_to_hash) {
bool CacheManager::CanAppStealFocus(const std::string& app_id) const {
CACHE_MANAGER_CHECK(false);
+ sync_primitives::AutoLock auto_lock(cache_lock_);
bool result = false;
if (kDeviceId == app_id) {
result = pt_->policy_table.app_policies_section.device.steal_focus;
@@ -377,6 +385,7 @@ bool CacheManager::CanAppStealFocus(const std::string& app_id) const {
bool CacheManager::GetDefaultHMI(const std::string& app_id,
std::string& default_hmi) const {
CACHE_MANAGER_CHECK(false);
+ sync_primitives::AutoLock auto_lock(cache_lock_);
bool result = false;
default_hmi.clear();
if (kDeviceId == app_id) {
@@ -412,6 +421,7 @@ bool CacheManager::GetUserPermissionsForDevice(
StringArray& disallowed_groups) const {
LOG4CXX_AUTO_TRACE(logger_);
CACHE_MANAGER_CHECK(false);
+ sync_primitives::AutoLock auto_lock(cache_lock_);
policy_table::DeviceData& device_data = *pt_->policy_table.device_data;
if (device_data.end() == device_data.find(device_id)) {
LOG4CXX_ERROR(logger_,
@@ -444,6 +454,8 @@ void CacheManager::GetAllAppGroups(const std::string& app_id,
FunctionalGroupIDs& all_group_ids) {
LOG4CXX_AUTO_TRACE(logger_);
CACHE_MANAGER_CHECK_VOID();
+ sync_primitives::AutoLock auto_lock(cache_lock_);
+
if (kDeviceId == app_id) {
policy_table::DevicePolicy& device =
pt_->policy_table.app_policies_section.device;
@@ -481,6 +493,7 @@ void CacheManager::GetPreConsentedGroups(
const std::string& app_id, FunctionalGroupIDs& preconsented_groups) {
LOG4CXX_AUTO_TRACE(logger_);
CACHE_MANAGER_CHECK_VOID();
+ sync_primitives::AutoLock auto_lock(cache_lock_);
if (kDeviceId == app_id) {
policy_table::DevicePolicy& device =
pt_->policy_table.app_policies_section.device;
@@ -520,6 +533,7 @@ void CacheManager::GetConsentedGroups(const std::string& device_id,
FunctionalGroupIDs& disallowed_groups) {
LOG4CXX_AUTO_TRACE(logger_);
CACHE_MANAGER_CHECK_VOID();
+ sync_primitives::AutoLock auto_lock(cache_lock_);
policy_table::DeviceData::iterator dev_params_iter =
pt_->policy_table.device_data->find(device_id);
@@ -559,10 +573,11 @@ void CacheManager::GetUnconsentedGroups(
if (!IsApplicationRepresented(policy_app_id)) {
LOG4CXX_WARN(logger_,
"The application with app_id: " << policy_app_id
- << " is not reresented");
+ << " is not represented");
return;
}
+ sync_primitives::AutoLock auto_lock(cache_lock_);
policy_table::Strings::iterator iter_groups;
policy_table::Strings::iterator iter_groups_end;
if (kDeviceId == policy_app_id) {
@@ -608,6 +623,7 @@ void CacheManager::GetUnconsentedGroups(
void CacheManager::RemoveAppConsentForGroup(const std::string& app_id,
const std::string& group_name) {
CACHE_MANAGER_CHECK_VOID();
+ sync_primitives::AutoLock auto_lock(cache_lock_);
policy_table::DeviceData::iterator device_iter =
pt_->policy_table.device_data->begin();
policy_table::DeviceData::iterator device_iter_end =
@@ -658,6 +674,7 @@ void CacheManager::ProcessUpdate(
}
}
+ sync_primitives::AutoLock lock(cache_lock_);
const RequestTypes merged_pt_request_types =
update_request_types
? new_request_types
@@ -716,6 +733,7 @@ void CacheManager::GetHMIAppTypeAfterUpdate(
std::map<std::string, StringArray>& app_hmi_types) {
LOG4CXX_AUTO_TRACE(logger_);
CACHE_MANAGER_CHECK_VOID();
+ sync_primitives::AutoLock auto_lock(cache_lock_);
policy_table::ApplicationPolicies::const_iterator policy_iter_begin =
pt_->policy_table.app_policies_section.apps.begin();
policy_table::ApplicationPolicies::const_iterator policy_iter_end =
@@ -739,6 +757,7 @@ void CacheManager::GetHMIAppTypeAfterUpdate(
bool CacheManager::AppHasHMIType(const std::string& application_id,
policy_table::AppHMIType hmi_type) const {
+ sync_primitives::AutoLock auto_lock(cache_lock_);
const policy_table::ApplicationPolicies& policies =
pt_->policy_table.app_policies_section.apps;
@@ -798,6 +817,7 @@ bool CacheManager::GetDeviceGroupsFromPolicies(
policy_table::Strings& preconsented_groups) const {
LOG4CXX_AUTO_TRACE(logger_);
CACHE_MANAGER_CHECK(false);
+ sync_primitives::AutoLock auto_lock(cache_lock_);
groups = pt_->policy_table.app_policies_section.device.groups;
preconsented_groups =
*(pt_->policy_table.app_policies_section.device).preconsented_groups;
@@ -1057,6 +1077,7 @@ bool CacheManager::ReactOnUserDevConsentForApp(const std::string& app_id,
void CacheManager::GetGroupNameByHashID(const int32_t group_id,
std::string& group_name) {
CACHE_MANAGER_CHECK_VOID();
+ sync_primitives::AutoLock auto_lock(cache_lock_);
policy_table::FunctionalGroupings::const_iterator fg_iter =
pt_->policy_table.functional_groupings.begin();
policy_table::FunctionalGroupings::const_iterator fg_iter_end =
@@ -1125,6 +1146,7 @@ void CacheManager::SaveUpdateRequired(bool status) {
bool CacheManager::IsApplicationRevoked(const std::string& app_id) const {
CACHE_MANAGER_CHECK(false);
+ sync_primitives::AutoLock auto_lock(cache_lock_);
if (!IsApplicationRepresented(app_id)) {
return false;
}
@@ -1139,6 +1161,7 @@ void CacheManager::CheckPermissions(const PTString& app_id,
CheckPermissionResult& result) {
LOG4CXX_AUTO_TRACE(logger_);
CACHE_MANAGER_CHECK_VOID();
+ sync_primitives::AutoLock auto_lock(cache_lock_);
if (!IsApplicationRepresented(app_id)) {
LOG4CXX_ERROR(
@@ -1192,11 +1215,13 @@ void CacheManager::CheckPermissions(const PTString& app_id,
bool CacheManager::IsPTPreloaded() {
CACHE_MANAGER_CHECK(false);
+ sync_primitives::AutoLock auto_lock(cache_lock_);
return *pt_->policy_table.module_config.preloaded_pt;
}
int CacheManager::IgnitionCyclesBeforeExchange() {
CACHE_MANAGER_CHECK(0);
+ sync_primitives::AutoLock auto_lock(cache_lock_);
const uint8_t limit = std::max(
static_cast<int>(
pt_->policy_table.module_config.exchange_after_x_ignition_cycles),
@@ -1218,6 +1243,7 @@ int CacheManager::IgnitionCyclesBeforeExchange() {
int CacheManager::KilometersBeforeExchange(int current) {
CACHE_MANAGER_CHECK(0);
+ sync_primitives::AutoLock auto_lock(cache_lock_);
const int limit =
std::max(static_cast<int>(
pt_->policy_table.module_config.exchange_after_x_kilometers),
@@ -1238,6 +1264,7 @@ int CacheManager::KilometersBeforeExchange(int current) {
bool CacheManager::SetCountersPassedForSuccessfulUpdate(
policy::Counters counter, int value) {
CACHE_MANAGER_CHECK(false);
+ sync_primitives::AutoLock auto_lock(cache_lock_);
switch (counter) {
case KILOMETERS:
*pt_->policy_table.module_meta->pt_exchanged_at_odometer_x = value;
@@ -1263,6 +1290,7 @@ bool CacheManager::SetCountersPassedForSuccessfulUpdate(
int CacheManager::DaysBeforeExchange(uint16_t current) {
LOG4CXX_AUTO_TRACE(logger_);
CACHE_MANAGER_CHECK(0);
+ sync_primitives::AutoLock auto_lock(cache_lock_);
const rpc::Optional<rpc::Integer<uint16_t, 0, 65535> >& days_after_epoch =
(pt_->policy_table.module_meta->pt_exchanged_x_days_after_epoch);
@@ -1286,6 +1314,7 @@ int CacheManager::DaysBeforeExchange(uint16_t current) {
void CacheManager::IncrementIgnitionCycles() {
CACHE_MANAGER_CHECK_VOID();
+ sync_primitives::AutoLock auto_lock(cache_lock_);
const int ign_val = static_cast<int>(
*pt_->policy_table.module_meta->ignition_cycles_since_last_exchange);
(*pt_->policy_table.module_meta->ignition_cycles_since_last_exchange) =
@@ -1296,18 +1325,21 @@ void CacheManager::IncrementIgnitionCycles() {
void CacheManager::ResetIgnitionCycles() {
CACHE_MANAGER_CHECK_VOID();
+ sync_primitives::AutoLock auto_lock(cache_lock_);
(*pt_->policy_table.module_meta->ignition_cycles_since_last_exchange) = 0;
Backup();
}
int CacheManager::TimeoutResponse() {
CACHE_MANAGER_CHECK(0);
+ sync_primitives::AutoLock auto_lock(cache_lock_);
return pt_->policy_table.module_config.timeout_after_x_seconds *
date_time::DateTime::MILLISECONDS_IN_SECOND;
}
bool CacheManager::SecondsBetweenRetries(std::vector<int>& seconds) {
CACHE_MANAGER_CHECK(false);
+ sync_primitives::AutoLock auto_lock(cache_lock_);
rpc::policy_table_interface_base::SecondsBetweenRetries::iterator iter =
pt_->policy_table.module_config.seconds_between_retries.begin();
rpc::policy_table_interface_base::SecondsBetweenRetries::iterator iter_end =
@@ -1324,6 +1356,7 @@ bool CacheManager::SecondsBetweenRetries(std::vector<int>& seconds) {
const policy::VehicleInfo CacheManager::GetVehicleInfo() const {
CACHE_MANAGER_CHECK(VehicleInfo());
+ sync_primitives::AutoLock auto_lock(cache_lock_);
policy_table::ModuleConfig& module_config = pt_->policy_table.module_config;
VehicleInfo vehicle_info;
vehicle_info.vehicle_make = *module_config.vehicle_make;
@@ -1347,6 +1380,7 @@ std::vector<UserFriendlyMessage> CacheManager::GetUserFriendlyMsg(
std::vector<std::string>::const_iterator it = msg_codes.begin();
std::vector<std::string>::const_iterator it_end = msg_codes.end();
+ sync_primitives::AutoLock auto_lock(cache_lock_);
for (; it != it_end; ++it) {
policy_table::MessageLanguages msg_languages =
(*pt_->policy_table.consumer_friendly_messages->messages)[*it];
@@ -1410,6 +1444,7 @@ void CacheManager::GetUpdateUrls(const std::string& service_type,
LOG4CXX_DEBUG(logger_, "Search service value is: " << service_type);
+ sync_primitives::AutoLock auto_lock(cache_lock_);
policy_table::ServiceEndpoints::const_iterator iter =
pt_->policy_table.module_config.endpoints.find(service_type);
@@ -1442,6 +1477,7 @@ CacheManager::GetNotificationsNumber(const std::string& priority) {
CACHE_MANAGER_CHECK(0);
typedef rpc::policy_table_interface_base::NumberOfNotificationsPerMinute NNPM;
+ sync_primitives::AutoLock auto_lock(cache_lock_);
const NNPM& nnpm =
pt_->policy_table.module_config.notifications_per_minute_by_priority;
@@ -1455,6 +1491,7 @@ CacheManager::GetNotificationsNumber(const std::string& priority) {
bool CacheManager::GetPriority(const std::string& policy_app_id,
std::string& priority) const {
CACHE_MANAGER_CHECK(false);
+ sync_primitives::AutoLock auto_lock(cache_lock_);
if (kDeviceId == policy_app_id) {
priority = EnumToJsonString(
pt_->policy_table.app_policies_section.device.priority);
@@ -1593,10 +1630,10 @@ void CacheManager::PersistData() {
LOG4CXX_AUTO_TRACE(logger_);
if (backup_.valid()) {
if (pt_.valid()) {
- cache_lock_.Acquire();
- policy_table::Table copy_pt(*pt_);
- cache_lock_.Release();
-
+ // Comma expression is used to hold the lock only during the constructor
+ // call
+ policy_table::Table copy_pt(
+ (sync_primitives::AutoLock(cache_lock_), *pt_));
backup_->Save(copy_pt);
backup_->SaveUpdateRequired(update_required);
@@ -1716,8 +1753,8 @@ bool CacheManager::IsPermissionsCalculated(const std::string& device_id,
utils::SharedPtr<policy_table::Table> CacheManager::GenerateSnapshot() {
CACHE_MANAGER_CHECK(snapshot_);
- sync_primitives::AutoLock lock(cache_lock_);
snapshot_ = new policy_table::Table();
+ sync_primitives::AutoLock auto_lock(cache_lock_);
snapshot_->policy_table = pt_->policy_table;
snapshot_->SetPolicyTableType(policy_table::PT_SNAPSHOT);
@@ -1731,6 +1768,7 @@ bool CacheManager::GetInitialAppData(const std::string& app_id,
StringArray& app_hmi_types) {
LOG4CXX_AUTO_TRACE(logger_);
CACHE_MANAGER_CHECK(false);
+ sync_primitives::AutoLock auto_lock(cache_lock_);
policy_table::ApplicationPolicies::const_iterator policy_iter =
pt_->policy_table.app_policies_section.apps.find(app_id);
@@ -1753,6 +1791,7 @@ bool CacheManager::GetFunctionalGroupings(
policy_table::FunctionalGroupings& groups) {
LOG4CXX_AUTO_TRACE(logger_);
CACHE_MANAGER_CHECK(false);
+ sync_primitives::AutoLock auto_lock(cache_lock_);
const policy_table::FunctionalGroupings& f_groupings =
pt_->policy_table.functional_groupings;
@@ -1774,6 +1813,7 @@ int CacheManager::CountUnconsentedGroups(const std::string& policy_app_id,
return 0;
}
+ sync_primitives::AutoLock lock(cache_lock_);
policy_table::FunctionalGroupings::const_iterator groups_iter_end =
pt_->policy_table.functional_groupings.end();
@@ -1864,6 +1904,8 @@ bool CacheManager::SetMetaInfo(const std::string& ccpu_version,
const std::string& wers_country_code,
const std::string& language) {
CACHE_MANAGER_CHECK(false);
+ sync_primitives::AutoLock auto_lock(cache_lock_);
+
*pt_->policy_table.module_meta->ccpu_version = ccpu_version;
*pt_->policy_table.module_meta->wers_country_code = wers_country_code;
*pt_->policy_table.module_meta->language = language;
@@ -1879,6 +1921,7 @@ bool CacheManager::SetMetaInfo(const std::string& ccpu_version,
bool CacheManager::IsMetaInfoPresent() const {
CACHE_MANAGER_CHECK(false);
bool result = true;
+ sync_primitives::AutoLock lock(cache_lock_);
result = NULL != pt_->policy_table.module_meta->ccpu_version &&
NULL != pt_->policy_table.module_meta->wers_country_code &&
NULL != pt_->policy_table.module_meta->language;
@@ -1887,6 +1930,7 @@ bool CacheManager::IsMetaInfoPresent() const {
bool CacheManager::SetSystemLanguage(const std::string& language) {
CACHE_MANAGER_CHECK(false);
+ sync_primitives::AutoLock lock(cache_lock_);
*pt_->policy_table.module_meta->language = language;
Backup();
return true;
@@ -1895,6 +1939,7 @@ bool CacheManager::SetSystemLanguage(const std::string& language) {
bool CacheManager::GetFunctionalGroupNames(FunctionalGroupNames& names) {
LOG4CXX_AUTO_TRACE(logger_);
CACHE_MANAGER_CHECK(false);
+ sync_primitives::AutoLock auto_lock(cache_lock_);
rpc::policy_table_interface_base::FunctionalGroupings::iterator iter =
pt_->policy_table.functional_groupings.begin();
rpc::policy_table_interface_base::FunctionalGroupings::iterator iter_end =
@@ -2084,6 +2129,7 @@ bool CacheManager::SetDefaultPolicy(const std::string& app_id) {
bool CacheManager::IsDefaultPolicy(const std::string& app_id) const {
CACHE_MANAGER_CHECK(false);
+ sync_primitives::AutoLock auto_lock(cache_lock_);
const bool result =
IsApplicationRepresented(app_id) &&
policy::kDefaultId ==
@@ -2094,7 +2140,7 @@ bool CacheManager::IsDefaultPolicy(const std::string& app_id) const {
bool CacheManager::SetIsDefault(const std::string& app_id) {
CACHE_MANAGER_CHECK(false);
-
+ sync_primitives::AutoLock auto_lock(cache_lock_);
if (IsApplicationRepresented(app_id)) {
pt_->policy_table.app_policies_section.apps[app_id].set_to_string(
kDefaultId);
@@ -2137,6 +2183,7 @@ bool CacheManager::SetPredataPolicy(const std::string& app_id) {
}
bool CacheManager::IsPredataPolicy(const std::string& app_id) const {
+ sync_primitives::AutoLock auto_lock(cache_lock_);
if (!IsApplicationRepresented(app_id)) {
return false;
}
@@ -2146,6 +2193,7 @@ bool CacheManager::IsPredataPolicy(const std::string& app_id) const {
bool CacheManager::SetUnpairedDevice(const std::string& device_id,
bool unpaired) {
+ sync_primitives::AutoLock auto_lock(cache_lock_);
const bool result = pt_->policy_table.device_data->end() !=
pt_->policy_table.device_data->find(device_id);
if (!result) {
@@ -2169,15 +2217,17 @@ bool CacheManager::SetUnpairedDevice(const std::string& device_id,
bool CacheManager::SetVINValue(const std::string& value) {
CACHE_MANAGER_CHECK(false);
- cache_lock_.Acquire();
- *pt_->policy_table.module_meta->vin = value;
- cache_lock_.Release();
+ {
+ sync_primitives::AutoLock lock(cache_lock_);
+ *pt_->policy_table.module_meta->vin = value;
+ }
Backup();
return true;
}
bool CacheManager::IsApplicationRepresented(const std::string& app_id) const {
CACHE_MANAGER_CHECK(false);
+ sync_primitives::AutoLock auto_lock(cache_lock_);
policy_table::ApplicationPolicies::const_iterator iter =
pt_->policy_table.app_policies_section.apps.find(app_id);
return pt_->policy_table.app_policies_section.apps.end() != iter;
@@ -2249,6 +2299,27 @@ void CacheManager::FillDeviceSpecificData() {
}
}
+void CacheManager::MakeLowerCaseAppNames(policy_table::Table& pt) const {
+ policy_table::ApplicationPolicies& apps =
+ pt.policy_table.app_policies_section.apps;
+ for (policy_table::ApplicationPolicies::iterator iter = apps.begin();
+ iter != apps.end();) {
+ std::string key = iter->first;
+ if (key == kDefaultId || key == kPreDataConsentId || key == kDeviceId) {
+ ++iter;
+ continue;
+ }
+
+ std::transform(key.begin(), key.end(), key.begin(), ::tolower);
+ if (key.compare(iter->first) != 0) {
+ std::swap(apps[key], iter->second);
+ iter = apps.erase(iter);
+ } else {
+ ++iter;
+ }
+ }
+}
+
bool CacheManager::LoadFromBackup() {
sync_primitives::AutoLock lock(cache_lock_);
pt_ = backup_->GenerateSnapshot();
@@ -2282,6 +2353,7 @@ bool CacheManager::LoadFromFile(const std::string& file_name,
LOG4CXX_DEBUG(logger_,
"Start verification of policy table loaded from file.");
+ sync_primitives::AutoLock locker(cache_lock_);
table = policy_table::Table(&value);
#ifdef ENABLE_LOG
@@ -2291,6 +2363,8 @@ bool CacheManager::LoadFromFile(const std::string& file_name,
"Policy table content loaded:" << s_writer.write(table.ToJsonValue()));
#endif // ENABLE_LOG
+ MakeLowerCaseAppNames(table);
+
if (!table.is_valid()) {
rpc::ValidationReport report("policy_table");
table.ReportErrors(&report);
@@ -2323,6 +2397,7 @@ void CacheManager::GetAppRequestTypes(
std::vector<std::string>& request_types) const {
LOG4CXX_AUTO_TRACE(logger_);
CACHE_MANAGER_CHECK_VOID();
+ sync_primitives::AutoLock auto_lock(cache_lock_);
if (kDeviceId == policy_app_id) {
LOG4CXX_DEBUG(logger_,
"Request types not applicable for app_id " << kDeviceId);
@@ -2348,6 +2423,7 @@ void CacheManager::GetAppRequestTypes(
const MetaInfo CacheManager::GetMetaInfo() const {
LOG4CXX_AUTO_TRACE(logger_);
+ sync_primitives::AutoLock auto_lock(cache_lock_);
MetaInfo meta_info;
meta_info.ccpu_version = *pt_->policy_table.module_meta->ccpu_version;
meta_info.wers_country_code =
@@ -2358,6 +2434,7 @@ const MetaInfo CacheManager::GetMetaInfo() const {
std::string CacheManager::GetCertificate() const {
CACHE_MANAGER_CHECK(std::string(""));
+ sync_primitives::AutoLock auto_lock(cache_lock_);
if (pt_->policy_table.module_config.certificate.is_initialized()) {
return *pt_->policy_table.module_config.certificate;
}
@@ -2606,6 +2683,31 @@ const PolicySettings& CacheManager::get_settings() const {
return *settings_;
}
+void CacheManager::OnDeviceSwitching(const std::string& device_id_from,
+ const std::string& device_id_to) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ sync_primitives::AutoLock auto_lock(cache_lock_);
+ auto device_data = *(pt_->policy_table.device_data);
+
+ auto from = pt_->policy_table.device_data->find(device_id_from);
+ DCHECK_OR_RETURN_VOID(from != device_data.end());
+
+ auto to = pt_->policy_table.device_data->find(device_id_to);
+ DCHECK_OR_RETURN_VOID(to != device_data.end());
+
+ auto& consents_from = *(from->second.user_consent_records);
+ auto& consents_to = *(to->second.user_consent_records);
+
+ LOG4CXX_DEBUG(logger_,
+ "Merging user consents from device: "
+ << device_id_from << " to device: " << device_id_to);
+ for (auto f = consents_from.begin(); f != consents_from.end(); ++f) {
+ const auto app_id = f->first;
+ LOG4CXX_DEBUG(logger_, "Updating permissions for key: " << app_id);
+ consents_to[app_id] = f->second;
+ }
+}
+
CacheManager::BackgroundBackuper::BackgroundBackuper(
CacheManager* cache_manager)
: cache_manager_(cache_manager)
@@ -2633,9 +2735,10 @@ void CacheManager::BackgroundBackuper::threadMain() {
LOG4CXX_AUTO_TRACE(logger_);
sync_primitives::AutoLock lock(need_backup_lock_);
while (!stop_flag_) {
- need_backup_lock_.Release();
- InternalBackup();
- need_backup_lock_.Acquire();
+ {
+ sync_primitives::AutoUnlock need_backup_lock(need_backup_lock_);
+ InternalBackup();
+ }
if (new_data_available_ || stop_flag_) {
continue;
}
diff --git a/src/components/policy/policy_external/src/policy_helper.cc b/src/components/policy/policy_external/src/policy_helper.cc
index 5425777833..8be0372c03 100644
--- a/src/components/policy/policy_external/src/policy_helper.cc
+++ b/src/components/policy/policy_external/src/policy_helper.cc
@@ -797,7 +797,7 @@ void FillFunctionalGroupPermissions(
FunctionalGroupNames& names,
GroupConsent state,
std::vector<FunctionalGroupPermission>& permissions) {
- LOG4CXX_INFO(logger_, "FillFunctionalGroupPermissions");
+ LOG4CXX_AUTO_TRACE(logger_);
FunctionalGroupIDs::const_iterator it = ids.begin();
FunctionalGroupIDs::const_iterator it_end = ids.end();
for (; it != it_end; ++it) {
@@ -817,7 +817,7 @@ bool IsPredefinedApp(const AppPoliciesValueType& app) {
FunctionalGroupIDs ExcludeSame(const FunctionalGroupIDs& from,
const FunctionalGroupIDs& what) {
- LOG4CXX_INFO(logger_, "Exclude same groups");
+ LOG4CXX_AUTO_TRACE(logger_);
FunctionalGroupIDs from_copy(from);
FunctionalGroupIDs what_copy(what);
@@ -839,7 +839,7 @@ FunctionalGroupIDs ExcludeSame(const FunctionalGroupIDs& from,
FunctionalGroupIDs Merge(const FunctionalGroupIDs& first,
const FunctionalGroupIDs& second) {
- LOG4CXX_INFO(logger_, "Merge groups");
+ LOG4CXX_AUTO_TRACE(logger_);
FunctionalGroupIDs first_copy(first);
FunctionalGroupIDs second_copy(second);
diff --git a/src/components/policy/policy_external/src/policy_manager_impl.cc b/src/components/policy/policy_external/src/policy_manager_impl.cc
index d50779383a..433a7a6bca 100644
--- a/src/components/policy/policy_external/src/policy_manager_impl.cc
+++ b/src/components/policy/policy_external/src/policy_manager_impl.cc
@@ -313,7 +313,10 @@ bool PolicyManagerImpl::LoadPT(const std::string& file,
utils::SharedPtr<policy_table::Table> policy_table_snapshot =
cache_->GenerateSnapshot();
if (!policy_table_snapshot) {
- LOG4CXX_ERROR(logger_, "Failed to create snapshot of policy table");
+ LOG4CXX_ERROR(
+ logger_,
+ "Failed to create snapshot of policy table, trying another exchange");
+ ForcePTExchange();
return false;
}
@@ -327,7 +330,10 @@ bool PolicyManagerImpl::LoadPT(const std::string& file,
// Replace current data with updated
if (!cache_->ApplyUpdate(*pt_update)) {
- LOG4CXX_WARN(logger_, "Unsuccessful save of updated policy table.");
+ LOG4CXX_WARN(
+ logger_,
+ "Unsuccessful save of updated policy table, trying another exchange");
+ ForcePTExchange();
return false;
}
@@ -588,13 +594,7 @@ void PolicyManagerImpl::CheckPermissions(const PTString& app_id,
policy_table::FunctionalGroupings functional_groupings;
cache_->GetFunctionalGroupings(functional_groupings);
-#ifdef SDL_REMOTE_CONTROL
- ApplicationOnDevice who = {device_id, app_id};
- const policy_table::Strings app_groups = access_remote_->GetGroups(who);
-#else // SDL_REMOTE_CONTROL
- const policy_table::Strings app_groups =
- GetGroupsNames(app_group_permissions);
-#endif // SDL_REMOTE_CONTROL
+ policy_table::Strings app_groups = GetGroupsNames(app_group_permissions);
// Undefined groups (without user consent) disallowed by default, since
// OnPermissionsChange notification has no "undefined" section
@@ -614,8 +614,19 @@ void PolicyManagerImpl::CheckPermissions(const PTString& app_id,
<< " returns true");
}
+ if (cache_->IsApplicationRevoked(app_id)) {
+ // SDL must be able to notify mobile side with its status after app has
+ // been revoked by backend
+ if ("OnHMIStatus" == rpc && "NONE" == hmi_level) {
+ result.hmi_level_permitted = kRpcAllowed;
+ } else {
+ result.hmi_level_permitted = kRpcDisallowed;
+ }
+ return;
+ }
+
const bool known_rpc = rpc_permissions.end() != rpc_permissions.find(rpc);
- LOG4CXX_INFO(logger_, "Is known rpc " << known_rpc);
+ LOG4CXX_DEBUG(logger_, "Is known rpc " << (known_rpc ? "true" : "false"));
if (!known_rpc) {
// RPC not found in list == disallowed by backend
result.hmi_level_permitted = kRpcDisallowed;
@@ -637,6 +648,9 @@ void PolicyManagerImpl::CheckPermissions(const PTString& app_id,
rpc_permissions[rpc].hmi_permissions[kUserDisallowedKey].find(
hmi_level)) {
// RPC found in allowed == allowed by backend, but disallowed by user
+ LOG4CXX_DEBUG(
+ logger_,
+ "RPC found in allowed == allowed by backend, but disallowed by user");
result.hmi_level_permitted = kRpcUserDisallowed;
} else {
LOG4CXX_DEBUG(logger_,
@@ -715,17 +729,6 @@ void PolicyManagerImpl::CheckPermissions(const PTString& app_id,
LOG4CXX_DEBUG(logger_, "There are no parameters allowed.");
result.hmi_level_permitted = kRpcDisallowed;
}
-
- if (cache_->IsApplicationRevoked(app_id)) {
- // SDL must be able to notify mobile side with its status after app has
- // been revoked by backend
- if ("OnHMIStatus" == rpc && "NONE" == hmi_level) {
- result.hmi_level_permitted = kRpcAllowed;
- } else {
- result.hmi_level_permitted = kRpcDisallowed;
- }
- return;
- }
}
bool PolicyManagerImpl::ResetUserConsent() {
@@ -967,6 +970,7 @@ void PolicyManagerImpl::CheckPendingPermissionsChanges(
void PolicyManagerImpl::NotifyPermissionsChanges(
const std::string& policy_app_id,
const std::vector<FunctionalGroupPermission>& app_group_permissions) {
+ LOG4CXX_AUTO_TRACE(logger_);
// Get current functional groups from DB with RPC permissions
policy_table::FunctionalGroupings functional_groups;
cache_->GetFunctionalGroupings(functional_groups);
@@ -986,11 +990,6 @@ void PolicyManagerImpl::SetUserConsentForApp(
const PermissionConsent& permissions, const NotificationMode mode) {
LOG4CXX_AUTO_TRACE(logger_);
- if (permissions.group_permissions.empty()) {
- LOG4CXX_DEBUG(logger_, "Permissions list is empty, skipping update.");
- return;
- }
-
cache_->ResetCalculatedPermissions();
PermissionConsent verified_permissions =
EnsureCorrectPermissionConsent(permissions);
@@ -1157,14 +1156,8 @@ void PolicyManagerImpl::GetPermissionsForApp(
FunctionalIdType group_types;
-#ifdef SDL_REMOTE_CONTROL
- allowed_by_default = false;
- const bool ret = access_remote_->GetPermissionsForApp(
- device_id, app_id_to_check, group_types);
-#else
const bool ret =
cache_->GetPermissionsForApp(device_id, app_id_to_check, group_types);
-#endif // REMOTE_CONTROL
if (!ret) {
LOG4CXX_WARN(logger_,
@@ -1581,8 +1574,7 @@ void PolicyManagerImpl::OnUpdateStarted() {
uint32_t update_timeout = TimeoutExchangeMSec();
LOG4CXX_DEBUG(logger_,
"Update timeout will be set to (milisec): " << update_timeout);
- send_on_update_sent_out_ =
- !wrong_ptu_update_received_ && !update_status_manager_.IsUpdatePending();
+ send_on_update_sent_out_ = !update_status_manager_.IsUpdatePending();
if (send_on_update_sent_out_) {
update_status_manager_.OnUpdateSentOut(update_timeout);
@@ -1681,6 +1673,12 @@ void PolicyManagerImpl::OnAppRegisteredOnMobile(
SendNotificationOnPermissionsUpdated(application_id);
}
+void PolicyManagerImpl::OnDeviceSwitching(const std::string& device_id_from,
+ const std::string& device_id_to) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ cache_->OnDeviceSwitching(device_id_from, device_id_to);
+}
+
const MetaInfo PolicyManagerImpl::GetMetaInfo() const {
LOG4CXX_AUTO_TRACE(logger_);
return cache_->GetMetaInfo();
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 e3e1029692..9702c315b0 100644
--- a/src/components/policy/policy_external/src/sql_pt_queries.cc
+++ b/src/components/policy/policy_external/src/sql_pt_queries.cc
@@ -137,7 +137,7 @@ const std::string kCreateSchema =
"CREATE INDEX `rpc.select_rpc_name_hmi_level` "
" ON `rpc`(`name`,`hmi_level_value`);"
"CREATE TABLE IF NOT EXISTS `application`( "
- " `id` VARCHAR(45) PRIMARY KEY NOT NULL, "
+ " `id` VARCHAR(45) PRIMARY KEY NOT NULL COLLATE NOCASE, "
" `keep_context` BOOLEAN, "
" `steal_focus` BOOLEAN, "
" `default_hmi` VARCHAR(45), "
@@ -160,7 +160,7 @@ const std::string kCreateSchema =
"CREATE INDEX IF NOT EXISTS `application.fk_application_priorities1_idx` "
" ON `application`(`priority_value`); "
"CREATE TABLE IF NOT EXISTS `app_group`( "
- " `application_id` VARCHAR(45) NOT NULL, "
+ " `application_id` VARCHAR(45) NOT NULL COLLATE NOCASE, "
" `functional_group_id` INTEGER NOT NULL, "
" PRIMARY KEY(`application_id`,`functional_group_id`), "
" CONSTRAINT `fk_application_has_functional_group_application1` "
@@ -175,9 +175,9 @@ const std::string kCreateSchema =
" ON `app_group`(`functional_group_id`); "
"CREATE INDEX IF NOT EXISTS "
"`app_group.fk_application_has_functional_group_application1_idx` "
- " ON `app_group`(`application_id`); "
+ " ON `app_group`(`application_id` COLLATE NOCASE); "
"CREATE TABLE IF NOT EXISTS `preconsented_group`( "
- " `application_id` VARCHAR(45) NOT NULL, "
+ " `application_id` VARCHAR(45) NOT NULL COLLATE NOCASE, "
" `functional_group_id` INTEGER NOT NULL, "
" PRIMARY KEY(`application_id`,`functional_group_id`), "
" CONSTRAINT `fk_application_has_functional_group_application2` "
@@ -193,7 +193,7 @@ const std::string kCreateSchema =
" ON `preconsented_group`(`functional_group_id`); "
"CREATE INDEX IF NOT EXISTS "
"`preconsented_group.fk_application_has_functional_group_application2_idx` "
- " ON `preconsented_group`(`application_id`); "
+ " ON `preconsented_group`(`application_id` COLLATE NOCASE); "
"CREATE TABLE IF NOT EXISTS `seconds_between_retry`( "
" `index` INTEGER PRIMARY KEY NOT NULL, "
" `value` INTEGER NOT NULL "
@@ -220,7 +220,7 @@ const std::string kCreateSchema =
"`device_consent_group.fk_device_has_functional_group_device1_idx` "
" ON `device_consent_group`(`device_id`); "
"CREATE TABLE IF NOT EXISTS `app_level`( "
- " `application_id` VARCHAR(45) PRIMARY KEY NOT NULL, "
+ " `application_id` VARCHAR(45) PRIMARY KEY NOT NULL COLLATE NOCASE, "
" `minutes_in_hmi_full` INTEGER DEFAULT 0, "
" `minutes_in_hmi_limited` INTEGER DEFAULT 0, "
" `minutes_in_hmi_background` INTEGER DEFAULT 0, "
@@ -247,24 +247,24 @@ const std::string kCreateSchema =
" REFERENCES `language`(`code`) "
"); "
"CREATE INDEX IF NOT EXISTS `app_level.fk_app_levels_application1_idx` "
- " ON `app_level`(`application_id`); "
+ " ON `app_level`(`application_id` COLLATE NOCASE); "
"CREATE INDEX IF NOT EXISTS `app_level.fk_app_level_language1_idx` "
" ON `app_level`(`app_registration_language_gui`); "
"CREATE INDEX IF NOT EXISTS `app_level.fk_app_level_language2_idx` "
" ON `app_level`(`app_registration_language_vui`); "
"CREATE TABLE IF NOT EXISTS `nickname`( "
- " `name` VARCHAR(100) NOT NULL, "
- " `application_id` VARCHAR(45) NOT NULL, "
+ " `name` VARCHAR(100) NOT NULL COLLATE NOCASE, "
+ " `application_id` VARCHAR(45) NOT NULL COLLATE NOCASE, "
" PRIMARY KEY(`name`,`application_id`), "
" CONSTRAINT `fk_nickname_application1` "
" FOREIGN KEY(`application_id`) "
" REFERENCES `application`(`id`) "
"); "
"CREATE INDEX IF NOT EXISTS `nickname.fk_nickname_application1_idx` "
- " ON `nickname`(`application_id`); "
+ " ON `nickname`(`application_id` COLLATE NOCASE); "
"CREATE TABLE IF NOT EXISTS `app_type`( "
" `name` VARCHAR(50) NOT NULL, "
- " `application_id` VARCHAR(45) NOT NULL, "
+ " `application_id` VARCHAR(45) NOT NULL COLLATE NOCASE, "
" PRIMARY KEY(`name`,`application_id`), "
" CONSTRAINT `fk_app_type_application1` "
" FOREIGN KEY(`application_id`) "
@@ -272,17 +272,17 @@ const std::string kCreateSchema =
"); "
"CREATE TABLE IF NOT EXISTS `request_type`( "
" `request_type` VARCHAR(50) NOT NULL, "
- " `application_id` VARCHAR(45) NOT NULL, "
+ " `application_id` VARCHAR(45) NOT NULL COLLATE NOCASE, "
" PRIMARY KEY(`request_type`,`application_id`), "
" CONSTRAINT `fk_app_type_application1` "
" FOREIGN KEY(`application_id`) "
" REFERENCES `application`(`id`) "
"); "
"CREATE INDEX IF NOT EXISTS `app_type.fk_app_type_application1_idx` "
- " ON `app_type`(`application_id`); "
+ " ON `app_type`(`application_id` COLLATE NOCASE); "
"CREATE TABLE IF NOT EXISTS `consent_group`( "
" `device_id` VARCHAR(100) NOT NULL, "
- " `application_id` VARCHAR(45) NOT NULL, "
+ " `application_id` VARCHAR(45) NOT NULL COLLATE NOCASE, "
" `functional_group_id` INTEGER NOT NULL, "
" `is_consented` BOOL NOT NULL, "
" `input` VARCHAR(45), "
@@ -301,7 +301,7 @@ const std::string kCreateSchema =
"); "
"CREATE TABLE IF NOT EXISTS `external_consent_status_group`( "
" `device_id` VARCHAR(100) NOT NULL, "
- " `application_id` VARCHAR(45) NOT NULL, "
+ " `application_id` VARCHAR(45) NOT NULL COLLATE NOCASE, "
" `functional_group_id` INTEGER NOT NULL, "
" `is_consented` BOOL NOT NULL, "
" `input` VARCHAR(45), "
@@ -325,15 +325,15 @@ const std::string kCreateSchema =
"`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, "
+ " `application_id` VARCHAR(45) NOT NULL COLLATE NOCASE, "
" CONSTRAINT `fk_endpoint_application1` "
" FOREIGN KEY(`application_id`) "
" REFERENCES `application`(`id`) "
"); "
"CREATE INDEX IF NOT EXISTS `endpoint.fk_endpoint_application1_idx` "
- " ON `endpoint`(`application_id`); "
+ " ON `endpoint`(`application_id` COLLATE NOCASE); "
"CREATE TABLE IF NOT EXISTS `message`( "
" `id` INTEGER PRIMARY KEY NOT NULL, "
" `tts` TEXT, "
@@ -374,14 +374,14 @@ const std::string kCreateSchema =
/* module type */
"CREATE TABLE IF NOT EXISTS `module_type`( "
" `name` VARCHAR(50) NOT NULL, "
- " `application_id` VARCHAR(45) NOT NULL, "
+ " `application_id` VARCHAR(45) NOT NULL COLLATE NOCASE, "
" PRIMARY KEY(`name`,`application_id`), "
" CONSTRAINT `fk_module_type_application1` "
" FOREIGN KEY(`application_id`) "
" REFERENCES `application`(`id`) "
"); "
"CREATE INDEX IF NOT EXISTS `module_type.fk_module_type_application1_idx` "
- " ON `module_type`(`application_id`); "
+ " ON `module_type`(`application_id` COLLATE NOCASE); "
"CREATE INDEX IF NOT EXISTS `message.fk_messages_languages1_idx` "
" ON `message`(`language_code`);"
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 f9cc5e5ed5..4315d99b3a 100644
--- a/src/components/policy/policy_external/src/sql_pt_representation.cc
+++ b/src/components/policy/policy_external/src/sql_pt_representation.cc
@@ -559,10 +559,10 @@ void SQLPTRepresentation::GatherModuleConfig(
LOG4CXX_WARN(logger_, "Incorrect select statement for endpoints");
} else {
while (endpoints.Next()) {
- std::stringstream stream;
- stream << "0x0" << endpoints.GetInteger(1);
- config->endpoints[stream.str()][endpoints.GetString(2)].push_back(
- endpoints.GetString(0));
+ const std::string& url = endpoints.GetString(0);
+ const std::string& service = endpoints.GetString(1);
+ const std::string& app_id = endpoints.GetString(2);
+ config->endpoints[service][app_id].push_back(url);
}
}
@@ -1262,11 +1262,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()) {
diff --git a/src/components/policy/policy_external/test/json/PTU.json b/src/components/policy/policy_external/test/json/PTU.json
index 7316c7539d..c0f18bb6a9 100644
--- a/src/components/policy/policy_external/test/json/PTU.json
+++ b/src/components/policy/policy_external/test/json/PTU.json
@@ -15,7 +15,7 @@
"endpoints": {
"0x07": {
"default": [
- "http://policies.telematics.ford.com/api/policies"
+ "http://x.x.x.x:3000/api/1/policies"
]
}
},
diff --git a/src/components/policy/policy_external/test/json/PTU2.json b/src/components/policy/policy_external/test/json/PTU2.json
index c1a6bccb68..8ad6aefb83 100644
--- a/src/components/policy/policy_external/test/json/PTU2.json
+++ b/src/components/policy/policy_external/test/json/PTU2.json
@@ -15,7 +15,7 @@
"endpoints": {
"0x07": {
"default": [
- "http://policies.telematics.ford.com/api/policies"
+ "http://x.x.x.x:3000/api/1/policies"
]
}
},
diff --git a/src/components/policy/policy_external/test/json/PTU3.json b/src/components/policy/policy_external/test/json/PTU3.json
index 56939a789a..33f699d068 100644
--- a/src/components/policy/policy_external/test/json/PTU3.json
+++ b/src/components/policy/policy_external/test/json/PTU3.json
@@ -15,7 +15,7 @@
"endpoints": {
"0x07": {
"default": [
- "http://policies.telematics.ford.com/api/policies"
+ "http://x.x.x.x:3000/api/1/policies"
]
}
},
diff --git a/src/components/policy/policy_external/test/json/PTU_default_app.json b/src/components/policy/policy_external/test/json/PTU_default_app.json
index 833d46316a..b036d96b50 100644
--- a/src/components/policy/policy_external/test/json/PTU_default_app.json
+++ b/src/components/policy/policy_external/test/json/PTU_default_app.json
@@ -1,7 +1,7 @@
{
"policy_table" : {
"app_policies" : {
- "1766825573" : {
+ "1010101010" : {
"AppHMIType" : [ "MEDIA" ],
"certificate" : "akdjfhaliuygrglurng",
"default_hmi" : "BACKGROUND",
@@ -295,7 +295,7 @@
},
"endpoints" : {
"0x07" : {
- "default" : [ "http://policies.telematics.ford.com/api/policies" ]
+ "default" : [ "http://x.x.x.x:3000/api/1/policies" ]
}
},
"exchange_after_x_days" : 30,
diff --git a/src/components/policy/policy_external/test/json/PTU_default_app_app_invalid_values_RequestType_array.json b/src/components/policy/policy_external/test/json/PTU_default_app_app_invalid_values_RequestType_array.json
index 1e5b1c46a4..49ed46f16c 100644
--- a/src/components/policy/policy_external/test/json/PTU_default_app_app_invalid_values_RequestType_array.json
+++ b/src/components/policy/policy_external/test/json/PTU_default_app_app_invalid_values_RequestType_array.json
@@ -1,7 +1,7 @@
{
"policy_table" : {
"app_policies" : {
- "1766825573" : {
+ "1010101010" : {
"AppHMIType" : [ "MEDIA" ],
"certificate" : "akdjfhaliuygrglurng",
"default_hmi" : "BACKGROUND",
@@ -293,7 +293,7 @@
},
"endpoints" : {
"0x07" : {
- "default" : [ "http://policies.telematics.ford.com/api/policies" ]
+ "default" : [ "http://x.x.x.x:3000/api/1/policies" ]
}
},
"exchange_after_x_days" : 30,
diff --git a/src/components/policy/policy_external/test/json/PTU_default_app_empty_RequestType_array.json b/src/components/policy/policy_external/test/json/PTU_default_app_empty_RequestType_array.json
index 76365ee4bb..66af76309a 100644
--- a/src/components/policy/policy_external/test/json/PTU_default_app_empty_RequestType_array.json
+++ b/src/components/policy/policy_external/test/json/PTU_default_app_empty_RequestType_array.json
@@ -1,7 +1,7 @@
{
"policy_table" : {
"app_policies" : {
- "1766825573" : {
+ "1010101010" : {
"AppHMIType" : [ "MEDIA" ],
"certificate" : "akdjfhaliuygrglurng",
"default_hmi" : "BACKGROUND",
@@ -290,7 +290,7 @@
},
"endpoints" : {
"0x07" : {
- "default" : [ "http://policies.telematics.ford.com/api/policies" ]
+ "default" : [ "http://x.x.x.x:3000/api/1/policies" ]
}
},
"exchange_after_x_days" : 30,
diff --git a/src/components/policy/policy_external/test/json/PTU_default_app_omitted_RequestType_array.json b/src/components/policy/policy_external/test/json/PTU_default_app_omitted_RequestType_array.json
index b380fa2de5..0a7c059097 100644
--- a/src/components/policy/policy_external/test/json/PTU_default_app_omitted_RequestType_array.json
+++ b/src/components/policy/policy_external/test/json/PTU_default_app_omitted_RequestType_array.json
@@ -1,7 +1,7 @@
{
"policy_table" : {
"app_policies" : {
- "1766825573" : {
+ "1010101010" : {
"AppHMIType" : [ "MEDIA" ],
"certificate" : "akdjfhaliuygrglurng",
"default_hmi" : "BACKGROUND",
@@ -289,7 +289,7 @@
},
"endpoints" : {
"0x07" : {
- "default" : [ "http://policies.telematics.ford.com/api/policies" ]
+ "default" : [ "http://x.x.x.x:3000/api/1/policies" ]
}
},
"exchange_after_x_days" : 30,
diff --git a/src/components/policy/policy_external/test/json/PTU_default_app_one_invalid_value_RequestType_array.json b/src/components/policy/policy_external/test/json/PTU_default_app_one_invalid_value_RequestType_array.json
index b8793b6cdc..08f12a21c8 100644
--- a/src/components/policy/policy_external/test/json/PTU_default_app_one_invalid_value_RequestType_array.json
+++ b/src/components/policy/policy_external/test/json/PTU_default_app_one_invalid_value_RequestType_array.json
@@ -1,7 +1,7 @@
{
"policy_table" : {
"app_policies" : {
- "1766825573" : {
+ "1010101010" : {
"AppHMIType" : [ "MEDIA" ],
"certificate" : "akdjfhaliuygrglurng",
"default_hmi" : "BACKGROUND",
@@ -296,7 +296,7 @@
},
"endpoints" : {
"0x07" : {
- "default" : [ "http://policies.telematics.ford.com/api/policies" ]
+ "default" : [ "http://x.x.x.x:3000/api/1/policies" ]
}
},
"exchange_after_x_days" : 30,
diff --git a/src/components/policy/policy_external/test/json/PTU_pre_data_consent_app.json b/src/components/policy/policy_external/test/json/PTU_pre_data_consent_app.json
index 833d46316a..b036d96b50 100644
--- a/src/components/policy/policy_external/test/json/PTU_pre_data_consent_app.json
+++ b/src/components/policy/policy_external/test/json/PTU_pre_data_consent_app.json
@@ -1,7 +1,7 @@
{
"policy_table" : {
"app_policies" : {
- "1766825573" : {
+ "1010101010" : {
"AppHMIType" : [ "MEDIA" ],
"certificate" : "akdjfhaliuygrglurng",
"default_hmi" : "BACKGROUND",
@@ -295,7 +295,7 @@
},
"endpoints" : {
"0x07" : {
- "default" : [ "http://policies.telematics.ford.com/api/policies" ]
+ "default" : [ "http://x.x.x.x:3000/api/1/policies" ]
}
},
"exchange_after_x_days" : 30,
diff --git a/src/components/policy/policy_external/test/json/PTU_pre_data_consent_app_empty_RequestType_array.json b/src/components/policy/policy_external/test/json/PTU_pre_data_consent_app_empty_RequestType_array.json
index 8a183b45d5..6aeb637503 100644
--- a/src/components/policy/policy_external/test/json/PTU_pre_data_consent_app_empty_RequestType_array.json
+++ b/src/components/policy/policy_external/test/json/PTU_pre_data_consent_app_empty_RequestType_array.json
@@ -1,7 +1,7 @@
{
"policy_table" : {
"app_policies" : {
- "1766825573" : {
+ "1010101010" : {
"AppHMIType" : [ "MEDIA" ],
"certificate" : "akdjfhaliuygrglurng",
"default_hmi" : "BACKGROUND",
@@ -290,7 +290,7 @@
},
"endpoints" : {
"0x07" : {
- "default" : [ "http://policies.telematics.ford.com/api/policies" ]
+ "default" : [ "http://x.x.x.x:3000/api/1/policies" ]
}
},
"exchange_after_x_days" : 30,
diff --git a/src/components/policy/policy_external/test/json/PTU_pre_data_consent_app_invalid_values_RequestType_array.json b/src/components/policy/policy_external/test/json/PTU_pre_data_consent_app_invalid_values_RequestType_array.json
index 6ffc42c3e4..8c68aaeb89 100644
--- a/src/components/policy/policy_external/test/json/PTU_pre_data_consent_app_invalid_values_RequestType_array.json
+++ b/src/components/policy/policy_external/test/json/PTU_pre_data_consent_app_invalid_values_RequestType_array.json
@@ -1,7 +1,7 @@
{
"policy_table" : {
"app_policies" : {
- "1766825573" : {
+ "1010101010" : {
"AppHMIType" : [ "MEDIA" ],
"certificate" : "akdjfhaliuygrglurng",
"default_hmi" : "BACKGROUND",
@@ -291,7 +291,7 @@
},
"endpoints" : {
"0x07" : {
- "default" : [ "http://policies.telematics.ford.com/api/policies" ]
+ "default" : [ "http://x.x.x.x:3000/api/1/policies" ]
}
},
"exchange_after_x_days" : 30,
diff --git a/src/components/policy/policy_external/test/json/PTU_pre_data_consent_app_omitted_RequestType_array.json b/src/components/policy/policy_external/test/json/PTU_pre_data_consent_app_omitted_RequestType_array.json
index 24d0871d18..0ae0761f27 100644
--- a/src/components/policy/policy_external/test/json/PTU_pre_data_consent_app_omitted_RequestType_array.json
+++ b/src/components/policy/policy_external/test/json/PTU_pre_data_consent_app_omitted_RequestType_array.json
@@ -1,7 +1,7 @@
{
"policy_table" : {
"app_policies" : {
- "1766825573" : {
+ "1010101010" : {
"AppHMIType" : [ "MEDIA" ],
"certificate" : "akdjfhaliuygrglurng",
"default_hmi" : "BACKGROUND",
@@ -283,7 +283,7 @@
},
"endpoints" : {
"0x07" : {
- "default" : [ "http://policies.telematics.ford.com/api/policies" ]
+ "default" : [ "http://x.x.x.x:3000/api/1/policies" ]
}
},
"exchange_after_x_days" : 30,
diff --git a/src/components/policy/policy_external/test/json/PTU_pre_data_consent_app_one_invalid_value_RequestType_array.json b/src/components/policy/policy_external/test/json/PTU_pre_data_consent_app_one_invalid_value_RequestType_array.json
index b674913268..6b170089fe 100644
--- a/src/components/policy/policy_external/test/json/PTU_pre_data_consent_app_one_invalid_value_RequestType_array.json
+++ b/src/components/policy/policy_external/test/json/PTU_pre_data_consent_app_one_invalid_value_RequestType_array.json
@@ -1,7 +1,7 @@
{
"policy_table" : {
"app_policies" : {
- "1766825573" : {
+ "1010101010" : {
"AppHMIType" : [ "MEDIA" ],
"certificate" : "akdjfhaliuygrglurng",
"default_hmi" : "BACKGROUND",
@@ -296,7 +296,7 @@
},
"endpoints" : {
"0x07" : {
- "default" : [ "http://policies.telematics.ford.com/api/policies" ]
+ "default" : [ "http://x.x.x.x:3000/api/1/policies" ]
}
},
"exchange_after_x_days" : 30,
diff --git a/src/components/policy/policy_external/test/json/PTU_with_empty_requestType_array.json b/src/components/policy/policy_external/test/json/PTU_with_empty_requestType_array.json
index 7e0836a805..45e616c874 100644
--- a/src/components/policy/policy_external/test/json/PTU_with_empty_requestType_array.json
+++ b/src/components/policy/policy_external/test/json/PTU_with_empty_requestType_array.json
@@ -1,7 +1,7 @@
{
"policy_table" : {
"app_policies" : {
- "1766825573" : {
+ "1010101010" : {
"AppHMIType" : [ "MEDIA" ],
"certificate" : "akdjfhaliuygrglurng",
"default_hmi" : "BACKGROUND",
@@ -1703,7 +1703,7 @@
},
"endpoints" : {
"0x07" : {
- "default" : [ "http://policies.telematics.ford.com/api/policies" ]
+ "default" : [ "http://x.x.x.x:3000/api/1/policies" ]
}
},
"exchange_after_x_days" : 30,
diff --git a/src/components/policy/policy_external/test/json/PTU_with_invalid_requestType_between_correct.json b/src/components/policy/policy_external/test/json/PTU_with_invalid_requestType_between_correct.json
index a056c3ce9c..917d53177f 100644
--- a/src/components/policy/policy_external/test/json/PTU_with_invalid_requestType_between_correct.json
+++ b/src/components/policy/policy_external/test/json/PTU_with_invalid_requestType_between_correct.json
@@ -1,7 +1,7 @@
{
"policy_table" : {
"app_policies" : {
- "1766825573" : {
+ "1010101010" : {
"AppHMIType" : [ "MEDIA" ],
"certificate" : "akdjfhaliuygrglurng",
"default_hmi" : "BACKGROUND",
@@ -1706,7 +1706,7 @@
},
"endpoints" : {
"0x07" : {
- "default" : [ "http://policies.telematics.ford.com/api/policies" ]
+ "default" : [ "http://x.x.x.x:3000/api/1/policies" ]
}
},
"exchange_after_x_days" : 30,
diff --git a/src/components/policy/policy_external/test/json/PTU_with_one_invalid_requestType.json b/src/components/policy/policy_external/test/json/PTU_with_one_invalid_requestType.json
index c7e0a727fe..f514f279de 100644
--- a/src/components/policy/policy_external/test/json/PTU_with_one_invalid_requestType.json
+++ b/src/components/policy/policy_external/test/json/PTU_with_one_invalid_requestType.json
@@ -1,7 +1,7 @@
{
"policy_table" : {
"app_policies" : {
- "1766825573" : {
+ "1010101010" : {
"AppHMIType" : [ "MEDIA" ],
"certificate" : "akdjfhaliuygrglurng",
"default_hmi" : "BACKGROUND",
@@ -1703,7 +1703,7 @@
},
"endpoints" : {
"0x07" : {
- "default" : [ "http://policies.telematics.ford.com/api/policies" ]
+ "default" : [ "http://x.x.x.x:3000/api/1/policies" ]
}
},
"exchange_after_x_days" : 30,
diff --git a/src/components/policy/policy_external/test/json/PTU_without_requestType_field.json b/src/components/policy/policy_external/test/json/PTU_without_requestType_field.json
index a96ef74bd1..57c1bce8f1 100644
--- a/src/components/policy/policy_external/test/json/PTU_without_requestType_field.json
+++ b/src/components/policy/policy_external/test/json/PTU_without_requestType_field.json
@@ -1,7 +1,7 @@
{
"policy_table" : {
"app_policies" : {
- "1766825573" : {
+ "1010101010" : {
"AppHMIType" : [ "MEDIA" ],
"certificate" : "akdjfhaliuygrglurng",
"default_hmi" : "BACKGROUND",
@@ -1702,7 +1702,7 @@
},
"endpoints" : {
"0x07" : {
- "default" : [ "http://policies.telematics.ford.com/api/policies" ]
+ "default" : [ "http://x.x.x.x:3000/api/1/policies" ]
}
},
"exchange_after_x_days" : 30,
diff --git a/src/components/policy/policy_external/test/json/preloadedPT_with_invalid_default_reqestType_between_valid.json b/src/components/policy/policy_external/test/json/preloadedPT_with_invalid_default_reqestType_between_valid.json
index 4c1bf19005..20023ba8e5 100644
--- a/src/components/policy/policy_external/test/json/preloadedPT_with_invalid_default_reqestType_between_valid.json
+++ b/src/components/policy/policy_external/test/json/preloadedPT_with_invalid_default_reqestType_between_valid.json
@@ -14,7 +14,7 @@
625],
"endpoints": {
"0x07": {
- "default": ["http://policies.telematics.ford.com/api/policies"]
+ "default": ["http://x.x.x.x:3000/api/1/policies"]
}
},
"notifications_per_minute_by_priority": {
diff --git a/src/components/policy/policy_external/test/json/preloadedPT_with_invalid_default_requestType.json b/src/components/policy/policy_external/test/json/preloadedPT_with_invalid_default_requestType.json
index 02801cc976..5e4dffbc56 100644
--- a/src/components/policy/policy_external/test/json/preloadedPT_with_invalid_default_requestType.json
+++ b/src/components/policy/policy_external/test/json/preloadedPT_with_invalid_default_requestType.json
@@ -14,7 +14,7 @@
625],
"endpoints": {
"0x07": {
- "default": ["http://policies.telematics.ford.com/api/policies"]
+ "default": ["http://x.x.x.x:3000/api/1/policies"]
}
},
"notifications_per_minute_by_priority": {
diff --git a/src/components/policy/policy_external/test/json/preloadedPT_with_several_invalid_default_requestTypes.json b/src/components/policy/policy_external/test/json/preloadedPT_with_several_invalid_default_requestTypes.json
index a9abeea5a2..6b92db7c17 100644
--- a/src/components/policy/policy_external/test/json/preloadedPT_with_several_invalid_default_requestTypes.json
+++ b/src/components/policy/policy_external/test/json/preloadedPT_with_several_invalid_default_requestTypes.json
@@ -14,7 +14,7 @@
625],
"endpoints": {
"0x07": {
- "default": ["http://policies.telematics.ford.com/api/policies"]
+ "default": ["http://x.x.x.x:3000/api/1/policies"]
}
},
"notifications_per_minute_by_priority": {
diff --git a/src/components/policy/policy_external/test/json/ptu2_requestType.json b/src/components/policy/policy_external/test/json/ptu2_requestType.json
index 899e58a68d..c12ec773e0 100644
--- a/src/components/policy/policy_external/test/json/ptu2_requestType.json
+++ b/src/components/policy/policy_external/test/json/ptu2_requestType.json
@@ -16,12 +16,12 @@
"endpoints": {
"0x07": {
"default": [
- "http://policies.telematics.ford.com/api/policies"
+ "http://x.x.x.x:3000/api/1/policies"
]
},
"0x04": {
"default": [
- "http://ivsu.software.ford.com/api/getsoftwareupdates"
+ "http://x.x.x.x:3000/api/1/softwareUpdate"
]
}
},
@@ -2594,7 +2594,7 @@
"PROPRIETARY"
]
},
- "584421907": {
+ "123454321": {
"keep_context" : false,
"steal_focus" : false,
"priority"
diff --git a/src/components/policy/policy_external/test/json/ptu_requestType.json b/src/components/policy/policy_external/test/json/ptu_requestType.json
index a1f085ac74..0b1f0ed469 100644
--- a/src/components/policy/policy_external/test/json/ptu_requestType.json
+++ b/src/components/policy/policy_external/test/json/ptu_requestType.json
@@ -15,12 +15,12 @@
"endpoints": {
"0x07": {
"default": [
- "http://policies.telematics.ford.com/api/policies"
+ "http://x.x.x.x:3000/api/1/policies"
]
},
"0x04": {
"default": [
- "http://ivsu.software.ford.com/api/getsoftwareupdates"
+ "http://x.x.x.x:3000/api/1/softwareUpdate"
]
}
},
@@ -2553,7 +2553,7 @@
}
},
"app_policies": {
- "584421907": {
+ "123454321": {
"keep_context": false,
"steal_focus": false,
"priority": "NONE",
diff --git a/src/components/policy/policy_external/test/json/sdl_preloaded_pt.json b/src/components/policy/policy_external/test/json/sdl_preloaded_pt.json
index d6f34c12fc..10894516cf 100644
--- a/src/components/policy/policy_external/test/json/sdl_preloaded_pt.json
+++ b/src/components/policy/policy_external/test/json/sdl_preloaded_pt.json
@@ -14,7 +14,7 @@
625],
"endpoints": {
"0x07": {
- "default": ["http://policies.telematics.ford.com/api/policies"]
+ "default": ["http://x.x.x.x:3000/api/1/policies"]
}
},
"notifications_per_minute_by_priority": {
diff --git a/src/components/policy/policy_external/test/json/sdl_preloaded_pt1.json b/src/components/policy/policy_external/test/json/sdl_preloaded_pt1.json
index 78c5f873d9..79d1b572e6 100644
--- a/src/components/policy/policy_external/test/json/sdl_preloaded_pt1.json
+++ b/src/components/policy/policy_external/test/json/sdl_preloaded_pt1.json
@@ -2385,11 +2385,11 @@
{
"0x04" :
{
- "default" : [ "http://ivsu.software.ford.com/api/getsoftwareupdates" ]
+ "default" : [ "http://x.x.x.x:3000/api/1/softwareUpdate" ]
},
"0x07" :
{
- "default" : [ "http://policies.telematics.ford.com/api/policies" ]
+ "default" : [ "http://x.x.x.x:3000/api/1/policies" ]
}
},
"exchange_after_x_days" : 20,
diff --git a/src/components/policy/policy_external/test/json/sdl_preloaded_pt_send_location.json b/src/components/policy/policy_external/test/json/sdl_preloaded_pt_send_location.json
index 49f9a1da3a..1401c3b7a1 100644
--- a/src/components/policy/policy_external/test/json/sdl_preloaded_pt_send_location.json
+++ b/src/components/policy/policy_external/test/json/sdl_preloaded_pt_send_location.json
@@ -16,12 +16,12 @@
"endpoints": {
"0x04": {
"default": [
- "http://ivsu.software.ford.com/api/getsoftwareupdates"
+ "http://x.x.x.x:3000/api/1/softwareUpdate"
]
},
"0x07": {
"default": [
- "http://policies.telematics.ford.com/api/policies"
+ "http://x.x.x.x:3000/api/1/policies"
]
}
},
diff --git a/src/components/policy/policy_external/test/json/sdl_pt_first_update.json b/src/components/policy/policy_external/test/json/sdl_pt_first_update.json
index e6817da0d3..ac2b18ab6f 100644
--- a/src/components/policy/policy_external/test/json/sdl_pt_first_update.json
+++ b/src/components/policy/policy_external/test/json/sdl_pt_first_update.json
@@ -1,7 +1,7 @@
{
"policy_table" : {
"app_policies" : {
- "1766825573" : {
+ "1010101010" : {
"AppHMIType" : [ "MEDIA" ],
"certificate" : "akdjfhaliuygrglurng",
"default_hmi" : "BACKGROUND",
@@ -1720,7 +1720,7 @@
},
"endpoints" : {
"0x07" : {
- "default" : [ "http://policies.telematics.ford.com/api/policies" ]
+ "default" : [ "http://x.x.x.x:3000/api/1/policies" ]
}
},
"exchange_after_x_days" : 30,
diff --git a/src/components/policy/policy_external/test/json/sdl_pt_second_update.json b/src/components/policy/policy_external/test/json/sdl_pt_second_update.json
index d5f5f480f3..230ad1fa4f 100644
--- a/src/components/policy/policy_external/test/json/sdl_pt_second_update.json
+++ b/src/components/policy/policy_external/test/json/sdl_pt_second_update.json
@@ -1,7 +1,7 @@
{
"policy_table" : {
"app_policies" : {
- "1766825573" : {
+ "1010101010" : {
"AppHMIType" : [ "MEDIA" ],
"certificate" : "akdjfhaliuygrglurng",
"default_hmi" : "BACKGROUND",
@@ -1720,7 +1720,7 @@
},
"endpoints" : {
"0x07" : {
- "default" : [ "http://policies.telematics.ford.com/api/policies" ]
+ "default" : [ "http://x.x.x.x:3000/api/1/policies" ]
}
},
"exchange_after_x_days" : 30,
diff --git a/src/components/policy/policy_external/test/json/sdl_pt_update.json b/src/components/policy/policy_external/test/json/sdl_pt_update.json
index 5047d832dd..4e2dd3a85c 100644
--- a/src/components/policy/policy_external/test/json/sdl_pt_update.json
+++ b/src/components/policy/policy_external/test/json/sdl_pt_update.json
@@ -1,7 +1,7 @@
{
"policy_table" : {
"app_policies" : {
- "1766825573" : {
+ "1010101010" : {
"AppHMIType" : [ "MEDIA" ],
"certificate" : "akdjfhaliuygrglurng",
"default_hmi" : "BACKGROUND",
@@ -1704,7 +1704,7 @@
},
"endpoints" : {
"0x07" : {
- "default" : [ "http://policies.telematics.ford.com/api/policies" ]
+ "default" : [ "http://x.x.x.x:3000/api/1/policies" ]
}
},
"exchange_after_x_days" : 30,
diff --git a/src/components/policy/policy_external/test/json/sdl_update_pt_2_groups_have_params.json b/src/components/policy/policy_external/test/json/sdl_update_pt_2_groups_have_params.json
index 18b0a09040..8a3ef897c5 100644
--- a/src/components/policy/policy_external/test/json/sdl_update_pt_2_groups_have_params.json
+++ b/src/components/policy/policy_external/test/json/sdl_update_pt_2_groups_have_params.json
@@ -15,12 +15,12 @@
"endpoints": {
"0x04": {
"default": [
- "http://ivsu.software.ford.com/api/getsoftwareupdates"
+ "http://x.x.x.x:3000/api/1/softwareUpdate"
]
},
"0x07": {
"default": [
- "http://policies.telematics.ford.com/api/policies"
+ "http://x.x.x.x:3000/api/1/policies"
]
}
},
diff --git a/src/components/policy/policy_external/test/json/sdl_update_pt_2_groups_no_params_in1.json b/src/components/policy/policy_external/test/json/sdl_update_pt_2_groups_no_params_in1.json
index 3530c01388..dcb96f147b 100644
--- a/src/components/policy/policy_external/test/json/sdl_update_pt_2_groups_no_params_in1.json
+++ b/src/components/policy/policy_external/test/json/sdl_update_pt_2_groups_no_params_in1.json
@@ -15,12 +15,12 @@
"endpoints": {
"0x04": {
"default": [
- "http://ivsu.software.ford.com/api/getsoftwareupdates"
+ "http://x.x.x.x:3000/api/1/softwareUpdate"
]
},
"0x07": {
"default": [
- "http://policies.telematics.ford.com/api/policies"
+ "http://x.x.x.x:3000/api/1/policies"
]
}
},
diff --git a/src/components/policy/policy_external/test/json/sdl_update_pt_2_groups_no_params_in1_omitted_in2.json b/src/components/policy/policy_external/test/json/sdl_update_pt_2_groups_no_params_in1_omitted_in2.json
index e169aea24a..dd7a529ec8 100644
--- a/src/components/policy/policy_external/test/json/sdl_update_pt_2_groups_no_params_in1_omitted_in2.json
+++ b/src/components/policy/policy_external/test/json/sdl_update_pt_2_groups_no_params_in1_omitted_in2.json
@@ -15,12 +15,12 @@
"endpoints": {
"0x04": {
"default": [
- "http://ivsu.software.ford.com/api/getsoftwareupdates"
+ "http://x.x.x.x:3000/api/1/softwareUpdate"
]
},
"0x07": {
"default": [
- "http://policies.telematics.ford.com/api/policies"
+ "http://x.x.x.x:3000/api/1/policies"
]
}
},
diff --git a/src/components/policy/policy_external/test/json/sdl_update_pt_send_location.json b/src/components/policy/policy_external/test/json/sdl_update_pt_send_location.json
index df45a0be61..14eb11d195 100644
--- a/src/components/policy/policy_external/test/json/sdl_update_pt_send_location.json
+++ b/src/components/policy/policy_external/test/json/sdl_update_pt_send_location.json
@@ -15,12 +15,12 @@
"endpoints": {
"0x04": {
"default": [
- "http://ivsu.software.ford.com/api/getsoftwareupdates"
+ "http://x.x.x.x:3000/api/1/softwareUpdate"
]
},
"0x07": {
"default": [
- "http://policies.telematics.ford.com/api/policies"
+ "http://x.x.x.x:3000/api/1/policies"
]
}
},
diff --git a/src/components/policy/policy_external/test/json/sdl_update_pt_send_location_all_params.json b/src/components/policy/policy_external/test/json/sdl_update_pt_send_location_all_params.json
index c471d6ec97..f1e460e603 100644
--- a/src/components/policy/policy_external/test/json/sdl_update_pt_send_location_all_params.json
+++ b/src/components/policy/policy_external/test/json/sdl_update_pt_send_location_all_params.json
@@ -15,12 +15,12 @@
"endpoints": {
"0x04": {
"default": [
- "http://ivsu.software.ford.com/api/getsoftwareupdates"
+ "http://x.x.x.x:3000/api/1/softwareUpdate"
]
},
"0x07": {
"default": [
- "http://policies.telematics.ford.com/api/policies"
+ "http://x.x.x.x:3000/api/1/policies"
]
}
},
diff --git a/src/components/policy/policy_external/test/json/sdl_update_pt_send_location_no_params.json b/src/components/policy/policy_external/test/json/sdl_update_pt_send_location_no_params.json
index 29781d211c..0ba24ce484 100644
--- a/src/components/policy/policy_external/test/json/sdl_update_pt_send_location_no_params.json
+++ b/src/components/policy/policy_external/test/json/sdl_update_pt_send_location_no_params.json
@@ -15,12 +15,12 @@
"endpoints": {
"0x04": {
"default": [
- "http://ivsu.software.ford.com/api/getsoftwareupdates"
+ "http://x.x.x.x:3000/api/1/softwareUpdate"
]
},
"0x07": {
"default": [
- "http://policies.telematics.ford.com/api/policies"
+ "http://x.x.x.x:3000/api/1/policies"
]
}
},
diff --git a/src/components/policy/policy_external/test/json/sdl_update_pt_send_location_some_params.json b/src/components/policy/policy_external/test/json/sdl_update_pt_send_location_some_params.json
index 91be06a561..6e8ce0c6a7 100644
--- a/src/components/policy/policy_external/test/json/sdl_update_pt_send_location_some_params.json
+++ b/src/components/policy/policy_external/test/json/sdl_update_pt_send_location_some_params.json
@@ -15,12 +15,12 @@
"endpoints": {
"0x04": {
"default": [
- "http://ivsu.software.ford.com/api/getsoftwareupdates"
+ "http://x.x.x.x:3000/api/1/softwareUpdate"
]
},
"0x07": {
"default": [
- "http://policies.telematics.ford.com/api/policies"
+ "http://x.x.x.x:3000/api/1/policies"
]
}
},
diff --git a/src/components/policy/policy_external/test/json/valid_sdl_pt_update.json b/src/components/policy/policy_external/test/json/valid_sdl_pt_update.json
index 56c728f104..c384ea73e2 100644
--- a/src/components/policy/policy_external/test/json/valid_sdl_pt_update.json
+++ b/src/components/policy/policy_external/test/json/valid_sdl_pt_update.json
@@ -1,7 +1,7 @@
{
"policy_table" : {
"app_policies" : {
- "1766825573" : {
+ "1010101010" : {
"AppHMIType" : [ "MEDIA" ],
"certificate" : "akdjfhaliuygrglurng",
"default_hmi" : "BACKGROUND",
@@ -1696,7 +1696,7 @@
},
"endpoints" : {
"0x07" : {
- "default" : [ "http://policies.telematics.ford.com/api/policies" ]
+ "default" : [ "http://x.x.x.x:3000/api/1/policies" ]
}
},
"exchange_after_x_days" : 30,
diff --git a/src/components/policy/policy_external/test/policy_manager_impl_ptu_test.cc b/src/components/policy/policy_external/test/policy_manager_impl_ptu_test.cc
index da0cd913b6..947bb5d3ad 100644
--- a/src/components/policy/policy_external/test/policy_manager_impl_ptu_test.cc
+++ b/src/components/policy/policy_external/test/policy_manager_impl_ptu_test.cc
@@ -574,8 +574,7 @@ TEST_F(PolicyManagerImplTest2, GetUpdateUrl) {
CreateLocalPT(preloaded_pt_filename_);
GetPTU(kValidSdlPtUpdateJson);
// Check expectations
- const std::string update_url(
- "http://policies.telematics.ford.com/api/policies");
+ const std::string update_url("http://x.x.x.x:3000/api/1/policies");
EXPECT_EQ(update_url, policy_manager_->GetUpdateUrl(7));
EXPECT_EQ("", policy_manager_->GetUpdateUrl(4));
}
diff --git a/src/components/policy/policy_external/test/policy_manager_impl_test_base.cc b/src/components/policy/policy_external/test/policy_manager_impl_test_base.cc
index 0608799535..48e86d24b7 100644
--- a/src/components/policy/policy_external/test/policy_manager_impl_test_base.cc
+++ b/src/components/policy/policy_external/test/policy_manager_impl_test_base.cc
@@ -238,8 +238,8 @@ void PolicyManagerImplTest::TearDown() {
// PolicyManagerImplTest2 class methods
PolicyManagerImplTest2::PolicyManagerImplTest2()
: app_id_1_("123456789")
- , app_id_2_("1766825573")
- , app_id_3_("584421907")
+ , app_id_2_("1010101010")
+ , app_id_3_("123454321")
, device_id_1_("XXX123456789ZZZ")
, device_id_2_("08-00-27-CE-76-FE")
, application_id_("1234")
@@ -629,7 +629,7 @@ PolicyManagerImplTest_RequestTypes::PolicyManagerImplTest_RequestTypes()
"PTU_pre_data_consent_app_one_invalid_value_RequestType_"
"array."
"json"}
- , kAppId("1766825573")
+ , kAppId("1010101010")
, kDefaultAppId(policy::kDefaultId)
, app_storage_folder_("storage3")
, preloaded_pt_filename_(kSdlPreloadedPtJson) {}
diff --git a/src/components/policy/policy_regular/include/policy/cache_manager.h b/src/components/policy/policy_regular/include/policy/cache_manager.h
index c5d4c848f4..8c0acd44d2 100644
--- a/src/components/policy/policy_regular/include/policy/cache_manager.h
+++ b/src/components/policy/policy_regular/include/policy/cache_manager.h
@@ -701,6 +701,15 @@ class CacheManager : public CacheManagerInterface {
return pt_;
}
+ /**
+ * @brief OnDeviceSwitching Processes existing policy permissions for devices
+ * switching transport
+ * @param device_id_from Device ID original
+ * @param device_id_to Device ID new
+ */
+ void OnDeviceSwitching(const std::string& device_id_from,
+ const std::string& device_id_to) OVERRIDE;
+
private:
std::string currentDateTime();
struct AppHMITypeToString {
@@ -722,6 +731,13 @@ class CacheManager : public CacheManagerInterface {
void PersistData();
+ /**
+ * @brief Transform to lower case all non default application names in
+ * applications policies section
+ * @param pt polict rable for update
+ */
+ void MakeLowerCaseAppNames(policy_table::Table& pt) const;
+
void ResetCalculatedPermissions();
void AddCalculatedPermissions(const std::string& device_id,
@@ -740,7 +756,7 @@ class CacheManager : public CacheManagerInterface {
typedef std::set<std::string> UnpairedDevices;
UnpairedDevices is_unpaired_;
- sync_primitives::Lock cache_lock_;
+ mutable sync_primitives::Lock cache_lock_;
sync_primitives::Lock unpaired_lock_;
typedef std::map<std::string, Permissions> AppCalculatedPermissions;
diff --git a/src/components/policy/policy_regular/include/policy/cache_manager_interface.h b/src/components/policy/policy_regular/include/policy/cache_manager_interface.h
index 9712b799dc..9f7c7318db 100644
--- a/src/components/policy/policy_regular/include/policy/cache_manager_interface.h
+++ b/src/components/policy/policy_regular/include/policy/cache_manager_interface.h
@@ -641,6 +641,15 @@ class CacheManagerInterface {
*
*/
virtual utils::SharedPtr<policy_table::Table> pt() const = 0;
+
+ /**
+ * @brief OnDeviceSwitching Processes existing policy permissions for devices
+ * switching transport
+ * @param device_id_from Device ID original
+ * @param device_id_to Device ID new
+ */
+ virtual void OnDeviceSwitching(const std::string& device_id_from,
+ const std::string& device_id_to) = 0;
};
typedef utils::SharedPtr<CacheManagerInterface> CacheManagerInterfaceSPtr;
diff --git a/src/components/policy/policy_regular/include/policy/policy_helper.h b/src/components/policy/policy_regular/include/policy/policy_helper.h
index 996c2917d0..8a60801dd4 100644
--- a/src/components/policy/policy_regular/include/policy/policy_helper.h
+++ b/src/components/policy/policy_regular/include/policy/policy_helper.h
@@ -114,7 +114,8 @@ struct CheckAppPolicy {
const std::vector<FunctionalGroupPermission>& revoked_groups) const;
bool IsKnownAppication(const std::string& application_id) const;
void NotifySystem(const AppPoliciesValueType& app_policy) const;
- void SendPermissionsToApp(const AppPoliciesValueType& app_policy) const;
+ void SendPermissionsToApp(const std::string& app_id,
+ const policy_table::Strings& groups) const;
bool IsAppRevoked(const AppPoliciesValueType& app_policy) const;
bool NicknamesMatch(const AppPoliciesValueType& app_policy) const;
/**
diff --git a/src/components/policy/policy_regular/include/policy/policy_manager_impl.h b/src/components/policy/policy_regular/include/policy/policy_manager_impl.h
index 1b39392c0c..941db1a67f 100644
--- a/src/components/policy/policy_regular/include/policy/policy_manager_impl.h
+++ b/src/components/policy/policy_regular/include/policy/policy_manager_impl.h
@@ -553,6 +553,9 @@ class PolicyManagerImpl : public PolicyManager {
*/
void OnAppRegisteredOnMobile(const std::string& application_id) OVERRIDE;
+ void OnDeviceSwitching(const std::string& device_id_from,
+ const std::string& device_id_to) OVERRIDE;
+
/**
* @brief RetrieveCertificate Allows to obtain certificate in order
* to start secure connection.
diff --git a/src/components/policy/policy_regular/include/policy/policy_table/enums.h b/src/components/policy/policy_regular/include/policy/policy_table/enums.h
index 66ab9a1b60..4eb35d2aa4 100644
--- a/src/components/policy/policy_regular/include/policy/policy_table/enums.h
+++ b/src/components/policy/policy_regular/include/policy/policy_table/enums.h
@@ -87,6 +87,7 @@ enum Parameter {
P_DEVICESTATUS,
P_EMERGENCYEVENT,
P_ECALLINFO,
+ P_EMPTY // Added to allow empty parameters handling
};
bool IsValidEnum(Parameter val);
diff --git a/src/components/policy/policy_regular/include/policy/policy_types.h b/src/components/policy/policy_regular/include/policy/policy_types.h
index 25aa126a03..af1d119e7a 100644
--- a/src/components/policy/policy_regular/include/policy/policy_types.h
+++ b/src/components/policy/policy_regular/include/policy/policy_types.h
@@ -41,6 +41,8 @@
#include <utility>
#include "utils/shared_ptr.h"
#include "utils/helpers.h"
+#include "transport_manager/common.h"
+
namespace policy {
// TODO(PV): specify errors
@@ -190,7 +192,7 @@ struct DeviceParams {
std::string device_name;
std::string device_mac_address;
std::string device_connection_type;
- uint32_t device_handle;
+ transport_manager::DeviceHandle device_handle;
};
/**
diff --git a/src/components/policy/policy_regular/src/cache_manager.cc b/src/components/policy/policy_regular/src/cache_manager.cc
index 377278949b..6a142374d5 100644
--- a/src/components/policy/policy_regular/src/cache_manager.cc
+++ b/src/components/policy/policy_regular/src/cache_manager.cc
@@ -83,11 +83,27 @@ struct LanguageFinder {
const std::string& language_;
};
+struct PolicyTableUpdater {
+ PolicyTableUpdater(const policy_table::ApplicationParams& default_params)
+ : default_params_(default_params) {}
+
+ void operator()(policy_table::ApplicationPolicies::value_type& pt_value) {
+ if (policy::kDefaultId == pt_value.second.get_string()) {
+ pt_value.second = default_params_;
+ pt_value.second.set_to_string(policy::kDefaultId);
+ }
+ }
+
+ private:
+ const policy_table::ApplicationParams& default_params_;
+};
+
CacheManager::CacheManager()
: CacheManagerInterface()
, pt_(new policy_table::Table)
, backup_(new SQLPTRepresentation())
- , update_required(false) {
+ , update_required(false)
+ , cache_lock_(true) {
LOG4CXX_AUTO_TRACE(logger_);
backuper_ = new BackgroundBackuper(this);
backup_thread_ = threads::CreateThread("Backup thread", backuper_);
@@ -103,6 +119,7 @@ CacheManager::~CacheManager() {
}
const policy_table::Strings& CacheManager::GetGroups(const PTString& app_id) {
+ sync_primitives::AutoLock auto_lock(cache_lock_);
return pt_->policy_table.app_policies_section.apps[app_id].groups;
}
@@ -114,6 +131,7 @@ bool CacheManager::CanAppKeepContext(const std::string& app_id) const {
uint32_t CacheManager::HeartBeatTimeout(const std::string& app_id) const {
CACHE_MANAGER_CHECK(0);
+ sync_primitives::AutoLock auto_lock(cache_lock_);
uint32_t result = 0;
if (!AppExists(app_id)) {
return result;
@@ -130,6 +148,7 @@ uint32_t CacheManager::HeartBeatTimeout(const std::string& app_id) const {
const policy_table::AppHMITypes* CacheManager::GetHMITypes(
const std::string& app_id) {
+ sync_primitives::AutoLock auto_lock(cache_lock_);
const policy_table::ApplicationPolicies& apps =
pt_->policy_table.app_policies_section.apps;
policy_table::ApplicationPolicies::const_iterator i = apps.find(app_id);
@@ -180,6 +199,7 @@ void CacheManager::GetAllAppGroups(const std::string& app_id,
return;
}
+ sync_primitives::AutoLock auto_lock(cache_lock_);
policy_table::ApplicationPolicies::const_iterator app_params_iter =
pt_->policy_table.app_policies_section.apps.find(app_id);
@@ -244,6 +264,11 @@ bool CacheManager::ApplyUpdate(const policy_table::Table& update_pt) {
"");
} else {
pt_->policy_table.app_policies_section.apps[iter->first] = iter->second;
+ if (kDefaultId == iter->first) {
+ std::for_each(pt_->policy_table.app_policies_section.apps.begin(),
+ pt_->policy_table.app_policies_section.apps.end(),
+ PolicyTableUpdater(iter->second));
+ }
}
}
@@ -265,6 +290,7 @@ void CacheManager::GetHMIAppTypeAfterUpdate(
std::map<std::string, StringArray>& app_hmi_types) {
LOG4CXX_AUTO_TRACE(logger_);
CACHE_MANAGER_CHECK_VOID();
+ sync_primitives::AutoLock auto_lock(cache_lock_);
policy_table::ApplicationPolicies::const_iterator policy_iter_begin =
pt_->policy_table.app_policies_section.apps.begin();
policy_table::ApplicationPolicies::const_iterator policy_iter_end =
@@ -288,6 +314,7 @@ void CacheManager::GetHMIAppTypeAfterUpdate(
bool CacheManager::AppHasHMIType(const std::string& application_id,
policy_table::AppHMIType hmi_type) const {
+ sync_primitives::AutoLock auto_lock(cache_lock_);
const policy_table::ApplicationPolicies& policies =
pt_->policy_table.app_policies_section.apps;
@@ -399,6 +426,7 @@ bool CacheManager::ReactOnUserDevConsentForApp(const std::string& app_id,
void CacheManager::GetGroupNameByHashID(const int32_t group_id,
std::string& group_name) {
CACHE_MANAGER_CHECK_VOID();
+ sync_primitives::AutoLock auto_lock(cache_lock_);
policy_table::FunctionalGroupings::const_iterator fg_iter =
pt_->policy_table.functional_groupings.begin();
policy_table::FunctionalGroupings::const_iterator fg_iter_end =
@@ -432,6 +460,7 @@ void CacheManager::SaveUpdateRequired(bool status) {
bool CacheManager::IsApplicationRevoked(const std::string& app_id) const {
CACHE_MANAGER_CHECK(false);
+ sync_primitives::AutoLock auto_lock(cache_lock_);
bool is_revoked = false;
if (pt_->policy_table.app_policies_section.apps.end() !=
pt_->policy_table.app_policies_section.apps.find(app_id)) {
@@ -447,6 +476,7 @@ void CacheManager::CheckPermissions(const policy_table::Strings& groups,
CheckPermissionResult& result) {
LOG4CXX_AUTO_TRACE(logger_);
CACHE_MANAGER_CHECK_VOID();
+ sync_primitives::AutoLock auto_lock(cache_lock_);
policy_table::Strings::const_iterator app_groups_iter = groups.begin();
policy_table::Strings::const_iterator app_groups_iter_end = groups.end();
@@ -463,6 +493,13 @@ void CacheManager::CheckPermissions(const policy_table::Strings& groups,
if (rpcs.rpcs.end() != rpc_iter) {
policy_table::RpcParameters rpc_param = rpc_iter->second;
+ if (rpc_param.parameters.is_initialized() &&
+ rpc_param.parameters->empty()) {
+ // If "parameters" field exist in PT section of incoming RPC but empty
+ // all params considered as DISALLOWED
+ result.hmi_level_permitted = kRpcDisallowed;
+ return;
+ }
policy_table::HmiLevel hmi_level_e;
policy_table::EnumFromJsonString(hmi_level, &hmi_level_e);
@@ -491,11 +528,13 @@ void CacheManager::CheckPermissions(const policy_table::Strings& groups,
bool CacheManager::IsPTPreloaded() {
CACHE_MANAGER_CHECK(false);
+ sync_primitives::AutoLock auto_lock(cache_lock_);
return *pt_->policy_table.module_config.preloaded_pt;
}
int CacheManager::IgnitionCyclesBeforeExchange() {
CACHE_MANAGER_CHECK(0);
+ sync_primitives::AutoLock auto_lock(cache_lock_);
const uint8_t limit = std::max(
static_cast<int>(
pt_->policy_table.module_config.exchange_after_x_ignition_cycles),
@@ -515,6 +554,7 @@ int CacheManager::IgnitionCyclesBeforeExchange() {
int CacheManager::KilometersBeforeExchange(int current) {
CACHE_MANAGER_CHECK(0);
+ sync_primitives::AutoLock auto_lock(cache_lock_);
const int limit =
std::max(static_cast<int>(
pt_->policy_table.module_config.exchange_after_x_kilometers),
@@ -535,6 +575,7 @@ int CacheManager::KilometersBeforeExchange(int current) {
bool CacheManager::SetCountersPassedForSuccessfulUpdate(
policy::Counters counter, int value) {
CACHE_MANAGER_CHECK(false);
+ sync_primitives::AutoLock auto_lock(cache_lock_);
switch (counter) {
case KILOMETERS:
*pt_->policy_table.module_meta->pt_exchanged_at_odometer_x = value;
@@ -560,6 +601,7 @@ bool CacheManager::SetCountersPassedForSuccessfulUpdate(
int CacheManager::DaysBeforeExchange(int current) {
LOG4CXX_AUTO_TRACE(logger_);
CACHE_MANAGER_CHECK(0);
+ sync_primitives::AutoLock auto_lock(cache_lock_);
const rpc::Optional<rpc::Integer<uint16_t, 0, 65535> >& days_after_epoch =
(pt_->policy_table.module_meta->pt_exchanged_x_days_after_epoch);
@@ -583,6 +625,7 @@ int CacheManager::DaysBeforeExchange(int current) {
void CacheManager::IncrementIgnitionCycles() {
CACHE_MANAGER_CHECK_VOID();
+ sync_primitives::AutoLock auto_lock(cache_lock_);
const int ign_val = static_cast<int>(
*pt_->policy_table.module_meta->ignition_cycles_since_last_exchange);
(*pt_->policy_table.module_meta->ignition_cycles_since_last_exchange) =
@@ -593,18 +636,21 @@ void CacheManager::IncrementIgnitionCycles() {
void CacheManager::ResetIgnitionCycles() {
CACHE_MANAGER_CHECK_VOID();
+ sync_primitives::AutoLock auto_lock(cache_lock_);
(*pt_->policy_table.module_meta->ignition_cycles_since_last_exchange) = 0;
Backup();
}
int CacheManager::TimeoutResponse() {
CACHE_MANAGER_CHECK(0);
+ sync_primitives::AutoLock auto_lock(cache_lock_);
return pt_->policy_table.module_config.timeout_after_x_seconds *
date_time::DateTime::MILLISECONDS_IN_SECOND;
}
bool CacheManager::SecondsBetweenRetries(std::vector<int>& seconds) {
CACHE_MANAGER_CHECK(false);
+ sync_primitives::AutoLock auto_lock(cache_lock_);
rpc::policy_table_interface_base::SecondsBetweenRetries::iterator iter =
pt_->policy_table.module_config.seconds_between_retries.begin();
rpc::policy_table_interface_base::SecondsBetweenRetries::iterator iter_end =
@@ -621,6 +667,7 @@ bool CacheManager::SecondsBetweenRetries(std::vector<int>& seconds) {
const policy::VehicleInfo CacheManager::GetVehicleInfo() const {
CACHE_MANAGER_CHECK(VehicleInfo());
+ sync_primitives::AutoLock auto_lock(cache_lock_);
policy_table::ModuleConfig& module_config = pt_->policy_table.module_config;
VehicleInfo vehicle_info;
vehicle_info.vehicle_make = *module_config.vehicle_make;
@@ -642,6 +689,7 @@ std::vector<UserFriendlyMessage> CacheManager::GetUserFriendlyMsg(
std::vector<std::string>::const_iterator it = msg_codes.begin();
std::vector<std::string>::const_iterator it_end = msg_codes.end();
+ sync_primitives::AutoLock auto_lock(cache_lock_);
for (; it != it_end; ++it) {
policy_table::MessageLanguages msg_languages =
(*pt_->policy_table.consumer_friendly_messages->messages)[*it];
@@ -701,6 +749,7 @@ void CacheManager::GetUpdateUrls(const std::string& service_type,
LOG4CXX_DEBUG(logger_, "Search service value is: " << service_type);
+ sync_primitives::AutoLock auto_lock(cache_lock_);
policy_table::ServiceEndpoints::const_iterator iter =
pt_->policy_table.module_config.endpoints.find(service_type);
@@ -733,6 +782,7 @@ CacheManager::GetNotificationsNumber(const std::string& priority) {
CACHE_MANAGER_CHECK(0);
typedef rpc::policy_table_interface_base::NumberOfNotificationsPerMinute NNPM;
+ sync_primitives::AutoLock auto_lock(cache_lock_);
const NNPM& nnpm =
pt_->policy_table.module_config.notifications_per_minute_by_priority;
@@ -746,6 +796,7 @@ CacheManager::GetNotificationsNumber(const std::string& priority) {
bool CacheManager::GetPriority(const std::string& policy_app_id,
std::string& priority) const {
CACHE_MANAGER_CHECK(false);
+ sync_primitives::AutoLock auto_lock(cache_lock_);
if (kDeviceId == policy_app_id) {
priority = EnumToJsonString(
pt_->policy_table.app_policies_section.device.priority);
@@ -884,9 +935,10 @@ void CacheManager::PersistData() {
LOG4CXX_AUTO_TRACE(logger_);
if (backup_.valid()) {
if (pt_.valid()) {
- cache_lock_.Acquire();
- policy_table::Table copy_pt(*pt_);
- cache_lock_.Release();
+ // Comma expression is used to hold the lock only during the constructor
+ // call
+ policy_table::Table copy_pt(
+ (sync_primitives::AutoLock(cache_lock_), *pt_));
backup_->Save(copy_pt);
backup_->SaveUpdateRequired(update_required);
@@ -978,12 +1030,12 @@ bool CacheManager::IsPermissionsCalculated(const std::string& device_id,
utils::SharedPtr<policy_table::Table> CacheManager::GenerateSnapshot() {
CACHE_MANAGER_CHECK(snapshot_);
- sync_primitives::AutoLock lock(cache_lock_);
snapshot_ = new policy_table::Table();
// Copy all members of policy table except messages in consumer friendly
// messages
+ sync_primitives::AutoLock auto_lock(cache_lock_);
snapshot_->policy_table.app_policies_section =
pt_->policy_table.app_policies_section;
snapshot_->policy_table.functional_groupings =
@@ -1010,6 +1062,7 @@ bool CacheManager::GetInitialAppData(const std::string& app_id,
StringArray& app_hmi_types) {
LOG4CXX_AUTO_TRACE(logger_);
CACHE_MANAGER_CHECK(false);
+ sync_primitives::AutoLock auto_lock(cache_lock_);
policy_table::ApplicationPolicies::const_iterator policy_iter =
pt_->policy_table.app_policies_section.apps.find(app_id);
@@ -1032,6 +1085,7 @@ bool CacheManager::GetFunctionalGroupings(
policy_table::FunctionalGroupings& groups) {
LOG4CXX_AUTO_TRACE(logger_);
CACHE_MANAGER_CHECK(false);
+ sync_primitives::AutoLock auto_lock(cache_lock_);
const policy_table::FunctionalGroupings& f_groupings =
pt_->policy_table.functional_groupings;
@@ -1052,6 +1106,7 @@ bool CacheManager::SetMetaInfo(const std::string& ccpu_version,
const std::string& wers_country_code,
const std::string& language) {
CACHE_MANAGER_CHECK(false);
+ sync_primitives::AutoLock auto_lock(cache_lock_);
// We have to set preloaded flag as false in policy table on any response
// of GetSystemInfo (SDLAQ-CRS-2365)
@@ -1076,6 +1131,7 @@ bool CacheManager::SetSystemLanguage(const std::string& language) {
bool CacheManager::GetFunctionalGroupNames(FunctionalGroupNames& names) {
LOG4CXX_AUTO_TRACE(logger_);
CACHE_MANAGER_CHECK(false);
+ sync_primitives::AutoLock auto_lock(cache_lock_);
rpc::policy_table_interface_base::FunctionalGroupings::iterator iter =
pt_->policy_table.functional_groupings.begin();
rpc::policy_table_interface_base::FunctionalGroupings::iterator iter_end =
@@ -1209,7 +1265,7 @@ long CacheManager::ConvertSecondsToMinute(int seconds) {
bool CacheManager::SetDefaultPolicy(const std::string& app_id) {
CACHE_MANAGER_CHECK(false);
- sync_primitives::AutoLock lock(cache_lock_);
+ sync_primitives::AutoLock auto_lock(cache_lock_);
policy_table::ApplicationPolicies::const_iterator iter =
pt_->policy_table.app_policies_section.apps.find(kDefaultId);
if (pt_->policy_table.app_policies_section.apps.end() != iter) {
@@ -1224,6 +1280,7 @@ bool CacheManager::SetDefaultPolicy(const std::string& app_id) {
bool CacheManager::IsDefaultPolicy(const std::string& app_id) const {
CACHE_MANAGER_CHECK(false);
+ sync_primitives::AutoLock auto_lock(cache_lock_);
const bool result =
pt_->policy_table.app_policies_section.apps.end() !=
pt_->policy_table.app_policies_section.apps.find(app_id) &&
@@ -1235,6 +1292,7 @@ bool CacheManager::IsDefaultPolicy(const std::string& app_id) const {
bool CacheManager::SetIsDefault(const std::string& app_id) {
CACHE_MANAGER_CHECK(false);
+ sync_primitives::AutoLock auto_lock(cache_lock_);
policy_table::ApplicationPolicies::const_iterator iter =
pt_->policy_table.app_policies_section.apps.find(app_id);
if (pt_->policy_table.app_policies_section.apps.end() != iter) {
@@ -1246,7 +1304,7 @@ bool CacheManager::SetIsDefault(const std::string& app_id) {
bool CacheManager::SetPredataPolicy(const std::string& app_id) {
CACHE_MANAGER_CHECK(false);
- sync_primitives::AutoLock lock(cache_lock_);
+ sync_primitives::AutoLock auto_lock(cache_lock_);
policy_table::ApplicationPolicies::const_iterator iter =
pt_->policy_table.app_policies_section.apps.find(kPreDataConsentId);
@@ -1270,6 +1328,7 @@ bool CacheManager::SetPredataPolicy(const std::string& app_id) {
bool CacheManager::IsPredataPolicy(const std::string& app_id) const {
// TODO(AOleynik): Maybe change for comparison with pre_DataConsent
// permissions or check string value from get_string()
+ sync_primitives::AutoLock auto_lock(cache_lock_);
if (!IsApplicationRepresented(app_id)) {
return false;
}
@@ -1296,6 +1355,7 @@ bool CacheManager::IsPredataPolicy(const std::string& app_id) const {
bool CacheManager::SetUnpairedDevice(const std::string& device_id,
bool unpaired) {
+ sync_primitives::AutoLock auto_lock(cache_lock_);
const bool result = pt_->policy_table.device_data->end() !=
pt_->policy_table.device_data->find(device_id);
if (!result) {
@@ -1328,6 +1388,7 @@ bool CacheManager::IsApplicationRepresented(const std::string& app_id) const {
if (kDeviceId == app_id) {
return true;
}
+ sync_primitives::AutoLock auto_lock(cache_lock_);
policy_table::ApplicationPolicies::const_iterator iter =
pt_->policy_table.app_policies_section.apps.find(app_id);
return pt_->policy_table.app_policies_section.apps.end() != iter;
@@ -1398,6 +1459,27 @@ bool CacheManager::LoadFromBackup() {
return true;
}
+void CacheManager::MakeLowerCaseAppNames(policy_table::Table& pt) const {
+ policy_table::ApplicationPolicies& apps =
+ pt.policy_table.app_policies_section.apps;
+ for (policy_table::ApplicationPolicies::iterator iter = apps.begin();
+ iter != apps.end();) {
+ std::string key = iter->first;
+ if (key == kDefaultId || key == kPreDataConsentId || key == kDeviceId) {
+ ++iter;
+ continue;
+ }
+
+ std::transform(key.begin(), key.end(), key.begin(), ::tolower);
+ if (key.compare(iter->first) != 0) {
+ std::swap(apps[key], iter->second);
+ iter = apps.erase(iter);
+ } else {
+ ++iter;
+ }
+ }
+}
+
bool CacheManager::LoadFromFile(const std::string& file_name,
policy_table::Table& table) {
LOG4CXX_AUTO_TRACE(logger_);
@@ -1426,6 +1508,8 @@ bool CacheManager::LoadFromFile(const std::string& file_name,
LOG4CXX_DEBUG(logger_, "PT out:");
LOG4CXX_DEBUG(logger_, s_writer.write(table.ToJsonValue()));
+ MakeLowerCaseAppNames(table);
+
if (!table.is_valid()) {
rpc::ValidationReport report("policy_table");
table.ReportErrors(&report);
@@ -1433,6 +1517,7 @@ bool CacheManager::LoadFromFile(const std::string& file_name,
"Parsed table is not valid " << rpc::PrettyFormat(report));
return false;
}
+
return true;
}
@@ -1444,6 +1529,7 @@ bool CacheManager::ResetPT(const std::string& file_name) {
bool CacheManager::AppExists(const std::string& app_id) const {
CACHE_MANAGER_CHECK(false);
+ sync_primitives::AutoLock auto_lock(cache_lock_);
policy_table::ApplicationPolicies::iterator policy_iter =
pt_->policy_table.app_policies_section.apps.find(app_id);
return pt_->policy_table.app_policies_section.apps.end() != policy_iter;
@@ -1469,6 +1555,7 @@ void CacheManager::GetAppRequestTypes(
std::vector<std::string>& request_types) const {
LOG4CXX_AUTO_TRACE(logger_);
CACHE_MANAGER_CHECK_VOID();
+ sync_primitives::AutoLock auto_lock(cache_lock_);
if (kDeviceId == policy_app_id) {
LOG4CXX_DEBUG(logger_,
"Request types not applicable for app_id " << kDeviceId);
@@ -1492,6 +1579,7 @@ void CacheManager::GetAppRequestTypes(
std::string CacheManager::GetCertificate() const {
CACHE_MANAGER_CHECK(std::string(""));
+ sync_primitives::AutoLock auto_lock(cache_lock_);
if (pt_->policy_table.module_config.certificate.is_initialized()) {
return *pt_->policy_table.module_config.certificate;
}
@@ -1588,6 +1676,12 @@ const PolicySettings& CacheManager::get_settings() const {
return *settings_;
}
+void CacheManager::OnDeviceSwitching(const std::string& device_id_from,
+ const std::string& device_id_to) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ LOG4CXX_INFO(logger_, "Implementation does not support user consents.");
+}
+
CacheManager::BackgroundBackuper::BackgroundBackuper(
CacheManager* cache_manager)
: cache_manager_(cache_manager)
@@ -1615,9 +1709,10 @@ void CacheManager::BackgroundBackuper::threadMain() {
LOG4CXX_AUTO_TRACE(logger_);
sync_primitives::AutoLock lock(need_backup_lock_);
while (!stop_flag_) {
- need_backup_lock_.Release();
- InternalBackup();
- need_backup_lock_.Acquire();
+ {
+ sync_primitives::AutoUnlock unlock(need_backup_lock_);
+ InternalBackup();
+ }
if (new_data_available_ || stop_flag_) {
continue;
}
diff --git a/src/components/policy/policy_regular/src/policy_helper.cc b/src/components/policy/policy_regular/src/policy_helper.cc
index b72a041a83..95f275769c 100644
--- a/src/components/policy/policy_regular/src/policy_helper.cc
+++ b/src/components/policy/policy_regular/src/policy_helper.cc
@@ -267,9 +267,7 @@ void policy::CheckAppPolicy::NotifySystem(
}
void CheckAppPolicy::SendPermissionsToApp(
- const AppPoliciesValueType& app_policy) const {
- const std::string app_id = app_policy.first;
-
+ const std::string& app_id, const policy_table::Strings& groups) const {
const std::string device_id = pm_->GetCurrentDeviceId(app_id);
if (device_id.empty()) {
LOG4CXX_WARN(logger_,
@@ -281,7 +279,7 @@ void CheckAppPolicy::SendPermissionsToApp(
Permissions notification_data;
pm_->PrepareNotificationData(update_->policy_table.functional_groupings,
- app_policy.second.groups,
+ groups,
group_permissons,
notification_data);
@@ -356,6 +354,20 @@ bool CheckAppPolicy::operator()(const AppPoliciesValueType& app_policy) {
"Permissions for application:" << app_id
<< " have been changed.");
+ if (IsPredefinedApp(app_policy)) {
+ for (const policy_table::ApplicationPolicies::value_type& app :
+ snapshot_->policy_table.app_policies_section.apps) {
+ if (app_policy.first == app.second.get_string()) {
+ if (RESULT_CONSENT_NOT_REQIURED != result) {
+ SetPendingPermissions(app, result);
+ NotifySystem(app);
+ }
+ SendPermissionsToApp(app.first, app_policy.second.groups);
+ }
+ }
+ return true;
+ }
+
if (!IsPredefinedApp(app_policy) && RESULT_CONSENT_NOT_REQIURED != result) {
SetPendingPermissions(app_policy, result);
NotifySystem(app_policy);
@@ -363,7 +375,7 @@ bool CheckAppPolicy::operator()(const AppPoliciesValueType& app_policy) {
// Don't sent notification for predefined apps (e.g. default, device etc.)
if (!IsPredefinedApp(app_policy)) {
- SendPermissionsToApp(app_policy);
+ SendPermissionsToApp(app_policy.first, app_policy.second.groups);
}
return true;
}
@@ -697,7 +709,7 @@ void FillFunctionalGroupPermissions(
FunctionalGroupNames& names,
GroupConsent state,
std::vector<FunctionalGroupPermission>& permissions) {
- LOG4CXX_INFO(logger_, "FillFunctionalGroupPermissions");
+ LOG4CXX_AUTO_TRACE(logger_);
FunctionalGroupIDs::const_iterator it = ids.begin();
FunctionalGroupIDs::const_iterator it_end = ids.end();
for (; it != it_end; ++it) {
@@ -717,7 +729,7 @@ bool IsPredefinedApp(const AppPoliciesValueType& app) {
FunctionalGroupIDs ExcludeSame(const FunctionalGroupIDs& from,
const FunctionalGroupIDs& what) {
- LOG4CXX_INFO(logger_, "Exclude same groups");
+ LOG4CXX_AUTO_TRACE(logger_);
FunctionalGroupIDs from_copy(from);
FunctionalGroupIDs what_copy(what);
@@ -739,7 +751,7 @@ FunctionalGroupIDs ExcludeSame(const FunctionalGroupIDs& from,
FunctionalGroupIDs Merge(const FunctionalGroupIDs& first,
const FunctionalGroupIDs& second) {
- LOG4CXX_INFO(logger_, "Merge groups");
+ LOG4CXX_AUTO_TRACE(logger_);
FunctionalGroupIDs first_copy(first);
FunctionalGroupIDs second_copy(second);
diff --git a/src/components/policy/policy_regular/src/policy_manager_impl.cc b/src/components/policy/policy_regular/src/policy_manager_impl.cc
index 640b9c1457..3e08147a4c 100644
--- a/src/components/policy/policy_regular/src/policy_manager_impl.cc
+++ b/src/components/policy/policy_regular/src/policy_manager_impl.cc
@@ -196,7 +196,10 @@ bool PolicyManagerImpl::LoadPT(const std::string& file,
utils::SharedPtr<policy_table::Table> policy_table_snapshot =
cache_->GenerateSnapshot();
if (!policy_table_snapshot) {
- LOG4CXX_ERROR(logger_, "Failed to create snapshot of policy table");
+ LOG4CXX_ERROR(
+ logger_,
+ "Failed to create snapshot of policy table, trying another exchange");
+ ForcePTExchange();
return false;
}
@@ -209,7 +212,10 @@ bool PolicyManagerImpl::LoadPT(const std::string& file,
// Replace current data with updated
if (!cache_->ApplyUpdate(*pt_update)) {
- LOG4CXX_WARN(logger_, "Unsuccessful save of updated policy table.");
+ LOG4CXX_WARN(
+ logger_,
+ "Unsuccessful save of updated policy table, trying another exchange");
+ ForcePTExchange();
return false;
}
@@ -366,6 +372,12 @@ void PolicyManagerImpl::OnAppRegisteredOnMobile(
SendNotificationOnPermissionsUpdated(application_id);
}
+void PolicyManagerImpl::OnDeviceSwitching(const std::string& device_id_from,
+ const std::string& device_id_to) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ cache_->OnDeviceSwitching(device_id_from, device_id_to);
+}
+
const std::vector<std::string> PolicyManagerImpl::GetAppRequestTypes(
const std::string policy_app_id) const {
std::vector<std::string> request_types;
@@ -748,7 +760,7 @@ void PolicyManagerImpl::GetPermissionsForApp(
std::string& PolicyManagerImpl::GetCurrentDeviceId(
const std::string& policy_app_id) const {
- LOG4CXX_INFO(logger_, "GetDeviceInfo");
+ LOG4CXX_AUTO_TRACE(logger_);
last_device_id_ = listener()->OnCurrentDeviceIdUpdateRequired(policy_app_id);
return last_device_id_;
}
diff --git a/src/components/policy/policy_regular/src/policy_table/enums.cc b/src/components/policy/policy_regular/src/policy_table/enums.cc
index e0f77be989..34d12420d8 100644
--- a/src/components/policy/policy_regular/src/policy_table/enums.cc
+++ b/src/components/policy/policy_regular/src/policy_table/enums.cc
@@ -161,6 +161,8 @@ bool IsValidEnum(Parameter val) {
return true;
case P_ECALLINFO:
return true;
+ case P_EMPTY:
+ return true;
default:
return false;
}
@@ -217,10 +219,13 @@ const char* EnumToJsonString(Parameter val) {
return "emergencyEvent";
case P_ECALLINFO:
return "eCallInfo";
+ case P_EMPTY:
+ return "EMPTY";
default:
return "";
}
}
+
bool EnumFromJsonString(const std::string& literal, Parameter* result) {
if ("gps" == literal) {
*result = P_GPS;
@@ -297,6 +302,9 @@ bool EnumFromJsonString(const std::string& literal, Parameter* result) {
} else if ("eCallInfo" == literal) {
*result = P_ECALLINFO;
return true;
+ } else if ("EMPTY" == literal) {
+ *result = P_EMPTY;
+ return true;
} else {
return false;
}
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 27a43c84ad..5f6f85f5dd 100644
--- a/src/components/policy/policy_regular/src/policy_table/types.cc
+++ b/src/components/policy/policy_regular/src/policy_table/types.cc
@@ -308,19 +308,24 @@ void ApplicationParams::SetPolicyTableType(PolicyTableType pt_type) {
// RpcParameters methods
RpcParameters::RpcParameters() : CompositeType(kUninitialized) {}
+
RpcParameters::RpcParameters(const HmiLevels& hmi_levels)
: CompositeType(kUninitialized), hmi_levels(hmi_levels) {}
+
RpcParameters::~RpcParameters() {}
+
RpcParameters::RpcParameters(const Json::Value* value__)
: CompositeType(InitHelper(value__, &Json::Value::isObject))
, hmi_levels(impl::ValueMember(value__, "hmi_levels"))
, parameters(impl::ValueMember(value__, "parameters")) {}
+
Json::Value RpcParameters::ToJsonValue() const {
Json::Value result__(Json::objectValue);
impl::WriteJsonField("hmi_levels", hmi_levels, &result__);
impl::WriteJsonField("parameters", parameters, &result__);
return result__;
}
+
bool RpcParameters::is_valid() const {
if (!hmi_levels.is_valid()) {
return false;
@@ -330,9 +335,11 @@ bool RpcParameters::is_valid() const {
}
return Validate();
}
+
bool RpcParameters::is_initialized() const {
return (initialization_state__ != kUninitialized) || (!struct_empty());
}
+
bool RpcParameters::struct_empty() const {
if (hmi_levels.is_initialized()) {
return false;
@@ -343,6 +350,7 @@ bool RpcParameters::struct_empty() const {
return true;
}
+
void RpcParameters::ReportErrors(rpc::ValidationReport* report__) const {
if (struct_empty()) {
rpc::CompositeType::ReportErrors(report__);
@@ -363,18 +371,23 @@ void RpcParameters::SetPolicyTableType(PolicyTableType pt_type) {
// Rpcs methods
Rpcs::Rpcs() : CompositeType(kUninitialized) {}
+
Rpcs::Rpcs(const Rpc& rpcs) : CompositeType(kUninitialized), rpcs(rpcs) {}
+
Rpcs::~Rpcs() {}
+
Rpcs::Rpcs(const Json::Value* value__)
: CompositeType(InitHelper(value__, &Json::Value::isObject))
, user_consent_prompt(impl::ValueMember(value__, "user_consent_prompt"))
, rpcs(impl::ValueMember(value__, "rpcs")) {}
+
Json::Value Rpcs::ToJsonValue() const {
Json::Value result__(Json::objectValue);
impl::WriteJsonField("user_consent_prompt", user_consent_prompt, &result__);
impl::WriteJsonField("rpcs", rpcs, &result__);
return result__;
}
+
bool Rpcs::is_valid() const {
if (!user_consent_prompt.is_valid()) {
return false;
@@ -384,9 +397,11 @@ bool Rpcs::is_valid() const {
}
return Validate();
}
+
bool Rpcs::is_initialized() const {
return (initialization_state__ != kUninitialized) || (!struct_empty());
}
+
bool Rpcs::struct_empty() const {
if (user_consent_prompt.is_initialized()) {
return false;
@@ -397,6 +412,7 @@ bool Rpcs::struct_empty() const {
return true;
}
+
void Rpcs::ReportErrors(rpc::ValidationReport* report__) const {
if (struct_empty()) {
rpc::CompositeType::ReportErrors(report__);
@@ -418,6 +434,7 @@ void Rpcs::SetPolicyTableType(PolicyTableType pt_type) {
// ModuleConfig methods
ModuleConfig::ModuleConfig() : CompositeType(kUninitialized) {}
+
ModuleConfig::ModuleConfig(
uint8_t exchange_after_x_ignition_cycles,
int64_t exchange_after_x_kilometers,
@@ -435,7 +452,9 @@ ModuleConfig::ModuleConfig(
, endpoints(endpoints)
, notifications_per_minute_by_priority(
notifications_per_minute_by_priority) {}
+
ModuleConfig::~ModuleConfig() {}
+
ModuleConfig::ModuleConfig(const Json::Value* value__)
: CompositeType(InitHelper(value__, &Json::Value::isObject))
, device_certificates(impl::ValueMember(value__, "device_certificates"))
@@ -501,6 +520,7 @@ Json::Value ModuleConfig::ToJsonValue() const {
impl::WriteJsonField("preloaded_date", preloaded_date, &result__);
return result__;
}
+
bool ModuleConfig::is_valid() const {
if (!preloaded_pt.is_valid()) {
return false;
@@ -543,9 +563,11 @@ bool ModuleConfig::is_valid() const {
}
return Validate();
}
+
bool ModuleConfig::is_initialized() const {
return (initialization_state__ != kUninitialized) || (!struct_empty());
}
+
bool ModuleConfig::struct_empty() const {
if (preloaded_pt.is_initialized()) {
return false;
@@ -587,6 +609,7 @@ bool ModuleConfig::struct_empty() const {
}
return true;
}
+
void ModuleConfig::ReportErrors(rpc::ValidationReport* report__) const {
if (struct_empty()) {
rpc::CompositeType::ReportErrors(report__);
@@ -670,7 +693,9 @@ void ModuleConfig::SetPolicyTableType(PolicyTableType pt_type) {
// MessageString methods
MessageString::MessageString() : CompositeType(kUninitialized) {}
+
MessageString::~MessageString() {}
+
MessageString::MessageString(const Json::Value* value__)
: CompositeType(InitHelper(value__, &Json::Value::isObject))
, line1(impl::ValueMember(value__, "line1"))
@@ -678,6 +703,7 @@ MessageString::MessageString(const Json::Value* value__)
, tts(impl::ValueMember(value__, "tts"))
, label(impl::ValueMember(value__, "label"))
, textBody(impl::ValueMember(value__, "textBody")) {}
+
Json::Value MessageString::ToJsonValue() const {
Json::Value result__(Json::objectValue);
impl::WriteJsonField("line1", line1, &result__);
@@ -687,6 +713,7 @@ Json::Value MessageString::ToJsonValue() const {
impl::WriteJsonField("textBody", textBody, &result__);
return result__;
}
+
bool MessageString::is_valid() const {
if (struct_empty()) {
return initialization_state__ == kInitialized && Validate();
@@ -708,9 +735,11 @@ bool MessageString::is_valid() const {
}
return Validate();
}
+
bool MessageString::is_initialized() const {
return (initialization_state__ != kUninitialized) || (!struct_empty());
}
+
bool MessageString::struct_empty() const {
if (line1.is_initialized()) {
return false;
@@ -731,6 +760,7 @@ bool MessageString::struct_empty() const {
}
return true;
}
+
void MessageString::ReportErrors(rpc::ValidationReport* report__) const {
if (struct_empty()) {
rpc::CompositeType::ReportErrors(report__);
@@ -765,17 +795,22 @@ void MessageString::SetPolicyTableType(PolicyTableType pt_type) {
const std::string MessageLanguages::default_language_("en-us");
MessageLanguages::MessageLanguages() : CompositeType(kUninitialized) {}
+
MessageLanguages::MessageLanguages(const Languages& languages)
: CompositeType(kUninitialized), languages(languages) {}
+
MessageLanguages::~MessageLanguages() {}
+
MessageLanguages::MessageLanguages(const Json::Value* value__)
: CompositeType(InitHelper(value__, &Json::Value::isObject))
, languages(impl::ValueMember(value__, "languages")) {}
+
Json::Value MessageLanguages::ToJsonValue() const {
Json::Value result__(Json::objectValue);
impl::WriteJsonField("languages", languages, &result__);
return result__;
}
+
bool MessageLanguages::is_valid() const {
if (!languages.is_valid()) {
return false;
@@ -786,9 +821,11 @@ bool MessageLanguages::is_valid() const {
}
return Validate();
}
+
bool MessageLanguages::is_initialized() const {
return (initialization_state__ != kUninitialized) || (!struct_empty());
}
+
bool MessageLanguages::struct_empty() const {
if (languages.is_initialized()) {
return false;
@@ -827,19 +864,24 @@ void MessageLanguages::SetPolicyTableType(PolicyTableType pt_type) {
// ConsumerFriendlyMessages methods
ConsumerFriendlyMessages::ConsumerFriendlyMessages()
: CompositeType(kUninitialized) {}
+
ConsumerFriendlyMessages::ConsumerFriendlyMessages(const std::string& version)
: CompositeType(kUninitialized), version(version) {}
+
ConsumerFriendlyMessages::~ConsumerFriendlyMessages() {}
+
ConsumerFriendlyMessages::ConsumerFriendlyMessages(const Json::Value* value__)
: CompositeType(InitHelper(value__, &Json::Value::isObject))
, version(impl::ValueMember(value__, "version"))
, messages(impl::ValueMember(value__, "messages")) {}
+
Json::Value ConsumerFriendlyMessages::ToJsonValue() const {
Json::Value result__(Json::objectValue);
impl::WriteJsonField("version", version, &result__);
impl::WriteJsonField("messages", messages, &result__);
return result__;
}
+
bool ConsumerFriendlyMessages::is_valid() const {
if (!version.is_valid()) {
return false;
@@ -849,9 +891,11 @@ bool ConsumerFriendlyMessages::is_valid() const {
}
return Validate();
}
+
bool ConsumerFriendlyMessages::is_initialized() const {
return (initialization_state__ != kUninitialized) || (!struct_empty());
}
+
bool ConsumerFriendlyMessages::struct_empty() const {
if (version.is_initialized()) {
return false;
@@ -862,6 +906,7 @@ bool ConsumerFriendlyMessages::struct_empty() const {
return true;
}
+
void ConsumerFriendlyMessages::ReportErrors(
rpc::ValidationReport* report__) const {
if (struct_empty()) {
@@ -892,7 +937,9 @@ void ConsumerFriendlyMessages::SetPolicyTableType(PolicyTableType pt_type) {
// ModuleMeta methods
ModuleMeta::ModuleMeta() : CompositeType(kUninitialized) {}
+
ModuleMeta::~ModuleMeta() {}
+
ModuleMeta::ModuleMeta(const Json::Value* value__)
: CompositeType(InitHelper(value__, &Json::Value::isObject))
, pt_exchanged_at_odometer_x(
@@ -901,6 +948,7 @@ ModuleMeta::ModuleMeta(const Json::Value* value__)
impl::ValueMember(value__, "pt_exchanged_x_days_after_epoch"))
, ignition_cycles_since_last_exchange(
impl::ValueMember(value__, "ignition_cycles_since_last_exchange")) {}
+
Json::Value ModuleMeta::ToJsonValue() const {
Json::Value result__(Json::objectValue);
impl::WriteJsonField(
@@ -913,6 +961,7 @@ Json::Value ModuleMeta::ToJsonValue() const {
&result__);
return result__;
}
+
bool ModuleMeta::is_valid() const {
if (struct_empty()) {
return initialization_state__ == kInitialized && Validate();
@@ -928,9 +977,11 @@ bool ModuleMeta::is_valid() const {
}
return Validate();
}
+
bool ModuleMeta::is_initialized() const {
return (initialization_state__ != kUninitialized) || (!struct_empty());
}
+
bool ModuleMeta::struct_empty() const {
if (pt_exchanged_at_odometer_x.is_initialized()) {
return false;
@@ -944,6 +995,7 @@ bool ModuleMeta::struct_empty() const {
}
return true;
}
+
void ModuleMeta::ReportErrors(rpc::ValidationReport* report__) const {
if (struct_empty()) {
rpc::CompositeType::ReportErrors(report__);
@@ -1006,7 +1058,9 @@ AppLevel::AppLevel(uint16_t minutes_in_hmi_full,
, count_of_tls_errors(count_of_tls_errors)
, count_of_run_attempts_while_revoked(count_of_run_attempts_while_revoked) {
}
+
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"))
@@ -1042,6 +1096,7 @@ Json::Value AppLevel::ToJsonValue() const {
impl::WriteJsonField("count_of_TLS_errors", count_of_tls_errors, &result__);
return result__;
}
+
bool AppLevel::is_valid() const {
if (!minutes_in_hmi_full.is_valid()) {
return false;
@@ -1090,9 +1145,11 @@ bool AppLevel::is_valid() const {
}
return Validate();
}
+
bool AppLevel::is_initialized() const {
return (initialization_state__ != kUninitialized) || (!struct_empty());
}
+
bool AppLevel::struct_empty() const {
if (minutes_in_hmi_full.is_initialized()) {
return false;
@@ -1147,6 +1204,7 @@ bool AppLevel::struct_empty() const {
}
return true;
}
+
void AppLevel::ReportErrors(rpc::ValidationReport* report__) const {
if (struct_empty()) {
rpc::CompositeType::ReportErrors(report__);
@@ -1171,6 +1229,7 @@ Json::Value UsageAndErrorCounts::ToJsonValue() const {
impl::WriteJsonField("app_level", app_level, &result__);
return result__;
}
+
bool UsageAndErrorCounts::is_valid() const {
if (struct_empty()) {
return initialization_state__ == kInitialized && Validate();
@@ -1180,15 +1239,18 @@ bool UsageAndErrorCounts::is_valid() const {
}
return Validate();
}
+
bool UsageAndErrorCounts::is_initialized() const {
return (initialization_state__ != kUninitialized) || (!struct_empty());
}
+
bool UsageAndErrorCounts::struct_empty() const {
if (app_level.is_initialized()) {
return false;
}
return true;
}
+
void UsageAndErrorCounts::ReportErrors(rpc::ValidationReport* report__) const {
if (struct_empty()) {
rpc::CompositeType::ReportErrors(report__);
@@ -1211,25 +1273,32 @@ void UsageAndErrorCounts::SetPolicyTableType(PolicyTableType pt_type) {
// DeviceParams methods
DeviceParams::DeviceParams() : CompositeType(kUninitialized) {}
+
DeviceParams::~DeviceParams() {}
+
DeviceParams::DeviceParams(const Json::Value* value__)
: CompositeType(InitHelper(value__, &Json::Value::isObject)) {}
+
Json::Value DeviceParams::ToJsonValue() const {
Json::Value result__(Json::objectValue);
return result__;
}
+
bool DeviceParams::is_valid() const {
if (struct_empty()) {
return initialization_state__ == kInitialized && Validate();
}
return Validate();
}
+
bool DeviceParams::is_initialized() const {
return (initialization_state__ != kUninitialized) || (!struct_empty());
}
+
bool DeviceParams::struct_empty() const {
return true;
}
+
void DeviceParams::ReportErrors(rpc::ValidationReport* report__) const {
if (struct_empty()) {
rpc::CompositeType::ReportErrors(report__);
@@ -1238,6 +1307,7 @@ void DeviceParams::ReportErrors(rpc::ValidationReport* report__) const {
// PolicyTable methods
PolicyTable::PolicyTable() : CompositeType(kUninitialized) {}
+
PolicyTable::PolicyTable(
const ApplicationPoliciesSection& app_policies_section,
const FunctionalGroupings& functional_groupings,
@@ -1248,7 +1318,9 @@ PolicyTable::PolicyTable(
, functional_groupings(functional_groupings)
, consumer_friendly_messages(consumer_friendly_messages)
, module_config(module_config) {}
+
PolicyTable::~PolicyTable() {}
+
PolicyTable::PolicyTable(const Json::Value* value__)
: CompositeType(InitHelper(value__, &Json::Value::isObject))
, app_policies_section(impl::ValueMember(value__, "app_policies"))
@@ -1260,6 +1332,7 @@ PolicyTable::PolicyTable(const Json::Value* value__)
, usage_and_error_counts(
impl::ValueMember(value__, "usage_and_error_counts"))
, device_data(impl::ValueMember(value__, "device_data")) {}
+
Json::Value PolicyTable::ToJsonValue() const {
Json::Value result__(Json::objectValue);
impl::WriteJsonField("app_policies", app_policies_section, &result__);
@@ -1273,6 +1346,7 @@ Json::Value PolicyTable::ToJsonValue() const {
impl::WriteJsonField("device_data", device_data, &result__);
return result__;
}
+
bool PolicyTable::is_valid() const {
if (!app_policies_section.is_valid()) {
return false;
@@ -1297,9 +1371,11 @@ bool PolicyTable::is_valid() const {
}
return Validate();
}
+
bool PolicyTable::is_initialized() const {
return (initialization_state__ != kUninitialized) || (!struct_empty());
}
+
bool PolicyTable::struct_empty() const {
if (app_policies_section.is_initialized()) {
return false;
@@ -1327,6 +1403,7 @@ bool PolicyTable::struct_empty() const {
}
return true;
}
+
void PolicyTable::ReportErrors(rpc::ValidationReport* report__) const {
if (struct_empty()) {
rpc::CompositeType::ReportErrors(report__);
@@ -1381,32 +1458,40 @@ void PolicyTable::SetPolicyTableType(PolicyTableType pt_type) {
// Table methods
Table::Table() : CompositeType(kUninitialized) {}
+
Table::Table(const PolicyTable& policy_table)
: CompositeType(kUninitialized), policy_table(policy_table) {}
+
Table::~Table() {}
+
Table::Table(const Json::Value* value__)
: CompositeType(InitHelper(value__, &Json::Value::isObject))
, policy_table(impl::ValueMember(value__, "policy_table")) {}
+
Json::Value Table::ToJsonValue() const {
Json::Value result__(Json::objectValue);
impl::WriteJsonField("policy_table", policy_table, &result__);
return result__;
}
+
bool Table::is_valid() const {
if (!policy_table.is_valid()) {
return false;
}
return Validate();
}
+
bool Table::is_initialized() const {
return (initialization_state__ != kUninitialized) || (!struct_empty());
}
+
bool Table::struct_empty() const {
if (policy_table.is_initialized()) {
return false;
}
return true;
}
+
void Table::ReportErrors(rpc::ValidationReport* report__) const {
if (struct_empty()) {
rpc::CompositeType::ReportErrors(report__);
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 7938eb4085..ef4ef49273 100644
--- a/src/components/policy/policy_regular/src/sql_pt_queries.cc
+++ b/src/components/policy/policy_regular/src/sql_pt_queries.cc
@@ -123,7 +123,7 @@ const std::string kCreateSchema =
"CREATE INDEX `rpc.select_rpc_name_hmi_level` "
" ON `rpc`(`name`,`hmi_level_value`);"
"CREATE TABLE IF NOT EXISTS `application`( "
- " `id` VARCHAR(45) PRIMARY KEY NOT NULL, "
+ " `id` VARCHAR(45) PRIMARY KEY NOT NULL COLLATE NOCASE, "
" `keep_context` BOOLEAN, "
" `steal_focus` BOOLEAN, "
" `default_hmi` VARCHAR(45), "
@@ -147,7 +147,7 @@ const std::string kCreateSchema =
"CREATE INDEX IF NOT EXISTS `application.fk_application_priorities1_idx` "
" ON `application`(`priority_value`); "
"CREATE TABLE IF NOT EXISTS `app_group`( "
- " `application_id` VARCHAR(45) NOT NULL, "
+ " `application_id` VARCHAR(45) NOT NULL COLLATE NOCASE, "
" `functional_group_id` INTEGER NOT NULL, "
" PRIMARY KEY(`application_id`,`functional_group_id`), "
" CONSTRAINT `fk_application_has_functional_group_application1` "
@@ -162,9 +162,9 @@ const std::string kCreateSchema =
" ON `app_group`(`functional_group_id`); "
"CREATE INDEX IF NOT EXISTS "
"`app_group.fk_application_has_functional_group_application1_idx` "
- " ON `app_group`(`application_id`); "
+ " ON `app_group`(`application_id` COLLATE NOCASE); "
"CREATE TABLE IF NOT EXISTS `preconsented_group`( "
- " `application_id` VARCHAR(45) NOT NULL, "
+ " `application_id` VARCHAR(45) NOT NULL COLLATE NOCASE, "
" `functional_group_id` INTEGER NOT NULL, "
" PRIMARY KEY(`application_id`,`functional_group_id`), "
" CONSTRAINT `fk_application_has_functional_group_application2` "
@@ -180,7 +180,7 @@ const std::string kCreateSchema =
" ON `preconsented_group`(`functional_group_id`); "
"CREATE INDEX IF NOT EXISTS "
"`preconsented_group.fk_application_has_functional_group_application2_idx` "
- " ON `preconsented_group`(`application_id`); "
+ " ON `preconsented_group`(`application_id` COLLATE NOCASE); "
"CREATE TABLE IF NOT EXISTS `seconds_between_retry`( "
" `index` INTEGER PRIMARY KEY NOT NULL, "
" `value` INTEGER NOT NULL "
@@ -207,7 +207,7 @@ const std::string kCreateSchema =
"`device_consent_group.fk_device_has_functional_group_device1_idx` "
" ON `device_consent_group`(`device_id`); "
"CREATE TABLE IF NOT EXISTS `app_level`( "
- " `application_id` VARCHAR(45) PRIMARY KEY NOT NULL, "
+ " `application_id` VARCHAR(45) PRIMARY KEY NOT NULL COLLATE NOCASE, "
" `minutes_in_hmi_full` INTEGER DEFAULT 0, "
" `minutes_in_hmi_limited` INTEGER DEFAULT 0, "
" `minutes_in_hmi_background` INTEGER DEFAULT 0, "
@@ -234,24 +234,24 @@ const std::string kCreateSchema =
" REFERENCES `language`(`code`) "
"); "
"CREATE INDEX IF NOT EXISTS `app_level.fk_app_levels_application1_idx` "
- " ON `app_level`(`application_id`); "
+ " ON `app_level`(`application_id` COLLATE NOCASE); "
"CREATE INDEX IF NOT EXISTS `app_level.fk_app_level_language1_idx` "
" ON `app_level`(`app_registration_language_gui`); "
"CREATE INDEX IF NOT EXISTS `app_level.fk_app_level_language2_idx` "
" ON `app_level`(`app_registration_language_vui`); "
"CREATE TABLE IF NOT EXISTS `nickname`( "
- " `name` VARCHAR(100) NOT NULL, "
- " `application_id` VARCHAR(45) NOT NULL, "
+ " `name` VARCHAR(100) NOT NULL COLLATE NOCASE, "
+ " `application_id` VARCHAR(45) NOT NULL COLLATE NOCASE, "
" PRIMARY KEY(`name`,`application_id`), "
" CONSTRAINT `fk_nickname_application1` "
" FOREIGN KEY(`application_id`) "
" REFERENCES `application`(`id`) "
"); "
"CREATE INDEX IF NOT EXISTS `nickname.fk_nickname_application1_idx` "
- " ON `nickname`(`application_id`); "
+ " ON `nickname`(`application_id` COLLATE NOCASE); "
"CREATE TABLE IF NOT EXISTS `app_type`( "
" `name` VARCHAR(50) NOT NULL, "
- " `application_id` VARCHAR(45) NOT NULL, "
+ " `application_id` VARCHAR(45) NOT NULL COLLATE NOCASE, "
" PRIMARY KEY(`name`,`application_id`), "
" CONSTRAINT `fk_app_type_application1` "
" FOREIGN KEY(`application_id`) "
@@ -259,17 +259,17 @@ const std::string kCreateSchema =
"); "
"CREATE TABLE IF NOT EXISTS `request_type`( "
" `request_type` VARCHAR(50) NOT NULL, "
- " `application_id` VARCHAR(45) NOT NULL, "
+ " `application_id` VARCHAR(45) NOT NULL COLLATE NOCASE, "
" PRIMARY KEY(`request_type`,`application_id`), "
" CONSTRAINT `fk_app_type_application1` "
" FOREIGN KEY(`application_id`) "
" REFERENCES `application`(`id`) "
"); "
"CREATE INDEX IF NOT EXISTS `app_type.fk_app_type_application1_idx` "
- " ON `app_type`(`application_id`); "
+ " ON `app_type`(`application_id` COLLATE NOCASE); "
"CREATE TABLE IF NOT EXISTS `consent_group`( "
" `device_id` VARCHAR(100) NOT NULL, "
- " `application_id` VARCHAR(45) NOT NULL, "
+ " `application_id` VARCHAR(45) NOT NULL COLLATE NOCASE, "
" `functional_group_id` INTEGER NOT NULL, "
" `is_consented` BOOL NOT NULL, "
" `input` VARCHAR(45), "
@@ -294,13 +294,13 @@ const std::string kCreateSchema =
"CREATE TABLE IF NOT EXISTS `endpoint`( "
" `service` VARCHAR(100) NOT NULL, "
" `url` VARCHAR(100) NOT NULL, "
- " `application_id` VARCHAR(45) NOT NULL, "
+ " `application_id` VARCHAR(45) NOT NULL COLLATE NOCASE, "
" CONSTRAINT `fk_endpoint_application1` "
" FOREIGN KEY(`application_id`) "
" REFERENCES `application`(`id`) "
"); "
"CREATE INDEX IF NOT EXISTS `endpoint.fk_endpoint_application1_idx` "
- " ON `endpoint`(`application_id`); "
+ " ON `endpoint`(`application_id` COLLATE NOCASE); "
"CREATE TABLE IF NOT EXISTS `message`( "
" `id` INTEGER PRIMARY KEY NOT NULL, "
" `tts` TEXT, "
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 04fc0d7658..9840a08b26 100644
--- a/src/components/policy/policy_regular/src/sql_pt_representation.cc
+++ b/src/components/policy/policy_regular/src/sql_pt_representation.cc
@@ -596,8 +596,8 @@ void SQLPTRepresentation::GatherDeviceData(
bool SQLPTRepresentation::GatherFunctionalGroupings(
policy_table::FunctionalGroupings* groups) const {
LOG4CXX_INFO(logger_, "Gather Functional Groupings info");
- utils::dbms::SQLQuery func_group(db());
- if (!func_group.Prepare(sql_pt::kSelectFunctionalGroups)) {
+ utils::dbms::SQLQuery functional_group(db());
+ if (!functional_group.Prepare(sql_pt::kSelectFunctionalGroups)) {
LOG4CXX_WARN(logger_, "Incorrect select from functional_groupings");
return false;
}
@@ -606,32 +606,50 @@ bool SQLPTRepresentation::GatherFunctionalGroupings(
LOG4CXX_WARN(logger_, "Incorrect select all from rpc");
return false;
}
- while (func_group.Next()) {
- policy_table::Rpcs rpcs_tbl;
- if (!func_group.IsNull(2)) {
- *rpcs_tbl.user_consent_prompt = func_group.GetString(2);
+
+ while (functional_group.Next()) {
+ policy_table::Rpcs rpcs_structure;
+
+ if (!functional_group.IsNull(2)) {
+ *rpcs_structure.user_consent_prompt = functional_group.GetString(2);
}
- int func_id = func_group.GetInteger(0);
- rpcs.Bind(0, func_id);
+
+ const int group_id = functional_group.GetInteger(0);
+
+ // Collecting RPCs with their HMI levels and parameters (if any)
+ rpcs.Bind(0, group_id);
while (rpcs.Next()) {
if (!rpcs.IsNull(1)) {
policy_table::HmiLevel level;
if (policy_table::EnumFromJsonString(rpcs.GetString(1), &level)) {
- InsertUnique(level, &rpcs_tbl.rpcs[rpcs.GetString(0)].hmi_levels);
+ InsertUnique(level,
+ &rpcs_structure.rpcs[rpcs.GetString(0)].hmi_levels);
}
}
if (!rpcs.IsNull(2)) {
policy_table::Parameter param;
- if (policy_table::EnumFromJsonString(rpcs.GetString(2), &param)) {
- InsertUnique(param, &(*rpcs_tbl.rpcs[rpcs.GetString(0)].parameters));
+ if (EnumFromJsonString(rpcs.GetString(2), &param)) {
+ // EMPTY is a special mark to specify that 'parameters' section is
+ // present, but has no parameters. It is not valid parameter value.
+ if (policy_table::P_EMPTY == param) {
+ (*rpcs_structure.rpcs[rpcs.GetString(0)].parameters)
+ .mark_initialized();
+ continue;
+ }
+ InsertUnique(param,
+ &(*rpcs_structure.rpcs[rpcs.GetString(0)].parameters));
}
}
}
- if (!rpcs_tbl.rpcs.is_initialized()) {
- rpcs_tbl.rpcs.set_to_null();
- }
+
rpcs.Reset();
- (*groups)[func_group.GetString(1)] = rpcs_tbl;
+
+ if (!rpcs_structure.rpcs.is_initialized()) {
+ rpcs_structure.rpcs.set_to_null();
+ }
+ policy_table::Rpcs& group_rpcs_structure =
+ (*groups)[functional_group.GetString(1)];
+ group_rpcs_structure = rpcs_structure;
}
return true;
}
@@ -848,6 +866,18 @@ bool SQLPTRepresentation::SaveRpcs(int64_t group_id,
return false;
}
}
+ } else if (parameters.is_initialized()) {
+ query_parameter.Bind(0, it->first);
+ query_parameter.Bind(
+ 1, std::string(policy_table::EnumToJsonString(*hmi_it)));
+ query_parameter.Bind(
+ 2,
+ std::string(policy_table::EnumToJsonString(policy_table::P_EMPTY)));
+ query_parameter.Bind(3, group_id);
+ if (!query_parameter.Exec() || !query_parameter.Reset()) {
+ LOG4CXX_WARN(logger_, "Incorrect insert into rpc with parameter");
+ return false;
+ }
} else {
query.Bind(0, it->first);
query.Bind(1, std::string(policy_table::EnumToJsonString(*hmi_it)));
@@ -1834,12 +1864,7 @@ bool SQLPTRepresentation::SetDefaultPolicy(const std::string& app_id) {
return false;
}
- bool ret = (GatherAppGroup(kDefaultId, &default_groups) &&
- SaveAppGroup(app_id, default_groups));
- if (ret) {
- return SetIsDefault(app_id, true);
- }
- return false;
+ return SetIsDefault(app_id, true);
}
bool SQLPTRepresentation::SetIsDefault(const std::string& app_id,
diff --git a/src/components/policy/policy_regular/test/PTU.json b/src/components/policy/policy_regular/test/PTU.json
index 6d663e9a0c..d9f70426d1 100644
--- a/src/components/policy/policy_regular/test/PTU.json
+++ b/src/components/policy/policy_regular/test/PTU.json
@@ -14,7 +14,7 @@
625],
"endpoints": {
"0x07": {
- "default": ["http://policies.telematics.ford.com/api/policies"]
+ "default": ["http://x.x.x.x:3000/api/1/policies"]
}
},
"notifications_per_minute_by_priority": {
diff --git a/src/components/policy/policy_regular/test/PTU2.json b/src/components/policy/policy_regular/test/PTU2.json
index 4062e94516..b4c3c0624c 100644
--- a/src/components/policy/policy_regular/test/PTU2.json
+++ b/src/components/policy/policy_regular/test/PTU2.json
@@ -14,7 +14,7 @@
625],
"endpoints": {
"0x07": {
- "default": ["http://policies.telematics.ford.com/api/policies"]
+ "default": ["http://x.x.x.x:3000/api/1/policies"]
}
},
"notifications_per_minute_by_priority": {
diff --git a/src/components/policy/policy_regular/test/PTU3.json b/src/components/policy/policy_regular/test/PTU3.json
index 78596189da..6309bd9cfd 100644
--- a/src/components/policy/policy_regular/test/PTU3.json
+++ b/src/components/policy/policy_regular/test/PTU3.json
@@ -83,7 +83,7 @@
625],
"endpoints": {
"0x07": {
- "default": ["http://policies.telematics.ford.com/api/policies"]
+ "default": ["http://x.x.x.x:3000/api/1/policies"]
}
},
"notifications_per_minute_by_priority": {
diff --git a/src/components/policy/policy_regular/test/PTU4.json b/src/components/policy/policy_regular/test/PTU4.json
index ab4c2f8927..651a4cb2ef 100644
--- a/src/components/policy/policy_regular/test/PTU4.json
+++ b/src/components/policy/policy_regular/test/PTU4.json
@@ -14,7 +14,7 @@
625],
"endpoints": {
"0x07": {
- "default": ["http://policies.telematics.ford.com/api/policies"]
+ "default": ["http://x.x.x.x:3000/api/1/policies"]
}
},
"notifications_per_minute_by_priority": {
diff --git a/src/components/policy/policy_regular/test/policy_manager_impl_test.cc b/src/components/policy/policy_regular/test/policy_manager_impl_test.cc
index f76e856cd0..5fd0a48f7c 100644
--- a/src/components/policy/policy_regular/test/policy_manager_impl_test.cc
+++ b/src/components/policy/policy_regular/test/policy_manager_impl_test.cc
@@ -181,7 +181,7 @@ class PolicyManagerImplTest2 : public ::testing::Test {
public:
PolicyManagerImplTest2()
: app_id1("123456789")
- , app_id2("1766825573")
+ , app_id2("1010101010")
, dev_id1("XXX123456789ZZZ")
, dev_id2("08-00-27-CE-76-FE")
, PTU_request_types(Json::arrayValue) {}
diff --git a/src/components/policy/policy_regular/test/ptu2_requestType.json b/src/components/policy/policy_regular/test/ptu2_requestType.json
index 50364397fd..e25095bb9f 100644
--- a/src/components/policy/policy_regular/test/ptu2_requestType.json
+++ b/src/components/policy/policy_regular/test/ptu2_requestType.json
@@ -17,12 +17,12 @@
"endpoints": {
"0x07": {
"default": [
- "http://policies.telematics.ford.com/api/policies"
+ "http://x.x.x.x:3000/api/1/policies"
]
},
"0x04": {
"default": [
- "http://ivsu.software.ford.com/api/getsoftwareupdates"
+ "http://x.x.x.x:3000/api/1/softwareUpdate"
]
}
},
@@ -2595,7 +2595,7 @@
"PROPRIETARY"
]
},
- "584421907": {
+ "123454321": {
"keep_context": false,
"steal_focus": false,
"priority": "NONE",
diff --git a/src/components/policy/policy_regular/test/ptu_requestType.json b/src/components/policy/policy_regular/test/ptu_requestType.json
index 44bd8356fe..c5aa6f0a6c 100644
--- a/src/components/policy/policy_regular/test/ptu_requestType.json
+++ b/src/components/policy/policy_regular/test/ptu_requestType.json
@@ -17,12 +17,12 @@
"endpoints": {
"0x07": {
"default": [
- "http://policies.telematics.ford.com/api/policies"
+ "http://x.x.x.x:3000/api/1/policies"
]
},
"0x04": {
"default": [
- "http://ivsu.software.ford.com/api/getsoftwareupdates"
+ "http://x.x.x.x:3000/api/1/softwareUpdate"
]
}
},
@@ -2590,7 +2590,7 @@
"PROPRIETARY"
]
},
- "584421907": {
+ "123454321": {
"keep_context": false,
"steal_focus": false,
"priority": "NONE",
diff --git a/src/components/policy/policy_regular/test/sdl_preloaded_pt.json b/src/components/policy/policy_regular/test/sdl_preloaded_pt.json
index d6f34c12fc..10894516cf 100644
--- a/src/components/policy/policy_regular/test/sdl_preloaded_pt.json
+++ b/src/components/policy/policy_regular/test/sdl_preloaded_pt.json
@@ -14,7 +14,7 @@
625],
"endpoints": {
"0x07": {
- "default": ["http://policies.telematics.ford.com/api/policies"]
+ "default": ["http://x.x.x.x:3000/api/1/policies"]
}
},
"notifications_per_minute_by_priority": {
diff --git a/src/components/policy/policy_regular/test/sdl_pt_first_update.json b/src/components/policy/policy_regular/test/sdl_pt_first_update.json
index e6817da0d3..ac2b18ab6f 100644
--- a/src/components/policy/policy_regular/test/sdl_pt_first_update.json
+++ b/src/components/policy/policy_regular/test/sdl_pt_first_update.json
@@ -1,7 +1,7 @@
{
"policy_table" : {
"app_policies" : {
- "1766825573" : {
+ "1010101010" : {
"AppHMIType" : [ "MEDIA" ],
"certificate" : "akdjfhaliuygrglurng",
"default_hmi" : "BACKGROUND",
@@ -1720,7 +1720,7 @@
},
"endpoints" : {
"0x07" : {
- "default" : [ "http://policies.telematics.ford.com/api/policies" ]
+ "default" : [ "http://x.x.x.x:3000/api/1/policies" ]
}
},
"exchange_after_x_days" : 30,
diff --git a/src/components/policy/policy_regular/test/sdl_pt_second_update.json b/src/components/policy/policy_regular/test/sdl_pt_second_update.json
index d5f5f480f3..230ad1fa4f 100644
--- a/src/components/policy/policy_regular/test/sdl_pt_second_update.json
+++ b/src/components/policy/policy_regular/test/sdl_pt_second_update.json
@@ -1,7 +1,7 @@
{
"policy_table" : {
"app_policies" : {
- "1766825573" : {
+ "1010101010" : {
"AppHMIType" : [ "MEDIA" ],
"certificate" : "akdjfhaliuygrglurng",
"default_hmi" : "BACKGROUND",
@@ -1720,7 +1720,7 @@
},
"endpoints" : {
"0x07" : {
- "default" : [ "http://policies.telematics.ford.com/api/policies" ]
+ "default" : [ "http://x.x.x.x:3000/api/1/policies" ]
}
},
"exchange_after_x_days" : 30,
diff --git a/src/components/policy/policy_regular/test/sdl_pt_update.json b/src/components/policy/policy_regular/test/sdl_pt_update.json
index a332f92382..f890e8e5ae 100644
--- a/src/components/policy/policy_regular/test/sdl_pt_update.json
+++ b/src/components/policy/policy_regular/test/sdl_pt_update.json
@@ -1,7 +1,7 @@
{
"policy_table" : {
"app_policies" : {
- "1766825573" : {
+ "1010101010" : {
"AppHMIType" : [ "MEDIA" ],
"certificate" : "akdjfhaliuygrglurng",
"default_hmi" : "BACKGROUND",
@@ -1698,7 +1698,7 @@
},
"endpoints" : {
"0x07" : {
- "default" : [ "http://policies.telematics.ford.com/api/policies" ]
+ "default" : [ "http://x.x.x.x:3000/api/1/policies" ]
}
},
"exchange_after_x_days" : 30,
diff --git a/src/components/policy/policy_regular/test/valid_sdl_pt_update.json b/src/components/policy/policy_regular/test/valid_sdl_pt_update.json
index 56c728f104..c384ea73e2 100644
--- a/src/components/policy/policy_regular/test/valid_sdl_pt_update.json
+++ b/src/components/policy/policy_regular/test/valid_sdl_pt_update.json
@@ -1,7 +1,7 @@
{
"policy_table" : {
"app_policies" : {
- "1766825573" : {
+ "1010101010" : {
"AppHMIType" : [ "MEDIA" ],
"certificate" : "akdjfhaliuygrglurng",
"default_hmi" : "BACKGROUND",
@@ -1696,7 +1696,7 @@
},
"endpoints" : {
"0x07" : {
- "default" : [ "http://policies.telematics.ford.com/api/policies" ]
+ "default" : [ "http://x.x.x.x:3000/api/1/policies" ]
}
},
"exchange_after_x_days" : 30,