summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin Dickow <jjdickow@gmail.com>2014-07-15 16:13:37 -0400
committerJustin Dickow <jjdickow@gmail.com>2014-07-15 16:13:37 -0400
commit0d4653c3f3160267f4399ba7df4636170b87fbdd (patch)
tree772bcf2d8b4fbac019cecde88f8e8ed197bcc49a
parent073ceeb8e5dec65b178e028dab20c542bc863584 (diff)
downloadsmartdevicelink-dev/merge_3.4.tar.gz
policy updatesdev/merge_3.4
Signed-off-by: Justin Dickow <jjdickow@gmail.com>
-rw-r--r--src/components/policy/src/policy/CMakeLists.txt17
-rw-r--r--src/components/policy/src/policy/include/policy/policy_helper.h24
-rw-r--r--src/components/policy/src/policy/include/policy/policy_listener.h20
-rw-r--r--src/components/policy/src/policy/include/policy/policy_manager.h494
-rw-r--r--src/components/policy/src/policy/include/policy/policy_manager_impl.h18
-rw-r--r--src/components/policy/src/policy/include/policy/policy_table.h2
-rw-r--r--src/components/policy/src/policy/include/policy/policy_types.h222
-rw-r--r--src/components/policy/src/policy/include/policy/pt_ext_representation.h387
-rw-r--r--src/components/policy/src/policy/include/policy/pt_representation.h14
-rw-r--r--src/components/policy/src/policy/include/policy/sql_pt_ext_queries.h6
-rw-r--r--src/components/policy/src/policy/include/policy/sql_pt_ext_representation.h203
-rw-r--r--src/components/policy/src/policy/include/policy/sql_pt_queries.h1
-rw-r--r--src/components/policy/src/policy/include/policy/sql_pt_representation.h17
-rw-r--r--src/components/policy/src/policy/policy_table_interface.xml450
-rw-r--r--src/components/policy/src/policy/policy_table_interface_ext.xml42
-rw-r--r--src/components/policy/src/policy/qdb_wrapper/include/qdb_wrapper/sql_query.h2
-rw-r--r--src/components/policy/src/policy/qdb_wrapper/src/sql_query.cc18
-rw-r--r--src/components/policy/src/policy/sqlite_wrapper/include/sqlite_wrapper/sql_database.h6
-rw-r--r--src/components/policy/src/policy/sqlite_wrapper/src/sql_database.cc4
-rw-r--r--src/components/policy/src/policy/src/policy_helper.cc127
-rw-r--r--src/components/policy/src/policy/src/policy_manager_impl.cc322
-rw-r--r--src/components/policy/src/policy/src/policy_table.cc5
-rw-r--r--src/components/policy/src/policy/src/sql_pt_ext_queries.cc157
-rw-r--r--src/components/policy/src/policy/src/sql_pt_ext_representation.cc534
-rw-r--r--src/components/policy/src/policy/src/sql_pt_queries.cc33
-rw-r--r--src/components/policy/src/policy/src/sql_pt_representation.cc249
-rw-r--r--src/components/policy/test/policy/CMakeLists.txt60
-rw-r--r--src/components/policy/test/policy/include/mock_policy_listener.h68
-rw-r--r--src/components/policy/test/policy/include/mock_pt_ext_representation.h130
-rw-r--r--src/components/policy/test/policy/include/mock_pt_representation.h3
-rw-r--r--src/components/policy/test/policy/qdb_wrapper/CMakeLists.txt29
-rw-r--r--src/components/policy/test/policy/qdb_wrapper/src/test_sql_database.cc142
-rw-r--r--src/components/policy/test/policy/qdb_wrapper/src/test_sql_query.cc284
-rwxr-xr-xsrc/components/policy/test/policy/qdbserver.sh6
-rw-r--r--src/components/policy/test/policy/sqlite_wrapper/CMakeLists.txt2
-rw-r--r--src/components/policy/test/policy/src/generated_code_test.cc60
-rw-r--r--src/components/policy/test/policy/src/test_policy_manager_impl.cc172
-rw-r--r--src/components/policy/test/policy/src/test_sql_pt_ext_representation.cc82
-rw-r--r--src/components/policy/test/policy/src/test_sql_pt_representation.cc334
-rw-r--r--src/components/policy/test/policy/src/test_stress_policy_manager_impl.cc41
-rw-r--r--src/components/policy/test/policy/test-qdb.ini10
-rw-r--r--src/components/policy/test/policy/valid_sdl_pt_update.json1817
42 files changed, 5017 insertions, 1597 deletions
diff --git a/src/components/policy/src/policy/CMakeLists.txt b/src/components/policy/src/policy/CMakeLists.txt
index e11422125..33c4f50a9 100644
--- a/src/components/policy/src/policy/CMakeLists.txt
+++ b/src/components/policy/src/policy/CMakeLists.txt
@@ -54,6 +54,7 @@ include_directories (
${CMAKE_SOURCE_DIR}/src/components/rpc_base/include
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_SOURCE_DIR}/src/components/utils/include/
+ ${CMAKE_SOURCE_DIR}/src/components/config_profile/include
)
set(SOURCES
@@ -84,11 +85,16 @@ else ()
add_subdirectory(sqlite_wrapper)
endif ()
-set(LIBRARIES dbms policy_table_interface_base log4cxx )
+set(LIBRARIES ConfigProfile dbms policy_table_interface_base)
add_library(${target} SHARED ${SOURCES})
target_link_libraries(${target} ${LIBRARIES})
+if(ENABLE_LOG)
+ add_dependencies(${target} liblog4cxx)
+ target_link_libraries(${target} log4cxx -L${LOG4CXX_LIBS_DIRECTORY})
+endif()
+
add_custom_target(copy_library_${target} ALL
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${CMAKE_CURRENT_BINARY_DIR}/${library_name}
@@ -96,6 +102,15 @@ add_custom_target(copy_library_${target} ALL
DEPENDS ${target}
COMMENT "Copying library ${library_name}")
+if (BUILD_TESTS_WITH_HMI)
+ add_custom_target(test_copy_library_${target} ALL
+ COMMAND ${CMAKE_COMMAND} -E copy_if_different
+ ${CMAKE_CURRENT_BINARY_DIR}/${library_name}
+ ${CMAKE_BINARY_DIR}/test/
+ DEPENDS ${target}
+ COMMENT "Copying library ${library_name}")
+endif(BUILD_TESTS_WITH_HMI)
+
install(TARGETS ${target}
DESTINATION ${install_destination}
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE
diff --git a/src/components/policy/src/policy/include/policy/policy_helper.h b/src/components/policy/src/policy/include/policy/policy_helper.h
index f9bf0c87f..d0f4317a2 100644
--- a/src/components/policy/src/policy/include/policy/policy_helper.h
+++ b/src/components/policy/src/policy/include/policy/policy_helper.h
@@ -40,6 +40,9 @@
namespace policy {
class PolicyManagerImpl;
+const std::string kAllowedKey = "allowed";
+const std::string kUserDisallowedKey = "userDisallowed";
+
namespace policy_table = rpc::policy_table_interface_base;
typedef policy_table::Strings::const_iterator StringsConstItr;
@@ -85,6 +88,8 @@ struct CheckAppPolicy {
void SendOnPendingPermissions(const AppPoliciesValueType& app_policy,
AppPermissions permissions) const;
bool IsAppRevoked(const AppPoliciesValueType& app_policy) const;
+ bool NicknamesMatch(const std::string app_id,
+ const AppPoliciesValueType& app_policy) const;
bool operator()(const AppPoliciesValueType& app_policy);
private:
PolicyManagerImpl* pm_;
@@ -96,7 +101,7 @@ struct CheckAppPolicy {
* parameters
*/
struct FillNotificationData {
- FillNotificationData(Permissions& data, PermissionState group_state);
+ FillNotificationData(Permissions& data, GroupConsent group_state);
bool operator()(const RpcValueType& rpc);
void UpdateHMILevels(const policy_table::HmiLevels& in_hmi,
std::set<HMILevel>& out_hmi);
@@ -105,8 +110,6 @@ struct FillNotificationData {
private:
void ExcludeDisAllowed();
std::string current_key_;
- std::string allowed_key_;
- std::string disallowed_key_;
Permissions& data_;
};
@@ -121,7 +124,7 @@ struct ProcessFunctionalGroup {
Permissions& data);
bool operator()(const StringsValueType& group_name);
private:
- PermissionState GetGroupState(const std::string& group_name);
+ GroupConsent GetGroupState(const std::string& group_name);
const policy_table::FunctionalGroupings& fg_;
Permissions& data_;
const std::vector<FunctionalGroupPermission>& group_permissions_;
@@ -136,6 +139,19 @@ struct FunctionalGroupInserter {
const policy_table::Strings& preconsented_;
};
+/**
+ * @brief Fills FunctionalGroupPermissions with provided params
+ * @param ids Functional group ids from DB
+ * @param names Group names and user_consent_prompt
+ * @param state User consent for group
+ * @param permissions Struct to be filled with provided params
+ */
+void FillFunctionalGroupPermissions(
+ FunctionalGroupIDs& ids,
+ FunctionalGroupNames& names,
+ GroupConsent state,
+ std::vector<FunctionalGroupPermission>& permissions);
+
}
#endif // SRC_COMPONENTS_POLICY_INCLUDE_POLICY_POLICY_HELPER_H_
diff --git a/src/components/policy/src/policy/include/policy/policy_listener.h b/src/components/policy/src/policy/include/policy/policy_listener.h
index c62c19f3e..e2cbd86a5 100644
--- a/src/components/policy/src/policy/include/policy/policy_listener.h
+++ b/src/components/policy/src/policy/include/policy/policy_listener.h
@@ -37,16 +37,18 @@
namespace policy {
class PolicyListener {
- public:
- virtual void OnPTExchangeNeeded() = 0;
- virtual void OnPermissionsUpdated(const std::string& policy_app_id,
- const Permissions& permissions) = 0;
- virtual void OnPendingPermissionChange(const std::string& policy_app_id) = 0;
- virtual void OnAppRevoked(const std::string& policy_app_id) = 0;
- virtual void OnUpdateStatusChanged(policy::PolicyTableStatus status) = 0;
- virtual void OnCurrentDeviceIdUpdateRequired(
+ public:
+ virtual void OnPTExchangeNeeded() = 0;
+ virtual void OnPermissionsUpdated(const std::string& policy_app_id,
+ const Permissions& permissions,
+ const policy::HMILevel& default_hmi) = 0;
+ virtual void OnPendingPermissionChange(const std::string& policy_app_id) = 0;
+ virtual void OnAppRevoked(const std::string& policy_app_id) = 0;
+ virtual void OnUpdateStatusChanged(policy::PolicyTableStatus status) = 0;
+ virtual std::string OnCurrentDeviceIdUpdateRequired(
const std::string& policy_app_id) = 0;
- virtual void OnSystemInfoUpdateRequired() = 0;
+ virtual void OnSystemInfoUpdateRequired() = 0;
+ virtual std::string GetAppName(const std::string& policy_app_id) = 0;
};
} // namespace policy
#endif // SRC_COMPONENTS_POLICY_INCLUDE_POLICY_LISTENER_H_
diff --git a/src/components/policy/src/policy/include/policy/policy_manager.h b/src/components/policy/src/policy/include/policy/policy_manager.h
index 7bc0e19af..cdb81b60f 100644
--- a/src/components/policy/src/policy/include/policy/policy_manager.h
+++ b/src/components/policy/src/policy/include/policy/policy_manager.h
@@ -42,34 +42,35 @@
namespace policy {
class PolicyManager : public usage_statistics::StatisticsManager {
- public:
- virtual ~PolicyManager() {
- }
-
- virtual void set_listener(PolicyListener* listener) = 0;
-
- /**
- *@brief Loads Policy Table from json file. Used for loading
- * Preloaded Policy Table or after Master Reset of the system.
- *@param file_name Path to preloaded PT file
- * @return bool Success of operation
- */
- virtual bool LoadPTFromFile(const std::string& file_name) = 0;
-
- /**
- * @brief Updates Policy Table from binary message received from
- * mobile device. Saves to Policy Table diff between Policy Table
- * sent in snapshot and received Policy Table.
- * @param pt_content PTU as binary string
- * @return bool Success of operation
- */
- virtual bool LoadPT(const BinaryMessage& pt_content) = 0;
-
- /**
- * @brief Gets URL for sending PTS to from PT itself.
- * @param service_type Service specifies user of URL
- * @return string URL
- */
+ public:
+ virtual ~PolicyManager() {
+ }
+
+ virtual void set_listener(PolicyListener* listener) = 0;
+
+ /**
+ *@brief Loads Policy Table from json file. Used for loading
+ * Preloaded Policy Table or after Master Reset of the system.
+ *@param file_name Path to preloaded PT file
+ * @return bool Success of operation
+ */
+ virtual bool LoadPTFromFile(const std::string& file_name) = 0;
+
+ /**
+ * @brief Updates Policy Table from binary message received from
+ * mobile device. Saves to Policy Table diff between Policy Table
+ * sent in snapshot and received Policy Table.
+ * @param file name of file with update policy table
+ * @param pt_content PTU as binary string
+ * @return bool Success of operation
+ */
+ virtual bool LoadPT(const std::string& file, const BinaryMessage& pt_content) = 0;
+
+ /**
+ * @brief Gets URL for sending PTS to from PT itself.
+ * @param service_type Service specifies user of URL
+ * @return string URL
+ */
virtual std::string GetUpdateUrl(int service_type) = 0;
/**
@@ -79,220 +80,245 @@ class PolicyManager : public usage_statistics::StatisticsManager {
*/
virtual EndpointUrls GetUpdateUrls(int service_type) = 0;
- /**
- * @brief PTU is needed, for this PTS has to be formed and sent.
- * @return BinaryMessage* PTS.
- */
- virtual BinaryMessageSptr RequestPTUpdate() = 0;
-
- /**
- * @brief Check if specified RPC for specified application
- * has permission to be executed in specified HMI Level
- * and also its permitted params.
- * @param app_id Id of application provided during registration
- * @param hmi_level Current HMI Level of application
- * @param rpc Name of RPC
- * @return CheckPermissionResult containing flag if HMI Level is allowed
- * and list of allowed params.
- */
- virtual CheckPermissionResult CheckPermissions(const PTString& app_id,
- const PTString& hmi_level,
- const PTString& rpc) = 0;
-
- /**
- * @brief Clear all record of user consents. Used during Factory Reset.
- * @return bool Success of operation
- */
- virtual bool ResetUserConsent() = 0;
-
- /**
- * @brief Checks, if policy update is necessary for application
- * @param Application id assigned by Ford to the application
- */
- virtual void CheckAppPolicyState(const std::string& application_id) = 0;
-
- /**
- * @brief Returns current status of policy table for HMI
- * @return Current status of policy table
- */
- virtual PolicyTableStatus GetPolicyTableStatus() = 0;
-
- /**
- * Checks is PT exceeded IgnitionCycles
- * @return true if exceeded
- */
- virtual bool ExceededIgnitionCycles() = 0;
-
- /**
- * Checks is PT exceeded days
- * @param days current day after epoch
- * @return true if exceeded
- */
- virtual bool ExceededDays(int days) = 0;
-
- /**
- * Checks is PT exceeded kilometers
- * @param kilometers current kilometers at odometer
- * @return true if exceeded
- */
- virtual bool ExceededKilometers(int kilometers) = 0;
-
- /**
- * Increments counter of ignition cycles
- */
- virtual void IncrementIgnitionCycles() = 0;
-
- /**
- * Resets retry sequence
- */
- virtual void ResetRetrySequence() = 0;
-
- /**
- * Gets timeout to wait before next retry updating PT
- * If timeout is less or equal to zero then the retry sequence is not need.
- * @return timeout in seconds
- */
- virtual int NextRetryTimeout() = 0;
-
- /**
- * Gets timeout to wait until receive response
- * @return timeout in seconds
- */
- virtual int TimeoutExchange() = 0;
-
- /**
- * @brief List of timeouts in seconds between retries
- * when attempt to update PT fails
- * @return List of delays between attempts.
- */
- virtual const std::vector<int> RetrySequenceDelaysSeconds() = 0;
-
- /**
- * Handler of exceeding timeout of exchanging policy table
- */
- virtual void OnExceededTimeout() = 0;
-
- /**
- * @brief Check user consent for mobile device data connection
- * @param device_id Unique device identifier
- * @return status of device consent
- */
- virtual DeviceConsent GetUserConsentForDevice(
+ /**
+ * @brief PTU is needed, for this PTS has to be formed and sent.
+ * @return BinaryMessage* PTS.
+ */
+ virtual BinaryMessageSptr RequestPTUpdate() = 0;
+
+ /**
+ * @brief Check if specified RPC for specified application
+ * has permission to be executed in specified HMI Level
+ * and also its permitted params.
+ * @param app_id Id of application provided during registration
+ * @param hmi_level Current HMI Level of application
+ * @param rpc Name of RPC
+ * @return CheckPermissionResult containing flag if HMI Level is allowed
+ * and list of allowed params.
+ */
+ virtual CheckPermissionResult CheckPermissions(const PTString& app_id,
+ const PTString& hmi_level,
+ const PTString& rpc) = 0;
+
+ /**
+ * @brief Clear all record of user consents. Used during Factory Reset.
+ * @return bool Success of operation
+ */
+ virtual bool ResetUserConsent() = 0;
+
+ /**
+ * @brief Checks, if policy update is necessary for application
+ * @param Application id assigned by Ford to the application
+ */
+ virtual void CheckAppPolicyState(const std::string& application_id) = 0;
+
+ /**
+ * @brief Returns current status of policy table for HMI
+ * @return Current status of policy table
+ */
+ virtual PolicyTableStatus GetPolicyTableStatus() = 0;
+
+ /**
+ * Checks is PT exceeded IgnitionCycles
+ * @return true if exceeded
+ */
+ virtual bool ExceededIgnitionCycles() = 0;
+
+ /**
+ * Checks is PT exceeded days
+ * @param days current day after epoch
+ * @return true if exceeded
+ */
+ virtual bool ExceededDays(int days) = 0;
+
+ /**
+ * Checks is PT exceeded kilometers
+ * @param kilometers current kilometers at odometer
+ * @return true if exceeded
+ */
+ virtual bool ExceededKilometers(int kilometers) = 0;
+
+ /**
+ * Increments counter of ignition cycles
+ */
+ virtual void IncrementIgnitionCycles() = 0;
+
+ /**
+ * Resets retry sequence
+ */
+ virtual void ResetRetrySequence() = 0;
+
+ /**
+ * Gets timeout to wait before next retry updating PT
+ * If timeout is less or equal to zero then the retry sequence is not need.
+ * @return timeout in seconds
+ */
+ virtual int NextRetryTimeout() = 0;
+
+ /**
+ * Gets timeout to wait until receive response
+ * @return timeout in seconds
+ */
+ virtual int TimeoutExchange() = 0;
+
+ /**
+ * @brief List of timeouts in seconds between retries
+ * when attempt to update PT fails
+ * @return List of delays between attempts.
+ */
+ virtual const std::vector<int> RetrySequenceDelaysSeconds() = 0;
+
+ /**
+ * Handler of exceeding timeout of exchanging policy table
+ */
+ virtual void OnExceededTimeout() = 0;
+
+ /**
+ * @brief Check user consent for mobile device data connection
+ * @param device_id Unique device identifier
+ * @return status of device consent
+ */
+ virtual DeviceConsent GetUserConsentForDevice(
const std::string& device_id) = 0;
- /**
- * @brief Set user consent for mobile device data connection
- * @param device_id Unique device identifier
- * @param is_allowed User consent for usage device data connection
- */
- virtual void SetUserConsentForDevice(const std::string& device_id,
- bool is_allowed) = 0;
- /**
- * Sets number of kilometers and days after epoch, that passed for
- * receiving PT UPdate.
- */
- virtual void PTUpdatedAt(int kilometers, int days_after_epoch) = 0;
-
- /**
- * @brief Retrieves data from app_policies about app on its registration:
- * @param app_id - id of registered app
- * @param app_types Section on HMI where app can appear (Navigation, Phone etc)
- * @param nicknames Synonyms for application
- */
- virtual bool GetInitialAppData(const std::string& application_id,
- StringArray* nicknames = NULL,
- StringArray* app_hmi_types = NULL) = 0;
- /**
- * @brief Stores device parameters received during application registration
- * to policy table
- * @param device_id Device mac address
- * @param device_info Received device parameters
- */
- virtual void SetDeviceInfo(const std::string& device_id,
- const DeviceInfo& device_info) = 0;
-
- /**
- * @brief Set user consent for application functional groups
- * @param permissions User-defined application group pemissions
- */
- virtual void SetUserConsentForApp(const PermissionConsent& permissions) = 0;
-
- /**
- * @brief Get default HMI level for application
- * @param policy_app_id Unique application id
- * @param default_hmi Default HMI level for application or empty, if value
- * was not set
- * @return true, if succedeed, otherwise - false
- */
- virtual bool GetDefaultHmi(const std::string& policy_app_id,
- std::string* default_hmi) = 0;
-
- /**
- * @brief Get priority for application
- * @param policy_app_id Unique application id
- * @param priority Priority for application or empty, if value was not set
- * @return true, if succedeed, otherwise - false
- */
- virtual bool GetPriority(const std::string& policy_app_id,
- std::string* priority) = 0;
-
- /**
- * @brief Get user friendly messages for given RPC messages and language
- * @param message_codes RPC message codes
- * @param language Language
- * @return Array of structs with appropriate message parameters
- */
- virtual std::vector<UserFriendlyMessage> GetUserFriendlyMessages(
+ /**
+ * @brief Set user consent for mobile device data connection
+ * @param device_id Unique device identifier
+ * @param is_allowed User consent for usage device data connection
+ */
+ virtual void SetUserConsentForDevice(const std::string& device_id,
+ bool is_allowed) = 0;
+
+ /**
+ * @brief Update Application Policies as reaction
+ * on User allowing/disallowing device this app is running on.
+ */
+ virtual bool ReactOnUserDevConsentForApp(const std::string app_id,
+ bool is_device_allowed) = 0;
+ /**
+ * Sets number of kilometers and days after epoch, that passed for
+ * receiving PT UPdate.
+ */
+ virtual void PTUpdatedAt(int kilometers, int days_after_epoch) = 0;
+
+ /**
+ * @brief Retrieves data from app_policies about app on its registration:
+ * @param app_id - id of registered app
+ * @param app_types Section on HMI where app can appear (Navigation, Phone etc)
+ * @param nicknames Synonyms for application
+ */
+ virtual bool GetInitialAppData(const std::string& application_id,
+ StringArray* nicknames = NULL,
+ StringArray* app_hmi_types = NULL) = 0;
+ /**
+ * @brief Stores device parameters received during application registration
+ * to policy table
+ * @param device_id Device mac address
+ * @param device_info Received device parameters
+ */
+ virtual void SetDeviceInfo(const std::string& device_id,
+ const DeviceInfo& device_info) = 0;
+
+ /**
+ * @brief Set user consent for application functional groups
+ * @param permissions User-defined application group pemissions
+ */
+ virtual void SetUserConsentForApp(const PermissionConsent& permissions) = 0;
+
+ /**
+ * @brief Get default HMI level for application
+ * @param policy_app_id Unique application id
+ * @param default_hmi Default HMI level for application or empty, if value
+ * was not set
+ * @return true, if succedeed, otherwise - false
+ */
+ virtual bool GetDefaultHmi(const std::string& policy_app_id,
+ std::string* default_hmi) = 0;
+
+ /**
+ * @brief Get priority for application
+ * @param policy_app_id Unique application id
+ * @param priority Priority for application or empty, if value was not set
+ * @return true, if succedeed, otherwise - false
+ */
+ virtual bool GetPriority(const std::string& policy_app_id,
+ std::string* priority) = 0;
+
+ /**
+ * @brief Get user friendly messages for given RPC messages and language
+ * @param message_codes RPC message codes
+ * @param language Language
+ * @return Array of structs with appropriate message parameters
+ */
+ virtual std::vector<UserFriendlyMessage> GetUserFriendlyMessages(
const std::vector<std::string>& message_code,
const std::string& language) = 0;
- /**
- * Checks if the application is revoked
- * @param app_id application id
- * @return true if application is revoked
- */
- virtual bool IsApplicationRevoked(const std::string& app_id) const = 0;
-
- /**
- * @brief Get user permissions for application which started on specific device
- * @param device_id Device id
- * @param policy_app_id Unique application id
- * @param permissions Array of functional groups permissions
- */
- virtual void GetUserPermissionsForApp(
+ /**
+ * Checks if the application is revoked
+ * @param app_id application id
+ * @return true if application is revoked
+ */
+ virtual bool IsApplicationRevoked(const std::string& app_id) const = 0;
+
+ /**
+ * @brief Get user permissions for application which started on specific device
+ * @param device_id Device id
+ * @param policy_app_id Unique application id
+ * @param permissions Array of functional groups permissions
+ */
+ virtual void GetUserPermissionsForApp(
const std::string& device_id, const std::string& policy_app_id,
std::vector<FunctionalGroupPermission>& permissions) = 0;
- virtual AppPermissions GetAppPermissionsChanges(
+ virtual AppPermissions GetAppPermissionsChanges(
const std::string& app_id) = 0;
- virtual void RemovePendingPermissionChanges(const std::string& app_id) = 0;
-
- /**
- * @brief Update current device id, which data should be proceeded
- * @param device_id Current device id
- */
- virtual void UpdateCurrentDeviceId(const std::string& device_id) = 0;
-
- /**
- * @brief Return device id, which hosts specific application
- * @param Application id, which is required to update device id
- */
- virtual std::string& GetCurrentDeviceId(const std::string& policy_app_id) = 0;
-
- /**
- * @brief Set current system language
- * @param language Language
- */
- virtual void SetSystemLanguage(const std::string& language) = 0;
-
- /**
- * @brief Set data from GetSystemInfo response to policy table
- * @param ccpu_version CCPU version
- * @param wers_country_code WERS country code
- * @param language System language
- */
- virtual void SetSystemInfo(const std::string& ccpu_version,
- const std::string& wers_country_code,
- const std::string& language) = 0;
+ virtual void RemovePendingPermissionChanges(const std::string& app_id) = 0;
+
+ /**
+ * @brief Return device id, which hosts specific application
+ * @param Application id, which is required to update device id
+ */
+ virtual std::string& GetCurrentDeviceId(const std::string& policy_app_id) = 0;
+
+ /**
+ * @brief Set current system language
+ * @param language Language
+ */
+ virtual void SetSystemLanguage(const std::string& language) = 0;
+
+ /**
+ * @brief Set data from GetSystemInfo response to policy table
+ * @param ccpu_version CCPU version
+ * @param wers_country_code WERS country code
+ * @param language System language
+ */
+ virtual void SetSystemInfo(const std::string& ccpu_version,
+ const std::string& wers_country_code,
+ const std::string& language) = 0;
+
+ /**
+ * @brief Send OnPermissionsUpdated for choosen application
+ * @param application_id
+ */
+ virtual void SendNotificationOnPermissionsUpdated(
+ const std::string& application_id) = 0;
+
+ /**
+ * @brief Removes unpaired device records and related records from DB
+ * @param device_ids List of device_id, which should be removed
+ * @return true, if succedeed, otherwise - false
+ */
+ virtual bool CleanupUnpairedDevices(const DeviceIds& device_ids) = 0;
+
+ /**
+ * @brief Check if app can keep context.
+ */
+ virtual bool CanAppKeepContext(const std::string& app_id) = 0;
+
+ /**
+ * @brief Check if app can steal focus.
+ */
+ virtual bool CanAppStealFocus(const std::string& app_id) = 0;
};
} // namespace policy
diff --git a/src/components/policy/src/policy/include/policy/policy_manager_impl.h b/src/components/policy/src/policy/include/policy/policy_manager_impl.h
index b510f5805..9b8983547 100644
--- a/src/components/policy/src/policy/include/policy/policy_manager_impl.h
+++ b/src/components/policy/src/policy/include/policy/policy_manager_impl.h
@@ -56,7 +56,7 @@ class PolicyManagerImpl : public PolicyManager {
return listener_;
}
virtual bool LoadPTFromFile(const std::string& file_name);
- virtual bool LoadPT(const BinaryMessage& pt_content);
+ virtual bool LoadPT(const std::string& file, const BinaryMessage& pt_content);
virtual std::string GetUpdateUrl(int service_type);
virtual EndpointUrls GetUpdateUrls(int service_type);
virtual BinaryMessageSptr RequestPTUpdate();
@@ -84,6 +84,8 @@ class PolicyManagerImpl : public PolicyManager {
virtual DeviceConsent GetUserConsentForDevice(const std::string& device_id);
virtual void SetUserConsentForDevice(const std::string& device_id,
bool is_allowed);
+ virtual bool ReactOnUserDevConsentForApp(const std::string app_id,
+ bool is_device_allowed);
virtual bool GetInitialAppData(const std::string& application_id,
StringArray* nicknames = NULL,
StringArray* app_hmi_types = NULL);
@@ -108,8 +110,6 @@ class PolicyManagerImpl : public PolicyManager {
const std::string& device_id, const std::string& policy_app_id,
std::vector<FunctionalGroupPermission>& permissions);
- virtual void UpdateCurrentDeviceId(const std::string& device_id);
-
virtual std::string& GetCurrentDeviceId(const std::string& policy_app_id);
virtual void SetSystemLanguage(const std::string& language);
@@ -132,6 +132,13 @@ class PolicyManagerImpl : public PolicyManager {
AppPermissions GetAppPermissionsChanges(const std::string& app_id);
void RemovePendingPermissionChanges(const std::string& app_id);
+ void SendNotificationOnPermissionsUpdated(const std::string& application_id);
+
+ bool CleanupUnpairedDevices(const DeviceIds& device_ids);
+
+ bool CanAppKeepContext(const std::string& app_id);
+ bool CanAppStealFocus(const std::string& app_id);
+
protected:
virtual utils::SharedPtr<policy_table::Table> Parse(
const BinaryMessage& pt_content);
@@ -198,11 +205,8 @@ class PolicyManagerImpl : public PolicyManager {
/**
* @brief Check update status and notify HMI on changes
*/
- void CheckUpdateStatus();
-
- void SendNotificationOnPermissionsUpdated(const std::string& application_id);
+ void CheckUpdateStatus();
- static log4cxx::LoggerPtr logger_;
PolicyListener* listener_;
PolicyTable policy_table_;
utils::SharedPtr<policy_table::Table> policy_table_snapshot_;
diff --git a/src/components/policy/src/policy/include/policy/policy_table.h b/src/components/policy/src/policy/include/policy/policy_table.h
index 571d160d1..fdd4c9c2f 100644
--- a/src/components/policy/src/policy/include/policy/policy_table.h
+++ b/src/components/policy/src/policy/include/policy/policy_table.h
@@ -33,7 +33,6 @@
#ifndef SRC_COMPONENTS_POLICY_INCLUDE_POLICY_POLICY_TABLE_H_
#define SRC_COMPONENTS_POLICY_INCLUDE_POLICY_POLICY_TABLE_H_
-#include "utils/logger.h"
#include "utils/shared_ptr.h"
#include "policy/pt_representation.h"
#include "policy/pt_ext_representation.h"
@@ -56,7 +55,6 @@ class PolicyTable {
}
private:
- static log4cxx::LoggerPtr logger_;
utils::SharedPtr<PTRepresentation> pt_data_;
};
} // namespace policy
diff --git a/src/components/policy/src/policy/include/policy/policy_types.h b/src/components/policy/src/policy/include/policy/policy_types.h
index 5a89a0b2f..61c003604 100644
--- a/src/components/policy/src/policy/include/policy/policy_types.h
+++ b/src/components/policy/src/policy/include/policy/policy_types.h
@@ -45,24 +45,35 @@ namespace policy {
enum PolicyErrorEnum {
};
+const std::string kDefaultDeviceMacAddress = "00:00:00:00:00:00";
+const std::string kDefaultDeviceName = "MyDevice";
+
+/**
+ * @brief Constants for special ids in application policies section of
+ * policy table
+ */
+const std::string kPreDataConsentId = "pre_DataConsent";
+const std::string kDefaultId = "default";
+const std::string kDeviceId = "device";
+
/*
*@brief Policy Services specifies Users of Updates
* received from cloud through mobile device
*/
enum PolicyServiceTypes {
- SERVICE_NONE = 0,
- IVSU = 0x04,
- POLICY = 0x07
+ SERVICE_NONE = 0,
+ IVSU = 0x04,
+ POLICY = 0x07
};
/*
* @brief Status of policy table update
*/
enum PolicyTableStatus {
- StatusUpToDate = 0,
- StatusUpdatePending,
- StatusUpdateRequired,
- StatusUnknown
+ StatusUpToDate = 0,
+ StatusUpdatePending,
+ StatusUpdateRequired,
+ StatusUnknown
};
// Code generator uses String class name, so this typedef was renamed to PTSring
@@ -78,8 +89,8 @@ typedef std::map<std::string, std::set<policy::HMILevel> > HMIPermissions;
typedef std::map<std::string, std::set<policy::Parameter> > ParameterPermissions;
struct RpcPermissions {
- HMIPermissions hmi_permissions;
- ParameterPermissions parameter_permissions;
+ HMIPermissions hmi_permissions;
+ ParameterPermissions parameter_permissions;
};
typedef std::map<RpcName, RpcPermissions> Permissions;
@@ -94,33 +105,35 @@ typedef std::vector<std::string> PermissionsList;
*/
typedef std::vector<std::string> StringArray;
+enum PermitResult {
+ kRpcAllowed = 0,
+ kRpcDisallowed,
+ kRpcUserDisallowed
+};
+
/**
* @struct Stores result of check:
* if HMI Level was allowed for RPC to work in
* and list of parameters allowed for RPC if specified in PT.
*/
struct CheckPermissionResult {
- explicit CheckPermissionResult(bool hmi_level_ok = false)
- : hmi_level_permitted(hmi_level_ok) {
- }
+ CheckPermissionResult()
+ : hmi_level_permitted(kRpcDisallowed) {
+ }
- ~CheckPermissionResult() {
- hmi_level_permitted = false;
- }
-
- bool hmi_level_permitted;
- utils::SharedPtr<std::vector<PTString> > list_of_allowed_params;
+ PermitResult hmi_level_permitted;
+ utils::SharedPtr<std::vector<PTString> > list_of_allowed_params;
};
/**
@struct Holds Url string and optional policy app id.
*/
struct EndpointData {
- explicit EndpointData(const std::string& url_string = "")
- : url(url_string)
- , app_id("default") {}
- std::string url;
- std::string app_id;
+ explicit EndpointData(const std::string& url_string = "")
+ : url(url_string)
+ , app_id("default") {}
+ std::string url;
+ std::string app_id;
};
typedef std::vector<EndpointData> EndpointUrls;
@@ -129,15 +142,15 @@ typedef std::vector<EndpointData> EndpointUrls;
* @brief Struct contains device data to be used for dialogs, generation of IDs
*/
struct DeviceParams {
- DeviceParams()
- : device_name("MyDevice"),
- device_mac_address("00:00:00:00:00:00"),
- device_handle(0) {
- }
-
- std::string device_name;
- std::string device_mac_address;
- uint32_t device_handle;
+ DeviceParams()
+ : device_name(kDefaultDeviceName),
+ device_mac_address(kDefaultDeviceMacAddress),
+ device_handle(0) {
+ }
+
+ std::string device_name;
+ std::string device_mac_address;
+ uint32_t device_handle;
};
/**
@@ -145,30 +158,33 @@ struct DeviceParams {
*/
struct AppPermissions {
- AppPermissions(const std::string& app_id)
- : application_id(app_id),
- isAppPermissionsRevoked(false),
- appRevoked(false),
- appPermissionsConsentNeeded(false),
- appUnauthorized(false) {
- }
-
- std::string application_id;
- bool isAppPermissionsRevoked;
- // TODO(AOleynik): Change type according to HMI_API spec
- std::vector<std::string> appRevokedPermissions;
- bool appRevoked;
- bool appPermissionsConsentNeeded;
- bool appUnauthorized;
- bool isSDLAllowed;
- std::string priority;
- DeviceParams deviceInfo;
+ AppPermissions(const std::string& app_id)
+ : application_id(app_id),
+ isAppPermissionsRevoked(false),
+ appRevoked(false),
+ appPermissionsConsentNeeded(false),
+ appUnauthorized(false) {
+ }
+
+ std::string application_id;
+ bool isAppPermissionsRevoked;
+ // TODO(AOleynik): Change type according to HMI_API spec
+ std::vector<std::string> appRevokedPermissions;
+ bool appRevoked;
+ bool appPermissionsConsentNeeded;
+ bool appUnauthorized;
+ bool isSDLAllowed;
+ std::string priority;
+ DeviceParams deviceInfo;
};
+/**
+ * @brief User consent for device data usage
+ */
enum DeviceConsent {
- kDeviceAllowed = 0,
- kDeviceDisallowed,
- kDeviceHasNoConsent
+ kDeviceAllowed = 0,
+ kDeviceDisallowed,
+ kDeviceHasNoConsent
};
/**
@@ -176,22 +192,25 @@ enum DeviceConsent {
* registration and should be stored in policy table
*/
struct DeviceInfo {
- DeviceInfo()
- : max_number_rfcom_ports(0) {
- }
-
- std::string hardware;
- std::string firmware_rev;
- std::string os;
- std::string os_ver;
- std::string carrier;
- uint32_t max_number_rfcom_ports;
+ DeviceInfo()
+ : max_number_rfcom_ports(0) {
+ }
+
+ std::string hardware;
+ std::string firmware_rev;
+ std::string os;
+ std::string os_ver;
+ std::string carrier;
+ uint32_t max_number_rfcom_ports;
};
-enum PermissionState {
- kAllowed = 0,
- kDisallowed,
- kUndefined
+/**
+ * @brief User consent for functional group
+ */
+enum GroupConsent {
+ kGroupAllowed = 0,
+ kGroupDisallowed,
+ kGroupUndefined
};
/**
@@ -199,15 +218,15 @@ enum PermissionState {
* and id from DB
*/
struct FunctionalGroupPermission {
- FunctionalGroupPermission()
- : group_id(0),
- state(kUndefined) {
- }
-
- std::string group_alias;
- std::string group_name;
- uint32_t group_id;
- PermissionState state;
+ FunctionalGroupPermission()
+ : group_id(0),
+ state(kGroupUndefined) {
+ }
+
+ std::string group_alias;
+ std::string group_name;
+ uint32_t group_id;
+ GroupConsent state;
};
/**
@@ -215,23 +234,56 @@ struct FunctionalGroupPermission {
* functional groups on given device
*/
struct PermissionConsent {
- std::string device_id;
- std::string policy_app_id;
- std::vector<FunctionalGroupPermission> group_permissions;
- std::string consent_source;
+ std::string device_id;
+ std::string policy_app_id;
+ std::vector<FunctionalGroupPermission> group_permissions;
+ std::string consent_source;
};
/**
* @brief Contain data for GetUserFriendyMessage response
*/
struct UserFriendlyMessage {
- std::string tts;
- std::string label;
- std::string line1;
- std::string line2;
- std::string text_body;
+ std::string message_code;
+ std::string tts;
+ std::string label;
+ std::string line1;
+ std::string line2;
+ std::string text_body;
+};
+
+/**
+ * @brief Types of functional groups in policy table
+ */
+enum GroupType {
+ kTypeDefault = 0,
+ kTypeAllowed,
+ kTypeDisallowed,
+ kTypePreconsented,
+ kTypeGeneral // means, all types above
};
+/**
+ * @brief Array of functional group id from DB
+ */
+typedef std::vector<uint32_t> FunctionalGroupIDs;
+
+/**
+ * @brief Array of functional group ids sorted by types
+ */
+typedef std::map<GroupType, FunctionalGroupIDs> FunctionalIdType;
+
+/**
+ * @brief Array of functional group ids binded to group name (e.g.
+ * VehicleData-4) and user_consent_prompt (e.g. VehicleData)
+ */
+typedef std::map<uint32_t, std::pair<std::string, std::string> > FunctionalGroupNames;
+
+/**
+ * @brief Array of device ids, which are an identifiers in policy table
+ */
+typedef std::set<std::string> DeviceIds;
+
} // namespace policy
#endif // SRC_COMPONENTS_POLICY_INCLUDE_POLICY_POLICY_TYPES_H_
diff --git a/src/components/policy/src/policy/include/policy/pt_ext_representation.h b/src/components/policy/src/policy/include/policy/pt_ext_representation.h
index a1f251c3e..45d3b1b4b 100644
--- a/src/components/policy/src/policy/include/policy/pt_ext_representation.h
+++ b/src/components/policy/src/policy/include/policy/pt_ext_representation.h
@@ -64,197 +64,228 @@ enum LanguageType {
};
class PTExtRepresentation : public virtual PTRepresentation {
- public:
- virtual ~PTExtRepresentation() {
- }
-
- /**
- * @brief Is application allowed to send notifications while in
- * Backgound or limited mode.
- * @param app_id Application id
- * @return bool Allowed/disallowed.
- */
- virtual bool CanAppKeepContext(const std::string& app_id) = 0;
-
- /**
- * @brief Is application allowed to move foreground at will?
- * @param app_id Application id
- * @return bool Allowed/disallowed.
- */
- virtual bool CanAppStealFocus(const std::string& app_id) = 0;
-
- /**
- * @brief Get default_hmi for given application
- * @param policy_app_id Unique application id
- * @param default_hmi Default HMI level for application or empty, if value was
- * not set
- * @return true, if succedeed, otherwise - false
- */
- virtual bool GetDefaultHMI(const std::string& policy_app_id,
- std::string* default_hmi) = 0;
-
- /**
- * @brief Get priority for given application
- * @param policy_app_id Unique application id
- * @param priority Priority for application or empty, if value was not set
- * @return true, if succedeed, otherwise - false
- */
- virtual bool GetPriority(const std::string& policy_app_id,
- std::string* priority) = 0;
-
- /**
- * @brief Reset user consent for device data and applications permissions
- * @return
- */
- virtual bool ResetUserConsent() = 0;
-
- /**
- * @brief Get user permissions for device data usage
- * @param device_id Generated or obtained id of device
- * @param consented_groups Groups consented by user
- * @param disallowed_groups Groups not consented by user
- * @return true, if query was successfull, otherwise - false
- */
- virtual bool GetUserPermissionsForDevice(
+ public:
+ virtual ~PTExtRepresentation() {
+ }
+
+ /**
+ * @brief Is application allowed to send notifications while in
+ * Backgound or limited mode.
+ * @param app_id Application id
+ * @return bool Allowed/disallowed.
+ */
+ virtual bool CanAppKeepContext(const std::string& app_id) = 0;
+
+ /**
+ * @brief Is application allowed to move foreground at will?
+ * @param app_id Application id
+ * @return bool Allowed/disallowed.
+ */
+ virtual bool CanAppStealFocus(const std::string& app_id) = 0;
+
+ /**
+ * @brief Get default_hmi for given application
+ * @param policy_app_id Unique application id
+ * @param default_hmi Default HMI level for application or empty, if value was
+ * not set
+ * @return true, if succedeed, otherwise - false
+ */
+ virtual bool GetDefaultHMI(const std::string& policy_app_id,
+ std::string* default_hmi) = 0;
+
+ /**
+ * @brief Get priority for given application
+ * @param policy_app_id Unique application id
+ * @param priority Priority for application or empty, if value was not set
+ * @return true, if succedeed, otherwise - false
+ */
+ virtual bool GetPriority(const std::string& policy_app_id,
+ std::string* priority) = 0;
+
+ /**
+ * @brief Reset user consent for device data and applications permissions
+ * @return
+ */
+ virtual bool ResetUserConsent() = 0;
+
+ /**
+ * @brief Get user permissions for device data usage
+ * @param device_id Generated or obtained id of device
+ * @param consented_groups Groups consented by user
+ * @param disallowed_groups Groups not consented by user
+ * @return true, if query was successfull, otherwise - false
+ */
+ virtual bool GetUserPermissionsForDevice(
const std::string& device_id, StringArray* consented_groups = NULL,
StringArray* disallowed_groups = NULL) = 0;
- /**
- * @brief Get user consent for application consent functional groups from DB
- * @param device_id Device id of specific device, which hosts application
- * @param policy_app_id Unique application id
- * @param permissions User consents from DB
- * @return true, if query was successfull, otherwise - false
- */
- virtual bool GetUserPermissionsForApp(
+ /**
+ * @brief GetUserPermissionsForApp
+ * @param device_id
+ * @param policy_app_id
+ * @param group_types
+ * @return
+ */
+ virtual bool GetUserPermissionsForApp(
const std::string& device_id,
const std::string& policy_app_id,
- std::vector<FunctionalGroupPermission>& permissions) = 0;
-
- /**
- * @brief Get device groups and preconsented groups from policies section
- * @param groups List of groups to be consented for device usage
- * @param preconsented_groups List of preconsented groups for device usage
- * @return true, if query was successful, otherwise - false
- */
- virtual bool GetDeviceGroupsFromPolicies(
+ FunctionalIdType* group_types) = 0;
+
+ /**
+ * @brief Get device groups and preconsented groups from policies section
+ * @param groups List of groups to be consented for device usage
+ * @param preconsented_groups List of preconsented groups for device usage
+ * @return true, if query was successful, otherwise - false
+ */
+ virtual bool GetDeviceGroupsFromPolicies(
policy_table::Strings* groups = NULL,
policy_table::Strings* preconsented_groups = NULL) = 0;
- /**
- * @brief Record information about mobile device in Policy Table.
- * @param device_id Generated or obtained id of device
- * @return bool Success of operation
- */
- virtual bool SetDeviceData(const std::string& device_id,
- const std::string& hardware = "",
- const std::string& firmware = "",
- const std::string& os = "",
- const std::string& os_version = "",
- const std::string& carrier = "",
- const uint32_t number_of_ports = 0) = 0;
-
- /**
- * @brief Sets user consent for particular mobile device,
- * i.e. to use device for exchanging of Policy Table.
- * @return bool Success of operation
- */
- virtual bool SetUserPermissionsForDevice(
+ /**
+ * @brief Record information about mobile device in Policy Table.
+ * @param device_id Generated or obtained id of device
+ * @return bool Success of operation
+ */
+ virtual bool SetDeviceData(const std::string& device_id,
+ const std::string& hardware = "",
+ const std::string& firmware = "",
+ const std::string& os = "",
+ const std::string& os_version = "",
+ const std::string& carrier = "",
+ const uint32_t number_of_ports = 0) = 0;
+
+ /**
+ * @brief Sets user consent for particular mobile device,
+ * i.e. to use device for exchanging of Policy Table.
+ * @return bool Success of operation
+ */
+ virtual bool SetUserPermissionsForDevice(
const std::string& device_id, const StringArray& consented_groups =
- StringArray(),
+ StringArray(),
const StringArray& disallowed_gropus = StringArray()) = 0;
- /**
- * @brief Set user consent on functional groups
- * @param permissions User consent on functional group
- * @return true, if operation succedeed, otherwise - false
- */
- virtual bool SetUserPermissionsForApp(
+ /**
+ * @brief Update Application Policies as reaction
+ * on User allowing/disallowing device this app is running on.
+ */
+ virtual bool ReactOnUserDevConsentForApp(
+ const std::string& app_id,
+ bool is_device_allowed) = 0;
+
+ /**
+ * @brief Set user consent on functional groups
+ * @param permissions User consent on functional group
+ * @return true, if operation succedeed, otherwise - false
+ */
+ virtual bool SetUserPermissionsForApp(
const PermissionConsent& permissions) = 0;
- /**
- * @brief Counter for statistics information: adds 1 to existing number.
- * @param type Type of statistics (errors, mins in mode etc)
- * @return bool Success of operation
- */
- virtual bool IncreaseStatisticsData(StatisticsType type) = 0;
-
- /**
- * @brief Records information about what language
- * application tried to register with.
- * @param app_id Id of application
- * @param type - language for UI/VR
- * @param language Language
- * @return bool Success of operation
- */
- virtual bool SetAppRegistrationLanguage(const std::string& app_id,
- LanguageType type,
- const std::string& language) = 0;
-
- /**
- * @brief Records information about head unit system to PT
- * @return bool Success of operation
- */
- virtual bool SetMetaInfo(const std::string& ccpu_version,
- const std::string& wers_country_code,
- const std::string& language) = 0;
-
- /**
- * @brief Kms pass since last successfull PT update
- */
- virtual int GetKmFromSuccessfulExchange() = 0;
-
- /**
- * @brief Days pass since last successfull PT update
- */
- virtual int GetDayFromScsExchange() = 0;
-
- /**
- * @brief Ignition cycles pass since last successfull PT update
- */
- virtual int GetIgnitionsFromScsExchange() = 0;
-
- /**
- * @brief Set current system language
- * @param language System language
- * @return true, if succedeed, otherwise - false
- */
- virtual bool SetSystemLanguage(const std::string& language) = 0;
-
- /**
- * Increments global counter
- * @param type type of counter
- */
- virtual void Increment(const std::string& type) const = 0;
-
- /**
- * Increments counter of application
- * @param app_id id application
- * @param type type of counter
- */
- virtual void Increment(const std::string& app_id,
- const std::string& type) const = 0;
-
- /**
- * Sets value of application information
- * @param app_id id application
- * @param type type of information
- * @param value value of information
- */
- virtual void Set(const std::string& app_id, const std::string& type,
- const std::string& value) const = 0;
-
- /**
- * Adds value to stopwatch of application
- * @param app_id id application
- * @param type type of stopwatch
- * @param seconds value for adding in seconds
- */
- virtual void Add(const std::string& app_id, const std::string& type,
- int seconds) const = 0;
-
- virtual bool CountUnconsentedGroups(const std::string& policy_app_id,
- int* result) const = 0;
+ /**
+ * @brief Counter for statistics information: adds 1 to existing number.
+ * @param type Type of statistics (errors, mins in mode etc)
+ * @return bool Success of operation
+ */
+ virtual bool IncreaseStatisticsData(StatisticsType type) = 0;
+
+ /**
+ * @brief Records information about what language
+ * application tried to register with.
+ * @param app_id Id of application
+ * @param type - language for UI/VR
+ * @param language Language
+ * @return bool Success of operation
+ */
+ virtual bool SetAppRegistrationLanguage(const std::string& app_id,
+ LanguageType type,
+ const std::string& language) = 0;
+
+ /**
+ * @brief Records information about head unit system to PT
+ * @return bool Success of operation
+ */
+ virtual bool SetMetaInfo(const std::string& ccpu_version,
+ const std::string& wers_country_code,
+ const std::string& language) = 0;
+
+ /**
+ * @brief Kms pass since last successfull PT update
+ */
+ virtual int GetKmFromSuccessfulExchange() = 0;
+
+ /**
+ * @brief Days pass since last successfull PT update
+ */
+ virtual int GetDayFromScsExchange() = 0;
+
+ /**
+ * @brief Ignition cycles pass since last successfull PT update
+ */
+ virtual int GetIgnitionsFromScsExchange() = 0;
+
+ /**
+ * @brief Set current system language
+ * @param language System language
+ * @return true, if succedeed, otherwise - false
+ */
+ virtual bool SetSystemLanguage(const std::string& language) = 0;
+
+ /**
+ * Increments global counter
+ * @param type type of counter
+ */
+ virtual void Increment(const std::string& type) const = 0;
+
+ /**
+ * Increments counter of application
+ * @param app_id id application
+ * @param type type of counter
+ */
+ virtual void Increment(const std::string& app_id,
+ const std::string& type) const = 0;
+
+ /**
+ * Sets value of application information
+ * @param app_id id application
+ * @param type type of information
+ * @param value value of information
+ */
+ virtual void Set(const std::string& app_id, const std::string& type,
+ const std::string& value) const = 0;
+
+ /**
+ * Adds value to stopwatch of application
+ * @param app_id id application
+ * @param type type of stopwatch
+ * @param seconds value for adding in seconds
+ */
+ virtual void Add(const std::string& app_id, const std::string& type,
+ int seconds) const = 0;
+
+ virtual bool CountUnconsentedGroups(const std::string& policy_app_id,
+ int* result) const = 0;
+
+ /**
+ * @brief Gets functional group names and user_consent_prompts, if any
+ * @param Array to be filled with group ids, names and functional prompts
+ * @return true, if succeeded, otherwise - false
+ */
+ // TODO(AOleynik): Possibly, we can get rid of this method. Check this.
+ virtual bool GetFunctionalGroupNames(policy::FunctionalGroupNames& names) = 0;
+
+ /**
+ * @brief Set app policy to pre_DataConsented policy
+ * @param app_id Policy ID of application to be changed
+ * @return true, if succeeded, otherwise - false
+ */
+ virtual bool SetPredataPolicy(const std::string& app_id) = 0;
+
+ /**
+ * @brief Updates application policy to either pre_DataConsented or not
+ * @param app_id Policy Id of application to be checked
+ * @param is_pre_data True of False to setting app policy to be pre_DataConsented
+ * @return true, if succeeded, otherwise - false
+ */
+ virtual bool SetIsPredata(const std::string& app_id, bool is_pre_data) = 0;
};
} // namespace policy
diff --git a/src/components/policy/src/policy/include/policy/pt_representation.h b/src/components/policy/src/policy/include/policy/pt_representation.h
index 04dfb9834..ff6544ef2 100644
--- a/src/components/policy/src/policy/include/policy/pt_representation.h
+++ b/src/components/policy/src/policy/include/policy/pt_representation.h
@@ -245,11 +245,25 @@ class PTRepresentation {
virtual bool IsDefaultPolicy(const std::string& app_id) const = 0;
/**
+ * Checks if the application has pre_data policy
+ * @param app_id application id
+ * @return true if application has pre_data policy
+ */
+ virtual bool IsPredataPolicy(const std::string& app_id) const = 0;
+
+ /**
* Sets default policy for application
* @param app_id application id
* @return true if success
*/
virtual bool SetDefaultPolicy(const std::string& app_id) = 0;
+
+ /**
+ * @brief Removes unpaired device records and related records from DB
+ * @param device_ids List of device_id, which should be removed
+ * @return true, if succedeed, otherwise - false
+ */
+ virtual bool CleanupUnpairedDevices(const DeviceIds& device_ids) = 0;
};
} // namespace policy
diff --git a/src/components/policy/src/policy/include/policy/sql_pt_ext_queries.h b/src/components/policy/src/policy/include/policy/sql_pt_ext_queries.h
index 2227e3dc0..ddcba6ae4 100644
--- a/src/components/policy/src/policy/include/policy/sql_pt_ext_queries.h
+++ b/src/components/policy/src/policy/include/policy/sql_pt_ext_queries.h
@@ -68,10 +68,16 @@ extern const std::string kInsertApplication;
extern const std::string kSelectFriendlyMsg;
extern const std::string kSelectAppGroupsId;
extern const std::string kSelectConsentedGroupsId;
+extern const std::string kCountAppConsents;
extern const std::string kSelectPreconsentedGroupsId;
extern const std::string kSelectFunctionalGroupNames;
extern const std::string kSelectAppPolicies;
extern const std::string kUpdateMetaLanguage;
+extern const std::string kDeleteDeviceConsent;
+extern const std::string kDeleteAppConsent;
+extern const std::string kSelectApplicationIsPreData;
+extern const std::string kUpdateIsPredata;
+extern const std::string kHasAppPreloadedGroups;
} // namespace sql_pt_ext
} // namespace policy
diff --git a/src/components/policy/src/policy/include/policy/sql_pt_ext_representation.h b/src/components/policy/src/policy/include/policy/sql_pt_ext_representation.h
index aa171b906..3718d4ebb 100644
--- a/src/components/policy/src/policy/include/policy/sql_pt_ext_representation.h
+++ b/src/components/policy/src/policy/include/policy/sql_pt_ext_representation.h
@@ -39,119 +39,124 @@
namespace policy {
-typedef std::vector<uint32_t> FunctionalGroupIDs;
-typedef std::map<uint32_t, std::pair<std::string, std::string> > FunctionalGroupNames;
-
class SQLPTExtRepresentation : public SQLPTRepresentation,
- public PTExtRepresentation {
- public:
- bool CanAppKeepContext(const std::string& app_id);
- bool CanAppStealFocus(const std::string& app_id);
- bool GetDefaultHMI(const std::string& policy_app_id,
- std::string* default_hmi);
- bool GetPriority(const std::string& policy_app_id, std::string* priority);
- bool ResetUserConsent();
- bool GetUserPermissionsForDevice(const std::string& device_id,
- StringArray* consented_groups = NULL,
- StringArray* disallowed_groups = NULL);
-
- bool GetUserPermissionsForApp(
+ public PTExtRepresentation {
+ public:
+ bool CanAppKeepContext(const std::string& app_id);
+ bool CanAppStealFocus(const std::string& app_id);
+ bool GetDefaultHMI(const std::string& policy_app_id,
+ std::string* default_hmi);
+ bool GetPriority(const std::string& policy_app_id, std::string* priority);
+ bool ResetUserConsent();
+ bool GetUserPermissionsForDevice(const std::string& device_id,
+ StringArray* consented_groups = NULL,
+ StringArray* disallowed_groups = NULL);
+
+ bool GetUserPermissionsForApp(
const std::string& device_id, const std::string& policy_app_id,
- std::vector<FunctionalGroupPermission>& permissions);
+ FunctionalIdType* group_types);
- bool GetDeviceGroupsFromPolicies(policy_table::Strings* groups = NULL,
- policy_table::Strings* preconsented_groups =
- NULL);
- bool SetDeviceData(const std::string& device_id, const std::string& hardware =
+ bool GetDeviceGroupsFromPolicies(policy_table::Strings* groups = NULL,
+ policy_table::Strings* preconsented_groups =
+ NULL);
+ bool SetDeviceData(const std::string& device_id, const std::string& hardware =
"",
- const std::string& firmware = "", const std::string& os =
+ const std::string& firmware = "", const std::string& os =
"",
- const std::string& os_version = "",
- const std::string& carrier = "",
- const uint32_t number_of_ports = 0);
- bool SetUserPermissionsForDevice(const std::string& device_id,
- const StringArray& consented_groups =
+ const std::string& os_version = "",
+ const std::string& carrier = "",
+ const uint32_t number_of_ports = 0);
+ bool SetUserPermissionsForDevice(const std::string& device_id,
+ const StringArray& consented_groups =
StringArray(),
- const StringArray& disallowed_groups =
+ const StringArray& disallowed_groups =
StringArray());
- bool SetUserPermissionsForApp(const PermissionConsent& permissions);
+ bool ReactOnUserDevConsentForApp(const std::string& app_id,
+ bool is_device_allowed);
+
+ bool SetUserPermissionsForApp(const PermissionConsent& permissions);
- std::vector<UserFriendlyMessage> GetUserFriendlyMsg(
+ std::vector<UserFriendlyMessage> GetUserFriendlyMsg(
const std::vector<std::string>& msg_codes, const std::string& language);
- bool IncreaseStatisticsData(StatisticsType type) {
- return true;
- }
- bool SetAppRegistrationLanguage(const std::string& app_id, LanguageType type,
- const std::string& language) {
- return true;
- }
-
- bool SetMetaInfo(const std::string& ccpu_version,
- const std::string& wers_country_code,
- const std::string& language);
-
- bool SetSystemLanguage(const std::string& language);
-
- int GetKmFromSuccessfulExchange() {
- return true;
- }
- int GetDayFromScsExchange() {
- return true;
- }
- int GetIgnitionsFromScsExchange() {
- return true;
- }
-
- void Increment(const std::string& type) const;
- void Increment(const std::string& app_id, const std::string& type) const;
- void Set(const std::string& app_id, const std::string& type,
- const std::string& value) const;
- void Add(const std::string& app_id, const std::string& type,
- int seconds) const;
-
- private:
- void GatherModuleMeta(policy_table::ModuleMeta* meta) const;
- bool GatherApplicationPolicies(policy_table::ApplicationPolicies* apps) const;
- void GatherPreconsentedGroup(const std::string& app_id,
- policy_table::Strings* groups) const;
- bool GatherUsageAndErrorCounts(
+ bool IncreaseStatisticsData(StatisticsType type) {
+ return true;
+ }
+ bool SetAppRegistrationLanguage(const std::string& app_id, LanguageType type,
+ const std::string& language) {
+ return true;
+ }
+
+ bool SetMetaInfo(const std::string& ccpu_version,
+ const std::string& wers_country_code,
+ const std::string& language);
+
+ bool SetSystemLanguage(const std::string& language);
+
+ int GetKmFromSuccessfulExchange() {
+ return true;
+ }
+ int GetDayFromScsExchange() {
+ return true;
+ }
+ int GetIgnitionsFromScsExchange() {
+ return true;
+ }
+
+ bool GetFunctionalGroupNames(FunctionalGroupNames& names);
+ bool CleanupUnpairedDevices(const DeviceIds& device_ids);
+
+ void Increment(const std::string& type) const;
+ void Increment(const std::string& app_id, const std::string& type) const;
+ void Set(const std::string& app_id, const std::string& type,
+ const std::string& value) const;
+ void Add(const std::string& app_id, const std::string& type,
+ int seconds) const;
+ bool SetDefaultPolicy(const std::string& app_id);
+ bool SetPredataPolicy(const std::string& app_id);
+ bool SetIsPredata(const std::string& app_id, bool is_pre_data);
+ bool IsPredataPolicy(const std::string& app_id) const;
+
+ private:
+ void GatherModuleMeta(policy_table::ModuleMeta* meta) const;
+ void GatherPreconsentedGroup(const std::string& app_id,
+ policy_table::Strings* groups) const;
+ bool GatherUsageAndErrorCounts(
policy_table::UsageAndErrorCounts* counts) const;
- bool GatherAppLevels(policy_table::AppLevels* apps) const;
- void GatherDeviceData(policy_table::DeviceData* data) const;
- void GatherConsentGroup(const std::string& device_id,
- policy_table::UserConsentRecords* records) const;
- bool SaveDeviceData(const policy_table::DeviceData& devices);
- bool SaveConsentGroup(const std::string& device_id,
- const policy_table::UserConsentRecords& records);
- bool SaveApplicationPolicies(const policy_table::ApplicationPolicies& apps);
- bool SavePreconsentedGroup(const std::string& app_id,
- const policy_table::Strings& groups);
- bool SaveMessageString(const std::string& type, const std::string& lang,
- const policy_table::MessageString& strings);
-
- bool IsExistAppLevel(const std::string& app_id) const;
-
- bool GetAllAppGroups(const std::string& policy_app_id,
- FunctionalGroupIDs& all_groups);
-
- bool GetConsentedGroups(const std::string& policy_app_id,
- const std::string& device_id,
- FunctionalGroupIDs& allowed_groups,
- FunctionalGroupIDs& disallowed_groups);
-
- bool GetPreconsentedGroups(const std::string& policy_app_id,
- FunctionalGroupIDs& preconsented_groups);
-
- bool GetFunctionalGroupNames(FunctionalGroupNames& names);
-
- void FillFunctionalGroupPermissions(
+ bool GatherAppLevels(policy_table::AppLevels* apps) const;
+ void GatherDeviceData(policy_table::DeviceData* data) const;
+ void GatherConsentGroup(const std::string& device_id,
+ policy_table::UserConsentRecords* records) const;
+ bool GatherApplicationPolicies(policy_table::ApplicationPolicies* apps) const;
+ bool SaveDeviceData(const policy_table::DeviceData& devices);
+ bool SaveConsentGroup(const std::string& device_id,
+ const policy_table::UserConsentRecords& records);
+ bool SaveApplicationPolicies(const policy_table::ApplicationPolicies& apps);
+ bool SavePreconsentedGroup(const std::string& app_id,
+ const policy_table::Strings& groups);
+ bool SaveMessageString(const std::string& type, const std::string& lang,
+ const policy_table::MessageString& strings);
+
+ bool IsExistAppLevel(const std::string& app_id) const;
+
+ bool GetAllAppGroups(const std::string& policy_app_id,
+ FunctionalGroupIDs& all_groups);
+
+ bool GetConsentedGroups(const std::string& policy_app_id,
+ const std::string& device_id,
+ FunctionalGroupIDs& allowed_groups,
+ FunctionalGroupIDs& disallowed_groups);
+
+ bool GetPreconsentedGroups(const std::string& policy_app_id,
+ FunctionalGroupIDs& preconsented_groups);
+
+ void FillFunctionalGroupPermissions(
FunctionalGroupIDs& ids, FunctionalGroupNames& names,
- PermissionState state,
+ GroupConsent state,
std::vector<FunctionalGroupPermission>& permissions);
- bool CountUnconsentedGroups(const std::string& policy_app_id,
- int* result) const;
+ bool CountUnconsentedGroups(const std::string& policy_app_id,
+ int* result) const;
};
} // namespace policy
diff --git a/src/components/policy/src/policy/include/policy/sql_pt_queries.h b/src/components/policy/src/policy/include/policy/sql_pt_queries.h
index f39e11c14..5eaea730b 100644
--- a/src/components/policy/src/policy/include/policy/sql_pt_queries.h
+++ b/src/components/policy/src/policy/include/policy/sql_pt_queries.h
@@ -87,6 +87,7 @@ extern const std::string kDeleteFunctionalGroup;
extern const std::string kDeleteRpc;
extern const std::string kDeleteAppGroup;
extern const std::string kDeleteApplication;
+extern const std::string kDeleteDevice;
extern const std::string kIncrementIgnitionCycles;
extern const std::string kResetIgnitionCycles;
extern const std::string kUpdateFlagUpdateRequired;
diff --git a/src/components/policy/src/policy/include/policy/sql_pt_representation.h b/src/components/policy/src/policy/include/policy/sql_pt_representation.h
index 78b7c0e21..2d37d53b5 100644
--- a/src/components/policy/src/policy/include/policy/sql_pt_representation.h
+++ b/src/components/policy/src/policy/include/policy/sql_pt_representation.h
@@ -36,7 +36,6 @@
#include <string>
#include <vector>
#include "policy/pt_representation.h"
-#include "utils/logger.h"
#include "rpc_base/rpc_base.h"
#include "policy_table_interface_base/types.h"
@@ -133,19 +132,16 @@ class SQLPTRepresentation : public virtual PTRepresentation {
bool IsApplicationRevoked(const std::string& app_id) const;
bool IsApplicationRepresented(const std::string& app_id) const;
- bool IsDefaultPolicy(const std::string& app_id) const;
- bool SetDefaultPolicy(const std::string& app_id);
+ virtual bool IsDefaultPolicy(const std::string& app_id) const;
+ virtual bool IsPredataPolicy(const std::string& app_id) const;
+ virtual bool SetDefaultPolicy(const std::string& app_id);
+ bool CleanupUnpairedDevices(const DeviceIds& device_ids);
- dbms::SQLDatabase* db() const {
- return db_;
- }
- static log4cxx::LoggerPtr logger() {
- return logger_;
- }
+ dbms::SQLDatabase* db() const;
+ virtual bool SetIsDefault(const std::string& app_id, bool is_default);
private:
static const std::string kDatabaseName;
- static log4cxx::LoggerPtr logger_;
dbms::SQLDatabase* db_;
bool SaveRpcs(int64_t group_id, const policy_table::Rpc& rpcs);
@@ -156,7 +152,6 @@ class SQLPTRepresentation : public virtual PTRepresentation {
const policy_table::NumberOfNotificationsPerMinute& notifications);
bool SaveMessageType(const std::string& type);
bool SaveLanguage(const std::string& code);
- bool SetIsDefault(const std::string& app_id, bool is_default);
};
} // namespace policy
diff --git a/src/components/policy/src/policy/policy_table_interface.xml b/src/components/policy/src/policy/policy_table_interface.xml
index 13840a45a..576b4b203 100644
--- a/src/components/policy/src/policy/policy_table_interface.xml
+++ b/src/components/policy/src/policy/policy_table_interface.xml
@@ -1,225 +1,225 @@
-<?xml version="1.0" standalone="no"?>
-<?xml-stylesheet type="text/xml" href="protocol2html.xsl"?>
-
-<interface name="policy table interface base" version="0.0"
- date="2014-01-23">
-
- <!-- Common parameters start -->
- <enum name="Priority">
- <element name="EMERGENCY" />
- <element name="NAVIGATION" />
- <element name="VOICECOM" />
- <element name="COMMUNICATION" />
- <element name="NORMAL" />
- <element name="NONE" />
- </enum>
-
- <enum name="HmiLevel">
- <element name="BACKGROUND" />
- <element name="FULL" />
- <element name="LIMITED" />
- <element name="NONE" />
- </enum>
-
- <enum name="Parameter">
- <element name="gps" />
- <element name="speed" />
- <element name="engineTorque" />
- <element name="externalTemperature" />
- <element name="fuelLevel" />
- <element name="fuelLevel_State" />
- <element name="headLampStatus" />
- <element name="instantFuelConsumption" />
- <element name="odometer" />
- <element name="tirePressure" />
- <element name="wiperStatus" />
- <element name="vin" />
- <element name="accPedalPosition" />
- <element name="beltStatus" />
- <element name="driverBraking" />
- <element name="prndl" />
- <element name="rpm" />
- <element name="steeringWheelAngle" />
- </enum>
-
- <enum name="AppHMIType">
- <element name="DEFAULT" />
- <element name="COMMUNICATION" />
- <element name="MEDIA" />
- <element name="MESSAGING" />
- <element name="NAVIGATION" />
- <element name="INFORMATION" />
- <element name="SOCIAL" />
- <element name="BACKGROUND_PROCESS" />
- <element name="TESTING" />
- <element name="SYSTEM" />
- </enum>
- <!-- Common parameters end -->
-
- <!-- app_policies section start -->
- <struct name="Dummy">
- <description>
- Typedefs won't proceeded until first struct
- definition
- To be removed after typedef issue fix within
- generator code
- </description>
- </struct>
-
- <typedef name="Strings" type="String" maxlength="255" array="true"
- maxsize="255" />
-
- <typedef name="AppHMITypes" type="AppHMIType" array="true"
- maxsize="255" />
-
- <struct name="ApplicationParams">
- <param name="groups" type="Strings" />
- <param name="nicknames" type="Strings" mandatory="false" />
- <param name="AppHMIType" type="AppHMITypes" mandatory="false" />
- <param name="memory_kb" type="Integer" minvalue="1" maxvalue="65225" />
- <param name="watchdog_timer_ms" type="Integer" minvalue="1"
- maxvalue="65225" />
- <param name="certificate" type="String" minlegth="0" maxlength="255"
- mandatory="false" />
- </struct>
-
- <typedef name="HmiLevels" type="HmiLevel" array="true"
- maxsize="4" />
- <typedef name="Parameters" type="Parameter" array="true"
- maxsize="24" />
-
- <struct name="RpcParameters">
- <!-- maxsizes are equal to number of currently known elements of
- given type -->
- <param name="hmi_levels" type="HmiLevels" />
- <param name="parameters" type="Parameters" mandatory="false" />
- </struct>
-
- <!-- maxsizes are equal to number of currently known elements of given
- type -->
- <typedef name="Rpc" type="RpcParameters" map="true" maxsize="50" />
-
- <struct name="Rpcs">
- <param name="user_consent_prompt" type="String" minlegth="1"
- maxlength="255" mandatory="false"/>
- <param name="rpcs" type="Rpc" />
- </struct>
- <!-- app_policies section end -->
-
- <!-- module_config section start -->
- <!-- minlenght="10" since minimum expected is "http://a.b" -->
- <typedef name="URL" type="String" minlength="10" maxlength="255"
- array="true" minsize="1" maxsize="255" />
-
- <typedef name="URLList" type="URL" map="true" minsize="1"
- maxsize="255" />
-
- <!-- max number of services is limited to 255 according to protocol specification -->
- <typedef name="ServiceEndpoints" type="URLList" map="true"
- minsize="1" maxsize="255" />
-
- <typedef name="NumberOfNotificationsPerMinute" type="Integer"
- map="true" maxsize="6" minvalue="0" maxvalue="255" />
-
- <typedef name="SecondsBetweenRetries" type="Integer" array="true"
- maxsize="10" minvalue="1" maxvalue="1000" />
-
- <struct name="ModuleConfig">
- <param name="preloaded_pt" type="Boolean" mandatory="false" />
- <param name="exchange_after_x_ignition_cycles" type="Integer"
- maxvalue="255" />
- <param name="exchange_after_x_kilometers" type="Integer"
- maxvalue="255" />
- <param name="exchange_after_x_days" type="Integer"
- maxvalue="255" />
- <param name="timeout_after_x_seconds" type="Integer"
- maxvalue="65535" />
- <param name="seconds_between_retries" type="SecondsBetweenRetries" />
- <param name="endpoints" type="ServiceEndpoints" />
- <param name="notifications_per_minute_by_priority" type="NumberOfNotificationsPerMinute" />
- <param name="vehicle_make" type="String" maxlength="100"
- mandatory="false" />
- <param name="vehicle_model" type="String" maxlength="100"
- mandatory="false" />
- <param name="vehicle_year" type="Integer" maxvalue="255"
- mandatory="false" />
- </struct>
- <!-- module_config section end -->
-
- <!-- consumer_friendly_messages section start -->
- <struct name="MessageString">
- <param name="line1" type="String" maxlength="255"
- mandatory="false" />
- <param name="line2" type="String" maxlength="255"
- mandatory="false" />
- <param name="tts" type="String" maxlength="255" mandatory="false" />
- <param name="label" type="String" maxlength="255"
- mandatory="false" />
- <param name="textBody" type="String" maxlength="255"
- mandatory="false" />
- </struct>
-
- <typedef name="Languages" map="true" type="MessageString"
- maxsize="255" mandatory="false" />
-
- <struct name="MessageLanguages">
- <param name="languages" type="Languages" />
- </struct>
-
- <typedef name="Messages" map="true" type="MessageLanguages"
- maxsize="255" />
-
- <struct name="ConsumerFriendlyMessages">
- <param name="version" type="String" maxlength="100" />
- <param name="messages" type="Messages" mandatory="false" />
- </struct>
- <!-- consumer_friendly_messages section end -->
-
- <!-- module_meta section start -->
- <struct name="ModuleMeta">
- </struct>
- <!-- module_meta section end -->
-
- <!-- usage_and_error_counts section start -->
- <struct name="AppLevel">
- </struct>
-
- <typedef name="AppLevels" type="AppLevel" map="true" maxsize="255" />
-
- <struct name="UsageAndErrorCounts">
- <param name="app_level" type="AppLevels" mandatory="false" />
- </struct>
- <!-- usage_and_error_counts section end -->
-
- <!-- device_data section start -->
- <struct name="DeviceParams">
- </struct>
- <!-- device_data section end -->
-
- <!-- policy_table section start -->
- <typedef name="ApplicationPolicies" map="true" type="ApplicationParams" null_values_allowed="true" minsize="1" maxsize="1000" />
-
- <typedef name="FunctionalGroupings" map="true" type="Rpcs"
- minsize="1" maxsize="255" />
-
- <typedef name="DeviceData" map="true" type="DeviceParams"
- maxsize="255" />
-
- <struct name="PolicyTable">
- <!-- maxsize for app_policies can be changed, if necessary -->
- <param name="app_policies" type="ApplicationPolicies" />
- <param name="functional_groupings" type="FunctionalGroupings" />
- <param name="consumer_friendly_messages" type="ConsumerFriendlyMessages" />
- <param name="module_config" type="ModuleConfig" />
- <param name="module_meta" type="ModuleMeta" />
- <param name="usage_and_error_counts" type="UsageAndErrorCounts" />
- <param name="device_data" type="DeviceData" />
- </struct>
- <!-- policy_table section end -->
-
- <!-- Root element -->
- <struct name="Table">
- <param name="policy_table" type="PolicyTable" />
- </struct>
-
-</interface>
+<?xml version="1.0" standalone="no"?>
+<?xml-stylesheet type="text/xml" href="protocol2html.xsl"?>
+
+<interface name="policy table interface base" version="0.0"
+ date="2014-01-23">
+
+ <!-- Common parameters start -->
+ <enum name="Priority">
+ <element name="EMERGENCY" />
+ <element name="NAVIGATION" />
+ <element name="VOICECOM" />
+ <element name="COMMUNICATION" />
+ <element name="NORMAL" />
+ <element name="NONE" />
+ </enum>
+
+ <enum name="HmiLevel">
+ <element name="BACKGROUND" />
+ <element name="FULL" />
+ <element name="LIMITED" />
+ <element name="NONE" />
+ </enum>
+
+ <enum name="Parameter">
+ <element name="gps" />
+ <element name="speed" />
+ <element name="engineTorque" />
+ <element name="externalTemperature" />
+ <element name="fuelLevel" />
+ <element name="fuelLevel_State" />
+ <element name="headLampStatus" />
+ <element name="instantFuelConsumption" />
+ <element name="odometer" />
+ <element name="tirePressure" />
+ <element name="wiperStatus" />
+ <element name="vin" />
+ <element name="accPedalPosition" />
+ <element name="beltStatus" />
+ <element name="driverBraking" />
+ <element name="prndl" />
+ <element name="rpm" />
+ <element name="steeringWheelAngle" />
+ <element name="myKey" />
+ <element name="airbagStatus" />
+ <element name="bodyInformation" />
+ <element name="clusterModeStatus" />
+ <element name="deviceStatus" />
+ <element name="emergencyEvent" />
+ <element name="eCallInfo" />
+ </enum>
+
+ <enum name="AppHMIType">
+ <element name="DEFAULT" />
+ <element name="COMMUNICATION" />
+ <element name="MEDIA" />
+ <element name="MESSAGING" />
+ <element name="NAVIGATION" />
+ <element name="INFORMATION" />
+ <element name="SOCIAL" />
+ <element name="BACKGROUND_PROCESS" />
+ <element name="TESTING" />
+ <element name="SYSTEM" />
+ </enum>
+ <!-- Common parameters end -->
+
+ <!-- app_policies section start -->
+
+ <typedef name="Strings" type="String" maxlength="255" array="true"
+ maxsize="255" />
+
+ <typedef name="AppHMITypes" type="AppHMIType" array="true"
+ maxsize="255" />
+
+ <struct name="ApplicationParams">
+ <param name="groups" type="Strings" />
+ <param name="nicknames" type="Strings" mandatory="false" />
+ <param name="AppHMIType" type="AppHMITypes" mandatory="false" />
+ <param name="memory_kb" type="Integer" minvalue="1" maxvalue="65225" mandatory="false"/>
+ <param name="watchdog_timer_ms" type="Integer" minvalue="1"
+ maxvalue="65225" mandatory="false"/>
+ <param name="certificate" type="String" minlength="0" maxlength="255"
+ mandatory="false" />
+ </struct>
+
+ <typedef name="HmiLevels" type="HmiLevel" array="true"
+ maxsize="4" />
+ <typedef name="Parameters" type="Parameter" array="true"
+ maxsize="24" />
+
+ <struct name="RpcParameters">
+ <!-- maxsizes are equal to number of currently known elements of
+ given type -->
+ <param name="hmi_levels" type="HmiLevels" />
+ <param name="parameters" type="Parameters" mandatory="false" />
+ </struct>
+
+ <!-- maxsizes are equal to number of currently known elements of given
+ type -->
+ <typedef name="Rpc" type="RpcParameters" map="true" maxsize="50" />
+
+ <struct name="Rpcs">
+ <param name="user_consent_prompt" type="String" minlegth="1"
+ maxlength="255" mandatory="false"/>
+ <param name="rpcs" type="Rpc" null_values_allowed="true"/>
+ </struct>
+ <!-- app_policies section end -->
+
+ <!-- module_config section start -->
+ <!-- minlenght="10" since minimum expected is "http://a.b" -->
+ <typedef name="URL" type="String" minlength="10" maxlength="255"
+ array="true" minsize="1" maxsize="255" />
+
+ <typedef name="URLList" type="URL" map="true" minsize="1"
+ maxsize="255" />
+
+ <!-- max number of services is limited to 255 according to protocol specification -->
+ <typedef name="ServiceEndpoints" type="URLList" map="true"
+ minsize="1" maxsize="255" />
+
+ <typedef name="NumberOfNotificationsPerMinute" type="Integer"
+ map="true" maxsize="6" minvalue="0" maxvalue="255" />
+
+ <typedef name="SecondsBetweenRetries" type="Integer" array="true"
+ maxsize="10" minvalue="1" maxvalue="1000" />
+
+ <struct name="ModuleConfig">
+ <param name="device_certificates" type="String" minlength="1" maxlength="100" mandatory="false" map="true" minsize="1" maxsize="255" />
+ <param name="preloaded_pt" type="Boolean" mandatory="false" />
+ <param name="exchange_after_x_ignition_cycles" type="Integer"
+ maxvalue="255" />
+ <param name="exchange_after_x_kilometers" type="Integer"
+ maxvalue="4294967296" />
+ <param name="exchange_after_x_days" type="Integer"
+ maxvalue="255" />
+ <param name="timeout_after_x_seconds" type="Integer"
+ maxvalue="65535" />
+ <param name="seconds_between_retries" type="SecondsBetweenRetries" />
+ <param name="endpoints" type="ServiceEndpoints" />
+ <param name="notifications_per_minute_by_priority" type="NumberOfNotificationsPerMinute" />
+ <param name="vehicle_make" type="String" maxlength="100"
+ mandatory="false" />
+ <param name="vehicle_model" type="String" maxlength="100"
+ mandatory="false" />
+ <param name="vehicle_year" type="Integer" minvalue="1900" maxvalue="2020"
+ mandatory="false" />
+ </struct>
+ <!-- module_config section end -->
+
+ <!-- consumer_friendly_messages section start -->
+ <struct name="MessageString">
+ <param name="line1" type="String" maxlength="255"
+ mandatory="false" />
+ <param name="line2" type="String" maxlength="255"
+ mandatory="false" />
+ <param name="tts" type="String" maxlength="65535" mandatory="false" />
+ <param name="label" type="String" maxlength="255"
+ mandatory="false" />
+ <param name="textBody" type="String" maxlength="500"
+ mandatory="false" />
+ </struct>
+
+ <typedef name="Languages" map="true" type="MessageString"
+ maxsize="500" mandatory="false" />
+
+ <struct name="MessageLanguages">
+ <param name="languages" type="Languages" />
+ </struct>
+
+ <typedef name="Messages" map="true" type="MessageLanguages"
+ maxsize="255" />
+
+ <struct name="ConsumerFriendlyMessages">
+ <param name="version" type="String" maxlength="100" />
+ <param name="messages" type="Messages" mandatory="false" />
+ </struct>
+ <!-- consumer_friendly_messages section end -->
+
+ <!-- module_meta section start -->
+ <struct name="ModuleMeta">
+ </struct>
+ <!-- module_meta section end -->
+
+ <!-- usage_and_error_counts section start -->
+ <struct name="AppLevel">
+ </struct>
+
+ <typedef name="AppLevels" type="AppLevel" map="true" maxsize="255" />
+
+ <struct name="UsageAndErrorCounts">
+ <param name="app_level" type="AppLevels" mandatory="false" />
+ </struct>
+ <!-- usage_and_error_counts section end -->
+
+ <!-- device_data section start -->
+ <struct name="DeviceParams">
+ </struct>
+ <!-- device_data section end -->
+
+ <!-- policy_table section start -->
+ <typedef name="ApplicationPolicies" map="true" type="ApplicationParams" null_values_allowed="true" minsize="1" maxsize="1000" />
+
+ <typedef name="FunctionalGroupings" map="true" type="Rpcs"
+ minsize="1" maxsize="255" />
+
+ <typedef name="DeviceData" map="true" type="DeviceParams"
+ maxsize="255" />
+
+ <struct name="PolicyTable">
+ <!-- maxsize for app_policies can be changed, if necessary -->
+ <param name="app_policies" type="ApplicationPolicies" />
+ <param name="functional_groupings" type="FunctionalGroupings" />
+ <param name="consumer_friendly_messages" type="ConsumerFriendlyMessages" />
+ <param name="module_config" type="ModuleConfig" />
+ <param name="module_meta" type="ModuleMeta" mandatory="false"/>
+ <param name="usage_and_error_counts" type="UsageAndErrorCounts" mandatory="false" />
+ <param name="device_data" type="DeviceData" mandatory="false" />
+ </struct>
+ <!-- policy_table section end -->
+
+ <!-- Root element -->
+ <struct name="Table">
+ <param name="policy_table" type="PolicyTable" />
+ </struct>
+
+</interface>
diff --git a/src/components/policy/src/policy/policy_table_interface_ext.xml b/src/components/policy/src/policy/policy_table_interface_ext.xml
index d971c9192..1f126a7df 100644
--- a/src/components/policy/src/policy/policy_table_interface_ext.xml
+++ b/src/components/policy/src/policy/policy_table_interface_ext.xml
@@ -40,6 +40,13 @@
<element name="prndl" />
<element name="rpm" />
<element name="steeringWheelAngle" />
+ <element name="myKey" />
+ <element name="airbagStatus" />
+ <element name="bodyInformation" />
+ <element name="clusterModeStatus" />
+ <element name="deviceStatus" />
+ <element name="emergencyEvent" />
+ <element name="eCallInfo" />
</enum>
<enum name="AppHMIType">
@@ -73,10 +80,10 @@
<param name="default_hmi" type="HmiLevel" />
<param name="keep_context" type="Boolean" />
<param name="steal_focus" type="Boolean" />
- <param name="memory_kb" type="Integer" minvalue="1" maxvalue="65225" />
+ <param name="memory_kb" type="Integer" minvalue="1" maxvalue="65225" mandatory="false"/>
<param name="watchdog_timer_ms" type="Integer" minvalue="1"
- maxvalue="65225" />
- <param name="certificate" type="String" minlegth="0" maxlength="255"
+ maxvalue="65225" mandatory="false"/>
+ <param name="certificate" type="String" minlength="0" maxlength="255"
mandatory="false" />
</struct>
@@ -94,7 +101,7 @@
<!-- maxsizes are equal to number of currently known elements of given
type -->
- <typedef name="Rpc" type="RpcParameters" map="true" maxsize="50" />
+ <typedef name="Rpc" type="RpcParameters" map="true" maxsize="50" null_values_allowed="true" />
<struct name="Rpcs">
<param name="user_consent_prompt" type="String" minlegth="1"
@@ -122,11 +129,12 @@
maxsize="10" minvalue="1" maxvalue="1000" />
<struct name="ModuleConfig">
+ <param name="device_certificates" type="String" minlength="1" maxlength="100" mandatory="false" map="true" minsize="1" maxsize="255" />
<param name="preloaded_pt" type="Boolean" mandatory="false" />
<param name="exchange_after_x_ignition_cycles" type="Integer"
maxvalue="255" />
<param name="exchange_after_x_kilometers" type="Integer"
- maxvalue="255" />
+ maxvalue="4294967296" />
<param name="exchange_after_x_days" type="Integer"
maxvalue="255" />
<param name="timeout_after_x_seconds" type="Integer"
@@ -138,7 +146,7 @@
mandatory="false" />
<param name="vehicle_model" type="String" maxlength="100"
mandatory="false" />
- <param name="vehicle_year" type="Integer" maxvalue="255"
+ <param name="vehicle_year" type="Integer" minvalue="1900" maxvalue="2020"
mandatory="false" />
</struct>
<!-- module_config section end -->
@@ -149,15 +157,15 @@
mandatory="false" />
<param name="line2" type="String" maxlength="255"
mandatory="false" />
- <param name="tts" type="String" maxlength="255" mandatory="false" />
+ <param name="tts" type="String" maxlength="65535" mandatory="false" />
<param name="label" type="String" maxlength="255"
mandatory="false" />
- <param name="textBody" type="String" maxlength="255"
+ <param name="textBody" type="String" maxlength="500"
mandatory="false" />
</struct>
<typedef name="Languages" map="true" type="MessageString"
- maxsize="255" mandatory="false" />
+ maxsize="500" mandatory="false" />
<struct name="MessageLanguages">
<param name="languages" type="Languages" />
@@ -187,8 +195,8 @@
<!-- usage_and_error_counts section start -->
<struct name="AppLevel">
<param name="minutes_in_hmi_full" type="Integer" minvalue="0" maxvalue="65535" />
- <param name="app_registration_language_gui" type="String" />
- <param name="app_registration_language_vui" type="String" />
+ <param name="app_registration_language_gui" type="String" minlength="1" maxlength="10" />
+ <param name="app_registration_language_vui" type="String" minlength="1" maxlength="10" />
<param name="count_of_rfcom_limit_reached" type="Integer" minvalue="0" maxvalue="65535" />
<param name="minutes_in_hmi_limited" type="Integer" minvalue="0" maxvalue="65535" />
<param name="minutes_in_hmi_background" type="Integer" minvalue="0" maxvalue="65535" />
@@ -210,7 +218,7 @@
<param name="count_of_iap_buffer_full" type="Integer" minvalue="0" maxvalue="65535" mandatory="false" />
<param name="count_sync_out_of_memory" type="Integer" minvalue="0" maxvalue="65535" mandatory="false" />
<param name="count_of_sync_reboots" type="Integer" minvalue="0" maxvalue="65535" mandatory="false" />
- <param name="app_level" type="AppLevels" />
+ <param name="app_level" type="AppLevels" mandatory="false" />
</struct>
<!-- usage_and_error_counts section end -->
@@ -232,10 +240,10 @@
<struct name="DeviceParams" scope="internal">
<param name="hardware" type="String" maxlength="255" mandatory="false"/>
- <param name="firmware_rev" type="String" maxlength="255" mandatory="false"/>
+ <param name="firmware_rev" type="String" maxlength="255" nullable="true" mandatory="false"/>
<param name="os" type="String" maxlength="255" mandatory="false"/>
<param name="os_version" type="String" maxlength="255" mandatory="false"/>
- <param name="carrier" type="String" maxlength="255" mandatory="false"/>
+ <param name="carrier" type="String" maxlength="255" nullable="true" mandatory="false"/>
<param name="user_consent_records" type="UserConsentRecords" mandatory="false"/>
<param name="max_number_rfcom_ports" type="Integer" maxvalue="255" mandatory="false"/>
</struct>
@@ -257,9 +265,9 @@
<param name="functional_groupings" type="FunctionalGroupings" />
<param name="consumer_friendly_messages" type="ConsumerFriendlyMessages" />
<param name="module_config" type="ModuleConfig" />
- <param name="module_meta" type="ModuleMeta" />
- <param name="usage_and_error_counts" type="UsageAndErrorCounts" />
- <param name="device_data" type="DeviceData" />
+ <param name="module_meta" type="ModuleMeta" mandatory="false"/>
+ <param name="usage_and_error_counts" type="UsageAndErrorCounts" mandatory="false" />
+ <param name="device_data" type="DeviceData" mandatory="false" />
</struct>
<!-- policy_table section end -->
diff --git a/src/components/policy/src/policy/qdb_wrapper/include/qdb_wrapper/sql_query.h b/src/components/policy/src/policy/qdb_wrapper/include/qdb_wrapper/sql_query.h
index 051569f29..f0b014e47 100644
--- a/src/components/policy/src/policy/qdb_wrapper/include/qdb_wrapper/sql_query.h
+++ b/src/components/policy/src/policy/qdb_wrapper/include/qdb_wrapper/sql_query.h
@@ -191,7 +191,7 @@ class SQLQuery {
/**
* The instantiation of database
*/
- SQLDatabase& db_;
+ SQLDatabase* db_;
/**
* The string of query
diff --git a/src/components/policy/src/policy/qdb_wrapper/src/sql_query.cc b/src/components/policy/src/policy/qdb_wrapper/src/sql_query.cc
index c2792f3f2..0bd709ed8 100644
--- a/src/components/policy/src/policy/qdb_wrapper/src/sql_query.cc
+++ b/src/components/policy/src/policy/qdb_wrapper/src/sql_query.cc
@@ -93,7 +93,7 @@ class SetBindNull {
};
SQLQuery::SQLQuery(SQLDatabase* db)
- : db_(*db),
+ : db_(db),
query_(""),
statement_(-1),
bindings_(NULL),
@@ -105,11 +105,13 @@ SQLQuery::SQLQuery(SQLDatabase* db)
SQLQuery::~SQLQuery() {
Finalize();
+ db_->Close();
+ delete db_;
}
bool SQLQuery::Prepare(const std::string& query) {
query_ = query;
- statement_ = qdb_stmt_init(db_.conn(), query.c_str(), query.length() + 1);
+ statement_ = qdb_stmt_init(db_->conn(), query.c_str(), query.length() + 1);
if (statement_ == -1) {
error_ = Error::ERROR;
return false;
@@ -135,7 +137,7 @@ int SQLQuery::SetBinds() {
}
bool SQLQuery::Result() {
- result_ = qdb_getresult(db_.conn());
+ result_ = qdb_getresult(db_->conn());
if (!result_) {
error_ = Error::ERROR;
return false;
@@ -156,7 +158,7 @@ bool SQLQuery::Exec() {
current_row_ = 0;
int binding_count = SetBinds();
- if (qdb_stmt_exec(db_.conn(), statement_, bindings_, binding_count) == -1) {
+ if (qdb_stmt_exec(db_->conn(), statement_, bindings_, binding_count) == -1) {
error_ = Error::ERROR;
return false;
}
@@ -187,7 +189,7 @@ bool SQLQuery::Reset() {
}
void SQLQuery::Finalize() {
- if (Reset() && qdb_stmt_free(db_.conn(), statement_) != -1) {
+ if (Reset() && qdb_stmt_free(db_->conn(), statement_) != -1) {
statement_ = 0;
} else {
error_ = Error::ERROR;
@@ -196,7 +198,7 @@ void SQLQuery::Finalize() {
bool SQLQuery::Exec(const std::string& query) {
query_ = query;
- if (qdb_statement(db_.conn(), query.c_str()) == -1) {
+ if (qdb_statement(db_->conn(), query.c_str()) == -1) {
error_ = Error::ERROR;
return false;
}
@@ -254,11 +256,11 @@ const std::string& SQLQuery::query() const {
}
SQLError SQLQuery::LastError() const {
- return SQLError(error_, qdb_geterrmsg(db_.conn()));
+ return SQLError(error_, qdb_geterrmsg(db_->conn()));
}
int64_t SQLQuery::LastInsertId() const {
- return qdb_last_insert_rowid(db_.conn(), result_);
+ return qdb_last_insert_rowid(db_->conn(), result_);
}
} // namespace dbms
diff --git a/src/components/policy/src/policy/sqlite_wrapper/include/sqlite_wrapper/sql_database.h b/src/components/policy/src/policy/sqlite_wrapper/include/sqlite_wrapper/sql_database.h
index 0e799c205..bd4f22db9 100644
--- a/src/components/policy/src/policy/sqlite_wrapper/include/sqlite_wrapper/sql_database.h
+++ b/src/components/policy/src/policy/sqlite_wrapper/include/sqlite_wrapper/sql_database.h
@@ -88,6 +88,12 @@ class SQLDatabase {
*/
SQLError LastError() const;
+ /**
+ * Sets path to database
+ * If the database is already opened then need reopen it
+ */
+ void set_path(const std::string& path);
+
protected:
/**
* Gets connection to the SQLite database
diff --git a/src/components/policy/src/policy/sqlite_wrapper/src/sql_database.cc b/src/components/policy/src/policy/sqlite_wrapper/src/sql_database.cc
index d7a4b10bb..95a1aaa6f 100644
--- a/src/components/policy/src/policy/sqlite_wrapper/src/sql_database.cc
+++ b/src/components/policy/src/policy/sqlite_wrapper/src/sql_database.cc
@@ -94,5 +94,9 @@ sqlite3* SQLDatabase::conn() const {
return conn_;
}
+void SQLDatabase::set_path(const std::string& path) {
+ databasename_ = path + databasename_;
+}
+
} // namespace dbms
} // namespace policy
diff --git a/src/components/policy/src/policy/src/policy_helper.cc b/src/components/policy/src/policy/src/policy_helper.cc
index c41045f1a..09362e6a7 100644
--- a/src/components/policy/src/policy/src/policy_helper.cc
+++ b/src/components/policy/src/policy/src/policy_helper.cc
@@ -31,12 +31,18 @@
*/
#include <algorithm>
+#include <sstream>
+#include <string.h>
+#include "utils/logger.h"
#include "policy/policy_helper.h"
#include "policy/policy_manager_impl.h"
namespace policy {
namespace {
+
+CREATE_LOGGERPTR_GLOBAL(logger_, "PolicyManagerImpl")
+
bool Match(const StringsValueType& first_name,
const StringsValueType& second_name) {
const std::string& first = first_name;
@@ -49,6 +55,7 @@ bool Compare(const StringsValueType& first, const StringsValueType& second) {
const std::string& second_str = second;
return (strcasecmp(first_str.c_str(), second_str.c_str()) < 0);
}
+
}
CompareGroupName::CompareGroupName(const StringsValueType& group_name)
@@ -171,7 +178,7 @@ void CheckAppPolicy::SendNotification(
// Get current device_id from application id
const std::string device_id = pm_->GetCurrentDeviceId(app_policy.first);
if (device_id.empty()) {
- LOG4CXX_WARN(pm_->logger_, "Couldn't find device info for application id "
+ LOG4CXX_WARN(logger_, "Couldn't find device info for application id "
"'" << app_policy.first << "'");
return;
}
@@ -182,8 +189,15 @@ void CheckAppPolicy::SendNotification(
group_permissons, notification_data);
const std::string app_id = app_policy.first;
- LOG4CXX_INFO(pm_->logger_, "Send notification for application_id:" << app_id);
- pm_->listener()->OnPermissionsUpdated(app_id, notification_data);
+ LOG4CXX_INFO(logger_, "Send notification for application_id:" << app_id);
+#if defined (EXTENDED_POLICY)
+ pm_->listener()->OnPermissionsUpdated(app_id, notification_data,
+ policy_table::EnumToJsonString(app_policy.second.default_hmi));
+#else
+ // Default_hmi is Ford-specific and should not be used with basic policy
+ const std::string default_hmi;
+ pm_->listener()->OnPermissionsUpdated(app_id, notification_data, default_hmi);
+#endif
}
void CheckAppPolicy::SendOnPendingPermissions(
@@ -192,7 +206,8 @@ void CheckAppPolicy::SendOnPendingPermissions(
if (permissions.appPermissionsConsentNeeded) {
#if defined(EXTENDED_POLICY)
const policy_table::Strings& groups = app_policy.second.groups;
- const policy_table::Strings& preconsented_groups = app_policy.second
+ // TODO(IKozyrenko): Check logic if optional container is missing
+ const policy_table::Strings& preconsented_groups = *app_policy.second
.preconsented_groups;
// TODO(KKolodiy): Use consent_groups to filtrate groups
@@ -223,6 +238,22 @@ bool CheckAppPolicy::IsAppRevoked(
return app_policy.second.is_null();
}
+bool CheckAppPolicy::NicknamesMatch(const std::string app_id,
+ const AppPoliciesValueType& app_policy) const {
+ std::string app_name = pm_->listener()->GetAppName(app_id);
+ if (!app_name.empty() && app_policy.second.nicknames && !app_policy.second.nicknames->empty()) {
+ for (policy_table::Strings::const_iterator it = app_policy.second.nicknames->begin();
+ app_policy.second.nicknames->end() != it; ++it) {
+ std::string temp = *it;
+ if (temp.compare(app_name) == 0) {
+ return true;
+ }
+ }
+ return false;
+ }
+ return true;
+}
+
bool CheckAppPolicy::operator()(const AppPoliciesValueType& app_policy) {
policy_table::ApplicationPolicies& current_policies = pm_
->policy_table_snapshot_->policy_table.app_policies;
@@ -243,7 +274,10 @@ bool CheckAppPolicy::operator()(const AppPoliciesValueType& app_policy) {
policy_table::ApplicationPolicies::iterator it = current_policies.find(
app_id);
// Update snapshot with new policies for application
- (*it).second = app_policy.second;
+ if (it != current_policies.end()) {
+ (*it).second = app_policy.second;
+ it->second.set_to_null();
+ }
return true;
}
@@ -256,9 +290,23 @@ bool CheckAppPolicy::operator()(const AppPoliciesValueType& app_policy) {
return true;
}
+ if (!NicknamesMatch(app_id, app_policy)) {
+ permissions_diff.appUnauthorized = true;
+ pm_->app_permissions_diff_.insert(std::make_pair(app_id, permissions_diff));
+ pm_->listener()->OnPendingPermissionChange(app_policy.first);
+ policy_table::ApplicationPolicies::iterator it = current_policies.find(
+ app_id);
+ // Update snapshot with new policies for application
+ if (it != current_policies.end()) {
+ (*it).second = app_policy.second;
+ it->second.set_to_null();
+ }
+ return true;
+ }
+
if (HasSameGroups(app_policy, &permissions_diff)) {
LOG4CXX_INFO(
- pm_->logger_,
+ logger_,
"Permissions for application:" << app_id << " wasn't changed.");
return true;
}
@@ -269,7 +317,7 @@ bool CheckAppPolicy::operator()(const AppPoliciesValueType& app_policy) {
(*it).second = app_policy.second;
// Don't sent notification for "default"
- if ("default" != app_id && "device" != app_id) {
+ if (kDefaultId != app_id && kDeviceId != app_id) {
SendNotification(app_policy);
SendOnPendingPermissions(app_policy, permissions_diff);
}
@@ -280,18 +328,15 @@ bool CheckAppPolicy::operator()(const AppPoliciesValueType& app_policy) {
}
FillNotificationData::FillNotificationData(Permissions& data,
- PermissionState group_state)
- : data_(data),
- allowed_key_("allowed"),
- disallowed_key_("userDisallowed") {
+ GroupConsent group_state)
+ : data_(data) {
switch (group_state) {
- case kAllowed:
- case kUndefined:
- current_key_ = allowed_key_;
- break;
- default:
- current_key_ = disallowed_key_;
- break;
+ case kGroupAllowed:
+ current_key_ = kAllowedKey;
+ break;
+ default:
+ current_key_ = kUserDisallowedKey;
+ break;
}
}
@@ -301,14 +346,16 @@ bool FillNotificationData::operator()(const RpcValueType& rpc) {
if (data_.end() != it) {
UpdateHMILevels(rpc.second.hmi_levels,
(*it).second.hmi_permissions[current_key_]);
- UpdateParameters(rpc.second.parameters,
+ // TODO(IKozyrenko): Check logic if optional container is missing
+ UpdateParameters(*rpc.second.parameters,
(*it).second.parameter_permissions[current_key_]);
ExcludeDisAllowed();
} else {
// If rpc is not present - add its permissions
UpdateHMILevels(rpc.second.hmi_levels,
data_[rpc.first].hmi_permissions[current_key_]);
- UpdateParameters(rpc.second.parameters,
+ // TODO(IKozyrenko): Check logic if optional container is missing
+ UpdateParameters(*rpc.second.parameters,
data_[rpc.first].parameter_permissions[current_key_]);
ExcludeDisAllowed();
}
@@ -343,9 +390,9 @@ void FillNotificationData::ExcludeDisAllowed() {
Permissions::const_iterator it_end = data_.end();
// Groups
for (; it != it_end; ++it) {
- std::set<HMILevel>& allowed_hmi_level = (*it).second.hmi_permissions[allowed_key_];
+ std::set<HMILevel>& allowed_hmi_level = (*it).second.hmi_permissions[kAllowedKey];
std::set<HMILevel>& disallowed_hmi_level =
- (*it).second.hmi_permissions[disallowed_key_];
+ (*it).second.hmi_permissions[kUserDisallowedKey];
std::set<HMILevel> diff_hmi;
std::set_difference(allowed_hmi_level.begin(), allowed_hmi_level.end(),
@@ -355,9 +402,9 @@ void FillNotificationData::ExcludeDisAllowed() {
allowed_hmi_level = diff_hmi;
std::set<Parameter>& allowed_parameters =
- (*it).second.parameter_permissions[allowed_key_];
+ (*it).second.parameter_permissions[kAllowedKey];
std::set<Parameter>& disallowed_parameters =
- (*it).second.parameter_permissions[disallowed_key_];
+ (*it).second.parameter_permissions[kUserDisallowedKey];
std::set<Parameter> diff_params;
@@ -371,9 +418,9 @@ void FillNotificationData::ExcludeDisAllowed() {
}
ProcessFunctionalGroup::ProcessFunctionalGroup(
- const policy_table::FunctionalGroupings& fg,
- const std::vector<FunctionalGroupPermission>& group_permissions,
- Permissions& data)
+ const policy_table::FunctionalGroupings& fg,
+ const std::vector<FunctionalGroupPermission>& group_permissions,
+ Permissions& data)
: fg_(fg),
group_permissions_(group_permissions),
data_(data) {
@@ -391,18 +438,18 @@ bool ProcessFunctionalGroup::operator()(const StringsValueType& group_name) {
return true;
}
-PermissionState ProcessFunctionalGroup::GetGroupState(
- const std::string& group_name) {
+GroupConsent ProcessFunctionalGroup::GetGroupState(
+ const std::string& group_name) {
std::vector<FunctionalGroupPermission>::const_iterator it =
- group_permissions_.begin();
+ group_permissions_.begin();
std::vector<FunctionalGroupPermission>::const_iterator it_end =
- group_permissions_.end();
+ group_permissions_.end();
for (; it != it_end; ++it) {
if (group_name == (*it).group_name) {
return (*it).state;
}
}
- return kUndefined;
+ return kGroupUndefined;
}
FunctionalGroupInserter::FunctionalGroupInserter(
@@ -419,4 +466,20 @@ void FunctionalGroupInserter::operator()(const StringsValueType& group_name) {
}
}
+void FillFunctionalGroupPermissions(FunctionalGroupIDs& ids,
+ FunctionalGroupNames& names,
+ GroupConsent state,
+ std::vector<FunctionalGroupPermission>& permissions) {
+ FunctionalGroupIDs::const_iterator it = ids.begin();
+ FunctionalGroupIDs::const_iterator it_end = ids.end();
+ for (; it != it_end; ++it) {
+ FunctionalGroupPermission current_group;
+ current_group.group_id = *it;
+ current_group.group_alias = names[*it].first;
+ current_group.group_name = names[*it].second;
+ current_group.state = state;
+ permissions.push_back(current_group);
+ }
+}
+
}
diff --git a/src/components/policy/src/policy/src/policy_manager_impl.cc b/src/components/policy/src/policy/src/policy_manager_impl.cc
index bd08694f2..74e9c0e55 100644
--- a/src/components/policy/src/policy/src/policy_manager_impl.cc
+++ b/src/components/policy/src/policy/src/policy_manager_impl.cc
@@ -39,14 +39,31 @@
#include "policy/policy_manager_impl.h"
#include "policy/policy_helper.h"
#include "utils/file_system.h"
+#include "utils/logger.h"
policy::PolicyManager* CreateManager() {
return new policy::PolicyManagerImpl();
}
+namespace {
+void CheckPreloadedGroups(policy_table::ApplicationParams& app_param) {
+
+}
+}
+
namespace policy {
-log4cxx::LoggerPtr PolicyManagerImpl::logger_ = log4cxx::LoggerPtr(
- log4cxx::Logger::getLogger("PolicyManagerImpl"));
+
+CREATE_LOGGERPTR_GLOBAL(logger_, "PolicyManagerImpl")
+
+#if defined(__QNXNTO__) and defined(GCOV_ENABLED)
+bool CheckGcov() {
+ LOG4CXX_ERROR(log4cxx::Logger::getLogger("appMain"),
+ "Attention! This application was built with unsupported "
+ "configuration (gcov + QNX). Use it at your own risk.");
+ return true;
+}
+bool check_gcov = CheckGcov();
+#endif
PolicyManagerImpl::PolicyManagerImpl()
: PolicyManager(),
@@ -134,11 +151,15 @@ utils::SharedPtr<policy_table::Table> PolicyManagerImpl::Parse(
std::string json(pt_content.begin(), pt_content.end());
Json::Value value;
Json::Reader reader;
- reader.parse(json.c_str(), value);
- return new policy_table::Table(&value);
+ if (reader.parse(json.c_str(), value)) {
+ return new policy_table::Table(&value);
+ } else {
+ return 0;
+ }
}
-bool PolicyManagerImpl::LoadPT(const BinaryMessage& pt_content) {
+bool PolicyManagerImpl::LoadPT(const std::string& file,
+ const BinaryMessage& pt_content) {
LOG4CXX_INFO(logger_, "LoadPTFromString of size " << pt_content.size());
// Parse message into table struct
@@ -149,13 +170,18 @@ bool PolicyManagerImpl::LoadPT(const BinaryMessage& pt_content) {
return false;
}
+#if defined (EXTENDED_POLICY)
+ file_system::DeleteFile(file);
+#endif
+
set_exchange_in_progress(false);
- // Temporary disabled until correct json will be prepared
- // if (!table->is_valid()) {
- // LOG4CXX_WARN(logger_, "Parsed table is not valid.");
- // return false;
- // }
+ if (!pt_update->is_valid()) {
+ rpc::ValidationReport report("policy_table");
+ pt_update->ReportErrors(&report);
+ LOG4CXX_WARN(logger_, "Parsed table is not valid " << rpc::PrettyFormat(report));
+ return false;
+ }
// Check and update permissions for applications, send notifications
CheckPermissionsChanges(pt_update);
@@ -311,9 +337,28 @@ BinaryMessageSptr PolicyManagerImpl::RequestPTUpdate() {
set_exchange_pending(false);
Json::Value value = policy_table_snapshot_->ToJsonValue();
+
+ policy_table::ApplicationPolicies& apps = policy_table_snapshot_->policy_table.app_policies;
+ std::map<std::string,
+ rpc::Nullable<rpc::policy_table_interface_base::ApplicationParams>>::iterator it = apps.begin();
+ for (; apps.end() != it; ++it) {
+ if (policy_table_.pt_data()->IsDefaultPolicy(it->first)) {
+ printf("\n\t\t\t\tDefault policy of %s\n", it->first.c_str());
+ value["policy_table"]["app_policies"][it->first] = kDefaultId;
+ continue;
+ }
+ if (policy_table_.pt_data()->IsPredataPolicy(it->first)) {
+ printf("\n\t\t\t\tPredata policy of %s\n", it->first.c_str());
+ value["policy_table"]["app_policies"][it->first] = kPreDataConsentId;
+ continue;
+ }
+ Json::Value app_value = it->second.ToJsonValue();
+ value["policy_table"]["app_policies"][it->first] = app_value;
+ }
+
Json::FastWriter writer;
std::string message_string = writer.write(value);
- LOG4CXX_INFO(logger_, "PT Snapshot " << message_string);
+ LOG4CXX_INFO(logger_, "\n\n\n\nPT Snapshot " << message_string << "\n\n\n");
return new BinaryMessage(message_string.begin(), message_string.end());
}
@@ -324,13 +369,8 @@ CheckPermissionResult PolicyManagerImpl::CheckPermissions(
"CheckPermissions for " << app_id << " and rpc " << rpc << " for "
<< hmi_level << " level.");
- const std::string device_id = GetCurrentDeviceId(app_id);
- if (kDeviceHasNoConsent == GetUserConsentForDevice(device_id)) {
- return policy_table_.pt_data()->CheckPermissions("pre_DataConsent",
- hmi_level, rpc);
- }
-
#if defined (EXTENDED_POLICY)
+ const std::string device_id = GetCurrentDeviceId(app_id);
// Get actual application group permission according to user consents
std::vector<FunctionalGroupPermission> app_group_permissions;
GetUserPermissionsForApp(device_id, app_id, app_group_permissions);
@@ -353,22 +393,32 @@ CheckPermissionResult PolicyManagerImpl::CheckPermissions(
app_group_permissions, rpc_permissions);
CheckPermissionResult result;
+ // If RPC is present in list, but not found in allowed and userDisallowed ==
+ // disallowed both by backend and by user, which is default value for result
if (rpc_permissions.end() == rpc_permissions.find(rpc)) {
+ // RPC not found in list == disallowed by backend
return result;
}
+ // Check HMI level
+ if (rpc_permissions[rpc].hmi_permissions[kAllowedKey].end() !=
+ rpc_permissions[rpc].hmi_permissions[kAllowedKey].find(hmi_level)) {
+ // RPC found in allowed == allowed by backend and user
+ result.hmi_level_permitted = kRpcAllowed;
+ }
+
+ if (rpc_permissions[rpc].hmi_permissions[kUserDisallowedKey].end() !=
+ rpc_permissions[rpc].hmi_permissions[kUserDisallowedKey].find(hmi_level)) {
+ // RPC found in allowed == allowed by backend, but disallowed by user
+ result.hmi_level_permitted = kRpcUserDisallowed;
+ }
+
// Add parameters of RPC, if any
result.list_of_allowed_params = new std::vector<PTString>();
- std::copy(rpc_permissions[rpc].parameter_permissions["allowed"].begin(),
- rpc_permissions[rpc].parameter_permissions["allowed"].end(),
+ std::copy(rpc_permissions[rpc].parameter_permissions[kAllowedKey].begin(),
+ rpc_permissions[rpc].parameter_permissions[kAllowedKey].end(),
result.list_of_allowed_params->begin());
- // Check HMI level
- if (rpc_permissions[rpc].hmi_permissions["allowed"].end() !=
- rpc_permissions[rpc].hmi_permissions["allowed"].find(hmi_level)) {
- result.hmi_level_permitted = true;
- }
-
return result;
#else
return policy_table_.pt_data()->CheckPermissions(app_id, hmi_level, rpc);
@@ -391,14 +441,33 @@ bool PolicyManagerImpl::ResetUserConsent() {
void PolicyManagerImpl::CheckAppPolicyState(const std::string& application_id) {
LOG4CXX_INFO(logger_, "CheckAppPolicyState");
+ const std::string device_id = GetCurrentDeviceId(application_id);
+ DeviceConsent device_consent = GetUserConsentForDevice(device_id);
if (!policy_table_.pt_data()->IsApplicationRepresented(application_id)) {
LOG4CXX_INFO(
logger_,
"Setting default permissions for application id: " << application_id);
+#if defined (EXTENDED_POLICY)
+ if (kDeviceHasNoConsent == device_consent ||
+ kDeviceDisallowed == device_consent) {
+ PTExtRepresentation* pt_ext = dynamic_cast<PTExtRepresentation*>(policy_table_
+ .pt_data().get());
+ if (!pt_ext) {
+ LOG4CXX_WARN(logger_, "Can't cleanup unpaired devices.");
+ return;
+ }
+ pt_ext->SetPredataPolicy(application_id);
+ } else {
+ policy_table_.pt_data()->SetDefaultPolicy(application_id);
+ }
+#else
policy_table_.pt_data()->SetDefaultPolicy(application_id);
+#endif
SendNotificationOnPermissionsUpdated(application_id);
} else {
- if (!policy_table_.pt_data()->IsDefaultPolicy(application_id)) {
+ if (!policy_table_.pt_data()->IsDefaultPolicy(application_id)
+ || (kDeviceHasNoConsent != device_consent
+ && policy_table_.pt_data()->IsPredataPolicy(application_id))) {
return;
}
}
@@ -412,7 +481,8 @@ void PolicyManagerImpl::CheckAppPolicyState(const std::string& application_id) {
}
}
-void PolicyManagerImpl::SendNotificationOnPermissionsUpdated(const std::string& application_id) {
+void PolicyManagerImpl::SendNotificationOnPermissionsUpdated(
+ const std::string& application_id) {
const std::string device_id = GetCurrentDeviceId(application_id);
if (device_id.empty()) {
LOG4CXX_WARN(logger_, "Couldn't find device info for application id "
@@ -440,7 +510,33 @@ void PolicyManagerImpl::SendNotificationOnPermissionsUpdated(const std::string&
notification_data);
LOG4CXX_INFO(logger_, "Send notification for application_id:" << application_id);
- listener()->OnPermissionsUpdated(application_id, notification_data);
+ std::string default_hmi;
+ PTExtRepresentation* pt_ext = dynamic_cast<PTExtRepresentation*>(policy_table_
+ .pt_data().get());
+ if (!pt_ext) {
+ LOG4CXX_WARN(logger_, "Can't get default hmi level for " << application_id);
+ return;
+ }
+
+ pt_ext->GetDefaultHMI(application_id, &default_hmi);
+ listener()->OnPermissionsUpdated(application_id, notification_data,
+ default_hmi);
+}
+
+bool PolicyManagerImpl::CleanupUnpairedDevices(const DeviceIds& device_ids) {
+ LOG4CXX_INFO(logger_, "CleanupUnpairedDevices");
+#if defined (EXTENDED_POLICY)
+ PTExtRepresentation* pt_ext = dynamic_cast<PTExtRepresentation*>(policy_table_
+ .pt_data().get());
+ if (!pt_ext) {
+ LOG4CXX_WARN(logger_, "Can't cleanup unpaired devices.");
+ return false;
+ }
+
+ return pt_ext->CleanupUnpairedDevices(device_ids);
+#else
+ return policy_table_.pt_data()->CleanupUnpairedDevices(device_ids);
+#endif
}
PolicyTableStatus PolicyManagerImpl::GetPolicyTableStatus() {
@@ -485,7 +581,6 @@ DeviceConsent PolicyManagerImpl::GetUserConsentForDevice(
if (!list_of_permissions.empty()) {
StringArray consented_groups;
StringArray disallowed_groups;
- // TODO(AOleynik): Change id to appropriate value (MAC with SHA-256)
if (!pt_ext->GetUserPermissionsForDevice(device_id, &consented_groups,
&disallowed_groups)) {
return kDeviceDisallowed;
@@ -504,8 +599,7 @@ DeviceConsent PolicyManagerImpl::GetUserConsentForDevice(
list_of_permissions.end(),
consented_groups.begin(),
consented_groups.end(),
- std::inserter(to_be_consented_by_user,
- to_be_consented_by_user.begin()));
+ std::back_inserter(to_be_consented_by_user));
if (to_be_consented_by_user.empty()) {
return kDeviceAllowed;
}
@@ -559,7 +653,6 @@ void PolicyManagerImpl::SetUserConsentForDevice(const std::string& device_id,
disallowed_groups.push_back(list_of_permissions[0]);
}
- // TODO(AOleynik): Change id to appropriate value (MAC with SHA-256)
if (!pt_ext->SetUserPermissionsForDevice(device_id, consented_groups,
disallowed_groups)) {
LOG4CXX_WARN(logger_, "Can't set user consent for device");
@@ -568,6 +661,21 @@ void PolicyManagerImpl::SetUserConsentForDevice(const std::string& device_id,
#endif
}
+bool PolicyManagerImpl::ReactOnUserDevConsentForApp(const std::string app_id,
+ bool is_device_allowed) {
+#if defined (EXTENDED_POLICY)
+ // TODO(AOleynik): Check design for more convenient access to policy ext data
+ PTExtRepresentation* pt_ext = dynamic_cast<PTExtRepresentation*>(policy_table_
+ .pt_data().get());
+ if (!pt_ext) {
+ LOG4CXX_WARN(logger_, "Can't set user consent for device");
+ return false;
+ }
+ return pt_ext->ReactOnUserDevConsentForApp(app_id, is_device_allowed);
+#endif
+ return true;
+}
+
bool PolicyManagerImpl::GetInitialAppData(const std::string& application_id,
StringArray* nicknames,
StringArray* app_hmi_types) {
@@ -584,7 +692,6 @@ void PolicyManagerImpl::SetDeviceInfo(const std::string& device_id,
PTExtRepresentation* pt_ext = dynamic_cast<PTExtRepresentation*>(policy_table_
.pt_data().get());
if (pt_ext) {
- // TODO(AOleynik): Change id to appropriate value (MAC with SHA-256)
if (!pt_ext->SetDeviceData(device_id, device_info.hardware,
device_info.firmware_rev, device_info.os,
device_info.os_ver, device_info.carrier,
@@ -632,8 +739,12 @@ void PolicyManagerImpl::SetUserConsentForApp(
PrepareNotificationData(functional_groups, app_groups,
app_group_permissons, notification_data);
+ std::string default_hmi;
+ pt_ext->GetDefaultHMI(permissions.policy_app_id, &default_hmi);
+
listener()->OnPermissionsUpdated(permissions.policy_app_id,
- notification_data);
+ notification_data,
+ default_hmi);
}
#endif
}
@@ -689,12 +800,9 @@ std::vector<UserFriendlyMessage> PolicyManagerImpl::GetUserFriendlyMessages(
if (pt_ext) {
return pt_ext->GetUserFriendlyMsg(message_code, language);
}
-
+#endif
// For basic policy
return policy_table_.pt_data()->GetUserFriendlyMsg(message_code, language);
-#else
- return std::vector<UserFriendlyMessage>(message_code.size());
-#endif
}
void PolicyManagerImpl::GetUserPermissionsForApp(
@@ -702,12 +810,110 @@ void PolicyManagerImpl::GetUserPermissionsForApp(
std::vector<FunctionalGroupPermission>& permissions) {
LOG4CXX_INFO(logger_, "GetUserPermissionsForApp");
#if defined (EXTENDED_POLICY)
+ std::string app_id_to_check = policy_app_id;
+
+ DeviceConsent device_consent = GetUserConsentForDevice(device_id);
+ // Application is limited to pre_DataConsent permission until device is
+ // allowed by user
+ if (kDeviceHasNoConsent == device_consent ||
+ kDeviceDisallowed == device_consent) {
+ app_id_to_check = kPreDataConsentId;
+ }
+
// TODO(AOleynik): Check design for more convenient access to policy ext data
PTExtRepresentation* pt_ext = dynamic_cast<PTExtRepresentation*>(policy_table_
.pt_data().get());
// For extended policy
if (pt_ext) {
- pt_ext->GetUserPermissionsForApp(device_id, policy_app_id, permissions);
+ FunctionalIdType group_types;
+ if (!pt_ext->GetUserPermissionsForApp(device_id, app_id_to_check,
+ &group_types)) {
+ LOG4CXX_WARN(logger_, "Can't get user permissions for app "
+ << policy_app_id);
+ return;
+ }
+
+ FunctionalGroupIDs all_groups = group_types[kTypeGeneral];
+ // If application is limited to pre_Dataconsent only related groups are
+ // allowed
+ FunctionalGroupIDs allowed_groups =
+ app_id_to_check == kPreDataConsentId ?
+ group_types[kTypeGeneral] :
+ group_types[kTypeAllowed];
+ FunctionalGroupIDs disallowed_groups = group_types[kTypeDisallowed];
+ FunctionalGroupIDs preconsented_groups = group_types[kTypePreconsented];
+ // If application is limited to pre_DataConsent - no default groups
+ // permissions should be used
+ FunctionalGroupIDs default_groups =
+ app_id_to_check == kPreDataConsentId ?
+ FunctionalGroupIDs() : group_types[kTypeDefault];
+
+ std::sort(all_groups.begin(), all_groups.end());
+ std::sort(allowed_groups.begin(), allowed_groups.end());
+ std::sort(disallowed_groups.begin(), disallowed_groups.end());
+ std::sort(preconsented_groups.begin(), preconsented_groups.end());
+ std::sort(default_groups.begin(), default_groups.end());
+
+ // Find groups with undefinded consent
+ FunctionalGroupIDs no_preconsented;
+ std::set_difference(all_groups.begin(), all_groups.end(),
+ preconsented_groups.begin(), preconsented_groups.end(),
+ std::back_inserter(no_preconsented));
+ FunctionalGroupIDs no_allowed_preconsented;
+ std::set_difference(no_preconsented.begin(), no_preconsented.end(),
+ allowed_groups.begin(), allowed_groups.end(),
+ std::back_inserter(no_allowed_preconsented));
+ FunctionalGroupIDs no_allowed_preconsented_default;
+ std::set_difference(no_allowed_preconsented.begin(),
+ no_allowed_preconsented.end(),
+ default_groups.begin(), default_groups.end(),
+ std::back_inserter(no_allowed_preconsented_default));
+ FunctionalGroupIDs undefined_consent;
+ std::set_difference(no_allowed_preconsented_default.begin(),
+ no_allowed_preconsented_default.end(),
+ disallowed_groups.begin(), disallowed_groups.end(),
+ std::back_inserter(undefined_consent));
+
+ // Find common allowed groups
+ FunctionalGroupIDs preconsented_allowed;
+ std::merge(allowed_groups.begin(), allowed_groups.end(),
+ preconsented_groups.begin(), preconsented_groups.end(),
+ std::back_inserter(preconsented_allowed));
+ FunctionalGroupIDs merged_allowed_preconsented(preconsented_allowed.begin(),
+ std::unique(preconsented_allowed.begin(),
+ preconsented_allowed.end()));
+ // Default groups are always allowed
+ FunctionalGroupIDs merged_allowed_preconsented_default;
+ std::merge(merged_allowed_preconsented.begin(),
+ merged_allowed_preconsented.end(),
+ default_groups.begin(), default_groups.end(),
+ std::back_inserter(merged_allowed_preconsented_default));
+ FunctionalGroupIDs common_allowed(
+ merged_allowed_preconsented_default.begin(),
+ std::unique(merged_allowed_preconsented_default.begin(),
+ merged_allowed_preconsented_default.end()));
+
+
+ // Find common disallowed groups
+ FunctionalGroupIDs common_disallowed;
+ std::set_difference(disallowed_groups.begin(), disallowed_groups.end(),
+ preconsented_groups.begin(), preconsented_groups.end(),
+ std::back_inserter(common_disallowed));
+
+ FunctionalGroupNames group_names;
+ if (!pt_ext->GetFunctionalGroupNames(group_names)) {
+ LOG4CXX_WARN(logger_, "Can't get functional group names");
+ return;
+ }
+
+ // Fill result
+ FillFunctionalGroupPermissions(undefined_consent, group_names,
+ kGroupUndefined, permissions);
+ FillFunctionalGroupPermissions(common_allowed, group_names,
+ kGroupAllowed, permissions);
+ FillFunctionalGroupPermissions(common_disallowed, group_names,
+ kGroupDisallowed, permissions);
+
return;
}
#else
@@ -716,15 +922,11 @@ void PolicyManagerImpl::GetUserPermissionsForApp(
#endif
}
-void PolicyManagerImpl::UpdateCurrentDeviceId(const std::string& device_id) {
- LOG4CXX_INFO(logger_, "UpdateDeviceInfo");
- last_device_id_ = device_id;
-}
-
std::string& PolicyManagerImpl::GetCurrentDeviceId(
const std::string& policy_app_id) {
LOG4CXX_INFO(logger_, "GetDeviceInfo");
- listener()->OnCurrentDeviceIdUpdateRequired(policy_app_id);
+ last_device_id_ =
+ listener()->OnCurrentDeviceIdUpdateRequired(policy_app_id);
return last_device_id_;
}
@@ -866,7 +1068,7 @@ void PolicyManagerImpl::Increment(const std::string& app_id,
counter = "count_of_ejected_rpc_calls";
break;
case usage_statistics::RPCS_IN_HMI_NONE:
- counter = "count_of_rpcs_in_hmi_none";
+ counter = "count_of_rpcs_sent_in_hmi_none";
break;
case usage_statistics::REMOVALS_MISBEHAVED:
counter = "count_of_removals_misbehaved";
@@ -990,5 +1192,33 @@ void PolicyManagerImpl::RemovePendingPermissionChanges(
app_permissions_diff_.erase(app_id);
}
+bool PolicyManagerImpl::CanAppKeepContext(const std::string& app_id) {
+#if defined (EXTENDED_POLICY)
+ // TODO(AOleynik): Check design for more convenient access to policy ext data
+ PTExtRepresentation* pt_ext = dynamic_cast<PTExtRepresentation*>(policy_table_
+ .pt_data().get());
+ if (pt_ext) {
+ return pt_ext->CanAppKeepContext(app_id);
+ }
+ return false;
+#else
+ return false;
+#endif
+}
+
+bool PolicyManagerImpl::CanAppStealFocus(const std::string& app_id) {
+#if defined (EXTENDED_POLICY)
+ // TODO(AOleynik): Check design for more convenient access to policy ext data
+ PTExtRepresentation* pt_ext = dynamic_cast<PTExtRepresentation*>(policy_table_
+ .pt_data().get());
+ if (pt_ext) {
+ return pt_ext->CanAppStealFocus(app_id);
+ }
+ return false;
+#else
+ return false;
+#endif
+}
+
} // namespace policy
diff --git a/src/components/policy/src/policy/src/policy_table.cc b/src/components/policy/src/policy/src/policy_table.cc
index 74ac7ebb1..7c37a049d 100644
--- a/src/components/policy/src/policy/src/policy_table.cc
+++ b/src/components/policy/src/policy/src/policy_table.cc
@@ -37,10 +37,11 @@
# include "policy/sql_pt_representation.h"
#endif // EXTENDED_POLICY
+#include "utils/logger.h"
+
namespace policy {
-log4cxx::LoggerPtr PolicyTable::logger_ = log4cxx::LoggerPtr(
- log4cxx::Logger::getLogger("PolicyTable"));
+CREATE_LOGGERPTR_GLOBAL(logger_, "PolicyTable")
PolicyTable::PolicyTable()
: pt_data_(
diff --git a/src/components/policy/src/policy/src/sql_pt_ext_queries.cc b/src/components/policy/src/policy/src/sql_pt_ext_queries.cc
index 49955af0d..328260fb5 100644
--- a/src/components/policy/src/policy/src/sql_pt_ext_queries.cc
+++ b/src/components/policy/src/policy/src/sql_pt_ext_queries.cc
@@ -36,16 +36,16 @@ namespace policy {
namespace sql_pt_ext {
const std::string kSelectKeepContext =
- "SELECT `keep_context` FROM `application` WHERE `id` = ? LIMIT 1";
+ "SELECT `keep_context` FROM `application` WHERE `id` = ? LIMIT 1";
const std::string kSelectStealFocus =
- "SELECT `steal_focus` FROM `application` WHERE `id` = ? LIMIT 1";
+ "SELECT `steal_focus` FROM `application` WHERE `id` = ? LIMIT 1";
const std::string kSelectDefaultHmi =
- "SELECT `default_hmi` FROM `application` WHERE `id` = ? LIMIT 1";
+ "SELECT `default_hmi` FROM `application` WHERE `id` = ? LIMIT 1";
const std::string kSelectPriority =
- "SELECT `priority_value` FROM `application` WHERE `id` = ? LIMIT 1";
+ "SELECT `priority_value` FROM `application` WHERE `id` = ? LIMIT 1";
const std::string kResetUserConsent = "DELETE FROM `device_consent_group`";
@@ -53,125 +53,146 @@ const std::string kCountDeviceConsentGroup = "SELECT COUNT (`device_id`) "
"FROM `device_consent_group` WHERE `device_id` = ?";
const std::string kCountDevice = "SELECT COUNT (`id`) "
- "FROM `device` WHERE `id` = ?";
+ "FROM `device` WHERE `id` = ?";
const std::string kSelectDeviceConsentedGroup =
- "SELECT * FROM `device_consent_group` WHERE `device_id` = ?";
+ "SELECT * FROM `device_consent_group` WHERE `device_id` = ?";
const std::string kUpdateDeviceConsentedGroup =
- "UPDATE `device_consent_group` SET `is_consented` = ? WHERE "
- "(`device_id` = ? AND `functional_group_id` = ?)";
+ "UPDATE `device_consent_group` SET `is_consented` = ? WHERE "
+ "(`device_id` = ? AND `functional_group_id` = ?)";
const std::string kUpdateDevice =
- "UPDATE `device` SET `hardware` = ?, `firmware_rev` = ?, `os` = ?, "
- "`os_version` = ?, `carrier` = ?, `max_number_rfcom_ports` = ? "
- "WHERE `id` = ? ";
+ "UPDATE `device` SET `hardware` = ?, `firmware_rev` = ?, `os` = ?, "
+ "`os_version` = ?, `carrier` = ?, `max_number_rfcom_ports` = ? "
+ "WHERE `id` = ? ";
const std::string kInsertDeviceConsentedGroup =
- "INSERT OR IGNORE INTO `device_consent_group` "
- "(`device_id`, `functional_group_id`, `is_consented`, `input`) "
- "VALUES (?,?,?,?)";
+ "INSERT OR IGNORE INTO `device_consent_group` "
+ "(`device_id`, `functional_group_id`, `is_consented`, `input`) "
+ "VALUES (?,?,?,?)";
const std::string kInsertDevice =
- "INSERT OR IGNORE INTO `device` "
- "(`id`, `hardware`, `firmware_rev`, `os`, `os_version`, `carrier`, `max_number_rfcom_ports`) "
- "VALUES (?,?,?,?,?,?,?)";
+ "INSERT OR IGNORE INTO `device` "
+ "(`id`, `hardware`, `firmware_rev`, `os`, `os_version`, `carrier`, `max_number_rfcom_ports`) "
+ "VALUES (?,?,?,?,?,?,?)";
const std::string kSelectDeviceData = "SELECT * FROM `device`";
const std::string kSelectConsentGroup =
- "SELECT * FROM `consent_group` WHERE `device_id` = ? ";
+ "SELECT * FROM `consent_group` WHERE `device_id` = ? ";
const std::string kInsertPreconsentedGroups =
- "INSERT INTO `preconsented_group` (`application_id`, `functional_group_id`)"
- " SELECT ?, `id` FROM `functional_group` WHERE `name` = ? LIMIT 1";
+ "INSERT INTO `preconsented_group` (`application_id`, `functional_group_id`)"
+ " SELECT ?, `id` FROM `functional_group` WHERE `name` = ? LIMIT 1";
const std::string kSelectPreconsentedGroups =
- "SELECT `f`.`name` FROM `preconsented_group` AS `p`"
- " LEFT JOIN `functional_group` AS `f` "
- " ON (`f`.`id` = `p`.`functional_group_id`)"
- " WHERE `p`.`application_id` = ?";
+ "SELECT `f`.`name` FROM `preconsented_group` AS `p`"
+ " LEFT JOIN `functional_group` AS `f` "
+ " ON (`f`.`id` = `p`.`functional_group_id`)"
+ " WHERE `p`.`application_id` = ?";
const std::string kDeletePreconsentedGroups = "DELETE FROM `preconsented_group`";
const std::string kSelectUsageAndErrorCount =
- "SELECT `count_of_iap_buffer_full`, `count_sync_out_of_memory`, "
- " `count_of_sync_reboots` "
- "FROM `usage_and_error_count` LIMIT 1";
+ "SELECT `count_of_iap_buffer_full`, `count_sync_out_of_memory`, "
+ " `count_of_sync_reboots` "
+ "FROM `usage_and_error_count` LIMIT 1";
const std::string kSelectAppLevels =
- "SELECT `application_id`, `minutes_in_hmi_full`, `minutes_in_hmi_limited`, "
- " `minutes_in_hmi_background`, `minutes_in_hmi_none`, "
- " `count_of_rfcomm_limit_reached`, `count_of_user_selections`, "
- " `count_of_rejections_sync_out_of_memory`, "
- " `count_of_rejections_nickname_mismatch`, "
- " `count_of_rejections_duplicate_name`, "
- " `count_of_rejected_rpcs_calls`, "
- " `count_of_rpcs_sent_in_hmi_none`, "
- " `count_of_removals_for_bad_behavior`, "
- " `count_of_run_attempts_while_revoked`, "
- " `app_registration_language_gui`, "
- " `app_registration_language_vui` "
- "FROM `app_level`";
+ "SELECT `application_id`, `minutes_in_hmi_full`, `minutes_in_hmi_limited`, "
+ " `minutes_in_hmi_background`, `minutes_in_hmi_none`, "
+ " `count_of_rfcomm_limit_reached`, `count_of_user_selections`, "
+ " `count_of_rejections_sync_out_of_memory`, "
+ " `count_of_rejections_nickname_mismatch`, "
+ " `count_of_rejections_duplicate_name`, "
+ " `count_of_rejected_rpcs_calls`, "
+ " `count_of_rpcs_sent_in_hmi_none`, "
+ " `count_of_removals_for_bad_behavior`, "
+ " `count_of_run_attempts_while_revoked`, "
+ " `app_registration_language_gui`, "
+ " `app_registration_language_vui` "
+ "FROM `app_level`";
const std::string kInsertDeviceData =
- "INSERT OR IGNORE INTO `device` "
- "(`id`, `hardware`, `firmware_rev`, `os`, `os_version`, `carrier`, `max_number_rfcom_ports`) "
- "VALUES (?,?,?,?,?,?,?) ";
+ "INSERT OR IGNORE INTO `device` "
+ "(`id`, `hardware`, `firmware_rev`, `os`, `os_version`, `carrier`, `max_number_rfcom_ports`) "
+ "VALUES (?,?,?,?,?,?,?) ";
const std::string kInsertConsentGroups =
- "INSERT OR IGNORE INTO `consent_group` "
- "(`device_id`, `application_id`, `functional_group_id`, `is_consented`, `input`) "
- "VALUES (?,?,?,?,?)";
+ "INSERT OR IGNORE INTO `consent_group` "
+ "(`device_id`, `application_id`, `functional_group_id`, `is_consented`, `input`) "
+ "VALUES (?,?,?,?,?)";
const std::string kCountUnconsentedGroups =
- "SELECT COUNT(`a`.`functional_group_id`) FROM `app_group` AS `a` "
- "JOIN `consent_group` AS `f` ON (`a`.`application_id` = `f`.`application_id`) "
- "JOIN `preconsented_group` AS `p` ON (`p`.`application_id` = `a`.`application_id`) "
- "WHERE `a`.`application_id` = ? AND NOT (`f`.`functional_group_id` = `a`.`functional_group_id`) "
- "AND NOT (`p`.`functional_group_id` = `a`.`functional_group_id`)";
+ "SELECT COUNT(`a`.`functional_group_id`) FROM `app_group` AS `a` "
+ "JOIN `consent_group` AS `f` ON (`a`.`application_id` = `f`.`application_id`) "
+ "JOIN `preconsented_group` AS `p` ON (`p`.`application_id` = `a`.`application_id`) "
+ "WHERE `a`.`application_id` = ? AND NOT (`f`.`functional_group_id` = `a`.`functional_group_id`) "
+ "AND NOT (`p`.`functional_group_id` = `a`.`functional_group_id`)";
const std::string kSelectModuleMeta = "SELECT * FROM `module_meta`";
const std::string kUpdateMetaParams = "UPDATE `module_meta` SET "
- "`ccpu_version` = ?, `wers_country_code` = ?, `language` = ? ";
+ "`ccpu_version` = ?, `wers_country_code` = ?, `language` = ? ";
const std::string kUpdateMetaLanguage = "UPDATE `module_meta` SET `language` = ? ";
const std::string kCountAppLevel =
- "SELECT COUNT(`application_id`) FROM `app_level`"
- " WHERE `application_id` = ?";
+ "SELECT COUNT(`application_id`) FROM `app_level`"
+ " WHERE `application_id` = ?";
const std::string kUpdateGroupPermissions =
- "UPDATE `consent_group` "
- "SET `is_consented` = ?, `input` = ? "
- "WHERE (`application_id` = ? AND `functional_group_id` = ? AND `device_id` = ?) ";
+ "UPDATE `consent_group` "
+ "SET `is_consented` = ?, `input` = ? "
+ "WHERE (`application_id` = ? AND `functional_group_id` = ? AND `device_id` = ?) ";
const std::string kInsertApplication =
- "INSERT OR IGNORE INTO `application` (`id`, `keep_context`, `steal_focus`,"
- " `default_hmi`, `priority_value`, `is_revoked`, `memory_kb`,"
- " `watchdog_timer_ms`, `certificate`) VALUES (?,?,?,?,?,?,?,?,?) ";
+ "INSERT OR IGNORE INTO `application` (`id`, `keep_context`, `steal_focus`,"
+ " `default_hmi`, `priority_value`, `is_revoked`, `memory_kb`,"
+ " `watchdog_timer_ms`, `certificate`) VALUES (?,?,?,?,?,?,?,?,?) ";
const std::string kSelectFriendlyMsg =
- "SELECT `tts`, `label`, `line1`, `line2`, `textBody` FROM `message` "
- "WHERE `message_type_name` = ? AND `language_code` = ? LIMIT 1";
+ "SELECT `tts`, `label`, `line1`, `line2`, `textBody` FROM `message` "
+ "WHERE `message_type_name` = ? AND `language_code` = ? LIMIT 1";
const std::string kSelectAppGroupsId = "SELECT `functional_group_id` "
- "FROM `app_group` WHERE `application_id` = ? ";
+ "FROM `app_group` WHERE `application_id` = ? ";
const std::string kSelectConsentedGroupsId =
- "SELECT `functional_group_id`, `is_consented` "
- "FROM `consent_group` WHERE (`application_id` = ? AND `device_id` = ?) ";
+ "SELECT `functional_group_id`, `is_consented` "
+ "FROM `consent_group` WHERE (`application_id` = ? AND `device_id` = ?) ";
+
+const std::string kCountAppConsents = "SELECT COUNT (*) from `consent_group`"
+ "WHERE (`device_id` = ? AND `application_id` = ? AND "
+ "`functional_group_id` = ?) ";
const std::string kSelectPreconsentedGroupsId = "SELECT `functional_group_id` "
"FROM `preconsented_group` WHERE `application_id` = ? ";
const std::string kSelectAppPolicies =
- "SELECT `id`, `priority_value`, `default_hmi`, `keep_context`, `steal_focus`,"
- " `memory_kb`, `watchdog_timer_ms`, `certificate` FROM `application`";
+ "SELECT `id`, `priority_value`, `default_hmi`, `keep_context`, `steal_focus`,"
+ " `memory_kb`, `watchdog_timer_ms`, `certificate` FROM `application`";
const std::string kSelectFunctionalGroupNames = "SELECT `id`, `user_consent_prompt`, `name`"
- " FROM `functional_group`";
+ " FROM `functional_group`";
+
+const std::string kDeleteDeviceConsent = "DELETE FROM `device_consent_group` "
+ "WHERE `device_id` = ? ";
+
+const std::string kDeleteAppConsent = "DELETE FROM `consent_group` "
+ "WHERE `device_id` = ? ";
+
+const std::string kSelectApplicationIsPreData =
+ "SELECT `is_predata` FROM `application` WHERE `id` = ?";
+
+const std::string kUpdateIsPredata =
+ "UPDATE `application` SET `is_predata` = ? WHERE `id` = ?";
+const std::string kHasAppPreloadedGroups =
+ "SELECT COUNT(`a1`.`functional_group_id`) FROM `app_group` "
+ " AS `a1` JOIN `app_group` AS `a2` "
+ " ON `a1`.`functional_group_id` = `a2`.`functional_group_id` "
+ " WHERE `a1`.`application_id` = ? AND `a2`.`application_id` = ? ";
} // namespace sql_pt_ext
diff --git a/src/components/policy/src/policy/src/sql_pt_ext_representation.cc b/src/components/policy/src/policy/src/sql_pt_ext_representation.cc
index 47f16b29d..78d33812d 100644
--- a/src/components/policy/src/policy/src/sql_pt_ext_representation.cc
+++ b/src/components/policy/src/policy/src/sql_pt_ext_representation.cc
@@ -31,6 +31,7 @@
*/
#include <algorithm>
#include <utility>
+#include "utils/logger.h"
#include "policy/sql_pt_ext_representation.h"
#include "policy/sql_wrapper.h"
#include "policy/sql_pt_queries.h"
@@ -38,6 +39,8 @@
namespace policy {
+CREATE_LOGGERPTR_GLOBAL(logger_, "SQLPTRepresentation")
+
bool SQLPTExtRepresentation::CanAppKeepContext(const std::string& app_id) {
dbms::SQLQuery query(db());
if (query.Prepare(sql_pt_ext::kSelectKeepContext)) {
@@ -61,22 +64,16 @@ bool SQLPTExtRepresentation::CanAppStealFocus(const std::string& app_id) {
}
bool SQLPTExtRepresentation::ResetUserConsent() {
- dbms::SQLQuery query(db());
- if (query.Prepare(sql_pt_ext::kResetUserConsent)) {
- if (query.Exec()) {
- return query.GetBoolean(0);
- }
- }
- return false;
+ return dbms::SQLQuery(db()).Exec(sql_pt_ext::kResetUserConsent);
}
bool SQLPTExtRepresentation::GetUserPermissionsForDevice(
const std::string& device_id, StringArray* consented_groups,
StringArray* disallowed_groups) {
- LOG4CXX_INFO(logger(), "GetUserPermissionsForDevice");
+ LOG4CXX_INFO(logger_, "GetUserPermissionsForDevice");
dbms::SQLQuery query(db());
if (!query.Prepare(sql_pt_ext::kSelectDeviceConsentedGroup)) {
- LOG4CXX_WARN(logger(), "Incorrect select from device consented groups");
+ LOG4CXX_WARN(logger_, "Incorrect select from device consented groups");
return false;
}
query.Bind(0, device_id);
@@ -99,8 +96,12 @@ bool SQLPTExtRepresentation::GetUserPermissionsForDevice(
bool SQLPTExtRepresentation::GetUserPermissionsForApp(
const std::string& device_id, const std::string& policy_app_id,
- std::vector<FunctionalGroupPermission>& permissions) {
- LOG4CXX_INFO(logger(), "GetUserPermissionsForApp");
+ FunctionalIdType* group_types) {
+ LOG4CXX_INFO(logger_, "GetUserPermissionsForApp");
+ if (!group_types) {
+ LOG4CXX_WARN(logger_, "Input parameter for group types is null.");
+ return false;
+ }
// Get all app groups for specified device and application
FunctionalGroupIDs all_groups;
if (!GetAllAppGroups(policy_app_id, all_groups)) {
@@ -118,61 +119,29 @@ bool SQLPTExtRepresentation::GetUserPermissionsForApp(
allowed_groups, disallowed_groups)) {
return false;
}
- // Get group names
- FunctionalGroupNames names;
- if (!GetFunctionalGroupNames(names)) {
+ // Get all default groups - they should always be allowed
+ FunctionalGroupIDs default_groups;
+ if (!GetAllAppGroups(kDefaultId, default_groups)) {
return false;
}
- std::sort(all_groups.begin(), all_groups.end());
- std::sort(allowed_groups.begin(), allowed_groups.end());
- std::sort(disallowed_groups.begin(), disallowed_groups.end());
- std::sort(preconsented_groups.begin(), preconsented_groups.end());
-
- // Find groups with undefinded consent
- FunctionalGroupIDs no_preconsented;
- std::set_difference(all_groups.begin(), all_groups.end(),
- preconsented_groups.begin(), preconsented_groups.end(),
- std::back_inserter(no_preconsented));
- FunctionalGroupIDs no_allowed_preconsented;
- std::set_difference(no_preconsented.begin(), no_preconsented.end(),
- allowed_groups.begin(), allowed_groups.end(),
- std::back_inserter(no_allowed_preconsented));
- FunctionalGroupIDs undefined_consent;
- std::set_difference(no_allowed_preconsented.begin(), no_allowed_preconsented.end(),
- disallowed_groups.begin(), disallowed_groups.end(),
- std::back_inserter(undefined_consent));
-
- // Find common allowed groups
- FunctionalGroupIDs preconsented_allowed;
- std::merge(allowed_groups.begin(), allowed_groups.end(),
- preconsented_groups.begin(), preconsented_groups.end(),
- std::back_inserter(preconsented_allowed));
- FunctionalGroupIDs common_allowed(preconsented_allowed.begin(),
- std::unique(preconsented_allowed.begin(), preconsented_allowed.end()));
-
- // Find common disallowed groups
- FunctionalGroupIDs common_disallowed;
- std::set_difference(disallowed_groups.begin(), disallowed_groups.end(),
- preconsented_groups.begin(), preconsented_groups.end(),
- std::back_inserter(common_disallowed));
-
- // Fill result
- FillFunctionalGroupPermissions(undefined_consent, names, kUndefined, permissions);
- FillFunctionalGroupPermissions(common_allowed, names, kAllowed, permissions);
- FillFunctionalGroupPermissions(common_disallowed, names, kDisallowed, permissions);
+ (*group_types)[kTypeDefault] = default_groups;
+ (*group_types)[kTypeAllowed] = allowed_groups;
+ (*group_types)[kTypeDisallowed] = disallowed_groups;
+ (*group_types)[kTypePreconsented] = preconsented_groups;
+ (*group_types)[kTypeGeneral] = all_groups;
return true;
}
bool SQLPTExtRepresentation::GetDeviceGroupsFromPolicies(
policy_table::Strings* groups, policy_table::Strings* preconsented_groups) {
- LOG4CXX_INFO(logger(), "GetDeviceGroupsFromPolicies");
+ LOG4CXX_INFO(logger_, "GetDeviceGroupsFromPolicies");
if (groups) {
- GatherAppGroup("device", groups);
+ GatherAppGroup(kDeviceId, groups);
}
if (preconsented_groups) {
- GatherPreconsentedGroup("device", preconsented_groups);
+ GatherPreconsentedGroup(kDeviceId, preconsented_groups);
}
return true;
}
@@ -184,17 +153,17 @@ bool SQLPTExtRepresentation::SetDeviceData(const std::string& device_id,
const std::string& os_version,
const std::string& carrier,
const uint32_t number_of_ports) {
- LOG4CXX_INFO(logger(), "SetDeviceData");
+ LOG4CXX_INFO(logger_, "SetDeviceData");
dbms::SQLQuery count_query(db());
if (!count_query.Prepare(sql_pt_ext::kCountDevice)) {
- LOG4CXX_WARN(logger(), "Incorrect statement for count of device.");
+ LOG4CXX_WARN(logger_, "Incorrect statement for count of device.");
return false;
}
count_query.Bind(0, device_id);
if (!count_query.Exec()) {
- LOG4CXX_WARN(logger(), "Incorrect count of device.");
+ LOG4CXX_WARN(logger_, "Incorrect count of device.");
return false;
}
@@ -204,7 +173,7 @@ bool SQLPTExtRepresentation::SetDeviceData(const std::string& device_id,
if (update) {
dbms::SQLQuery update_query(db());
if (!update_query.Prepare(sql_pt_ext::kUpdateDevice)) {
- LOG4CXX_WARN(logger(), "Incorrect statement for udpate device.");
+ LOG4CXX_WARN(logger_, "Incorrect statement for udpate device.");
return false;
}
@@ -217,7 +186,7 @@ bool SQLPTExtRepresentation::SetDeviceData(const std::string& device_id,
update_query.Bind(6, device_id);
if (!update_query.Exec() || !update_query.Reset()) {
- LOG4CXX_WARN(logger(), "Incorrect update for device.");
+ LOG4CXX_WARN(logger_, "Incorrect update for device.");
return false;
}
@@ -227,7 +196,7 @@ bool SQLPTExtRepresentation::SetDeviceData(const std::string& device_id,
// Insert new data
dbms::SQLQuery insert_query(db());
if (!insert_query.Prepare(sql_pt_ext::kInsertDevice)) {
- LOG4CXX_WARN(logger(), "Incorrect insert statement for device.");
+ LOG4CXX_WARN(logger_, "Incorrect insert statement for device.");
return false;
}
@@ -240,7 +209,7 @@ bool SQLPTExtRepresentation::SetDeviceData(const std::string& device_id,
insert_query.Bind(6, static_cast<int>(number_of_ports));
if (!insert_query.Exec() || !insert_query.Reset()) {
- LOG4CXX_WARN(logger(), "Incorrect insert to device.");
+ LOG4CXX_WARN(logger_, "Incorrect insert to device.");
return false;
}
@@ -250,17 +219,17 @@ bool SQLPTExtRepresentation::SetDeviceData(const std::string& device_id,
bool SQLPTExtRepresentation::SetUserPermissionsForDevice(
const std::string& device_id, const StringArray& consented_groups,
const StringArray& disallowed_groups) {
- LOG4CXX_INFO(logger(), "SetUserPermissionsForDevice");
+ LOG4CXX_INFO(logger_, "SetUserPermissionsForDevice");
dbms::SQLQuery count_query(db());
if (!count_query.Prepare(sql_pt_ext::kCountDeviceConsentGroup)) {
- LOG4CXX_WARN(logger(), "Incorrect count of device consented groups");
+ LOG4CXX_WARN(logger_, "Incorrect count of device consented groups");
return false;
}
count_query.Bind(0, device_id);
if (!count_query.Exec()) {
- LOG4CXX_WARN(logger(), "Incorrect count of device consented groups");
+ LOG4CXX_WARN(logger_, "Incorrect count of device consented groups");
return false;
}
@@ -271,7 +240,7 @@ bool SQLPTExtRepresentation::SetUserPermissionsForDevice(
// Update old values
if (update) {
if (!query.Prepare(sql_pt_ext::kUpdateDeviceConsentedGroup)) {
- LOG4CXX_WARN(logger(), "Incorrect update of device consented groups");
+ LOG4CXX_WARN(logger_, "Incorrect update of device consented groups");
return false;
}
@@ -286,7 +255,7 @@ bool SQLPTExtRepresentation::SetUserPermissionsForDevice(
// TODO(AOleynik): Get this info from external data
query.Bind(3, "GUI");
if (!query.Exec() || !query.Reset()) {
- LOG4CXX_WARN(logger(), "Incorrect update of device consented groups.");
+ LOG4CXX_WARN(logger_, "Incorrect update of device consented groups.");
return false;
}
}
@@ -301,7 +270,7 @@ bool SQLPTExtRepresentation::SetUserPermissionsForDevice(
query.Bind(1, device_id);
query.Bind(2, *it_disallowed_groups);
if (!query.Exec() || !query.Reset()) {
- LOG4CXX_WARN(logger(), "Incorrect update of device consented groups.");
+ LOG4CXX_WARN(logger_, "Incorrect update of device consented groups.");
return false;
}
}
@@ -311,7 +280,7 @@ bool SQLPTExtRepresentation::SetUserPermissionsForDevice(
// Insert new values
if (!query.Prepare(sql_pt_ext::kInsertDeviceConsentedGroup)) {
- LOG4CXX_WARN(logger(), "Incorrect insert to device consented groups");
+ LOG4CXX_WARN(logger_, "Incorrect insert to device consented groups");
return false;
}
@@ -325,7 +294,7 @@ bool SQLPTExtRepresentation::SetUserPermissionsForDevice(
// TODO(AOleynik): Get this info from external data
query.Bind(3, std::string("GUI"));
if (!query.Exec() || !query.Reset()) {
- LOG4CXX_WARN(logger(), "Incorrect insert to device consented groups.");
+ LOG4CXX_WARN(logger_, "Incorrect insert to device consented groups.");
return false;
}
}
@@ -339,7 +308,7 @@ bool SQLPTExtRepresentation::SetUserPermissionsForDevice(
query.Bind(1, *it_disallowed_groups);
query.Bind(2, 0);
if (!query.Exec() || !query.Reset()) {
- LOG4CXX_WARN(logger(), "Incorrect insert to device consented groups.");
+ LOG4CXX_WARN(logger_, "Incorrect insert to device consented groups.");
return false;
}
}
@@ -347,40 +316,122 @@ bool SQLPTExtRepresentation::SetUserPermissionsForDevice(
return true;
}
+bool SQLPTExtRepresentation::ReactOnUserDevConsentForApp(
+ const std::string& app_id,
+ bool is_device_allowed) {
+ bool result = true;
+ if (is_device_allowed) {
+ // If app has pre_DataConsented groups it should be 'promoted' to default
+ // If app has only pre_DataConsented flag it should be only set to false and
+ // all groups get restored automatically
+ if (IsPredataPolicy(app_id)) {
+ dbms::SQLQuery query(db());
+ if (!query.Prepare(sql_pt_ext::kHasAppPreloadedGroups)) {
+ LOG4CXX_WARN(logger_, "Incorrect statement for has app preloaded groups");
+ return false;
+ }
+ query.Bind(0, app_id);
+ query.Bind(1, kPreDataConsentId);
+ if (!query.Exec()) {
+ LOG4CXX_WARN(logger_, "Incorrect select for app has predataconsted groups");
+ return false;
+ }
+ if (query.GetInteger(0) > 0) {
+ result = result && SetDefaultPolicy(app_id);
+ } else {
+ result = result && SetIsPredata(app_id, false);
+ }
+ }
+ } else {
+ // If app has default groups change them to pre_DataConsented
+ // If app has 'normal' groups leave them as is and set
+ // pre_DataConsented flag to true.
+ if (IsDefaultPolicy(app_id)) {
+ result = result && SetPredataPolicy(app_id);
+ } else {
+ result = result && SetIsPredata(app_id, true);
+ }
+ }
+ return result;
+}
+
bool SQLPTExtRepresentation::SetUserPermissionsForApp(
const PermissionConsent& permissions) {
- LOG4CXX_INFO(logger(), "SetUserPermissionsForApp");
+ LOG4CXX_INFO(logger_, "SetUserPermissionsForApp");
// TODO(AOleynik): Handle situation, when no application was specified, i.e.
// general permissions were set
- dbms::SQLQuery query(db());
- if (!query.Prepare(sql_pt_ext::kUpdateGroupPermissions)) {
- LOG4CXX_WARN(logger(),
- "Incorrect statement for update app group permissions.");
- return false;
- }
-
std::vector<FunctionalGroupPermission>::const_iterator it = permissions
.group_permissions.begin();
std::vector<FunctionalGroupPermission>::const_iterator it_end = permissions
.group_permissions.end();
+
+ dbms::SQLQuery query(db());
for (; it != it_end; ++it) {
+ dbms::SQLQuery counter(db());
+ if (!counter.Prepare(sql_pt_ext::kCountAppConsents)) {
+ LOG4CXX_WARN(logger_, "Incorrect statement for consent group count.");
+ return false;
+ }
+
+ counter.Bind(0, permissions.device_id);
+ counter.Bind(1, permissions.policy_app_id);
+ counter.Bind(2, static_cast<int>((*it).group_id));
+ if (!counter.Exec()) {
+ LOG4CXX_WARN(logger_, "Incorrent count on consent groups.");
+ return false;
+ }
+
+ bool update_required = counter.GetInteger(0);
+
+ // Update already present consent record
+ if (update_required) {
+ if (!query.Prepare(sql_pt_ext::kUpdateGroupPermissions)) {
+ LOG4CXX_WARN(logger_, "Incorrect statement for update consent groups.");
+ return false;
+ }
+
+ // Skip consent saving, if user didn't choose any state
+ if (policy::kGroupUndefined == (*it).state) {
+ continue;
+ }
+ query.Bind(0, (*it).state == kGroupAllowed ? 1 : 0);
+ query.Bind(1, permissions.consent_source);
+ query.Bind(2, permissions.policy_app_id);
+ query.Bind(3, static_cast<int>((*it).group_id));
+ query.Bind(4, permissions.device_id);
+
+ if (!query.Exec() || !query.Reset()) {
+ LOG4CXX_WARN(logger_, "Incorrect update on user defined permissions "
+ "for app groups.");
+ return false;
+ }
+ continue;
+ }
+
+ // Insert new consent record
+ if (!query.Prepare(sql_pt_ext::kInsertConsentGroups)) {
+ LOG4CXX_WARN(logger_,
+ "Incorrect statement for update app group permissions.");
+ return false;
+ }
+
// Skip consent saving, if user didn't choose any state
- if (policy::kUndefined == (*it).state) {
+ if (policy::kGroupUndefined == (*it).state) {
continue;
}
- query.Bind(0, (*it).state);
- query.Bind(1, permissions.consent_source);
- query.Bind(2, permissions.policy_app_id);
- query.Bind(3, static_cast<int>((*it).group_id));
- query.Bind(4, permissions.device_id);
+ query.Bind(0, permissions.device_id);
+ query.Bind(1, permissions.policy_app_id);
+ query.Bind(2, static_cast<int>((*it).group_id));
+ query.Bind(3, (*it).state == kGroupAllowed ? 1 : 0);
+ query.Bind(4, permissions.consent_source);
if (!query.Exec() || !query.Reset()) {
- LOG4CXX_WARN(logger(), "Incorrect update on user defined permissions "
+ LOG4CXX_WARN(logger_, "Incorrect insert to user defined permissions "
"for app groups.");
return false;
}
+ continue;
}
-
return true;
}
@@ -389,7 +440,7 @@ std::vector<UserFriendlyMessage> SQLPTExtRepresentation::GetUserFriendlyMsg(
dbms::SQLQuery query(db());
std::vector<UserFriendlyMessage> result;
if (!query.Prepare(sql_pt_ext::kSelectFriendlyMsg)) {
- LOG4CXX_WARN(logger(), "Incorrect statement for select friendly messages.");
+ LOG4CXX_WARN(logger_, "Incorrect statement for select friendly messages.");
return result;
}
@@ -400,12 +451,13 @@ std::vector<UserFriendlyMessage> SQLPTExtRepresentation::GetUserFriendlyMsg(
query.Bind(1, language);
if (!query.Exec()) {
- LOG4CXX_WARN(logger(), "Incorrect select from friendly messages.");
+ LOG4CXX_WARN(logger_, "Incorrect select from friendly messages.");
return result;
}
UserFriendlyMessage msg;
+ msg.message_code = *it;
msg.tts = query.GetString(0);
msg.label = query.GetString(1);
msg.line1 = query.GetString(2);
@@ -415,7 +467,7 @@ std::vector<UserFriendlyMessage> SQLPTExtRepresentation::GetUserFriendlyMsg(
result.push_back(msg);
if (!query.Reset()) {
- LOG4CXX_WARN(logger(), "Faild reset statement for selecting friendly messages.");
+ LOG4CXX_WARN(logger_, "Faild reset statement for selecting friendly messages.");
return result;
}
}
@@ -424,12 +476,12 @@ std::vector<UserFriendlyMessage> SQLPTExtRepresentation::GetUserFriendlyMsg(
}
bool SQLPTExtRepresentation::SetMetaInfo(const std::string& ccpu_version,
- const std::string& wers_country_code,
- const std::string& language) {
- LOG4CXX_INFO(logger(), "SetMetaInfo");
+ const std::string& wers_country_code,
+ const std::string& language) {
+ LOG4CXX_INFO(logger_, "SetMetaInfo");
dbms::SQLQuery query(db());
if (!query.Prepare(sql_pt_ext::kUpdateMetaParams)) {
- LOG4CXX_WARN(logger(), "Incorrect statement for insert to module meta.");
+ LOG4CXX_WARN(logger_, "Incorrect statement for insert to module meta.");
return false;
}
@@ -438,7 +490,7 @@ bool SQLPTExtRepresentation::SetMetaInfo(const std::string& ccpu_version,
query.Bind(2, language);
if (!query.Exec() || !query.Reset()) {
- LOG4CXX_WARN(logger(), "Incorrect insert to module meta.");
+ LOG4CXX_WARN(logger_, "Incorrect insert to module meta.");
return false;
}
@@ -446,17 +498,17 @@ bool SQLPTExtRepresentation::SetMetaInfo(const std::string& ccpu_version,
}
bool SQLPTExtRepresentation::SetSystemLanguage(const std::string& language) {
- LOG4CXX_INFO(logger(), "SetSystemLanguage");
+ LOG4CXX_INFO(logger_, "SetSystemLanguage");
dbms::SQLQuery query(db());
if (!query.Prepare(sql_pt_ext::kUpdateMetaLanguage)) {
- LOG4CXX_WARN(logger(), "Incorrect statement for update meta language.");
+ LOG4CXX_WARN(logger_, "Incorrect statement for update meta language.");
return false;
}
query.Bind(0, language);
if (!query.Exec()) {
- LOG4CXX_WARN(logger(), "Incorrect update for meta language.");
+ LOG4CXX_WARN(logger_, "Incorrect update for meta language.");
return false;
}
@@ -465,23 +517,28 @@ bool SQLPTExtRepresentation::SetSystemLanguage(const std::string& language) {
bool SQLPTExtRepresentation::SaveApplicationPolicies(
const policy_table::ApplicationPolicies& apps) {
- LOG4CXX_INFO(logger(), "SaveApplicationPolicies ext");
+ LOG4CXX_INFO(logger_, "SaveApplicationPolicies ext");
dbms::SQLQuery query_delete(db());
if (!query_delete.Exec(sql_pt::kDeleteAppGroup)) {
- LOG4CXX_WARN(logger(), "Incorrect delete from app_group.");
+ LOG4CXX_WARN(logger_, "Incorrect delete from app_group.");
return false;
}
dbms::SQLQuery query_delete_preconsented(db());
if (!query_delete_preconsented.Exec(sql_pt_ext::kDeletePreconsentedGroups)) {
- LOG4CXX_WARN(logger(), "Incorrect delete from preconsented_group.");
+ LOG4CXX_WARN(logger_, "Incorrect delete from preconsented_group.");
+ return false;
+ }
+
+ if (!query_delete.Exec(sql_pt::kDeleteApplication)) {
+ LOG4CXX_WARN(logger_, "Incorrect delete from application.");
return false;
}
policy_table::ApplicationPolicies::const_iterator it;
dbms::SQLQuery app_query(db());
if (!app_query.Prepare(sql_pt_ext::kInsertApplication)) {
- LOG4CXX_WARN(logger(), "Incorrect insert statement into application.");
+ LOG4CXX_WARN(logger_, "Incorrect insert statement into application.");
return false;
}
for (it = apps.begin(); it != apps.end(); ++it) {
@@ -492,29 +549,33 @@ bool SQLPTExtRepresentation::SaveApplicationPolicies(
3, std::string(policy_table::EnumToJsonString(it->second.default_hmi)));
app_query.Bind(
4, std::string(policy_table::EnumToJsonString(it->second.priority)));
+ printf("\n\t\t\t\tIs app Revoked: %s: %d\n", it->first.c_str(), it->second.is_null());
app_query.Bind(
5, it->second.is_null());
app_query.Bind(6, it->second.memory_kb);
app_query.Bind(7, it->second.watchdog_timer_ms);
it->second.certificate.is_initialized() ?
- app_query.Bind(8, it->second.certificate) : app_query.Bind(8,std::string());
+ app_query.Bind(8, *it->second.certificate) : app_query.Bind(8, std::string());
if (!app_query.Exec() || !app_query.Reset()) {
- LOG4CXX_WARN(logger(), "Incorrect insert into application.");
+ LOG4CXX_WARN(logger_, "Incorrect insert into application.");
return false;
}
- LOG4CXX_INFO(logger(), "Saving data for application: " << it->first);
+ LOG4CXX_INFO(logger_, "Saving data for application: " << it->first);
if (!SaveAppGroup(it->first, it->second.groups)) {
return false;
}
- if (!SaveNickname(it->first, it->second.nicknames)) {
+ // TODO(IKozyrenko): Check logic if optional container is missing
+ if (!SaveNickname(it->first, *it->second.nicknames)) {
return false;
}
- if (!SaveAppType(it->first, it->second.AppHMIType)) {
+ // TODO(IKozyrenko): Check logic if optional container is missing
+ if (!SaveAppType(it->first, *it->second.AppHMIType)) {
return false;
}
- if (!SavePreconsentedGroup(it->first, it->second.preconsented_groups)) {
+ // TODO(IKozyrenko): Check logic if optional container is missing
+ if (!SavePreconsentedGroup(it->first, *it->second.preconsented_groups)) {
return false;
}
}
@@ -524,15 +585,15 @@ bool SQLPTExtRepresentation::SaveApplicationPolicies(
bool SQLPTExtRepresentation::GatherApplicationPolicies(
policy_table::ApplicationPolicies* apps) const {
- LOG4CXX_INFO(logger(), "Gather applications policies");
+ LOG4CXX_INFO(logger_, "Gather applications policies");
dbms::SQLQuery query(db());
if (!query.Prepare(sql_pt_ext::kSelectAppPolicies)) {
- LOG4CXX_WARN(logger(), "Incorrect select from app_policies");
+ LOG4CXX_WARN(logger_, "Incorrect select from app_policies");
return false;
}
while (query.Next()) {
- policy_table::ApplicationParams params;
+ rpc::Nullable<policy_table::ApplicationParams> params;
const std::string& app_id = query.GetString(0);
policy_table::Priority priority;
policy_table::EnumFromJsonString(query.GetString(1), &priority);
@@ -542,21 +603,24 @@ bool SQLPTExtRepresentation::GatherApplicationPolicies(
params.default_hmi = hmi;
params.keep_context = query.GetBoolean(3);
params.steal_focus = query.GetBoolean(4);
- params.memory_kb = query.GetInteger(5);
- params.watchdog_timer_ms = query.GetInteger(6);
+ *params.memory_kb = query.GetInteger(5);
+ *params.watchdog_timer_ms = query.GetInteger(6);
if (!query.IsNull(7)) {
*params.certificate = query.GetString(7);
}
if (!GatherAppGroup(app_id, &params.groups)) {
return false;
}
- if (!GatherNickName(app_id, &params.nicknames)) {
+ // TODO(IKozyrenko): Check logic if optional container is missing
+ if (!GatherNickName(app_id, &*params.nicknames)) {
return false;
}
- if (!GatherAppType(app_id, &params.AppHMIType)) {
+ // TODO(IKozyrenko): Check logic if optional container is missing
+ if (!GatherAppType(app_id, &*params.AppHMIType)) {
return false;
}
- GatherPreconsentedGroup(app_id, &params.preconsented_groups);
+ // TODO(IKozyrenko): Check logic if optional container is missing
+ GatherPreconsentedGroup(app_id, &*params.preconsented_groups);
(*apps)[app_id] = params;
}
return true;
@@ -566,7 +630,7 @@ void SQLPTExtRepresentation::GatherPreconsentedGroup(
const std::string& app_id, policy_table::Strings* groups) const {
dbms::SQLQuery query(db());
if (!query.Prepare(sql_pt_ext::kSelectPreconsentedGroups)) {
- LOG4CXX_WARN(logger(), "Incorrect select from preconsented group");
+ LOG4CXX_WARN(logger_, "Incorrect select from preconsented group");
return;
}
@@ -578,10 +642,10 @@ void SQLPTExtRepresentation::GatherPreconsentedGroup(
bool SQLPTExtRepresentation::GatherUsageAndErrorCounts(
policy_table::UsageAndErrorCounts* counts) const {
- LOG4CXX_INFO(logger(), "Gather Usage and Error Counts.");
+ LOG4CXX_INFO(logger_, "Gather Usage and Error Counts.");
dbms::SQLQuery query(db());
if (!query.Prepare(sql_pt_ext::kSelectUsageAndErrorCount) || !query.Exec()) {
- LOG4CXX_INFO(logger(), "Failed select from user_and_error_count");
+ LOG4CXX_INFO(logger_, "Failed select from user_and_error_count");
return false;
}
@@ -589,14 +653,14 @@ bool SQLPTExtRepresentation::GatherUsageAndErrorCounts(
*counts->count_sync_out_of_memory = query.GetInteger(1);
*counts->count_of_sync_reboots = query.GetInteger(2);
- return GatherAppLevels(&counts->app_level);
+ return GatherAppLevels(&*counts->app_level);
}
bool SQLPTExtRepresentation::GatherAppLevels(
policy_table::AppLevels* apps) const {
dbms::SQLQuery query(db());
if (query.Prepare(sql_pt_ext::kSelectAppLevels)) {
- LOG4CXX_INFO(logger(), "Failed select from app_level");
+ LOG4CXX_INFO(logger_, "Failed select from app_level");
return false;
}
const int kSecondsInMinute = 60;
@@ -626,10 +690,10 @@ bool SQLPTExtRepresentation::GatherAppLevels(
void SQLPTExtRepresentation::GatherDeviceData(
policy_table::DeviceData* data) const {
- LOG4CXX_INFO(logger(), "Gather device data.");
+ LOG4CXX_INFO(logger_, "Gather device data.");
dbms::SQLQuery query(db());
if (!query.Prepare(sql_pt_ext::kSelectDeviceData)) {
- LOG4CXX_WARN(logger(), "Incorrect select statement for device data.");
+ LOG4CXX_WARN(logger_, "Incorrect select statement for device data.");
return;
}
@@ -642,19 +706,20 @@ void SQLPTExtRepresentation::GatherDeviceData(
*specific_device->carrier = query.GetString(5);
*specific_device->max_number_rfcom_ports = query.GetInteger(6);
+ // TODO(IKozyrenko): Check logic if optional container is missing
GatherConsentGroup(query.GetString(0),
- &(specific_device->user_consent_records));
+ &(*specific_device->user_consent_records));
}
}
void SQLPTExtRepresentation::GatherConsentGroup(
const std::string& device_id,
policy_table::UserConsentRecords* records) const {
- LOG4CXX_INFO(logger(), "Gather consent records.");
+ LOG4CXX_INFO(logger_, "Gather consent records.");
dbms::SQLQuery query(db());
// Fill data for device
if (!query.Prepare(sql_pt_ext::kSelectDeviceConsentedGroup)) {
- LOG4CXX_WARN(logger(),
+ LOG4CXX_WARN(logger_,
"Incorrect select statement for device consented groups.");
return;
}
@@ -662,11 +727,11 @@ void SQLPTExtRepresentation::GatherConsentGroup(
query.Bind(0, device_id);
// Fill device_data -> user_consent_records -> "device"
- policy_table::ConsentRecords* device_consent_records = &(*records)["device"];
-
while (query.Next()) {
- (*device_consent_records).consent_groups[query.GetString(1)] = query
- .GetBoolean(2);
+ policy_table::ConsentRecords* device_consent_records = &(*records)[kDeviceId];
+ // TODO(IKozyrenko): Check logic if optional container is missing
+ policy_table::ConsentGroups& consent_groups = *device_consent_records->consent_groups;
+ consent_groups[query.GetString(1)] = query.GetBoolean(2);
policy_table::Input input;
policy_table::EnumFromJsonString(query.GetString(3), &input);
*device_consent_records->input = input;
@@ -679,7 +744,7 @@ void SQLPTExtRepresentation::GatherConsentGroup(
// Fill data for applications
if (!query.Prepare(sql_pt_ext::kSelectConsentGroup)) {
- LOG4CXX_WARN(logger(),
+ LOG4CXX_WARN(logger_,
"Incorrect select statement for app consented groups.");
return;
}
@@ -690,8 +755,10 @@ void SQLPTExtRepresentation::GatherConsentGroup(
while (query.Next()) {
policy_table::ConsentRecords* app_consent_records = &(*records)[query
.GetString(1)];
- (*app_consent_records).consent_groups[query.GetString(2)] =
- query.GetBoolean(3);
+ // TODO(IKozyrenko): Check logic if optional container is missing
+ policy_table::ConsentGroups& consent_groups = *app_consent_records->consent_groups;
+
+ consent_groups[query.GetString(2)] = query.GetBoolean(3);
policy_table::Input input;
policy_table::EnumFromJsonString(query.GetString(4), &input);
*app_consent_records->input = input;
@@ -701,10 +768,10 @@ void SQLPTExtRepresentation::GatherConsentGroup(
bool SQLPTExtRepresentation::SaveDeviceData(
const policy_table::DeviceData& devices) {
- LOG4CXX_INFO(logger(), "SaveDeviceData");
+ LOG4CXX_INFO(logger_, "SaveDeviceData");
dbms::SQLQuery query(db());
if (!query.Prepare(sql_pt_ext::kInsertDeviceData)) {
- LOG4CXX_WARN(logger(), "Incorrect insert statement for device data.");
+ LOG4CXX_WARN(logger_, "Incorrect insert statement for device data.");
return false;
}
@@ -720,11 +787,12 @@ bool SQLPTExtRepresentation::SaveDeviceData(
query.Bind(6, *(it->second.max_number_rfcom_ports));
if (!query.Exec() || !query.Reset()) {
- LOG4CXX_WARN(logger(), "Incorrect insert into device data.");
+ LOG4CXX_WARN(logger_, "Incorrect insert into device data.");
return false;
}
- if (!SaveConsentGroup(it->first, it->second.user_consent_records)) {
+ // TODO(IKozyrenko): Check logic if optional container is missing
+ if (!SaveConsentGroup(it->first, *it->second.user_consent_records)) {
return false;
}
}
@@ -735,20 +803,21 @@ bool SQLPTExtRepresentation::SaveDeviceData(
bool SQLPTExtRepresentation::SaveConsentGroup(
const std::string& device_id,
const policy_table::UserConsentRecords& records) {
- LOG4CXX_INFO(logger(), "SaveConsentGroup");
+ LOG4CXX_INFO(logger_, "SaveConsentGroup");
dbms::SQLQuery query(db());
policy_table::UserConsentRecords::const_iterator it = records.begin();
policy_table::UserConsentRecords::const_iterator it_end = records.end();
for (; it != it_end; ++it) {
+ // TODO(IKozyrenko): Check logic if optional container is missing
policy_table::ConsentGroups::const_iterator it_groups = it->second
- .consent_groups.begin();
+ .consent_groups->begin();
policy_table::ConsentGroups::const_iterator it_groups_end = it->second
- .consent_groups.end();
+ .consent_groups->end();
for (; it_groups != it_groups_end; ++it_groups) {
- if ("device" == it->first) {
+ if (kDeviceId == it->first) {
if (!query.Prepare(sql_pt_ext::kInsertDeviceConsentedGroup)) {
- LOG4CXX_WARN(logger(),
+ LOG4CXX_WARN(logger_,
"Incorrect insert statement for device consent group.");
return false;
}
@@ -760,7 +829,7 @@ bool SQLPTExtRepresentation::SaveConsentGroup(
std::string(policy_table::EnumToJsonString(*(it->second.input))));
} else {
if (!query.Prepare(sql_pt_ext::kInsertConsentGroups)) {
- LOG4CXX_WARN(logger(),
+ LOG4CXX_WARN(logger_,
"Incorrect insert statement for consent group.");
return false;
}
@@ -774,7 +843,7 @@ bool SQLPTExtRepresentation::SaveConsentGroup(
}
if (!query.Exec() && !query.Reset()) {
- LOG4CXX_WARN(logger(), "Incorrect insert into consent group.");
+ LOG4CXX_WARN(logger_, "Incorrect insert into consent group.");
return false;
}
}
@@ -785,10 +854,10 @@ bool SQLPTExtRepresentation::SaveConsentGroup(
bool SQLPTExtRepresentation::SavePreconsentedGroup(
const std::string& app_id, const policy_table::Strings& groups) {
- LOG4CXX_INFO(logger(), "SavePreconsentedGroup");
+ LOG4CXX_INFO(logger_, "SavePreconsentedGroup");
dbms::SQLQuery query(db());
if (!query.Prepare(sql_pt_ext::kInsertPreconsentedGroups)) {
- LOG4CXX_WARN(logger(),
+ LOG4CXX_WARN(logger_,
"Incorrect insert statement for preconsented groups");
return false;
}
@@ -798,7 +867,7 @@ bool SQLPTExtRepresentation::SavePreconsentedGroup(
query.Bind(0, app_id);
query.Bind(1, *it);
if (!query.Exec() || !query.Reset()) {
- LOG4CXX_WARN(logger(), "Incorrect insert into preconsented groups.");
+ LOG4CXX_WARN(logger_, "Incorrect insert into preconsented groups.");
return false;
}
}
@@ -808,7 +877,7 @@ bool SQLPTExtRepresentation::SavePreconsentedGroup(
void SQLPTExtRepresentation::GatherModuleMeta(
policy_table::ModuleMeta* meta) const {
- LOG4CXX_INFO(logger(), "Gather Module Meta Info");
+ LOG4CXX_INFO(logger_, "Gather Module Meta Info");
dbms::SQLQuery query(db());
if (query.Prepare(sql_pt_ext::kSelectModuleMeta) && query.Next()) {
*meta->ccpu_version = query.GetString(0);
@@ -826,19 +895,19 @@ void SQLPTExtRepresentation::Increment(const std::string& type) const {
std::string update_counter = "UPDATE `usage_and_error_count` SET `" + type
+ "` = `" + type + "` + 1";
if (!query.Exec(update_counter)) {
- LOG4CXX_INFO(logger(), "Failed updating global counter");
+ LOG4CXX_INFO(logger_, "Failed updating global counter");
}
}
bool SQLPTExtRepresentation::IsExistAppLevel(const std::string& app_id) const {
dbms::SQLQuery query(db());
if (!query.Prepare(sql_pt_ext::kCountAppLevel)) {
- LOG4CXX_INFO(logger(), "Incorrect statement of count app_level");
+ LOG4CXX_INFO(logger_, "Incorrect statement of count app_level");
return false;
}
query.Bind(0, app_id);
if (!query.Exec()) {
- LOG4CXX_INFO(logger(), "Failed count app_level");
+ LOG4CXX_INFO(logger_, "Failed count app_level");
return false;
}
return query.GetInteger(0) > 0;
@@ -846,10 +915,10 @@ bool SQLPTExtRepresentation::IsExistAppLevel(const std::string& app_id) const {
bool SQLPTExtRepresentation::GetAllAppGroups(const std::string& policy_app_id,
FunctionalGroupIDs& all_groups) {
- LOG4CXX_INFO(logger(), "GetAllAppGroups");
+ LOG4CXX_INFO(logger_, "GetAllAppGroups");
dbms::SQLQuery query(db());
if (!query.Prepare(sql_pt_ext::kSelectAppGroupsId)) {
- LOG4CXX_WARN(logger(), "Incorrect statement for select app groups id.");
+ LOG4CXX_WARN(logger_, "Incorrect statement for select app groups id.");
return false;
}
@@ -866,10 +935,10 @@ bool SQLPTExtRepresentation::GetConsentedGroups(
const std::string& policy_app_id, const std::string& device_id,
FunctionalGroupIDs& allowed_groups, FunctionalGroupIDs& disallowed_groups) {
- LOG4CXX_INFO(logger(), "GetConsentedGroups");
+ LOG4CXX_INFO(logger_, "GetConsentedGroups");
dbms::SQLQuery query(db());
if (!query.Prepare(sql_pt_ext::kSelectConsentedGroupsId)) {
- LOG4CXX_WARN(logger(), "Incorrect statement for select consent groups id.");
+ LOG4CXX_WARN(logger_, "Incorrect statement for select consent groups id.");
return false;
}
@@ -889,10 +958,10 @@ bool SQLPTExtRepresentation::GetConsentedGroups(
bool SQLPTExtRepresentation::GetPreconsentedGroups(
const std::string& policy_app_id, FunctionalGroupIDs& preconsented_groups) {
- LOG4CXX_INFO(logger(), "GetPreconsentedGroups");
+ LOG4CXX_INFO(logger_, "GetPreconsentedGroups");
dbms::SQLQuery query(db());
if (!query.Prepare(sql_pt_ext::kSelectPreconsentedGroupsId)) {
- LOG4CXX_WARN(logger(),
+ LOG4CXX_WARN(logger_,
"Incorrect statement for select preconsented groups id.");
return false;
}
@@ -908,10 +977,10 @@ bool SQLPTExtRepresentation::GetPreconsentedGroups(
bool SQLPTExtRepresentation::GetFunctionalGroupNames(
FunctionalGroupNames& names) {
- LOG4CXX_INFO(logger(), "GetFunctionalGroupNames");
+ LOG4CXX_INFO(logger_, "GetFunctionalGroupNames");
dbms::SQLQuery query(db());
if (!query.Prepare(sql_pt_ext::kSelectFunctionalGroupNames)) {
- LOG4CXX_WARN(logger(),
+ LOG4CXX_WARN(logger_,
"Incorrect statement for select functional groups names.");
return false;
}
@@ -920,10 +989,10 @@ bool SQLPTExtRepresentation::GetFunctionalGroupNames(
// Some of functional grous doesn't have filled user_consent_prompt
if (query.IsNull(1)) {
names[query.GetInteger(0)] =
- std::make_pair<std::string, std::string>("", query.GetString(2));
+ std::make_pair<std::string, std::string>("", query.GetString(2));
} else {
names[query.GetInteger(0)] =
- std::make_pair<std::string, std::string>(query.GetString(1), query.GetString(2));
+ std::make_pair<std::string, std::string>(query.GetString(1), query.GetString(2));
}
}
@@ -932,7 +1001,7 @@ bool SQLPTExtRepresentation::GetFunctionalGroupNames(
}
void SQLPTExtRepresentation::FillFunctionalGroupPermissions(
- FunctionalGroupIDs& ids, FunctionalGroupNames& names, PermissionState state,
+ FunctionalGroupIDs& ids, FunctionalGroupNames& names, GroupConsent state,
std::vector<FunctionalGroupPermission>& permissions) {
FunctionalGroupIDs::const_iterator it = ids.begin();
FunctionalGroupIDs::const_iterator it_end = ids.end();
@@ -960,12 +1029,12 @@ void SQLPTExtRepresentation::Increment(const std::string& app_id,
"VALUES (?, 1)";
}
if (!query.Prepare(sql_counter)) {
- LOG4CXX_INFO(logger(), "Incorrect statement of update app counter");
+ LOG4CXX_INFO(logger_, "Incorrect statement of update app counter");
return;
}
query.Bind(0, app_id);
if (!query.Exec()) {
- LOG4CXX_INFO(logger(), "Failed updating app counter");
+ LOG4CXX_INFO(logger_, "Failed updating app counter");
}
}
@@ -984,13 +1053,13 @@ void SQLPTExtRepresentation::Set(const std::string& app_id,
"VALUES (?, ?)";
}
if (!query.Prepare(sql_info)) {
- LOG4CXX_INFO(logger(), "Incorrect statement of update app info");
+ LOG4CXX_INFO(logger_, "Incorrect statement of update app info");
return;
}
query.Bind(0, value);
query.Bind(1, app_id);
if (!query.Exec()) {
- LOG4CXX_INFO(logger(), "Failed updating app info");
+ LOG4CXX_INFO(logger_, "Failed updating app info");
}
}
@@ -1009,29 +1078,29 @@ void SQLPTExtRepresentation::Add(const std::string& app_id,
"VALUES (?, ?)";
}
if (!query.Prepare(sql_stopwatch)) {
- LOG4CXX_INFO(logger(), "Incorrect statement of update app stopwatch");
+ LOG4CXX_INFO(logger_, "Incorrect statement of update app stopwatch");
return;
}
query.Bind(0, seconds);
query.Bind(1, app_id);
if (!query.Exec()) {
- LOG4CXX_INFO(logger(), "Failed updating app stopwatch");
+ LOG4CXX_INFO(logger_, "Failed updating app stopwatch");
}
}
bool SQLPTExtRepresentation::GetDefaultHMI(const std::string& policy_app_id,
std::string* default_hmi) {
- LOG4CXX_INFO(logger(), "GetDefaultHMI");
+ LOG4CXX_INFO(logger_, "GetDefaultHMI");
dbms::SQLQuery query(db());
if (!query.Prepare(sql_pt_ext::kSelectDefaultHmi)) {
- LOG4CXX_INFO(logger(), "Incorrect statement for default hmi.");
+ LOG4CXX_INFO(logger_, "Incorrect statement for default hmi.");
return false;
}
query.Bind(0, policy_app_id);
if (!query.Exec() || !query.Reset()) {
- LOG4CXX_INFO(logger(), "Error during default hmi getting.");
+ LOG4CXX_INFO(logger_, "Error during default hmi getting.");
return false;
}
@@ -1047,17 +1116,17 @@ bool SQLPTExtRepresentation::GetDefaultHMI(const std::string& policy_app_id,
bool SQLPTExtRepresentation::GetPriority(const std::string& policy_app_id,
std::string* priority) {
- LOG4CXX_INFO(logger(), "GetPriority");
+ LOG4CXX_INFO(logger_, "GetPriority");
dbms::SQLQuery query(db());
if (!query.Prepare(sql_pt_ext::kSelectPriority)) {
- LOG4CXX_INFO(logger(), "Incorrect statement for priority.");
+ LOG4CXX_INFO(logger_, "Incorrect statement for priority.");
return false;
}
query.Bind(0, policy_app_id);
if (!query.Exec()) {
- LOG4CXX_INFO(logger(), "Error during select priority.");
+ LOG4CXX_INFO(logger_, "Error during select priority.");
return false;
}
@@ -1073,17 +1142,17 @@ bool SQLPTExtRepresentation::GetPriority(const std::string& policy_app_id,
bool SQLPTExtRepresentation::CountUnconsentedGroups(
const std::string& policy_app_id, int* result) const {
- LOG4CXX_INFO(logger(), "CountUnconsentedGroups");
+ LOG4CXX_INFO(logger_, "CountUnconsentedGroups");
dbms::SQLQuery query(db());
if (!query.Prepare(sql_pt_ext::kCountUnconsentedGroups)) {
- LOG4CXX_WARN(logger(), "Incorrect select for unconsented groups.");
+ LOG4CXX_WARN(logger_, "Incorrect select for unconsented groups.");
return false;
}
query.Bind(0, policy_app_id);
- if (!query.Exec() || !query.Reset()) {
- LOG4CXX_INFO(logger(), "Error during executing unconsented groups.");
+ if (!query.Exec()) {
+ LOG4CXX_INFO(logger_, "Error during executing unconsented groups.");
return false;
}
*result = query.GetInteger(0);
@@ -1096,7 +1165,7 @@ bool SQLPTExtRepresentation::SaveMessageString(
const policy_table::MessageString& strings) {
dbms::SQLQuery query(db());
if (!query.Prepare(sql_pt::kInsertMessageString)) {
- LOG4CXX_WARN(logger(), "Incorrect insert statement for message.");
+ LOG4CXX_WARN(logger_, "Incorrect insert statement for message.");
return false;
}
@@ -1109,10 +1178,117 @@ bool SQLPTExtRepresentation::SaveMessageString(
query.Bind(6, *strings.textBody);
if (!query.Exec() || !query.Reset()) {
- LOG4CXX_WARN(logger(), "Incorrect insert into message.");
+ LOG4CXX_WARN(logger_, "Incorrect insert into message.");
+ return false;
+ }
+
+ return true;
+}
+
+bool SQLPTExtRepresentation::CleanupUnpairedDevices(
+ const DeviceIds& device_ids) {
+ LOG4CXX_INFO(logger_, "CleanupUnpairedDevices");
+ dbms::SQLQuery delete_device_query(db());
+ if (!delete_device_query.Prepare(sql_pt::kDeleteDevice)) {
+ LOG4CXX_WARN(logger_, "Incorrect statement for device delete.");
+ return true;
+ }
+
+ dbms::SQLQuery delete_device_consent_query(db());
+ if (!delete_device_consent_query.Prepare(sql_pt_ext::kDeleteDeviceConsent)) {
+ LOG4CXX_WARN(logger_, "Incorrect statement for delete device consent.");
+ return false;
+ }
+
+ dbms::SQLQuery delete_app_consent_query(db());
+ if (!delete_app_consent_query.Prepare(sql_pt_ext::kDeleteAppConsent)) {
+ LOG4CXX_WARN(logger_, "Incorrect statement for delete app consent.");
+ return false;
+ }
+
+ DeviceIds::const_iterator it = device_ids.begin();
+ DeviceIds::const_iterator it_end = device_ids.end();
+ for (; it != it_end; ++it) {
+ delete_device_query.Bind(0, (*it));
+ if (!delete_device_query.Exec() || !delete_device_query.Reset()) {
+ LOG4CXX_WARN(logger_, "Failed to delete from device");
+ return false;
+ }
+
+ delete_device_consent_query.Bind(0, (*it));
+ if (!delete_device_consent_query.Exec() ||
+ !delete_device_consent_query.Reset()) {
+ LOG4CXX_WARN(logger_, "Failed to delete from device consent.");
+ return false;
+ }
+
+ delete_app_consent_query.Bind(0, (*it));
+ if (!delete_app_consent_query.Exec() || !delete_app_consent_query.Reset()) {
+ LOG4CXX_WARN(logger_, "Failed to delete from app consent.");
+ return false;
+ }
+ }
+ return true;
+}
+
+bool SQLPTExtRepresentation::SetDefaultPolicy(const std::string& app_id) {
+ if (SQLPTRepresentation::SetDefaultPolicy(app_id)) {
+ return SetIsPredata(app_id, false);
+ }
+ return false;
+}
+
+bool SQLPTExtRepresentation::SetPredataPolicy(const std::string& app_id) {
+ LOG4CXX_INFO(logger_, "SQLPTExtRepresentation::SetPredataPolicy for " << app_id);
+ policy_table::ApplicationPolicies apps;
+ if (!GatherApplicationPolicies(&apps)) {
+ LOG4CXX_WARN(logger_, "Failed gathering application policies");
+ return false;
+ }
+ apps[app_id] = apps[kPreDataConsentId];
+ if (!SaveApplicationPolicies(apps)) {
+ LOG4CXX_WARN(logger_, "Failed saving application policies");
+ return false;
+ }
+ if (IsDefaultPolicy(app_id)) {
+ if (!SetIsDefault(app_id, false)) {
+ LOG4CXX_WARN(logger_, "Failed unsetting app policies from default.");
+ return false;
+ }
+ }
+ return SetIsPredata(app_id, true);
+}
+
+bool SQLPTExtRepresentation::IsPredataPolicy(const std::string& app_id) const {
+ dbms::SQLQuery query(db());
+ if (!query.Prepare(sql_pt_ext::kSelectApplicationIsPreData)) {
+ LOG4CXX_WARN(logger_, "Incorrect select application is pre_dataConsented");
return false;
}
+ query.Bind(0, app_id);
+ if (!query.Exec()) {
+ LOG4CXX_WARN(logger_, "Failed select application is pre_dataConsented");
+ return false;
+ }
+ return query.IsNull(0) ? false : query.GetBoolean(0);
+}
+
+bool SQLPTExtRepresentation::SetIsPredata(const std::string& app_id,
+ bool is_pre_data) {
+ LOG4CXX_TRACE(logger_, "Set flag is_predata of application");
+ dbms::SQLQuery query(db());
+ if (!query.Prepare(sql_pt_ext::kUpdateIsPredata)) {
+ LOG4CXX_WARN(logger_, "Incorect statement for updating is_predata");
+ return false;
+ }
+
+ query.Bind(0, is_pre_data);
+ query.Bind(1, app_id);
+ if (!query.Exec()) {
+ LOG4CXX_WARN(logger_, "Failed update is_predata");
+ return false;
+ }
return true;
}
diff --git a/src/components/policy/src/policy/src/sql_pt_queries.cc b/src/components/policy/src/policy/src/sql_pt_queries.cc
index ce81b54e6..dfc9cd263 100644
--- a/src/components/policy/src/policy/src/sql_pt_queries.cc
+++ b/src/components/policy/src/policy/src/sql_pt_queries.cc
@@ -83,7 +83,7 @@ const std::string kCreateSchema =
" `exchange_after_x_days`, `timeout_after_x_seconds`) "
" VALUES(1, 0, 0, 0, 0); "
"CREATE TABLE IF NOT EXISTS `functional_group`( "
- " `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "
+ " `id` INTEGER PRIMARY KEY NOT NULL, "
" `user_consent_prompt` TEXT UNIQUE ON CONFLICT REPLACE, "
" `name` VARCHAR(100) NOT NULL "
"); "
@@ -150,6 +150,7 @@ const std::string kCreateSchema =
" `priority_value` VARCHAR(45), "
" `is_revoked` BOOLEAN, "
" `is_default` BOOLEAN, "
+ " `is_predata` BOOLEAN, "
" `memory_kb` INTEGER NOT NULL, "
" `watchdog_timer_ms` INTEGER NOT NULL, "
" `certificate` VARCHAR(45), "
@@ -222,19 +223,19 @@ const std::string kCreateSchema =
" ON `device_consent_group`(`device_id`); "
"CREATE TABLE IF NOT EXISTS `app_level`( "
" `application_id` VARCHAR(45) PRIMARY KEY NOT NULL, "
- " `minutes_in_hmi_full` INTEGER, "
- " `minutes_in_hmi_limited` INTEGER, "
- " `minutes_in_hmi_background` INTEGER, "
- " `minutes_in_hmi_none` INTEGER, "
- " `count_of_rfcom_limit_reached` INTEGER, "
- " `count_of_user_selections` INTEGER, "
- " `count_of_rejections_sync_out_of_memory` INTEGER, "
- " `count_of_rejections_nickname_mismatch` INTEGER, "
- " `count_of_rejections_duplicate_name` INTEGER, "
- " `count_of_rejected_rpcs_calls` INTEGER, "
- " `count_of_rpcs_sent_in_hmi_none` INTEGER, "
- " `count_of_removals_for_bad_behavior` INTEGER, "
- " `count_of_run_attempts_while_revoked` INTEGER, "
+ " `minutes_in_hmi_full` INTEGER DEFAULT 0, "
+ " `minutes_in_hmi_limited` INTEGER DEFAULT 0, "
+ " `minutes_in_hmi_background` INTEGER DEFAULT 0, "
+ " `minutes_in_hmi_none` INTEGER DEFAULT 0, "
+ " `count_of_rfcom_limit_reached` INTEGER DEFAULT 0, "
+ " `count_of_user_selections` INTEGER DEFAULT 0, "
+ " `count_of_rejections_sync_out_of_memory` INTEGER DEFAULT 0, "
+ " `count_of_rejections_nickname_mismatch` INTEGER DEFAULT 0, "
+ " `count_of_rejections_duplicate_name` INTEGER DEFAULT 0, "
+ " `count_of_rejected_rpcs_calls` INTEGER DEFAULT 0, "
+ " `count_of_rpcs_sent_in_hmi_none` INTEGER DEFAULT 0, "
+ " `count_of_removals_for_bad_behavior` INTEGER DEFAULT 0, "
+ " `count_of_run_attempts_while_revoked` INTEGER DEFAULT 0, "
" `app_registration_language_gui` VARCHAR(25), "
" `app_registration_language_vui` VARCHAR(25), "
" CONSTRAINT `fk_app_levels_application1` "
@@ -307,7 +308,7 @@ const std::string kCreateSchema =
"CREATE INDEX IF NOT EXISTS `endpoint.fk_endpoint_application1_idx` "
" ON `endpoint`(`application_id`); "
"CREATE TABLE IF NOT EXISTS `message`( "
- " `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "
+ " `id` INTEGER PRIMARY KEY NOT NULL, "
" `tts` TEXT, "
" `label` TEXT, "
" `line1` TEXT, "
@@ -569,6 +570,8 @@ const std::string kSelectApplicationIsDefault =
const std::string kUpdateIsDefault =
"UPDATE `application` SET `is_default` = ? WHERE `id` = ?";
+const std::string kDeleteDevice = "DELETE FROM `device` WHERE `id` = ?";
+
} // namespace sql_pt
} // namespace policy
diff --git a/src/components/policy/src/policy/src/sql_pt_representation.cc b/src/components/policy/src/policy/src/sql_pt_representation.cc
index 742816e09..23322d8ab 100644
--- a/src/components/policy/src/policy/src/sql_pt_representation.cc
+++ b/src/components/policy/src/policy/src/sql_pt_representation.cc
@@ -31,12 +31,18 @@
*/
#include <sstream>
+#include "utils/logger.h"
#include "policy/sql_pt_representation.h"
#include "policy/sql_wrapper.h"
#include "policy/sql_pt_queries.h"
+#ifndef __QNX__
+# include "config_profile/profile.h"
+#endif // __QNX__
namespace policy {
+CREATE_LOGGERPTR_GLOBAL(logger_, "SQLPTRepresentation")
+
namespace {
template<typename T, typename K> void InsertUnique(K value, T* array) {
int i = 0;
@@ -49,13 +55,17 @@ template<typename T, typename K> void InsertUnique(K value, T* array) {
}
} // namespace
-log4cxx::LoggerPtr SQLPTRepresentation::logger_ = log4cxx::LoggerPtr(
- log4cxx::Logger::getLogger("SQLPTRepresentation"));
const std::string SQLPTRepresentation::kDatabaseName = "policy";
SQLPTRepresentation::SQLPTRepresentation()
: db_(new dbms::SQLDatabase(kDatabaseName)) {
+#ifndef __QNX__
+ std::string path = profile::Profile::instance()->app_storage_folder();
+ if (!path.empty()) {
+ db_->set_path(path + "/");
+ }
+#endif // __QNX__
}
SQLPTRepresentation::~SQLPTRepresentation() {
@@ -65,8 +75,8 @@ SQLPTRepresentation::~SQLPTRepresentation() {
CheckPermissionResult SQLPTRepresentation::CheckPermissions(
const PTString& app_id, const PTString& hmi_level, const PTString& rpc) {
- CheckPermissionResult result(false);
- dbms::SQLQuery query(db_);
+ CheckPermissionResult result;
+ dbms::SQLQuery query(db());
if (!query.Prepare(sql_pt::kSelectRpc)) {
LOG4CXX_WARN(
@@ -79,11 +89,11 @@ CheckPermissionResult SQLPTRepresentation::CheckPermissions(
query.Bind(2, rpc);
bool ret = query.Next();
- result.hmi_level_permitted = ret;
+ result.hmi_level_permitted = ret ? kRpcAllowed : kRpcDisallowed;
LOG4CXX_INFO(
logger_,
"Level is "
- << (result.hmi_level_permitted ? "permitted" : "not permitted"));
+ << (result.hmi_level_permitted == kRpcAllowed ? "permitted" : "not permitted"));
std::string parameter;
while (ret) {
if (!query.IsNull(0)) {
@@ -100,12 +110,12 @@ CheckPermissionResult SQLPTRepresentation::CheckPermissions(
}
bool SQLPTRepresentation::IsPTPreloaded() {
- dbms::SQLQuery query(db_);
+ dbms::SQLQuery query(db());
return query.Prepare(sql_pt::kSelectPreloaded) && query.Next();
}
int SQLPTRepresentation::IgnitionCyclesBeforeExchange() {
- dbms::SQLQuery query(db_);
+ dbms::SQLQuery query(db());
if (!query.Prepare(sql_pt::kSelectIgnitionCycles) || !query.Exec()) {
LOG4CXX_WARN(logger_, "Can not select ignition cycles");
return 0;
@@ -121,7 +131,7 @@ int SQLPTRepresentation::IgnitionCyclesBeforeExchange() {
}
int SQLPTRepresentation::KilometersBeforeExchange(int current) {
- dbms::SQLQuery query(db_);
+ dbms::SQLQuery query(db());
if (!query.Prepare(sql_pt::kSelectKilometers) || !query.Exec()) {
LOG4CXX_WARN(logger_, "Can not select kilometers");
return 0;
@@ -141,7 +151,7 @@ bool SQLPTRepresentation::SetCountersPassedForSuccessfulUpdate(
int kilometers, int days_after_epoch) {
LOG4CXX_INFO(logger_,
"SQLPTRepresentation::SetCountersPassedForSuccessfulUpdate");
- dbms::SQLQuery query(db_);
+ dbms::SQLQuery query(db());
if (!query.Prepare(sql_pt::kUpdateCountersSuccessfulUpdate)) {
LOG4CXX_WARN(logger_,
"Wrong update query for counters on successful update.");
@@ -157,7 +167,7 @@ bool SQLPTRepresentation::SetCountersPassedForSuccessfulUpdate(
}
int SQLPTRepresentation::DaysBeforeExchange(int current) {
- dbms::SQLQuery query(db_);
+ dbms::SQLQuery query(db());
if (!query.Prepare(sql_pt::kSelectDays) || !query.Exec()) {
LOG4CXX_WARN(logger_, "Can not select days");
return 0;
@@ -178,7 +188,7 @@ int SQLPTRepresentation::DaysBeforeExchange(int current) {
}
int SQLPTRepresentation::TimeoutResponse() {
- dbms::SQLQuery query(db_);
+ dbms::SQLQuery query(db());
if (!query.Prepare(sql_pt::kSelectTimeoutResponse) || !query.Exec()) {
LOG4CXX_INFO(logger_, "Can not select timeout response for retry sequence");
const int kDefault = 30;
@@ -188,7 +198,7 @@ int SQLPTRepresentation::TimeoutResponse() {
}
bool SQLPTRepresentation::SecondsBetweenRetries(std::vector<int>* seconds) {
- dbms::SQLQuery query(db_);
+ dbms::SQLQuery query(db());
if (!query.Prepare(sql_pt::kSelectSecondsBetweenRetries)) {
LOG4CXX_INFO(logger_,
"Incorrect select statement from seconds between retries");
@@ -202,17 +212,26 @@ bool SQLPTRepresentation::SecondsBetweenRetries(std::vector<int>* seconds) {
std::vector<UserFriendlyMessage> SQLPTRepresentation::GetUserFriendlyMsg(
const std::vector<std::string>& msg_codes, const std::string& language) {
- return std::vector<UserFriendlyMessage>();
+ std::vector<UserFriendlyMessage> result;
+ std::vector<std::string>::const_iterator it = msg_codes.begin();
+ std::vector<std::string>::const_iterator it_end = msg_codes.end();
+ for (; it != it_end; ++it) {
+ UserFriendlyMessage msg;
+ msg.message_code = *it;
+ result.push_back(msg);
+ }
+ return result;
}
EndpointUrls SQLPTRepresentation::GetUpdateUrls(int service_type) {
LOG4CXX_INFO(logger_, "SQLPTRepresentation::GetUpdateUrls for " << service_type);
- dbms::SQLQuery query(db_);
+ dbms::SQLQuery query(db());
EndpointUrls ret;
if (query.Prepare(sql_pt::kSelectEndpoint)) {
query.Bind(0, service_type);
while (query.Next()) {
EndpointData data;
+
data.url = query.GetString(0);
if (!query.IsNull(1)) {
data.app_id = query.GetString(1);
@@ -234,15 +253,15 @@ InitResult SQLPTRepresentation::Init() {
LOG4CXX_INFO(logger_, "SQLPTRepresentation::Init");
if (!db_->Open()) {
- LOG4CXX_INFO(logger_, "Failed opening database");
+ LOG4CXX_ERROR(logger_, "Failed opening database");
return InitResult::FAIL;
}
- dbms::SQLQuery check_pages(db_);
+ dbms::SQLQuery check_pages(db());
if (!check_pages.Prepare(sql_pt::kCheckPgNumber) || !check_pages.Next()) {
LOG4CXX_WARN(logger_, "Incorrect pragma for page counting.");
} else {
if (0 < check_pages.GetInteger(0)) {
- dbms::SQLQuery db_check(db_);
+ dbms::SQLQuery db_check(db());
if (!db_check.Prepare(sql_pt::kCheckDBIntegrity)) {
LOG4CXX_WARN(logger_, "Incorrect pragma for integrity check.");
} else {
@@ -259,7 +278,7 @@ InitResult SQLPTRepresentation::Init() {
}
}
}
- dbms::SQLQuery query(db_);
+ dbms::SQLQuery query(db());
if (!query.Exec(sql_pt::kCreateSchema)) {
LOG4CXX_INFO(
logger_,
@@ -279,7 +298,7 @@ VehicleData SQLPTRepresentation::GetVehicleData() {
}
bool SQLPTRepresentation::Clear() {
- dbms::SQLQuery query(db_);
+ dbms::SQLQuery query(db());
if (!query.Exec(sql_pt::kDropSchema)) {
LOG4CXX_WARN(logger_,
"Failed clearing database: " << query.LastError().text());
@@ -291,10 +310,10 @@ bool SQLPTRepresentation::Clear() {
utils::SharedPtr<policy_table::Table> SQLPTRepresentation::GenerateSnapshot() const {
LOG4CXX_INFO(logger_, "GenerateSnapshot");
utils::SharedPtr<policy_table::Table> table = new policy_table::Table();
- GatherModuleMeta(&table->policy_table.module_meta);
+ GatherModuleMeta(&*table->policy_table.module_meta);
GatherModuleConfig(&table->policy_table.module_config);
- GatherUsageAndErrorCounts(&table->policy_table.usage_and_error_counts);
- GatherDeviceData(&table->policy_table.device_data);
+ GatherUsageAndErrorCounts(&*table->policy_table.usage_and_error_counts);
+ GatherDeviceData(&*table->policy_table.device_data);
GatherFunctionalGroupings(&table->policy_table.functional_groupings);
GatherConsumerFriendlyMessages(
&table->policy_table.consumer_friendly_messages);
@@ -305,13 +324,14 @@ utils::SharedPtr<policy_table::Table> SQLPTRepresentation::GenerateSnapshot() co
void SQLPTRepresentation::GatherModuleMeta(
policy_table::ModuleMeta* meta) const {
LOG4CXX_INFO(logger_, "Gather Module Meta Info");
+ meta->mark_initialized();
// Section Module Meta is empty for SDL specific
}
void SQLPTRepresentation::GatherModuleConfig(
policy_table::ModuleConfig* config) const {
LOG4CXX_INFO(logger_, "Gather Configuration Info");
- dbms::SQLQuery query(db_);
+ dbms::SQLQuery query(db());
if (!query.Prepare(sql_pt::kSelectModuleConfig) || !query.Next()) {
LOG4CXX_WARN(logger_, "Incorrect select statement for module config");
} else {
@@ -325,19 +345,19 @@ void SQLPTRepresentation::GatherModuleConfig(
*config->vehicle_year = query.GetInteger(7);
}
- dbms::SQLQuery endpoints(db_);
+ dbms::SQLQuery endpoints(db());
if (!endpoints.Prepare(sql_pt::kSelectEndpoints)) {
LOG4CXX_WARN(logger_, "Incorrect select statement for endpoints");
} else {
while (endpoints.Next()) {
std::stringstream stream;
stream << "0x0" << endpoints.GetInteger(1);
- config->endpoints[endpoints.GetString(2)][stream.str()]
+ config->endpoints[stream.str()][endpoints.GetString(2)]
.push_back(endpoints.GetString(0));
}
}
- dbms::SQLQuery notifications(db_);
+ dbms::SQLQuery notifications(db());
if (!notifications.Prepare(sql_pt::kSelectNotificationsPerMin)) {
LOG4CXX_WARN(logger_, "Incorrect select statement for notifications");
} else {
@@ -346,7 +366,7 @@ void SQLPTRepresentation::GatherModuleConfig(
notifications.GetInteger(1);
}
}
- dbms::SQLQuery seconds(db_);
+ dbms::SQLQuery seconds(db());
if (!seconds.Prepare(sql_pt::kSelectSecondsBetweenRetries)) {
LOG4CXX_INFO(logger_,
"Incorrect select statement from seconds between retries");
@@ -360,10 +380,12 @@ void SQLPTRepresentation::GatherModuleConfig(
bool SQLPTRepresentation::GatherUsageAndErrorCounts(
policy_table::UsageAndErrorCounts* counts) const {
LOG4CXX_INFO(logger_, "Gather Usage and Error Counts.");
- dbms::SQLQuery query(db_);
+ dbms::SQLQuery query(db());
if (query.Prepare(sql_pt::kSelectAppLevels)) {
+ policy_table::AppLevel app_level_empty;
+ app_level_empty.mark_initialized();
while (query.Next()) {
- counts->app_level[query.GetString(0)] = policy_table::AppLevel();
+ (*counts->app_level)[query.GetString(0)] = app_level_empty;
}
}
return true;
@@ -372,10 +394,12 @@ bool SQLPTRepresentation::GatherUsageAndErrorCounts(
void SQLPTRepresentation::GatherDeviceData(
policy_table::DeviceData* data) const {
LOG4CXX_INFO(logger_, "Gather device data.");
- dbms::SQLQuery query(db_);
+ dbms::SQLQuery query(db());
if (query.Prepare(sql_pt::kSelectDeviceData)) {
+ policy_table::DeviceParams device_data_empty;
+ device_data_empty.mark_initialized();
while (query.Next()) {
- (*data)[query.GetString(0)] = policy_table::DeviceParams();
+ (*data)[query.GetString(0)] = device_data_empty;
}
}
}
@@ -383,12 +407,12 @@ void SQLPTRepresentation::GatherDeviceData(
bool SQLPTRepresentation::GatherFunctionalGroupings(
policy_table::FunctionalGroupings* groups) const {
LOG4CXX_INFO(logger_, "Gather Functional Groupings info");
- dbms::SQLQuery func_group(db_);
+ dbms::SQLQuery func_group(db());
if (!func_group.Prepare(sql_pt::kSelectFunctionalGroups)) {
LOG4CXX_WARN(logger_, "Incorrect select from functional_groupings");
return false;
}
- dbms::SQLQuery rpcs(db_);
+ dbms::SQLQuery rpcs(db());
if (!rpcs.Prepare(sql_pt::kSelectAllRpcs)) {
LOG4CXX_WARN(logger_, "Incorrect select all from rpc");
return false;
@@ -403,13 +427,16 @@ bool SQLPTRepresentation::GatherFunctionalGroupings(
while (rpcs.Next()) {
if (!rpcs.IsNull(1)) {
policy_table::HmiLevel level;
- policy_table::EnumFromJsonString(rpcs.GetString(1), &level);
- InsertUnique(level, &rpcs_tbl.rpcs[rpcs.GetString(0)].hmi_levels);
+ if (policy_table::EnumFromJsonString(rpcs.GetString(1), &level)) {
+ InsertUnique(level, &rpcs_tbl.rpcs[rpcs.GetString(0)].hmi_levels);
+ }
}
if (!rpcs.IsNull(2)) {
policy_table::Parameter param;
- policy_table::EnumFromJsonString(rpcs.GetString(2), &param);
- InsertUnique(param, &(rpcs_tbl.rpcs[rpcs.GetString(0)].parameters));
+ if (policy_table::EnumFromJsonString(rpcs.GetString(2), &param)) {
+ // TODO(IKozyrenko): Check logic if optional container is missing
+ InsertUnique(param, &(*rpcs_tbl.rpcs[rpcs.GetString(0)].parameters));
+ }
}
}
rpcs.Reset();
@@ -421,7 +448,7 @@ bool SQLPTRepresentation::GatherFunctionalGroupings(
bool SQLPTRepresentation::GatherConsumerFriendlyMessages(
policy_table::ConsumerFriendlyMessages* messages) const {
LOG4CXX_INFO(logger_, "Gather Consumer Friendly Messages");
- dbms::SQLQuery query(db_);
+ dbms::SQLQuery query(db());
if (!query.Prepare(sql_pt::kSelectUserMsgsVersion) || !query.Next()) {
LOG4CXX_WARN(logger_, "Incorrect select from consumer_friendly_messages");
return false;
@@ -433,27 +460,34 @@ bool SQLPTRepresentation::GatherConsumerFriendlyMessages(
bool SQLPTRepresentation::GatherApplicationPolicies(
policy_table::ApplicationPolicies* apps) const {
LOG4CXX_INFO(logger_, "Gather applications policies");
- dbms::SQLQuery query(db_);
+ dbms::SQLQuery query(db());
if (!query.Prepare(sql_pt::kSelectAppPolicies)) {
LOG4CXX_WARN(logger_, "Incorrect select from app_policies");
return false;
}
while (query.Next()) {
- policy_table::ApplicationParams params;
+ rpc::Nullable<policy_table::ApplicationParams> params;
const std::string& app_id = query.GetString(0);
- params.memory_kb = query.GetInteger(1);
- params.watchdog_timer_ms = query.GetInteger(2);
+ if (IsApplicationRevoked(app_id)) {
+ params.set_to_null();
+ (*apps)[app_id] = params;
+ continue;
+ }
+ *params.memory_kb = query.GetInteger(1);
+ *params.watchdog_timer_ms = query.GetInteger(2);
if (!query.IsNull(3)) {
*params.certificate = query.GetString(3);
}
if (!GatherAppGroup(app_id, &params.groups)) {
return false;
}
- if (!GatherNickName(app_id, &params.nicknames)) {
+ // TODO(IKozyrenko): Check logic if optional container is missing
+ if (!GatherNickName(app_id, &*params.nicknames)) {
return false;
}
- if (!GatherAppType(app_id, &params.AppHMIType)) {
+ // TODO(IKozyrenko): Check logic if optional container is missing
+ if (!GatherAppType(app_id, &*params.AppHMIType)) {
return false;
}
(*apps)[app_id] = params;
@@ -481,15 +515,15 @@ bool SQLPTRepresentation::Save(const policy_table::Table& table) {
db_->RollbackTransaction();
return false;
}
- if (!SaveDeviceData(table.policy_table.device_data)) {
+ if (!SaveDeviceData(*table.policy_table.device_data)) {
db_->RollbackTransaction();
return false;
}
- if (!SaveUsageAndErrorCounts(table.policy_table.usage_and_error_counts)) {
+ if (!SaveUsageAndErrorCounts(*table.policy_table.usage_and_error_counts)) {
db_->RollbackTransaction();
return false;
}
- if (!SaveModuleMeta(table.policy_table.module_meta)) {
+ if (!SaveModuleMeta(*table.policy_table.module_meta)) {
db_->RollbackTransaction();
return false;
}
@@ -500,13 +534,13 @@ bool SQLPTRepresentation::Save(const policy_table::Table& table) {
bool SQLPTRepresentation::SaveFunctionalGroupings(
const policy_table::FunctionalGroupings& groups) {
LOG4CXX_INFO(logger_, "SaveFunctionalGroupings");
- dbms::SQLQuery query_delete(db_);
+ dbms::SQLQuery query_delete(db());
if (!query_delete.Exec(sql_pt::kDeleteRpc)) {
LOG4CXX_WARN(logger_, "Incorrect delete from rpc.");
return false;
}
- dbms::SQLQuery query(db_);
+ dbms::SQLQuery query(db());
if (!query.Exec(sql_pt::kDeleteFunctionalGroup)) {
LOG4CXX_WARN(logger_, "Incorrect delete from seconds between retries.");
return false;
@@ -536,8 +570,8 @@ bool SQLPTRepresentation::SaveFunctionalGroupings(
bool SQLPTRepresentation::SaveRpcs(int64_t group_id,
const policy_table::Rpc& rpcs) {
- dbms::SQLQuery query(db_);
- dbms::SQLQuery query_parameter(db_);
+ dbms::SQLQuery query(db());
+ dbms::SQLQuery query_parameter(db());
if (!query.Prepare(sql_pt::kInsertRpc)
|| !query_parameter.Prepare(sql_pt::kInsertRpcWithParameter)) {
LOG4CXX_WARN(logger_, "Incorrect insert statement for rpc");
@@ -547,7 +581,8 @@ bool SQLPTRepresentation::SaveRpcs(int64_t group_id,
policy_table::Rpc::const_iterator it;
for (it = rpcs.begin(); it != rpcs.end(); ++it) {
const policy_table::HmiLevels& hmi_levels = it->second.hmi_levels;
- const policy_table::Parameters& parameters = it->second.parameters;
+ // TODO(IKozyrenko): Check logic if optional container is missing
+ const policy_table::Parameters& parameters = *it->second.parameters;
policy_table::HmiLevels::const_iterator hmi_it;
policy_table::Parameters::const_iterator ps_it;
for (hmi_it = hmi_levels.begin(); hmi_it != hmi_levels.end(); ++hmi_it) {
@@ -582,7 +617,7 @@ bool SQLPTRepresentation::SaveRpcs(int64_t group_id,
bool SQLPTRepresentation::SaveApplicationPolicies(
const policy_table::ApplicationPolicies& apps) {
LOG4CXX_INFO(logger_, "SaveApplicationPolicies");
- dbms::SQLQuery query_delete(db_);
+ dbms::SQLQuery query_delete(db());
if (!query_delete.Exec(sql_pt::kDeleteAppGroup)) {
LOG4CXX_WARN(logger_, "Incorrect delete from app_group.");
return false;
@@ -592,7 +627,7 @@ bool SQLPTRepresentation::SaveApplicationPolicies(
return false;
}
policy_table::ApplicationPolicies::const_iterator it;
- dbms::SQLQuery app_query(db_);
+ dbms::SQLQuery app_query(db());
if (!app_query.Prepare(sql_pt::kInsertApplication)) {
LOG4CXX_WARN(logger_, "Incorrect insert statement into application.");
return false;
@@ -603,7 +638,7 @@ bool SQLPTRepresentation::SaveApplicationPolicies(
app_query.Bind(2, it->second.memory_kb);
app_query.Bind(3, it->second.watchdog_timer_ms);
it->second.certificate.is_initialized() ?
- app_query.Bind(4, it->second.certificate) : app_query.Bind(4);
+ app_query.Bind(4, *it->second.certificate) : app_query.Bind(4);
if (!app_query.Exec() || !app_query.Reset()) {
LOG4CXX_WARN(logger_, "Incorrect insert into application.");
@@ -614,10 +649,12 @@ bool SQLPTRepresentation::SaveApplicationPolicies(
if (!SaveAppGroup(it->first, it->second.groups)) {
return false;
}
- if (!SaveNickname(it->first, it->second.nicknames)) {
+ // TODO(IKozyrenko): Check logic if optional container is missing
+ if (!SaveNickname(it->first, *it->second.nicknames)) {
return false;
}
- if (!SaveAppType(it->first, it->second.AppHMIType)) {
+ // TODO(IKozyrenko): Check logic if optional container is missing
+ if (!SaveAppType(it->first, *it->second.AppHMIType)) {
return false;
}
}
@@ -627,7 +664,7 @@ bool SQLPTRepresentation::SaveApplicationPolicies(
bool SQLPTRepresentation::SaveAppGroup(
const std::string& app_id, const policy_table::Strings& app_groups) {
- dbms::SQLQuery query(db_);
+ dbms::SQLQuery query(db());
if (!query.Prepare(sql_pt::kInsertAppGroup)) {
LOG4CXX_WARN(logger_, "Incorrect insert statement for app group");
return false;
@@ -652,7 +689,7 @@ bool SQLPTRepresentation::SaveAppGroup(
bool SQLPTRepresentation::SaveNickname(const std::string& app_id,
const policy_table::Strings& nicknames) {
- dbms::SQLQuery query(db_);
+ dbms::SQLQuery query(db());
if (!query.Prepare(sql_pt::kInsertNickname)) {
LOG4CXX_WARN(logger_, "Incorrect insert statement for nickname");
return false;
@@ -673,7 +710,7 @@ bool SQLPTRepresentation::SaveNickname(const std::string& app_id,
bool SQLPTRepresentation::SaveAppType(const std::string& app_id,
const policy_table::AppHMITypes& types) {
- dbms::SQLQuery query(db_);
+ dbms::SQLQuery query(db());
if (!query.Prepare(sql_pt::kInsertAppType)) {
LOG4CXX_WARN(logger_, "Incorrect insert statement for app type");
return false;
@@ -701,7 +738,7 @@ bool SQLPTRepresentation::SaveModuleMeta(const policy_table::ModuleMeta& meta) {
bool SQLPTRepresentation::SaveModuleConfig(
const policy_table::ModuleConfig& config) {
LOG4CXX_INFO(logger_, "SaveModuleConfig");
- dbms::SQLQuery query(db_);
+ dbms::SQLQuery query(db());
if (!query.Prepare(sql_pt::kUpdateModuleConfig)) {
LOG4CXX_WARN(logger_, "Incorrect update statement for module config");
return false;
@@ -743,7 +780,7 @@ bool SQLPTRepresentation::SaveModuleConfig(
bool SQLPTRepresentation::SaveServiceEndpoints(
const policy_table::ServiceEndpoints& endpoints) {
- dbms::SQLQuery query(db_);
+ dbms::SQLQuery query(db());
if (!query.Exec(sql_pt::kDeleteEndpoint)) {
LOG4CXX_WARN(logger_, "Incorrect delete from endpoint.");
return false;
@@ -784,7 +821,7 @@ bool SQLPTRepresentation::SaveConsumerFriendlyMessages(
const policy_table::ConsumerFriendlyMessages& messages) {
LOG4CXX_INFO(logger_, "SaveConsumerFriendlyMessages");
- dbms::SQLQuery query(db_);
+ dbms::SQLQuery query(db());
if (!query.Exec(sql_pt::kDeleteMessageString)) {
LOG4CXX_WARN(logger_, "Incorrect delete from message.");
return false;
@@ -802,7 +839,8 @@ bool SQLPTRepresentation::SaveConsumerFriendlyMessages(
}
policy_table::Messages::const_iterator it;
- for (it = messages.messages.begin(); it != messages.messages.end(); ++it) {
+ // TODO(IKozyrenko): Check logic if optional container is missing
+ for (it = messages.messages->begin(); it != messages.messages->end(); ++it) {
if (!SaveMessageType(it->first)) {
return false;
}
@@ -822,7 +860,7 @@ bool SQLPTRepresentation::SaveConsumerFriendlyMessages(
}
bool SQLPTRepresentation::SaveMessageType(const std::string& type) {
- dbms::SQLQuery query(db_);
+ dbms::SQLQuery query(db());
if (!query.Prepare(sql_pt::kInsertMessageType)) {
LOG4CXX_WARN(logger_, "Incorrect insert statement for message type.");
return false;
@@ -838,7 +876,7 @@ bool SQLPTRepresentation::SaveMessageType(const std::string& type) {
}
bool SQLPTRepresentation::SaveLanguage(const std::string& code) {
- dbms::SQLQuery query(db_);
+ dbms::SQLQuery query(db());
if (!query.Prepare(sql_pt::kInsertLanguage)) {
LOG4CXX_WARN(logger_, "Incorrect insert statement for language.");
return false;
@@ -862,7 +900,7 @@ bool SQLPTRepresentation::SaveMessageString(
bool SQLPTRepresentation::SaveSecondsBetweenRetries(
const policy_table::SecondsBetweenRetries& seconds) {
- dbms::SQLQuery query(db_);
+ dbms::SQLQuery query(db());
if (!query.Exec(sql_pt::kDeleteSecondsBetweenRetries)) {
LOG4CXX_WARN(logger_, "Incorrect delete from seconds between retries.");
return false;
@@ -887,7 +925,7 @@ bool SQLPTRepresentation::SaveSecondsBetweenRetries(
bool SQLPTRepresentation::SaveNumberOfNotificationsPerMinute(
const policy_table::NumberOfNotificationsPerMinute& notifications) {
- dbms::SQLQuery query(db_);
+ dbms::SQLQuery query(db());
if (!query.Prepare(sql_pt::kInsertNotificationsByPriority)) {
LOG4CXX_WARN(logger_,
"Incorrect insert statement for notifications by priority.");
@@ -910,7 +948,7 @@ bool SQLPTRepresentation::SaveNumberOfNotificationsPerMinute(
bool SQLPTRepresentation::SaveDeviceData(
const policy_table::DeviceData& devices) {
LOG4CXX_INFO(logger_, "SaveDeviceData");
- dbms::SQLQuery query(db_);
+ dbms::SQLQuery query(db());
if (!query.Prepare(sql_pt::kInsertDeviceData)) {
LOG4CXX_WARN(logger_, "Incorrect insert statement for device data.");
return false;
@@ -931,7 +969,7 @@ bool SQLPTRepresentation::SaveDeviceData(
bool SQLPTRepresentation::SaveUsageAndErrorCounts(
const policy_table::UsageAndErrorCounts& counts) {
LOG4CXX_INFO(logger_, "SaveUsageAndErrorCounts");
- dbms::SQLQuery query(db_);
+ dbms::SQLQuery query(db());
if (!query.Exec(sql_pt::kDeleteAppLevel)) {
LOG4CXX_WARN(logger_, "Incorrect delete from app level.");
return false;
@@ -942,7 +980,8 @@ bool SQLPTRepresentation::SaveUsageAndErrorCounts(
}
policy_table::AppLevels::const_iterator it;
- for (it = counts.app_level.begin(); it != counts.app_level.end(); ++it) {
+ const policy_table::AppLevels& app_levels = *counts.app_level;
+ for (it = app_levels.begin(); it != app_levels.end(); ++it) {
query.Bind(0, it->first);
if (!query.Exec()) {
LOG4CXX_WARN(logger_, "Incorrect insert into app level.");
@@ -954,7 +993,7 @@ bool SQLPTRepresentation::SaveUsageAndErrorCounts(
}
void SQLPTRepresentation::IncrementIgnitionCycles() {
- dbms::SQLQuery query(db_);
+ dbms::SQLQuery query(db());
if (!query.Exec(sql_pt::kIncrementIgnitionCycles)) {
LOG4CXX_WARN(logger_, "Failed incrementing ignition cycles");
}
@@ -962,14 +1001,14 @@ void SQLPTRepresentation::IncrementIgnitionCycles() {
void SQLPTRepresentation::ResetIgnitionCycles() {
LOG4CXX_INFO(logger_, "ResetIgnitionCycles");
- dbms::SQLQuery query(db_);
+ dbms::SQLQuery query(db());
if (!query.Exec(sql_pt::kResetIgnitionCycles)) {
LOG4CXX_WARN(logger_, "Failed to reset ignition cycles number.");
}
}
bool SQLPTRepresentation::UpdateRequired() const {
- dbms::SQLQuery query(db_);
+ dbms::SQLQuery query(db());
if (!query.Prepare(sql_pt::kSelectFlagUpdateRequired) || !query.Exec()) {
LOG4CXX_WARN(logger_,
"Failed select update required flag from module meta");
@@ -979,7 +1018,7 @@ bool SQLPTRepresentation::UpdateRequired() const {
}
void SQLPTRepresentation::SaveUpdateRequired(bool value) {
- dbms::SQLQuery query(db_);
+ dbms::SQLQuery query(db());
if (!query.Prepare(sql_pt::kUpdateFlagUpdateRequired)) {
LOG4CXX_WARN(logger_,
"Incorrect update into module meta (update_required)");
@@ -995,12 +1034,12 @@ bool SQLPTRepresentation::GetInitialAppData(const std::string& app_id,
StringArray* nicknames,
StringArray* app_types) {
LOG4CXX_INFO(logger_, "Getting initial application data.");
- dbms::SQLQuery app_names(db_);
+ dbms::SQLQuery app_names(db());
if (!app_names.Prepare(sql_pt::kSelectNicknames)) {
LOG4CXX_WARN(logger_, "Incorrect select from app nicknames");
return false;
}
- dbms::SQLQuery app_hmi_types(db_);
+ dbms::SQLQuery app_hmi_types(db());
if (!app_hmi_types.Prepare(sql_pt::kSelectAppTypes)) {
LOG4CXX_WARN(logger_, "Incorrect select from app types");
return false;
@@ -1020,13 +1059,13 @@ bool SQLPTRepresentation::GetInitialAppData(const std::string& app_id,
bool SQLPTRepresentation::GetFunctionalGroupings(
policy_table::FunctionalGroupings& groups) {
- LOG4CXX_INFO(logger(), "GetFunctionalGroupings");
+ LOG4CXX_INFO(logger_, "GetFunctionalGroupings");
return GatherFunctionalGroupings(&groups);
}
bool SQLPTRepresentation::GatherAppType(
const std::string& app_id, policy_table::AppHMITypes* app_types) const {
- dbms::SQLQuery query(db_);
+ dbms::SQLQuery query(db());
if (!query.Prepare(sql_pt::kSelectAppTypes)) {
LOG4CXX_WARN(logger_, "Incorrect select from app types");
return false;
@@ -1045,7 +1084,7 @@ bool SQLPTRepresentation::GatherAppType(
bool SQLPTRepresentation::GatherNickName(
const std::string& app_id, policy_table::Strings* nicknames) const {
- dbms::SQLQuery query(db_);
+ dbms::SQLQuery query(db());
if (!query.Prepare(sql_pt::kSelectNicknames)) {
LOG4CXX_WARN(logger_, "Incorrect select from app nicknames");
return false;
@@ -1060,7 +1099,7 @@ bool SQLPTRepresentation::GatherNickName(
bool SQLPTRepresentation::GatherAppGroup(
const std::string& app_id, policy_table::Strings* app_groups) const {
- dbms::SQLQuery query(db_);
+ dbms::SQLQuery query(db());
if (!query.Prepare(sql_pt::kSelectAppGroups)) {
LOG4CXX_WARN(logger_, "Incorrect select from app groups");
return false;
@@ -1075,7 +1114,7 @@ bool SQLPTRepresentation::GatherAppGroup(
bool SQLPTRepresentation::IsApplicationRevoked(
const std::string& app_id) const {
- dbms::SQLQuery query(db_);
+ dbms::SQLQuery query(db());
if (!query.Prepare(sql_pt::kSelectApplicationRevoked)) {
LOG4CXX_WARN(logger_, "Incorrect select from is_revoked of application");
return false;
@@ -1091,7 +1130,7 @@ bool SQLPTRepresentation::IsApplicationRevoked(
bool SQLPTRepresentation::IsApplicationRepresented(
const std::string& app_id) const {
- dbms::SQLQuery query(db_);
+ dbms::SQLQuery query(db());
if (!query.Prepare(sql_pt::kSelectApplicationRepresented)) {
LOG4CXX_WARN(logger_, "Incorrect select application by id");
return false;
@@ -1106,7 +1145,7 @@ bool SQLPTRepresentation::IsApplicationRepresented(
}
bool SQLPTRepresentation::IsDefaultPolicy(const std::string& app_id) const {
- dbms::SQLQuery query(db_);
+ dbms::SQLQuery query(db());
if (!query.Prepare(sql_pt::kSelectApplicationIsDefault)) {
LOG4CXX_WARN(logger_, "Incorrect select application by id");
return false;
@@ -1120,13 +1159,17 @@ bool SQLPTRepresentation::IsDefaultPolicy(const std::string& app_id) const {
return query.IsNull(0) ? false : query.GetBoolean(0);
}
+bool SQLPTRepresentation::IsPredataPolicy(const std::string& app_id) const {
+ return false;
+}
+
bool SQLPTRepresentation::SetDefaultPolicy(const std::string& app_id) {
policy_table::ApplicationPolicies apps;
if (!GatherApplicationPolicies(&apps)) {
LOG4CXX_WARN(logger_, "Failed gathering application policies");
return false;
}
- apps[app_id] = apps["default"];
+ apps[app_id] = apps[kDefaultId];
if (!SaveApplicationPolicies(apps)) {
LOG4CXX_WARN(logger_, "Failed saving application policies");
return false;
@@ -1135,12 +1178,32 @@ bool SQLPTRepresentation::SetDefaultPolicy(const std::string& app_id) {
return SetIsDefault(app_id, true);
}
+bool SQLPTRepresentation::CleanupUnpairedDevices(const DeviceIds& device_ids) {
+ LOG4CXX_INFO(logger_, "CleanupUnpairedDevices");
+ dbms::SQLQuery delete_device_query(db());
+ if (!delete_device_query.Prepare(sql_pt::kDeleteDevice)) {
+ LOG4CXX_WARN(logger_, "Incorrect statement for device delete.");
+ return true;
+ }
+
+ DeviceIds::const_iterator it = device_ids.begin();
+ DeviceIds::const_iterator it_end = device_ids.end();
+ for (; it != it_end; ++it) {
+ delete_device_query.Bind(0, (*it));
+ if (!delete_device_query.Exec() || !delete_device_query.Reset()) {
+ LOG4CXX_WARN(logger_, "Failed to delete from device");
+ return false;
+ }
+ }
+ return true;
+}
+
bool SQLPTRepresentation::SetIsDefault(const std::string& app_id,
bool is_default) {
LOG4CXX_TRACE(logger_, "Set flag is_default of application");
- dbms::SQLQuery query(db_);
+ dbms::SQLQuery query(db());
if (!query.Prepare(sql_pt::kUpdateIsDefault)) {
- LOG4CXX_WARN(logger_, "Incorect statement for updatign is_default");
+ LOG4CXX_WARN(logger_, "Incorect statement for updating is_default");
return false;
}
@@ -1153,5 +1216,15 @@ bool SQLPTRepresentation::SetIsDefault(const std::string& app_id,
return true;
}
+dbms::SQLDatabase* SQLPTRepresentation::db() const {
+#ifdef __QNX__
+ dbms::SQLDatabase* db = new dbms::SQLDatabase(kDatabaseName);
+ db->Open();
+ return db;
+#else
+ return db_;
+#endif
+}
+
} // namespace policy
diff --git a/src/components/policy/test/policy/CMakeLists.txt b/src/components/policy/test/policy/CMakeLists.txt
index bbecdd593..7d19dc213 100644
--- a/src/components/policy/test/policy/CMakeLists.txt
+++ b/src/components/policy/test/policy/CMakeLists.txt
@@ -8,6 +8,7 @@ include_directories(
${CMAKE_BINARY_DIR}/src/components/policy/src/policy/
${CMAKE_SOURCE_DIR}/src/components/rpc_base/include
${CMAKE_SOURCE_DIR}/src/components/policy/src/policy/sqlite_wrapper/include
+ ${CMAKE_SOURCE_DIR}/src/components/policy/src/policy/qdb_wrapper/include
${CMAKE_SOURCE_DIR}/src/components/policy/src/policy/usage_statistics/include
${CMAKE_SOURCE_DIR}/src/components/utils/include/
)
@@ -17,13 +18,20 @@ set(LIBRARIES
gtest_main
gmock
gmock_main
- dl
Policy
ConfigProfile
)
+set(SHARED_LIBRARY_LIBRARIES
+ gtest
+ gtest_main
+ gmock
+ gmock_main
+ dl
+)
+
if (CMAKE_SYSTEM_NAME STREQUAL "QNX")
- list(REMOVE_ITEM LIBRARIES dl)
+ list(REMOVE_ITEM SHARED_LIBRARY_LIBRARIES dl)
endif()
set(SHARED_LIBRARY_SOURCES
@@ -34,16 +42,11 @@ set(SQL_PT_REPRESENTATION_SOURCES
./src/test_sql_pt_representation.cc
)
-if (EXTENDED_POLICY_FLAG)
- if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
- set(SQL_PT_EXT_REPRESENTATION_SOURCES
- ./src/test_sql_pt_ext_representation.cc
- )
- create_test("test_SQLPTExtRepresentation" "${SQL_PT_EXT_REPRESENTATION_SOURCES}" "${LIBRARIES}")
- endif ()
-endif ()
-
set(GENERATED_CODE_SOURCES
+ ./src/generated_code_test.cc
+)
+
+set(GENERATED_CODE_WITH_SQLITE_SOURCES
./src/generated_code_with_sqlite_test.cc
)
@@ -57,15 +60,36 @@ set(STRESS_POLICY_MANAGER_IMPL_SOURCES
add_subdirectory(usage_statistics)
-if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
- # --- Tests for SQLite Wrapper
- add_subdirectory(sqlite_wrapper)
- create_test("test_generated_code_with_sqlite" "${GENERATED_CODE_SOURCES}" "${LIBRARIES}")
- create_test("test_SQLPTRepresentation" "${SQL_PT_REPRESENTATION_SOURCES}" "${LIBRARIES}")
+
+if (EXTENDED_POLICY_FLAG)
+ add_definitions(-DEXTENDED_POLICY)
+endif()
+
+if (CMAKE_SYSTEM_NAME STREQUAL "QNX")
+ # --- Tests for QDB Wrapper
+ add_subdirectory(qdb_wrapper)
+ file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/qdbserver.sh DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
+ file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/test-qdb.ini DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
+else ()
+ # --- Tests for SQLite Wrapper
+ add_subdirectory(sqlite_wrapper)
+ create_test("test_generated_code_with_sqlite" "${GENERATED_CODE_WITH_SQLITE_SOURCES}" "${LIBRARIES}")
+
+ if (EXTENDED_POLICY_FLAG)
+ set(SQL_PT_EXT_REPRESENTATION_SOURCES
+ ./src/test_sql_pt_ext_representation.cc
+ )
+ create_test("test_SQLPTExtRepresentation" "${SQL_PT_EXT_REPRESENTATION_SOURCES}" "${LIBRARIES}")
+ else ()
+ # TODO(KKolodiy): test crashes in QNX and failed for extended policy
+ create_test("test_stress_PolicyManagerImpl" "${STRESS_POLICY_MANAGER_IMPL_SOURCES}" "${LIBRARIES}")
+ endif ()
endif()
-create_test("test_SharedLibrary" "${SHARED_LIBRARY_SOURCES}" "${LIBRARIES}")
+create_test("test_generated_policy_code" "${GENERATED_CODE_SOURCES}" "${LIBRARIES}")
+create_test("test_SharedLibrary" "${SHARED_LIBRARY_SOURCES}" "${SHARED_LIBRARY_LIBRARIES}")
+create_test("test_SQLPTRepresentation" "${SQL_PT_REPRESENTATION_SOURCES}" "${LIBRARIES}")
create_test("test_PolicyManagerImpl" "${POLICY_MANAGER_IMPL_SOURCES}" "${LIBRARIES}")
-create_test("test_stress_PolicyManagerImpl" "${STRESS_POLICY_MANAGER_IMPL_SOURCES}" "${LIBRARIES}")
+file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/valid_sdl_pt_update.json DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/log4cxx.properties DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
diff --git a/src/components/policy/test/policy/include/mock_policy_listener.h b/src/components/policy/test/policy/include/mock_policy_listener.h
new file mode 100644
index 000000000..4a84bc2e4
--- /dev/null
+++ b/src/components/policy/test/policy/include/mock_policy_listener.h
@@ -0,0 +1,68 @@
+/* Copyright (c) 2014, Ford Motor Company
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of the Ford Motor Company nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef TEST_COMPONENTS_POLICY_INCLUDE_MOCK_POLICY_LISTENER_H_
+#define TEST_COMPONENTS_POLICY_INCLUDE_MOCK_POLICY_LISTENER_H_
+
+#include "gmock/gmock.h"
+#include "policy/policy_listener.h"
+#include "rpc_base/rpc_base.h"
+#include "policy_table_interface_base/types.h"
+
+namespace policy_table = ::rpc::policy_table_interface_base;
+
+namespace policy {
+
+class MockPolicyListener : public PolicyListener {
+ public:
+ MOCK_METHOD0(OnPTExchangeNeeded,
+ void());
+ MOCK_METHOD3(OnPermissionsUpdated,
+ void(const std::string& policy_app_id, const Permissions& permissions,
+ const policy::HMILevel& default_hmi));
+ MOCK_METHOD1(OnPendingPermissionChange,
+ void(const std::string& policy_app_id));
+ MOCK_METHOD1(OnAppRevoked,
+ void(const std::string& policy_app_id));
+ MOCK_METHOD1(OnUpdateStatusChanged,
+ void(policy::PolicyTableStatus status));
+ MOCK_METHOD1(OnCurrentDeviceIdUpdateRequired,
+ std::string(const std::string& policy_app_id));
+ MOCK_METHOD0(OnSystemInfoUpdateRequired,
+ void());
+ MOCK_METHOD1(GetAppName,
+ std::string(const std::string& policy_app_id));
+};
+
+}
+// namespace policy
+
+#endif // TEST_COMPONENTS_POLICY_INCLUDE_MOCK_POLICY_LISTENER_H_
diff --git a/src/components/policy/test/policy/include/mock_pt_ext_representation.h b/src/components/policy/test/policy/include/mock_pt_ext_representation.h
index ede173dc9..f8b2958ca 100644
--- a/src/components/policy/test/policy/include/mock_pt_ext_representation.h
+++ b/src/components/policy/test/policy/include/mock_pt_ext_representation.h
@@ -43,67 +43,75 @@ namespace policy_table = ::rpc::policy_table_interface_base;
namespace policy {
class MockPTExtRepresentation : public MockPTRepresentation,
- public PTExtRepresentation {
- public:
- MOCK_METHOD1(CanAppKeepContext,
- bool(const std::string& app_id));
- MOCK_METHOD1(CanAppStealFocus,
- bool(const std::string& app_id));
- MOCK_METHOD2(GetDefaultHMI,
- bool(const std::string& app_id, std::string* default_hmi));
- MOCK_METHOD2(GetPriority,
- bool(const std::string& app_id, std::string* priority));
- MOCK_METHOD0(ResetUserConsent,
- bool());
- MOCK_METHOD3(GetUserPermissionsForDevice,
- bool(const std::string&, StringArray*, StringArray*));
- MOCK_METHOD3(GetUserPermissionsForApp,
- bool(const std::string&, const std::string&,
- std::vector<FunctionalGroupPermission>&));
- MOCK_METHOD2(GetDeviceGroupsFromPolicies,
- bool(policy_table::Strings*, policy_table::Strings*));
- MOCK_METHOD2(GetUserFriendlyMsg,
- std::vector<UserFriendlyMessage>(const std::vector<std::string>& msg_code,
- const std::string& language));
- MOCK_METHOD7(SetDeviceData, bool (const std::string& device_id,
- const std::string& hardware,
- const std::string& firmware,
- const std::string& os,
- const std::string& os_version,
- const std::string& carrier,
- const uint32_t number_of_ports));
- MOCK_METHOD6(SetDeviceData,
- bool(const std::string&, const std::string&, const std::string&, const std::string&, const std::string&, const std::string&));
- MOCK_METHOD2(SetMaxNumberPorts,
- bool(const std::string& device_id, unsigned int number_of_ports));
- MOCK_METHOD3(SetUserPermissionsForDevice,
- bool(const std::string&, const StringArray&, const StringArray&));
- MOCK_METHOD1(SetUserPermissionsForApp,
- bool(const PermissionConsent&));
- MOCK_METHOD1(IncreaseStatisticsData,
- bool(StatisticsType type));
- MOCK_METHOD3(SetAppRegistrationLanguage,
- bool(const std::string& app_id, LanguageType type, const std::string& language));
- MOCK_METHOD3(SetMetaInfo,
- bool(const std::string& ccpu_version, const std::string& wers_country_code, const std::string& vin));
- MOCK_METHOD1(SetSystemLanguage,
- bool(const std::string& language));
- MOCK_METHOD0(GetKmFromSuccessfulExchange,
- int());
- MOCK_METHOD0(GetDayFromScsExchange,
- int());
- MOCK_METHOD0(GetIgnitionsFromScsExchange,
- int());
- MOCK_CONST_METHOD1(Increment,
- void(const std::string& type));
- MOCK_CONST_METHOD2(Increment,
- void(const std::string& app_id, const std::string& type));
- MOCK_CONST_METHOD3(Set,
- void(const std::string& app_id, const std::string& type, const std::string& value));
- MOCK_CONST_METHOD3(Add,
- void(const std::string& app_id, const std::string& type, int seconds));
- MOCK_CONST_METHOD2(CountUnconsentedGroups,
- bool(const std::string& app_id, int* count));
+ public PTExtRepresentation {
+ public:
+ MOCK_METHOD1(CanAppKeepContext,
+ bool(const std::string& app_id));
+ MOCK_METHOD1(CanAppStealFocus,
+ bool(const std::string& app_id));
+ MOCK_METHOD2(GetDefaultHMI,
+ bool(const std::string& app_id, std::string* default_hmi));
+ MOCK_METHOD2(GetPriority,
+ bool(const std::string& app_id, std::string* priority));
+ MOCK_METHOD0(ResetUserConsent,
+ bool());
+ MOCK_METHOD3(GetUserPermissionsForDevice,
+ bool(const std::string&, StringArray*, StringArray*));
+ MOCK_METHOD3(GetUserPermissionsForApp,
+ bool(const std::string&, const std::string&,
+ FunctionalIdType* group_types));
+ MOCK_METHOD2(GetDeviceGroupsFromPolicies,
+ bool(policy_table::Strings*, policy_table::Strings*));
+ MOCK_METHOD2(GetUserFriendlyMsg,
+ std::vector<UserFriendlyMessage>(const std::vector<std::string>& msg_code,
+ const std::string& language));
+ MOCK_METHOD7(SetDeviceData, bool (const std::string& device_id,
+ const std::string& hardware,
+ const std::string& firmware,
+ const std::string& os,
+ const std::string& os_version,
+ const std::string& carrier,
+ const uint32_t number_of_ports));
+ MOCK_METHOD6(SetDeviceData,
+ bool(const std::string&, const std::string&, const std::string&, const std::string&, const std::string&, const std::string&));
+ MOCK_METHOD2(SetMaxNumberPorts,
+ bool(const std::string& device_id, unsigned int number_of_ports));
+ MOCK_METHOD3(SetUserPermissionsForDevice,
+ bool(const std::string&, const StringArray&, const StringArray&));
+ MOCK_METHOD1(SetUserPermissionsForApp,
+ bool(const PermissionConsent&));
+ MOCK_METHOD1(IncreaseStatisticsData,
+ bool(StatisticsType type));
+ MOCK_METHOD3(SetAppRegistrationLanguage,
+ bool(const std::string& app_id, LanguageType type, const std::string& language));
+ MOCK_METHOD3(SetMetaInfo,
+ bool(const std::string& ccpu_version, const std::string& wers_country_code, const std::string& vin));
+ MOCK_METHOD1(SetSystemLanguage,
+ bool(const std::string& language));
+ MOCK_METHOD0(GetKmFromSuccessfulExchange,
+ int());
+ MOCK_METHOD0(GetDayFromScsExchange,
+ int());
+ MOCK_METHOD0(GetIgnitionsFromScsExchange,
+ int());
+ MOCK_CONST_METHOD1(Increment,
+ void(const std::string& type));
+ MOCK_CONST_METHOD2(Increment,
+ void(const std::string& app_id, const std::string& type));
+ MOCK_CONST_METHOD3(Set,
+ void(const std::string& app_id, const std::string& type, const std::string& value));
+ MOCK_CONST_METHOD3(Add,
+ void(const std::string& app_id, const std::string& type, int seconds));
+ MOCK_CONST_METHOD2(CountUnconsentedGroups,
+ bool(const std::string& app_id, int* count));
+ MOCK_METHOD1(GetFunctionalGroupNames,
+ bool(FunctionalGroupNames& names));
+ MOCK_METHOD1(CleanupUnpairedDevices,
+ bool(const DeviceIds& device_ids));
+ MOCK_METHOD2(ReactOnUserDevConsentForApp,
+ bool(const std::string& app_id, bool is_device_allowed));
+ MOCK_METHOD1(SetPredataPolicy, bool(const std::string& app_id));
+ MOCK_METHOD2(SetIsPredata, bool(const std::string& app_id, bool is_predata));
};
} // namespace policy
diff --git a/src/components/policy/test/policy/include/mock_pt_representation.h b/src/components/policy/test/policy/include/mock_pt_representation.h
index 69616f6f8..41ce49030 100644
--- a/src/components/policy/test/policy/include/mock_pt_representation.h
+++ b/src/components/policy/test/policy/include/mock_pt_representation.h
@@ -95,6 +95,9 @@ class MockPTRepresentation : virtual public PTRepresentation {
MOCK_CONST_METHOD1(IsApplicationRepresented, bool(const std::string& app_id));
MOCK_CONST_METHOD1(IsDefaultPolicy, bool(const std::string& app_id));
MOCK_METHOD1(SetDefaultPolicy, bool(const std::string& app_id));
+ MOCK_METHOD1(CleanupUnpairedDevices,
+ bool(const DeviceIds& device_ids));
+ MOCK_CONST_METHOD1(IsPredataPolicy, bool(const std::string& app_id));
};
}
diff --git a/src/components/policy/test/policy/qdb_wrapper/CMakeLists.txt b/src/components/policy/test/policy/qdb_wrapper/CMakeLists.txt
new file mode 100644
index 000000000..06ec91f28
--- /dev/null
+++ b/src/components/policy/test/policy/qdb_wrapper/CMakeLists.txt
@@ -0,0 +1,29 @@
+find_package(Sqlite3 REQUIRED)
+
+include_directories(
+ ${CMAKE_SOURCE_DIR}/src/thirdPartyLibs/gmock-1.7.0/include
+ ${CMAKE_SOURCE_DIR}/src/thirdPartyLibs/gmock-1.7.0/gtest/include
+ ${CMAKE_SOURCE_DIR}/src/components/policy/src/policy/qdb_wrapper/include
+)
+
+set(LIBRARIES
+ gtest
+ gtest_main
+ gmock
+ gmock_main
+ dbms
+)
+
+set(DATABASE_SOURCES
+ ./src/test_sql_database.cc
+)
+
+set(QUERY_SOURCES
+ ./src/test_sql_query.cc
+)
+
+create_test("test_SQLDatabase" "${DATABASE_SOURCES}" "${LIBRARIES}")
+create_test("test_SQLQuery" "${QUERY_SOURCES}" "${LIBRARIES}")
+
+file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/../qdbserver.sh DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
+file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/../test-qdb.ini DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) \ No newline at end of file
diff --git a/src/components/policy/test/policy/qdb_wrapper/src/test_sql_database.cc b/src/components/policy/test/policy/qdb_wrapper/src/test_sql_database.cc
new file mode 100644
index 000000000..103fbc7f4
--- /dev/null
+++ b/src/components/policy/test/policy/qdb_wrapper/src/test_sql_database.cc
@@ -0,0 +1,142 @@
+/* Copyright (c) 2013, Ford Motor Company
+* All rights reserved.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions are met:
+*
+* Redistributions of source code must retain the above copyright notice, this
+* list of conditions and the following disclaimer.
+*
+* Redistributions in binary form must reproduce the above copyright notice,
+* this list of conditions and the following
+* disclaimer in the documentation and/or other materials provided with the
+* distribution.
+*
+* Neither the name of the Ford Motor Company nor the names of its contributors
+* may be used to endorse or promote products derived from this software
+* without specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+* POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#include <gtest/gtest.h>
+#include <cstdlib>
+#include "qdb_wrapper/sql_error.h"
+#include "qdb_wrapper/sql_database.h"
+
+using ::policy::dbms::SQLError;
+using ::policy::dbms::SQLDatabase;
+
+namespace test {
+namespace components {
+namespace policy {
+namespace dbms {
+
+::testing::AssertionResult IsError(SQLError error) {
+ if (error.number() != ::policy::dbms::OK) {
+ return ::testing::AssertionSuccess() << error.text();
+ } else {
+ return ::testing::AssertionFailure() << error.text();
+ }
+}
+
+TEST(SQLDatabaseTest, OpenClose) {
+ SQLDatabase db("test-database");
+ bool ret = db.Open();
+ EXPECT_FALSE(IsError(db.LastError()));
+ ASSERT_TRUE(ret);
+
+ db.Close();
+ EXPECT_FALSE(IsError(db.LastError()));
+}
+
+TEST(SQLDatabaseTest, DoubleOpen) {
+ SQLDatabase db("test-database");
+ bool ret = db.Open();
+ EXPECT_FALSE(IsError(db.LastError()));
+ ASSERT_TRUE(ret);
+ ret = db.Open();
+ EXPECT_FALSE(IsError(db.LastError()));
+ ASSERT_TRUE(ret);
+ db.Close();
+}
+
+TEST(SQLDatabaseTest, DoubleClose) {
+ SQLDatabase db("test-database");
+ bool ret = db.Open();
+ EXPECT_FALSE(IsError(db.LastError()));
+ ASSERT_TRUE(ret);
+
+ db.Close();
+ EXPECT_FALSE(IsError(db.LastError()));
+ db.Close();
+ EXPECT_FALSE(IsError(db.LastError()));
+}
+
+TEST(SQLDatabaseTest, CloseWithoutOpen) {
+ SQLDatabase db("test-database");
+ db.Close();
+ EXPECT_FALSE(IsError(db.LastError()));
+}
+
+TEST(SQLDatabaseTest, CommitTransaction) {
+ SQLDatabase db("test-database");
+ ASSERT_TRUE(db.Open());
+ EXPECT_TRUE(db.BeginTransaction());
+ EXPECT_FALSE(IsError(db.LastError()));
+ EXPECT_TRUE(db.CommitTransaction());
+ EXPECT_FALSE(IsError(db.LastError()));
+ db.Close();
+}
+
+TEST(SQLDatabaseTest, RollbackTransaction) {
+ SQLDatabase db("test-database");
+ ASSERT_TRUE(db.Open());
+ EXPECT_TRUE(db.BeginTransaction());
+ EXPECT_FALSE(IsError(db.LastError()));
+ EXPECT_TRUE(db.RollbackTransaction());
+ EXPECT_FALSE(IsError(db.LastError()));
+ db.Close();
+}
+
+TEST(SQLDatabaseTest, FailedCommitTransaction) {
+ SQLDatabase db("test-database");
+ ASSERT_TRUE(db.Open());
+ EXPECT_FALSE(db.CommitTransaction());
+ EXPECT_TRUE(IsError(db.LastError()));
+ db.Close();
+}
+
+TEST(SQLDatabaseTest, FailedRollbackTransaction) {
+ SQLDatabase db("test-database");
+ ASSERT_TRUE(db.Open());
+ EXPECT_FALSE(db.RollbackTransaction());
+ EXPECT_TRUE(IsError(db.LastError()));
+ db.Close();
+}
+
+TEST(SQLDatabaseTest, BadTransaction) {
+ SQLDatabase db("test-database");
+ EXPECT_FALSE(db.BeginTransaction());
+ EXPECT_TRUE(IsError(db.LastError()));
+}
+
+} // namespace dbms
+} // namespace policy
+} // namespace components
+} // namespace test
+
+int main(int argc, char** argv) {
+ testing::InitGoogleTest(&argc, argv);
+ return RUN_ALL_TESTS();
+}
diff --git a/src/components/policy/test/policy/qdb_wrapper/src/test_sql_query.cc b/src/components/policy/test/policy/qdb_wrapper/src/test_sql_query.cc
new file mode 100644
index 000000000..fbe502d45
--- /dev/null
+++ b/src/components/policy/test/policy/qdb_wrapper/src/test_sql_query.cc
@@ -0,0 +1,284 @@
+/* Copyright (c) 2013, Ford Motor Company
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of the Ford Motor Company nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <gtest/gtest.h>
+#include <qdb/qdb.h>
+#include <string>
+#include "qdb_wrapper/sql_error.h"
+#include "qdb_wrapper/sql_database.h"
+#include "qdb_wrapper/sql_query.h"
+
+using ::policy::dbms::SQLError;
+using ::policy::dbms::SQLDatabase;
+using ::policy::dbms::SQLQuery;
+
+namespace test {
+namespace components {
+namespace policy {
+namespace dbms {
+
+class SQLQueryTest : public ::testing::Test {
+ protected:
+ static qdb_hdl_t* conn;
+ static const std::string kDatabaseName;
+
+ static void SetUpTestCase() {
+ conn = qdb_connect(kDatabaseName.c_str(), 0);
+ ASSERT_TRUE(conn);
+ int ret = qdb_statement(conn, "CREATE TABLE testTable (integerValue INTEGER,"
+ " doubleValue REAL, stringValue TEXT)");
+ ASSERT_NE(-1, ret);
+ }
+
+ static void TearDownTestCase() {
+ qdb_statement(conn, "DROP TABLE IF EXISTS testTable");
+ qdb_disconnect(conn);
+ }
+
+ void SetUp() {
+ qdb_statement(conn, "DELETE FROM testTable");
+ }
+};
+
+qdb_hdl_t* SQLQueryTest::conn = 0;
+const std::string SQLQueryTest::kDatabaseName = "test-query";
+
+::testing::AssertionResult IsError(SQLError error) {
+ if (error.number() != ::policy::dbms::OK) {
+ return ::testing::AssertionSuccess() << error.text();
+ } else {
+ return ::testing::AssertionFailure() << error.text();
+ }
+}
+
+TEST_F(SQLQueryTest, Query) {
+ const char* insert = "INSERT INTO testTable "
+ "(integerValue, doubleValue, stringValue) "
+ "VALUES (1, 2.3, 'four');";
+ ASSERT_NE(-1, qdb_statement(conn, insert));
+
+ const std::string kSelect("SELECT * FROM testTable WHERE integerValue = ?");
+ SQLDatabase db(kDatabaseName);
+ ASSERT_TRUE(db.Open());
+ SQLQuery query(&db);
+ query.Prepare(kSelect);
+ EXPECT_STREQ(kSelect.c_str(), query.query().c_str());
+}
+
+TEST_F(SQLQueryTest, ExecString) {
+ const std::string kInsert("INSERT INTO testTable"
+ " (integerValue, doubleValue, stringValue)"
+ " VALUES(2, 3.4, 'five-пять')");
+ SQLDatabase db(kDatabaseName);
+ ASSERT_TRUE(db.Open());
+ SQLQuery query(&db);
+ EXPECT_TRUE(query.Exec(kInsert));
+ EXPECT_FALSE(IsError(query.LastError()));
+}
+
+TEST_F(SQLQueryTest, Bind) {
+ const std::string kInsert1("INSERT INTO testTable (integerValue) VALUES (?)");
+ const std::string kInsert2("INSERT INTO testTable (doubleValue) VALUES (?)");
+ const std::string kInsert3("INSERT INTO testTable (stringValue) VALUES (?)");
+ const std::string kInsert4("INSERT INTO testTable (integerValue, doubleValue,"
+ " stringValue) VALUES (?, ?, ?)");
+ const int kIntegerValue = 1;
+ const double kDoubleValue = 2.3;
+ const std::string kStringValue = "four";
+
+ SQLDatabase db(kDatabaseName);
+ ASSERT_TRUE(db.Open());
+
+ SQLQuery query1(&db);
+ EXPECT_TRUE(query1.Prepare(kInsert1));
+ EXPECT_FALSE(IsError(query1.LastError()));
+ query1.Bind(0, kIntegerValue);
+ EXPECT_FALSE(IsError(query1.LastError()));
+ EXPECT_TRUE(query1.Exec());
+ EXPECT_FALSE(IsError(query1.LastError()));
+
+ SQLQuery query2(&db);
+ EXPECT_TRUE(query2.Prepare(kInsert2));
+ EXPECT_FALSE(IsError(query2.LastError()));
+ query2.Bind(0, kDoubleValue);
+ EXPECT_FALSE(IsError(query2.LastError()));
+ EXPECT_TRUE(query2.Exec());
+ EXPECT_FALSE(IsError(query2.LastError()));
+
+ SQLQuery query3(&db);
+ EXPECT_TRUE(query3.Prepare(kInsert3));
+ EXPECT_FALSE(IsError(query3.LastError()));
+ query3.Bind(0, kStringValue);
+ EXPECT_FALSE(IsError(query3.LastError()));
+ EXPECT_TRUE(query3.Exec());
+ EXPECT_FALSE(IsError(query3.LastError()));
+
+ SQLQuery query4(&db);
+ EXPECT_TRUE(query4.Prepare(kInsert4));
+ EXPECT_FALSE(IsError(query4.LastError()));
+ query4.Bind(0, kIntegerValue);
+ query4.Bind(1, kDoubleValue);
+ query4.Bind(2, kStringValue);
+ EXPECT_FALSE(IsError(query4.LastError()));
+ // TODO(KKolodiy): EXPECT -> ASSERT because test crashes in IsError
+ ASSERT_TRUE(query4.Exec());
+ EXPECT_FALSE(IsError(query4.LastError()));
+}
+
+TEST_F(SQLQueryTest, Value) {
+ const char* insert = "INSERT INTO testTable "
+ "(integerValue, doubleValue, stringValue) "
+ "VALUES (1, 2.3, 'four');";
+ ASSERT_NE(-1, qdb_statement(conn, insert));
+
+ const std::string kSelect("SELECT integerValue, doubleValue, stringValue"
+ " FROM testTable");
+ const int kIntegerValue = 1;
+ const double kDoubleValue = 2.3;
+ const std::string kStringValue = "four";
+
+ SQLDatabase db(kDatabaseName);
+ ASSERT_TRUE(db.Open());
+
+ SQLQuery query(&db);
+ EXPECT_TRUE(query.Prepare(kSelect));
+ EXPECT_FALSE(IsError(query.LastError()));
+ EXPECT_TRUE(query.Exec());
+ EXPECT_FALSE(IsError(query.LastError()));
+ EXPECT_EQ(kIntegerValue, query.GetInteger(0));
+ EXPECT_EQ(kDoubleValue, query.GetDouble(1));
+ EXPECT_EQ(kStringValue, query.GetString(2));
+ EXPECT_FALSE(query.Next());
+ EXPECT_FALSE(IsError(query.LastError()));
+}
+
+TEST_F(SQLQueryTest, EmptySelect) {
+ const std::string kSelect("SELECT integerValue, doubleValue, stringValue"
+ " FROM testTable WHERE 0");
+ SQLDatabase db(kDatabaseName);
+ ASSERT_TRUE(db.Open());
+
+ SQLQuery query(&db);
+ EXPECT_TRUE(query.Prepare(kSelect));
+ EXPECT_FALSE(IsError(query.LastError()));
+ EXPECT_TRUE(query.Exec());
+ EXPECT_FALSE(IsError(query.LastError()));
+}
+
+TEST_F(SQLQueryTest, NextAndBind) {
+ const char* insert = "INSERT INTO testTable "
+ "(integerValue, doubleValue, stringValue) "
+ "VALUES (1, 2.3, 'four');";
+ ASSERT_NE(-1, qdb_statement(conn, insert));
+
+ const std::string kSelect("SELECT integerValue, doubleValue, stringValue"
+ " FROM testTable WHERE stringValue = ?");
+ const int kIntegerValue = 1;
+ const double kDoubleValue = 2.3;
+ const std::string kStringValue = "four";
+
+ SQLDatabase db(kDatabaseName);
+ ASSERT_TRUE(db.Open());
+
+ SQLQuery query(&db);
+ ASSERT_TRUE(query.Prepare(kSelect));
+ EXPECT_FALSE(IsError(query.LastError()));
+ query.Bind(0, kStringValue);
+ EXPECT_FALSE(IsError(query.LastError()));
+ EXPECT_TRUE(query.Exec());
+ ASSERT_FALSE(IsError(query.LastError()));
+ EXPECT_EQ(kIntegerValue, query.GetInteger(0));
+ EXPECT_EQ(kDoubleValue, query.GetDouble(1));
+ EXPECT_EQ(kStringValue, query.GetString(2));
+ EXPECT_FALSE(query.Next());
+ EXPECT_FALSE(IsError(query.LastError()));
+}
+
+TEST_F(SQLQueryTest, LastInsertId) {
+ const char* create = "CREATE TABLE idTable ( "
+ "id INTEGER PRIMARY KEY AUTOINCREMENT,"
+ "value TEXT)";
+ ASSERT_NE(-1, qdb_statement(conn, create));
+
+ const int64_t kExpectId = 1;
+ const std::string kValue("Test last id of insert row");
+ const std::string kInsert("INSERT INTO idTable (value) VALUES(?)");
+
+ SQLDatabase db(kDatabaseName);
+ ASSERT_TRUE(db.Open());
+
+ SQLQuery query(&db);
+ ASSERT_TRUE(query.Prepare(kInsert));
+ EXPECT_FALSE(IsError(query.LastError()));
+ query.Bind(0, kValue);
+ EXPECT_FALSE(IsError(query.LastError()));
+ EXPECT_TRUE(query.Exec());
+ ASSERT_FALSE(IsError(query.LastError()));
+ EXPECT_EQ(kExpectId, query.LastInsertId());
+
+ ASSERT_NE(-1, qdb_statement(conn, "DROP TABLE idTable"));
+}
+
+TEST_F(SQLQueryTest, BindNull) {
+ const std::string kInsert("INSERT INTO testTable (`integerValue`)"
+ " VALUES (?)");
+ SQLDatabase db(kDatabaseName);
+ ASSERT_TRUE(db.Open());
+
+ SQLQuery query(&db);
+ ASSERT_TRUE(query.Prepare(kInsert));
+ EXPECT_FALSE(IsError(query.LastError()));
+ query.Bind(0);
+ EXPECT_FALSE(IsError(query.LastError()));
+ EXPECT_TRUE(query.Exec());
+ ASSERT_FALSE(IsError(query.LastError()));
+}
+
+TEST_F(SQLQueryTest, DoublePrepare) {
+ SQLDatabase db(kDatabaseName);
+ ASSERT_TRUE(db.Open());
+
+ SQLQuery query(&db);
+ EXPECT_TRUE(query.Prepare("SELECT * FROM testTable"));
+ EXPECT_FALSE(IsError(query.LastError()));
+ EXPECT_TRUE(query.Prepare("SELECT * FROM testTable"));
+ EXPECT_FALSE(IsError(query.LastError()));
+}
+
+} // namespace dbms
+} // namespace policy
+} // namespace components
+} // namespace test
+
+int main(int argc, char** argv) {
+ testing::InitGoogleTest(&argc, argv);
+ return RUN_ALL_TESTS();
+}
diff --git a/src/components/policy/test/policy/qdbserver.sh b/src/components/policy/test/policy/qdbserver.sh
new file mode 100755
index 000000000..3f0144106
--- /dev/null
+++ b/src/components/policy/test/policy/qdbserver.sh
@@ -0,0 +1,6 @@
+# This script star QDB server for SDL
+# Need superuser to start qdb
+
+LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/qnx650/target/qnx6/x86/usr/lib
+export LD_LIBRARY_PATH
+/usr/sbin/qdb -c test-qdb.ini
diff --git a/src/components/policy/test/policy/sqlite_wrapper/CMakeLists.txt b/src/components/policy/test/policy/sqlite_wrapper/CMakeLists.txt
index e95ce95b4..9d5a3fceb 100644
--- a/src/components/policy/test/policy/sqlite_wrapper/CMakeLists.txt
+++ b/src/components/policy/test/policy/sqlite_wrapper/CMakeLists.txt
@@ -3,7 +3,7 @@ find_package(Sqlite3 REQUIRED)
include_directories(
${CMAKE_SOURCE_DIR}/src/thirdPartyLibs/gmock-1.7.0/include
${CMAKE_SOURCE_DIR}/src/thirdPartyLibs/gmock-1.7.0/gtest/include
- ${CMAKE_SOURCE_DIR}/src/components/policy_impl/sqlite_wrapper/include
+ ${CMAKE_SOURCE_DIR}/src/components/policy/src/policy/sqlite_wrapper/include
)
set(LIBRARIES
diff --git a/src/components/policy/test/policy/src/generated_code_test.cc b/src/components/policy/test/policy/src/generated_code_test.cc
new file mode 100644
index 000000000..312b06a89
--- /dev/null
+++ b/src/components/policy/test/policy/src/generated_code_test.cc
@@ -0,0 +1,60 @@
+/* Copyright (c) 2013, Ford Motor Company
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of the Ford Motor Company nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <fstream>
+
+#include <gtest/gtest.h>
+#include "json/reader.h"
+#include "json/value.h"
+#include "policy_table_interface_base/enums.h"
+#include "policy_table_interface_base/types.h"
+#include "rpc_base/gtest_support.h"
+
+using namespace rpc::policy_table_interface_base;
+
+namespace test {
+namespace components {
+namespace policy {
+
+TEST(PolicyGeneratedCodeTest, TestValidPTUpdateJsonIsValid) {
+ std::ifstream json_file("valid_sdl_pt_update.json");
+ ASSERT_TRUE(json_file.is_open());
+ Json::Value valid_table;
+ Json::Reader reader;
+ ASSERT_TRUE(reader.parse(json_file, valid_table));
+ Table table(&valid_table);
+ ASSERT_RPCTYPE_VALID(table);
+}
+
+
+} // namespace policy
+} // namespace components
+} // namespace test
diff --git a/src/components/policy/test/policy/src/test_policy_manager_impl.cc b/src/components/policy/test/policy/src/test_policy_manager_impl.cc
index d52af67ab..0301b486e 100644
--- a/src/components/policy/test/policy/src/test_policy_manager_impl.cc
+++ b/src/components/policy/test/policy/src/test_policy_manager_impl.cc
@@ -32,11 +32,11 @@
#include <gtest/gtest.h>
#include <gmock/gmock.h>
#include <vector>
+#include "mock_policy_listener.h"
#include "mock_pt_representation.h"
#include "mock_pt_ext_representation.h"
-#include "policy/policy_table.h"
#include "policy/policy_manager_impl.h"
-#include "json/writer.h"
+#include "json/value.h"
using ::testing::_;
using ::testing::Return;
@@ -44,6 +44,7 @@ using ::testing::DoAll;
using ::testing::SetArgPointee;
using ::policy::PTRepresentation;
+using ::policy::MockPolicyListener;
using ::policy::MockPTRepresentation;
using ::policy::MockPTExtRepresentation;
using ::policy::PolicyManagerImpl;
@@ -144,7 +145,7 @@ TEST_F(PolicyManagerImplTest, GetUpdateUrl) {
EXPECT_EQ("http://ford.com/cloud/3", manager->GetUpdateUrl(7));
EXPECT_EQ("http://panasonic.com/cloud/1", manager->GetUpdateUrl(4));
EXPECT_EQ("http://ford.com/cloud/2", manager->GetUpdateUrl(7));
- EXPECT_EQ("http://panasonic.com/cloud/3", manager->GetUpdateUrl(7));
+ EXPECT_EQ("http://panasonic.com/cloud/3", manager->GetUpdateUrl(4));
}
TEST_F(PolicyManagerImplTest, RefreshRetrySequence) {
@@ -169,6 +170,7 @@ TEST_F(PolicyManagerImplTest, RefreshRetrySequence) {
EXPECT_EQ(200, manager->NextRetryTimeout());
}
+#ifdef EXTENDED_POLICY
TEST_F(PolicyManagerImplTest, IncrementGlobalCounter) {
::testing::NiceMock<MockPTExtRepresentation> mock_pt;
@@ -209,6 +211,7 @@ TEST_F(PolicyManagerImplTest, AddAppStopwatch) {
manager->ResetDefaultPT(::policy::PolicyTable(&mock_pt));
manager->Add("12345", usage_statistics::SECONDS_HMI_FULL, 30);
}
+#endif // EXTENDED_POLICY
TEST_F(PolicyManagerImplTest, LoadPTFromFile) {
::testing::NiceMock<MockPTRepresentation> mock_pt;
@@ -229,65 +232,169 @@ TEST_F(PolicyManagerImplTest, LoadPTFromFile) {
TEST_F(PolicyManagerImplTest, CheckPermissions) {
::testing::NiceMock<MockPTRepresentation> mock_pt;
+ MockPolicyListener mock_listener;
::policy::CheckPermissionResult result;
- result.hmi_level_permitted = true;
+ result.hmi_level_permitted = ::policy::kRpcAllowed;
result.list_of_allowed_params = new std::vector< ::policy::PTString>();
- result.list_of_allowed_params->push_back("FULL");
- result.list_of_allowed_params->push_back("NONE");
- result.list_of_allowed_params->push_back("LIMITED");
- result.list_of_allowed_params->push_back("BACKGROUND");
-
- ::policy::PTString app_id = "12345678";
- ::policy::PTString hmi_level = "FULL";
- ::policy::PTString rpc = "Alert";
-
- EXPECT_CALL(mock_pt, CheckPermissions(app_id, hmi_level, rpc)).WillOnce(
- Return(result));
+ result.list_of_allowed_params->push_back("speed");
+ result.list_of_allowed_params->push_back("gps");
+
+#ifdef EXTENDED_POLICY
+ EXPECT_CALL(mock_pt, CheckPermissions("pre_DataConsent", "FULL", "Alert")).WillOnce(
+ Return(result));
+#else // EXTENDED_POLICY
+ EXPECT_CALL(mock_pt, CheckPermissions("12345678", "FULL", "Alert")).WillOnce(
+ Return(result));
+#endif // EXTENDED_POLICY
+ EXPECT_CALL(mock_listener, OnCurrentDeviceIdUpdateRequired("12345678")).Times(1);
PolicyManagerImpl* manager = new PolicyManagerImpl();
manager->ResetDefaultPT(::policy::PolicyTable(&mock_pt));
+ manager->set_listener(&mock_listener);
::policy::CheckPermissionResult out_result = manager->CheckPermissions(
- app_id, hmi_level, rpc);
- EXPECT_TRUE(out_result.hmi_level_permitted == true);
+ "12345678", "FULL", "Alert");
+ EXPECT_EQ(::policy::kRpcAllowed, out_result.hmi_level_permitted);
+ ASSERT_TRUE(out_result.list_of_allowed_params);
+ ASSERT_EQ(2, out_result.list_of_allowed_params->size());
+ EXPECT_EQ("speed", (*out_result.list_of_allowed_params)[0]);
+ EXPECT_EQ("gps", (*out_result.list_of_allowed_params)[1]);
}
-TEST_F(PolicyManagerImplTest, LoadPT) {
+TEST_F(PolicyManagerImplTest, DISABLED_LoadPT) {
+ // TODO(KKolodiy): PolicyManagerImpl is hard for testing
::testing::NiceMock<MockPTRepresentation> mock_pt;
-
- ::policy_table::Table table;
- Json::Value value = table.ToJsonValue();
- Json::FastWriter writer;
- std::string json = writer.write(value);
+ MockPolicyListener mock_listener;
+
+ Json::Value table(Json::objectValue);
+ table["policy_table"] = Json::Value(Json::objectValue);
+
+ Json::Value& policy_table = table["policy_table"];
+ policy_table["module_meta"] = Json::Value(Json::objectValue);
+ policy_table["module_config"] = Json::Value(Json::objectValue);
+ policy_table["usage_and_error_counts"] = Json::Value(Json::objectValue);
+ policy_table["device_data"] = Json::Value(Json::objectValue);
+ policy_table["functional_groupings"] = Json::Value(Json::objectValue);
+ policy_table["consumer_friendly_messages"] = Json::Value(Json::objectValue);
+ policy_table["app_policies"] = Json::Value(Json::objectValue);
+ policy_table["app_policies"]["1234"] = Json::Value(Json::objectValue);
+
+ Json::Value& module_meta = policy_table["module_meta"];
+ module_meta["ccpu_version"] = Json::Value("ccpu version");
+ module_meta["language"] = Json::Value("ru");
+ module_meta["wers_country_code"] = Json::Value("ru");
+ module_meta["pt_exchanged_at_odometer_x"] = Json::Value(0);
+ module_meta["pt_exchanged_x_days_after_epoch"] = Json::Value(0);
+ module_meta["ignition_cycles_since_last_exchange"] = Json::Value(0);
+ module_meta["vin"] = Json::Value("vin");
+
+ Json::Value& module_config = policy_table["module_config"];
+ module_config["preloaded_pt"] = Json::Value(true);
+ module_config["exchange_after_x_ignition_cycles"] = Json::Value(10);
+ module_config["exchange_after_x_kilometers"] = Json::Value(100);
+ module_config["exchange_after_x_days"] = Json::Value(5);
+ module_config["timeout_after_x_seconds"] = Json::Value(500);
+ module_config["seconds_between_retries"] = Json::Value(Json::arrayValue);
+ module_config["seconds_between_retries"][0] = Json::Value(10);
+ module_config["seconds_between_retries"][1] = Json::Value(20);
+ module_config["seconds_between_retries"][2] = Json::Value(30);
+ module_config["endpoints"] = Json::Value(Json::objectValue);
+ module_config["endpoints"]["0x00"] = Json::Value(Json::objectValue);
+ module_config["endpoints"]["0x00"]["default"] = Json::Value(Json::arrayValue);
+ module_config["endpoints"]["0x00"]["default"][0] = Json::Value(
+ "http://ford.com/cloud/default");
+ module_config["notifications_per_minute_by_priority"] = Json::Value(
+ Json::objectValue);
+ module_config["notifications_per_minute_by_priority"]["emergency"] =
+ Json::Value(1);
+ module_config["notifications_per_minute_by_priority"]["navigation"] =
+ Json::Value(2);
+ module_config["notifications_per_minute_by_priority"]["voiceCommunication"] =
+ Json::Value(3);
+ module_config["notifications_per_minute_by_priority"]["communication"] =
+ Json::Value(4);
+ module_config["notifications_per_minute_by_priority"]["normal"] = Json::Value(
+ 5);
+ module_config["notifications_per_minute_by_priority"]["none"] = Json::Value(
+ 6);
+ module_config["vehicle_make"] = Json::Value("MakeT");
+ module_config["vehicle_model"] = Json::Value("ModelT");
+ module_config["vehicle_year"] = Json::Value(2014);
+
+ Json::Value& usage_and_error_counts = policy_table["usage_and_error_counts"];
+ usage_and_error_counts["count_of_iap_buffer_full"] = Json::Value(0);
+ usage_and_error_counts["count_sync_out_of_memory"] = Json::Value(0);
+ usage_and_error_counts["count_of_sync_reboots"] = Json::Value(0);
+
+ Json::Value& device_data = policy_table["device_data"];
+ device_data["DEVICEHASH"] = Json::Value(Json::objectValue);
+ device_data["DEVICEHASH"]["hardware"] = Json::Value("hardware");
+ device_data["DEVICEHASH"]["firmware_rev"] = Json::Value("firmware_rev");
+ device_data["DEVICEHASH"]["os"] = Json::Value("os");
+ device_data["DEVICEHASH"]["os_version"] = Json::Value("os_version");
+ device_data["DEVICEHASH"]["carrier"] = Json::Value("carrier");
+ device_data["DEVICEHASH"]["max_number_rfcom_ports"] = Json::Value(10);
+
+ Json::Value& functional_groupings = policy_table["functional_groupings"];
+ functional_groupings["default"] = Json::Value(Json::objectValue);
+ Json::Value& default_group = functional_groupings["default"];
+ default_group["rpcs"] = Json::Value(Json::objectValue);
+ default_group["rpcs"]["Update"] = Json::Value(Json::objectValue);
+ default_group["rpcs"]["Update"]["hmi_levels"] = Json::Value(Json::arrayValue);
+ default_group["rpcs"]["Update"]["hmi_levels"][0] = Json::Value("FULL");
+ default_group["rpcs"]["Update"]["parameters"] = Json::Value(Json::arrayValue);
+ default_group["rpcs"]["Update"]["parameters"][0] = Json::Value("speed");
+
+ Json::Value& consumer_friendly_messages =
+ policy_table["consumer_friendly_messages"];
+ consumer_friendly_messages["version"] = Json::Value("1.2");
+
+ Json::Value& app_policies = policy_table["app_policies"];
+ app_policies["default"] = Json::Value(Json::objectValue);
+ app_policies["default"]["memory_kb"] = Json::Value(50);
+ app_policies["default"]["watchdog_timer_ms"] = Json::Value(100);
+ app_policies["default"]["groups"] = Json::Value(Json::arrayValue);
+ app_policies["default"]["groups"][0] = Json::Value("default");
+ app_policies["default"]["priority"] = Json::Value("EMERGENCY");
+ app_policies["default"]["default_hmi"] = Json::Value("FULL");
+ app_policies["default"]["keep_context"] = Json::Value(true);
+ app_policies["default"]["steal_focus"] = Json::Value(true);
+ app_policies["default"]["certificate"] = Json::Value("sign");
+
+ std::string json = table.toStyledString();
::policy::BinaryMessage msg(json.begin(), json.end());
+ EXPECT_CALL(mock_pt, Save(_)).Times(1).WillOnce(Return(true));
+ EXPECT_CALL(mock_listener, OnUpdateStatusChanged(_)).Times(1);
+
PolicyManagerImpl* manager = new PolicyManagerImpl();
manager->ResetDefaultPT(::policy::PolicyTable(&mock_pt));
+ manager->set_listener(&mock_listener);
- // TODO(AOleynik): Validation is not enabled yet, so test fails
- // TODO(AOleynik): Segfault occurs, check
- //EXPECT_FALSE(manager->LoadPT(msg));
+ EXPECT_TRUE(manager->LoadPT("file_pt_update.json", msg));
}
TEST_F(PolicyManagerImplTest, RequestPTUpdate) {
::testing::NiceMock<MockPTRepresentation> mock_pt;
+ MockPolicyListener mock_listener;
::utils::SharedPtr< ::policy_table::Table> p_table =
new ::policy_table::Table();
- Json::Value value = p_table.get()->ToJsonValue();
- Json::FastWriter writer;
- std::string json(writer.write(value));
- ::policy::BinaryMessageSptr p_msg = new ::policy::BinaryMessage(json.begin(),
+ std::string json = p_table->ToJsonValue().toStyledString();
+ ::policy::BinaryMessageSptr expect = new ::policy::BinaryMessage(json.begin(),
json.end());
EXPECT_CALL(mock_pt, GenerateSnapshot()).WillOnce(Return(p_table));
+ EXPECT_CALL(mock_listener, OnUpdateStatusChanged(_)).Times(2);
PolicyManagerImpl* manager = new PolicyManagerImpl();
manager->ResetDefaultPT(::policy::PolicyTable(&mock_pt));
- ::policy::BinaryMessageSptr p_result = manager->RequestPTUpdate();
- EXPECT_TRUE(*p_msg.get() == *p_result.get());
+ manager->set_listener(&mock_listener);
+ ::policy::BinaryMessageSptr output = manager->RequestPTUpdate();
+ EXPECT_EQ(*expect, *output);
}
+#ifdef EXTENDED_POLICY
TEST_F(PolicyManagerImplTest, ResetUserConsent) {
::testing::NiceMock<MockPTExtRepresentation> mock_pt;
@@ -299,6 +406,7 @@ TEST_F(PolicyManagerImplTest, ResetUserConsent) {
EXPECT_TRUE(manager->ResetUserConsent());
EXPECT_FALSE(manager->ResetUserConsent());
}
+#endif // EXTENDED_POLICY
TEST_F(PolicyManagerImplTest, CheckAppPolicyState) {
::testing::NiceMock<MockPTExtRepresentation> mock_pt;
diff --git a/src/components/policy/test/policy/src/test_sql_pt_ext_representation.cc b/src/components/policy/test/policy/src/test_sql_pt_ext_representation.cc
index 178fdb749..ae19b0b15 100644
--- a/src/components/policy/test/policy/src/test_sql_pt_ext_representation.cc
+++ b/src/components/policy/test/policy/src/test_sql_pt_ext_representation.cc
@@ -51,18 +51,17 @@ class SQLPTExtRepresentationTest : public ::testing::Test {
static const std::string kFileName;
static void SetUpTestCase() {
- sqlite3_open(kFileName.c_str(), &conn);
reps = new SQLPTExtRepresentation;
- EXPECT_TRUE(reps->Init());
- sqlite3_open(kFileName.c_str(), &conn);
+ EXPECT_EQ(::policy::SUCCESS, reps->Init());
+ EXPECT_EQ(SQLITE_OK, sqlite3_open(kFileName.c_str(), &conn));
}
static void TearDownTestCase() {
-// EXPECT_TRUE(reps->Clear());
+ EXPECT_TRUE(reps->Clear());
EXPECT_TRUE(reps->Close());
delete reps;
sqlite3_close(conn);
-// remove(kFileName.c_str());
+ remove(kFileName.c_str());
}
};
@@ -70,6 +69,16 @@ sqlite3* SQLPTExtRepresentationTest::conn = 0;
SQLPTExtRepresentation* SQLPTExtRepresentationTest::reps = 0;
const std::string SQLPTExtRepresentationTest::kFileName = "policy.sqlite";
+::testing::AssertionResult IsValid(const policy_table::Table &table) {
+ if (table.is_valid()) {
+ return ::testing::AssertionSuccess();
+ } else {
+ ::rpc::ValidationReport report(" - table");
+ table.ReportErrors(&report);
+ return ::testing::AssertionFailure() << ::rpc::PrettyFormat(report);
+ }
+}
+
TEST_F(SQLPTExtRepresentationTest, SaveGenerateSnapshot) {
Json::Value expect(Json::objectValue);
expect["policy_table"] = Json::Value(Json::objectValue);
@@ -84,13 +93,13 @@ TEST_F(SQLPTExtRepresentationTest, SaveGenerateSnapshot) {
policy_table["app_policies"] = Json::Value(Json::objectValue);
Json::Value& module_meta = policy_table["module_meta"];
- module_meta["ccpu_version"] = Json::Value("");
- module_meta["language"] = Json::Value("");
- module_meta["wers_country_code"] = Json::Value("");
+ module_meta["ccpu_version"] = Json::Value("ccpu version");
+ module_meta["language"] = Json::Value("ru");
+ module_meta["wers_country_code"] = Json::Value("ru");
module_meta["pt_exchanged_at_odometer_x"] = Json::Value(0);
module_meta["pt_exchanged_x_days_after_epoch"] = Json::Value(0);
module_meta["ignition_cycles_since_last_exchange"] = Json::Value(0);
- module_meta["vin"] = Json::Value("");
+ module_meta["vin"] = Json::Value("vin");
Json::Value& module_config = policy_table["module_config"];
module_config["preloaded_pt"] = Json::Value(true);
@@ -103,10 +112,9 @@ TEST_F(SQLPTExtRepresentationTest, SaveGenerateSnapshot) {
module_config["seconds_between_retries"][1] = Json::Value(20);
module_config["seconds_between_retries"][2] = Json::Value(30);
module_config["endpoints"] = Json::Value(Json::objectValue);
- module_config["endpoints"]["default"] = Json::Value(Json::objectValue);
- module_config["endpoints"]["default"]["default"] = Json::Value(
- Json::arrayValue);
- module_config["endpoints"]["default"]["default"][0] = Json::Value(
+ module_config["endpoints"]["0x00"] = Json::Value(Json::objectValue);
+ module_config["endpoints"]["0x00"]["default"] = Json::Value(Json::arrayValue);
+ module_config["endpoints"]["0x00"]["default"][0] = Json::Value(
"http://ford.com/cloud/default");
module_config["notifications_per_minute_by_priority"] = Json::Value(
Json::objectValue);
@@ -124,21 +132,31 @@ TEST_F(SQLPTExtRepresentationTest, SaveGenerateSnapshot) {
6);
module_config["vehicle_make"] = Json::Value("MakeT");
module_config["vehicle_model"] = Json::Value("ModelT");
- module_config["vehicle_year"] = Json::Value(14);
+ module_config["vehicle_year"] = Json::Value(2014);
Json::Value& usage_and_error_counts = policy_table["usage_and_error_counts"];
usage_and_error_counts["count_of_iap_buffer_full"] = Json::Value(0);
usage_and_error_counts["count_sync_out_of_memory"] = Json::Value(0);
usage_and_error_counts["count_of_sync_reboots"] = Json::Value(0);
-// usage_and_error_counts["app_level"] = Json::Value(Json::objectValue);
- // this map is not mandatory but is_valid returns false if map is empty
-// usage_and_error_counts["app_level"]["12345"] = Json::Value(Json::objectValue);
Json::Value& device_data = policy_table["device_data"];
- device_data["user_consent_records"] = Json::Value(Json::objectValue);
+ device_data["DEVICEHASH"] = Json::Value(Json::objectValue);
+ device_data["DEVICEHASH"]["hardware"] = Json::Value("hardware");
+ device_data["DEVICEHASH"]["firmware_rev"] = Json::Value("firmware_rev");
+ device_data["DEVICEHASH"]["os"] = Json::Value("os");
+ device_data["DEVICEHASH"]["os_version"] = Json::Value("os_version");
+ device_data["DEVICEHASH"]["carrier"] = Json::Value("carrier");
+ device_data["DEVICEHASH"]["max_number_rfcom_ports"] = Json::Value(10);
Json::Value& functional_groupings = policy_table["functional_groupings"];
functional_groupings["default"] = Json::Value(Json::objectValue);
+ Json::Value& default_group = functional_groupings["default"];
+ default_group["rpcs"] = Json::Value(Json::objectValue);
+ default_group["rpcs"]["Update"] = Json::Value(Json::objectValue);
+ default_group["rpcs"]["Update"]["hmi_levels"] = Json::Value(Json::arrayValue);
+ default_group["rpcs"]["Update"]["hmi_levels"][0] = Json::Value("FULL");
+ default_group["rpcs"]["Update"]["parameters"] = Json::Value(Json::arrayValue);
+ default_group["rpcs"]["Update"]["parameters"][0] = Json::Value("speed");
Json::Value& consumer_friendly_messages =
policy_table["consumer_friendly_messages"];
@@ -146,22 +164,34 @@ TEST_F(SQLPTExtRepresentationTest, SaveGenerateSnapshot) {
Json::Value& app_policies = policy_table["app_policies"];
app_policies["default"] = Json::Value(Json::objectValue);
+ app_policies["default"]["memory_kb"] = Json::Value(50);
+ app_policies["default"]["watchdog_timer_ms"] = Json::Value(100);
+ app_policies["default"]["groups"] = Json::Value(Json::arrayValue);
+ app_policies["default"]["groups"][0] = Json::Value("default");
+ app_policies["default"]["priority"] = Json::Value("EMERGENCY");
+ app_policies["default"]["default_hmi"] = Json::Value("FULL");
+ app_policies["default"]["keep_context"] = Json::Value(true);
+ app_policies["default"]["steal_focus"] = Json::Value(true);
+ app_policies["default"]["certificate"] = Json::Value("sign");
policy_table::Table table(&expect);
- //TODO(KKolodiy): temporarily validation is turned off
-// EXPECT_TRUE(table.is_valid());
+ ASSERT_TRUE(IsValid(table));
ASSERT_TRUE(reps->Save(table));
+ ASSERT_TRUE(reps->SetMetaInfo("ccpu version", "ru", "ru"));
+ const char* query_vin = "UPDATE `module_meta` SET `vin` = 'vin'; ";
+ ASSERT_EQ(SQLITE_OK, sqlite3_exec(conn, query_vin, NULL, NULL, NULL));
utils::SharedPtr<policy_table::Table> snapshot = reps->GenerateSnapshot();
-// EXPECT_TRUE(snapshot->is_valid());
- EXPECT_EQ(expect.toStyledString(), snapshot->ToJsonValue().toStyledString());
+ EXPECT_TRUE(IsValid(*snapshot));
+ EXPECT_EQ(table.ToJsonValue().toStyledString(),
+ snapshot->ToJsonValue().toStyledString());
}
TEST_F(SQLPTExtRepresentationTest, CanAppKeepContext) {
const char* query_delete = "DELETE FROM `application`; ";
ASSERT_EQ(SQLITE_OK, sqlite3_exec(conn, query_delete, NULL, NULL, NULL));
- const char* query_insert =
- "INSERT INTO `application` (`id`, `keep_context`) VALUES ('12345', 1)";
+ const char* query_insert = "INSERT INTO `application` (`id`, `memory_kb`,"
+ " `watchdog_timer_ms`, `keep_context`) VALUES ('12345', 5, 10, 1)";
ASSERT_EQ(SQLITE_OK, sqlite3_exec(conn, query_insert, NULL, NULL, NULL));
EXPECT_FALSE(reps->CanAppKeepContext("0"));
EXPECT_TRUE(reps->CanAppKeepContext("12345"));
@@ -170,8 +200,8 @@ TEST_F(SQLPTExtRepresentationTest, CanAppKeepContext) {
TEST_F(SQLPTExtRepresentationTest, CanAppStealFocus) {
const char* query_delete = "DELETE FROM `application`; ";
ASSERT_EQ(SQLITE_OK, sqlite3_exec(conn, query_delete, NULL, NULL, NULL));
- const char* query_insert =
- "INSERT INTO `application` (`id`, `steal_focus`) VALUES ('12345', 1)";
+ const char* query_insert = "INSERT INTO `application` (`id`, `memory_kb`,"
+ " `watchdog_timer_ms`, `steal_focus`) VALUES ('12345', 5, 10, 1)";
ASSERT_EQ(SQLITE_OK, sqlite3_exec(conn, query_insert, NULL, NULL, NULL));
EXPECT_TRUE(reps->CanAppStealFocus("12345"));
EXPECT_FALSE(reps->CanAppStealFocus("0"));
diff --git a/src/components/policy/test/policy/src/test_sql_pt_representation.cc b/src/components/policy/test/policy/src/test_sql_pt_representation.cc
index 869b111f5..caa72bea4 100644
--- a/src/components/policy/test/policy/src/test_sql_pt_representation.cc
+++ b/src/components/policy/test/policy/src/test_sql_pt_representation.cc
@@ -30,7 +30,11 @@
*/
#include <gtest/gtest.h>
-#include <sqlite3.h>
+#ifdef __QNX__
+# include <qdb/qdb.h>
+#else // __QNX__
+# include <sqlite3.h>
+#endif // __QNX__
#include <vector>
#include "json/value.h"
#include "policy/sql_pt_representation.h"
@@ -46,100 +50,147 @@ namespace test {
namespace components {
namespace policy {
+#ifdef __QNX__
+class DBMS {
+ public:
+ bool Open() {
+ conn_ = qdb_connect(kDatabaseName_.c_str(), 0);
+ return conn_ != NULL;
+ }
+ void Close() {
+ qdb_disconnect(conn_);
+ }
+ bool Exec(const char* query) {
+ return -1 != qdb_statement(conn_, query);
+ }
+ private:
+ static qdb_hdl_t* conn_;
+ static const std::string kDatabaseName_;
+};
+qdb_hdl_t* DBMS::conn_ = 0;
+const std::string DBMS::kDatabaseName_ = "policy";
+#else // __QNX__
+class DBMS {
+ public:
+ bool Open() {
+ return SQLITE_OK == sqlite3_open(kFileName_.c_str(), &conn_);
+ }
+ void Close() {
+ sqlite3_close(conn_);
+ remove(kFileName_.c_str());
+ }
+ bool Exec(const char* query) {
+ return SQLITE_OK == sqlite3_exec(conn_, query, NULL, NULL, NULL);
+ }
+ private:
+ static sqlite3* conn_;
+ static const std::string kFileName_;
+};
+sqlite3* DBMS::conn_ = 0;
+const std::string DBMS::kFileName_ = "policy.sqlite";
+#endif // __QNX__
+
class SQLPTRepresentationTest : public ::testing::Test {
- protected:
- static sqlite3* conn;
- static SQLPTRepresentation* reps;
- static const std::string kFileName;
-
- static void SetUpTestCase() {
- sqlite3_open(kFileName.c_str(), &conn);
- reps = new SQLPTRepresentation;
- EXPECT_TRUE(reps->Init());
- sqlite3_open(kFileName.c_str(), &conn);
- }
-
- static void TearDownTestCase() {
- EXPECT_TRUE(reps->Clear());
- EXPECT_TRUE(reps->Close());
- delete reps;
- sqlite3_close(conn);
- remove(kFileName.c_str());
- }
+ protected:
+ static DBMS* dbms;
+ static SQLPTRepresentation* reps;
+
+ static void SetUpTestCase() {
+ reps = new SQLPTRepresentation;
+ dbms = new DBMS;
+ EXPECT_EQ(::policy::SUCCESS, reps->Init());
+ EXPECT_TRUE(dbms->Open());
+ }
+
+ static void TearDownTestCase() {
+ EXPECT_TRUE(reps->Clear());
+ EXPECT_TRUE(reps->Close());
+ delete reps;
+ dbms->Close();
+ }
};
-sqlite3* SQLPTRepresentationTest::conn = 0;
+DBMS* SQLPTRepresentationTest::dbms = 0;
SQLPTRepresentation* SQLPTRepresentationTest::reps = 0;
-const std::string SQLPTRepresentationTest::kFileName = "policy.sqlite";
+
+::testing::AssertionResult IsValid(const policy_table::Table &table) {
+ if (table.is_valid()) {
+ return ::testing::AssertionSuccess();
+ } else {
+ ::rpc::ValidationReport report(" - table");
+ table.ReportErrors(&report);
+ return ::testing::AssertionFailure() << ::rpc::PrettyFormat(report);
+ }
+}
TEST_F(SQLPTRepresentationTest, CheckPermissionsAllowed) {
- const char* query =
- "INSERT OR REPLACE INTO `application` (`id`) VALUES ('12345'); "
- "INSERT OR REPLACE INTO functional_group (`id`, `name`)"
- " VALUES (1, 'Base-4'); "
- "INSERT OR REPLACE INTO `app_group` (`application_id`,"
- " `functional_group_id`) VALUES ('12345', 1); "
- "INSERT OR REPLACE INTO `rpc` (`name`, `parameter`, `hmi_level_value`,"
- " `functional_group_id`) VALUES ('Update', 'gps', 'FULL', 1); "
- "INSERT OR REPLACE INTO `rpc` (`name`, `parameter`, `hmi_level_value`,"
- " `functional_group_id`) VALUES ('Update', 'speed', 'FULL', 1);";
- ASSERT_EQ(SQLITE_OK, sqlite3_exec(conn, query, NULL, NULL, NULL));
-
- CheckPermissionResult ret(false);
+ const char* query = "INSERT OR REPLACE INTO `application` (`id`, `memory_kb`,"
+ " `watchdog_timer_ms`) VALUES ('12345', 5, 10); "
+ "INSERT OR REPLACE INTO functional_group (`id`, `name`)"
+ " VALUES (1, 'Base-4'); "
+ "INSERT OR REPLACE INTO `app_group` (`application_id`,"
+ " `functional_group_id`) VALUES ('12345', 1); "
+ "INSERT OR REPLACE INTO `rpc` (`name`, `parameter`, `hmi_level_value`,"
+ " `functional_group_id`) VALUES ('Update', 'gps', 'FULL', 1); "
+ "INSERT OR REPLACE INTO `rpc` (`name`, `parameter`, `hmi_level_value`,"
+ " `functional_group_id`) VALUES ('Update', 'speed', 'FULL', 1);";
+ ASSERT_TRUE(dbms->Exec(query));
+
+ CheckPermissionResult ret;
ret = reps->CheckPermissions("12345", "FULL", "Update");
- ASSERT_TRUE(ret.hmi_level_permitted);
+ EXPECT_TRUE(ret.hmi_level_permitted == ::policy::kRpcAllowed);
ASSERT_EQ(2, ret.list_of_allowed_params->size());
EXPECT_EQ("gps", (*ret.list_of_allowed_params)[0]);
EXPECT_EQ("speed", (*ret.list_of_allowed_params)[1]);
}
TEST_F(SQLPTRepresentationTest, CheckPermissionsAllowedWithoutParameters) {
- const char* query =
- "INSERT OR REPLACE INTO `application` (`id`) VALUES ('12345'); "
- "INSERT OR REPLACE INTO functional_group (`id`, `name`)"
- " VALUES (1, 'Base-4'); "
- "INSERT OR REPLACE INTO `app_group` (`application_id`,"
- " `functional_group_id`) VALUES ('12345', 1); "
- "DELETE FROM `rpc`; "
- "INSERT OR REPLACE INTO `rpc` (`name`, `hmi_level_value`,"
- " `functional_group_id`) VALUES ('Update', 'LIMITED', 1);";
- ASSERT_EQ(SQLITE_OK, sqlite3_exec(conn, query, NULL, NULL, NULL));
-
- CheckPermissionResult ret(false);
+ const char* query = "INSERT OR REPLACE INTO `application` (`id`, `memory_kb`,"
+ " `watchdog_timer_ms`) VALUES ('12345', 5, 10); "
+ "INSERT OR REPLACE INTO functional_group (`id`, `name`)"
+ " VALUES (1, 'Base-4'); "
+ "INSERT OR REPLACE INTO `app_group` (`application_id`,"
+ " `functional_group_id`) VALUES ('12345', 1); "
+ "DELETE FROM `rpc`; "
+ "INSERT OR REPLACE INTO `rpc` (`name`, `hmi_level_value`,"
+ " `functional_group_id`) VALUES ('Update', 'LIMITED', 1);";
+ ASSERT_TRUE(dbms->Exec(query));
+
+ CheckPermissionResult ret;
ret = reps->CheckPermissions("12345", "LIMITED", "Update");
- EXPECT_TRUE(ret.hmi_level_permitted);
+ EXPECT_TRUE(ret.hmi_level_permitted == ::policy::kRpcAllowed);
EXPECT_TRUE(!ret.list_of_allowed_params);
}
TEST_F(SQLPTRepresentationTest, CheckPermissionsDisallowed) {
const char* query = "DELETE FROM `app_group`";
- ASSERT_EQ(SQLITE_OK, sqlite3_exec(conn, query, NULL, NULL, NULL));
+ ASSERT_TRUE(dbms->Exec(query));
CheckPermissionResult ret;
ret = reps->CheckPermissions("12345", "FULL", "Update");
- EXPECT_FALSE(ret.hmi_level_permitted);
+ EXPECT_EQ(::policy::kRpcDisallowed, ret.hmi_level_permitted);
EXPECT_TRUE(!ret.list_of_allowed_params);
}
TEST_F(SQLPTRepresentationTest, IsPTPReloaded) {
const char* query = "UPDATE `module_config` SET `preloaded_pt` = 1";
- ASSERT_EQ(SQLITE_OK, sqlite3_exec(conn, query, NULL, NULL, NULL));
+ ASSERT_TRUE(dbms->Exec(query));
EXPECT_TRUE(reps->IsPTPreloaded());
}
TEST_F(SQLPTRepresentationTest, GetUpdateUrls) {
const char* query_delete = "DELETE FROM `endpoint`; ";
- ASSERT_EQ(SQLITE_OK, sqlite3_exec(conn, query_delete, NULL, NULL, NULL));
+ ASSERT_TRUE(dbms->Exec(query_delete));
EndpointUrls ret = reps->GetUpdateUrls(7);
EXPECT_TRUE(ret.empty());
const char* query_insert =
- "INSERT INTO `endpoint` (`application_id`, `url`, `service`) "
- " VALUES ('12345', 'http://ford.com/cloud/1', '0x07');"
- "INSERT INTO `endpoint` (`application_id`, `url`, `service`) "
- " VALUES ('12345', 'http://ford.com/cloud/2', '0x07');";
+ "INSERT INTO `endpoint` (`application_id`, `url`, `service`) "
+ " VALUES ('12345', 'http://ford.com/cloud/1', '0x07');"
+ "INSERT INTO `endpoint` (`application_id`, `url`, `service`) "
+ " VALUES ('12345', 'http://ford.com/cloud/2', '0x07');";
- ASSERT_EQ(SQLITE_OK, sqlite3_exec(conn, query_insert, NULL, NULL, NULL));
+ ASSERT_TRUE(dbms->Exec(query_insert));
ret = reps->GetUpdateUrls(7);
ASSERT_EQ(2, ret.size());
EXPECT_EQ("http://ford.com/cloud/1", ret[0].url);
@@ -151,79 +202,75 @@ TEST_F(SQLPTRepresentationTest, GetUpdateUrls) {
TEST_F(SQLPTRepresentationTest, IgnitionCyclesBeforeExchangeAndIncrement) {
const char* query_zeros = "UPDATE `module_meta` SET "
- " `ignition_cycles_since_last_exchange` = 0; "
- " UPDATE `module_config` SET `exchange_after_x_ignition_cycles` = 0";
- ASSERT_EQ(SQLITE_OK, sqlite3_exec(conn, query_zeros, NULL, NULL, NULL));
+ " `ignition_cycles_since_last_exchange` = 0; "
+ " UPDATE `module_config` SET `exchange_after_x_ignition_cycles` = 0";
+ ASSERT_TRUE(dbms->Exec(query_zeros));
EXPECT_EQ(0, reps->IgnitionCyclesBeforeExchange());
reps->IncrementIgnitionCycles();
EXPECT_EQ(0, reps->IgnitionCyclesBeforeExchange());
const char* query_less_limit = "UPDATE `module_meta` SET "
- " `ignition_cycles_since_last_exchange` = 5; "
- " UPDATE `module_config` SET `exchange_after_x_ignition_cycles` = 10";
- ASSERT_EQ(SQLITE_OK, sqlite3_exec(conn, query_less_limit, NULL, NULL, NULL));
+ " `ignition_cycles_since_last_exchange` = 5; "
+ " UPDATE `module_config` SET `exchange_after_x_ignition_cycles` = 10";
+ ASSERT_TRUE(dbms->Exec(query_less_limit));
EXPECT_EQ(5, reps->IgnitionCyclesBeforeExchange());
reps->IncrementIgnitionCycles();
EXPECT_EQ(4, reps->IgnitionCyclesBeforeExchange());
const char* query_limit = "UPDATE `module_meta` SET "
- " `ignition_cycles_since_last_exchange` = 9; "
- " UPDATE `module_config` SET `exchange_after_x_ignition_cycles` = 10";
- ASSERT_EQ(SQLITE_OK, sqlite3_exec(conn, query_limit, NULL, NULL, NULL));
+ " `ignition_cycles_since_last_exchange` = 9; "
+ " UPDATE `module_config` SET `exchange_after_x_ignition_cycles` = 10";
+ ASSERT_TRUE(dbms->Exec(query_limit));
EXPECT_EQ(1, reps->IgnitionCyclesBeforeExchange());
reps->IncrementIgnitionCycles();
EXPECT_EQ(0, reps->IgnitionCyclesBeforeExchange());
const char* query_more_limit = "UPDATE `module_meta` SET "
- " `ignition_cycles_since_last_exchange` = 12; "
- " UPDATE `module_config` SET `exchange_after_x_ignition_cycles` = 10";
- ASSERT_EQ(SQLITE_OK, sqlite3_exec(conn, query_more_limit, NULL, NULL, NULL));
+ " `ignition_cycles_since_last_exchange` = 12; "
+ " UPDATE `module_config` SET `exchange_after_x_ignition_cycles` = 10";
+ ASSERT_TRUE(dbms->Exec(query_more_limit));
EXPECT_EQ(0, reps->IgnitionCyclesBeforeExchange());
const char* query_negative_limit = "UPDATE `module_meta` SET "
- " `ignition_cycles_since_last_exchange` = 3; "
- " UPDATE `module_config` SET `exchange_after_x_ignition_cycles` = -1";
- ASSERT_EQ(SQLITE_OK,
- sqlite3_exec(conn, query_negative_limit, NULL, NULL, NULL));
+ " `ignition_cycles_since_last_exchange` = 3; "
+ " UPDATE `module_config` SET `exchange_after_x_ignition_cycles` = -1";
+ ASSERT_TRUE(dbms->Exec(query_negative_limit));
EXPECT_EQ(0, reps->IgnitionCyclesBeforeExchange());
const char* query_negative_current = "UPDATE `module_meta` SET "
- " `ignition_cycles_since_last_exchange` = -1; "
- " UPDATE `module_config` SET `exchange_after_x_ignition_cycles` = 2";
- ASSERT_EQ(SQLITE_OK,
- sqlite3_exec(conn, query_negative_current, NULL, NULL, NULL));
+ " `ignition_cycles_since_last_exchange` = -1; "
+ " UPDATE `module_config` SET `exchange_after_x_ignition_cycles` = 2";
+ ASSERT_TRUE(dbms->Exec(query_negative_current));
EXPECT_EQ(0, reps->IgnitionCyclesBeforeExchange());
}
TEST_F(SQLPTRepresentationTest, KilometersBeforeExchange) {
const char* query_zeros = "UPDATE `module_meta` SET "
- " `pt_exchanged_at_odometer_x` = 0; "
- " UPDATE `module_config` SET `exchange_after_x_kilometers` = 0";
- ASSERT_EQ(SQLITE_OK, sqlite3_exec(conn, query_zeros, NULL, NULL, NULL));
+ " `pt_exchanged_at_odometer_x` = 0; "
+ " UPDATE `module_config` SET `exchange_after_x_kilometers` = 0";
+ ASSERT_TRUE(dbms->Exec(query_zeros));
EXPECT_EQ(0, reps->KilometersBeforeExchange(0));
EXPECT_EQ(0, reps->KilometersBeforeExchange(-10));
EXPECT_EQ(0, reps->KilometersBeforeExchange(10));
const char* query_negative_limit = "UPDATE `module_meta` SET "
- " `pt_exchanged_at_odometer_x` = 10; "
- " UPDATE `module_config` SET `exchange_after_x_kilometers` = -10";
- ASSERT_EQ(SQLITE_OK,
- sqlite3_exec(conn, query_negative_limit, NULL, NULL, NULL));
+ " `pt_exchanged_at_odometer_x` = 10; "
+ " UPDATE `module_config` SET `exchange_after_x_kilometers` = -10";
+ ASSERT_TRUE(dbms->Exec(query_negative_limit));
EXPECT_EQ(0, reps->KilometersBeforeExchange(0));
EXPECT_EQ(0, reps->KilometersBeforeExchange(10));
const char* query_negative_last = "UPDATE `module_meta` SET "
- " `pt_exchanged_at_odometer_x` = -10; "
- " UPDATE `module_config` SET `exchange_after_x_kilometers` = 20";
- ASSERT_EQ(SQLITE_OK,
- sqlite3_exec(conn, query_negative_last, NULL, NULL, NULL));
+ " `pt_exchanged_at_odometer_x` = -10; "
+ " UPDATE `module_config` SET `exchange_after_x_kilometers` = 20";
+ ASSERT_TRUE(dbms->Exec(query_negative_last));
EXPECT_EQ(0, reps->KilometersBeforeExchange(0));
EXPECT_EQ(0, reps->KilometersBeforeExchange(10));
const char* query_limit = "UPDATE `module_meta` SET "
- " `pt_exchanged_at_odometer_x` = 10; "
- " UPDATE `module_config` SET `exchange_after_x_kilometers` = 100";
- ASSERT_EQ(SQLITE_OK, sqlite3_exec(conn, query_limit, NULL, NULL, NULL));
+ " `pt_exchanged_at_odometer_x` = 10; "
+ " UPDATE `module_config` SET `exchange_after_x_kilometers` = 100";
+ ASSERT_TRUE(dbms->Exec(query_limit));
EXPECT_EQ(0, reps->KilometersBeforeExchange(120));
EXPECT_EQ(60, reps->KilometersBeforeExchange(50));
EXPECT_EQ(0, reps->KilometersBeforeExchange(5));
@@ -231,33 +278,31 @@ TEST_F(SQLPTRepresentationTest, KilometersBeforeExchange) {
TEST_F(SQLPTRepresentationTest, DaysBeforeExchange) {
const char* query_zeros = "UPDATE `module_meta` SET "
- " `pt_exchanged_x_days_after_epoch` = 0; "
- " UPDATE `module_config` SET `exchange_after_x_days` = 0";
- ASSERT_EQ(SQLITE_OK, sqlite3_exec(conn, query_zeros, NULL, NULL, NULL));
+ " `pt_exchanged_x_days_after_epoch` = 0; "
+ " UPDATE `module_config` SET `exchange_after_x_days` = 0";
+ ASSERT_TRUE(dbms->Exec(query_zeros));
EXPECT_EQ(0, reps->DaysBeforeExchange(0));
EXPECT_EQ(0, reps->DaysBeforeExchange(-10));
EXPECT_EQ(0, reps->DaysBeforeExchange(10));
const char* query_negative_limit = "UPDATE `module_meta` SET "
- " `pt_exchanged_x_days_after_epoch` = 10; "
- " UPDATE `module_config` SET `exchange_after_x_days` = -10";
- ASSERT_EQ(SQLITE_OK,
- sqlite3_exec(conn, query_negative_limit, NULL, NULL, NULL));
+ " `pt_exchanged_x_days_after_epoch` = 10; "
+ " UPDATE `module_config` SET `exchange_after_x_days` = -10";
+ ASSERT_TRUE(dbms->Exec(query_negative_limit));
EXPECT_EQ(0, reps->DaysBeforeExchange(0));
EXPECT_EQ(0, reps->DaysBeforeExchange(10));
const char* query_negative_last = "UPDATE `module_meta` SET "
- " `pt_exchanged_x_days_after_epoch` = -10; "
- " UPDATE `module_config` SET `exchange_after_x_days` = 20";
- ASSERT_EQ(SQLITE_OK,
- sqlite3_exec(conn, query_negative_last, NULL, NULL, NULL));
+ " `pt_exchanged_x_days_after_epoch` = -10; "
+ " UPDATE `module_config` SET `exchange_after_x_days` = 20";
+ ASSERT_TRUE(dbms->Exec(query_negative_last));
EXPECT_EQ(0, reps->DaysBeforeExchange(0));
EXPECT_EQ(0, reps->DaysBeforeExchange(10));
const char* query_limit = "UPDATE `module_meta` SET "
- " `pt_exchanged_x_days_after_epoch` = 10; "
- " UPDATE `module_config` SET `exchange_after_x_days` = 100";
- ASSERT_EQ(SQLITE_OK, sqlite3_exec(conn, query_limit, NULL, NULL, NULL));
+ " `pt_exchanged_x_days_after_epoch` = 10; "
+ " UPDATE `module_config` SET `exchange_after_x_days` = 100";
+ ASSERT_TRUE(dbms->Exec(query_limit));
EXPECT_EQ(0, reps->DaysBeforeExchange(120));
EXPECT_EQ(60, reps->DaysBeforeExchange(50));
EXPECT_EQ(0, reps->DaysBeforeExchange(5));
@@ -267,16 +312,16 @@ TEST_F(SQLPTRepresentationTest, SecondsBetweenRetries) {
std::vector<int> seconds;
const char* query_delete = "DELETE FROM `seconds_between_retry`; ";
- ASSERT_EQ(SQLITE_OK, sqlite3_exec(conn, query_delete, NULL, NULL, NULL));
+ ASSERT_TRUE(dbms->Exec(query_delete));
ASSERT_TRUE(reps->SecondsBetweenRetries(&seconds));
EXPECT_EQ(0, seconds.size());
const char* query_insert =
- "INSERT INTO `seconds_between_retry` (`index`, `value`) "
- " VALUES (0, 10); "
- "INSERT INTO `seconds_between_retry` (`index`, `value`) "
- " VALUES (1, 20); ";
- ASSERT_EQ(SQLITE_OK, sqlite3_exec(conn, query_insert, NULL, NULL, NULL));
+ "INSERT INTO `seconds_between_retry` (`index`, `value`) "
+ " VALUES (0, 10); "
+ "INSERT INTO `seconds_between_retry` (`index`, `value`) "
+ " VALUES (1, 20); ";
+ ASSERT_TRUE(dbms->Exec(query_insert));
ASSERT_TRUE(reps->SecondsBetweenRetries(&seconds));
ASSERT_EQ(2, seconds.size());
EXPECT_EQ(10, seconds[0]);
@@ -285,11 +330,12 @@ TEST_F(SQLPTRepresentationTest, SecondsBetweenRetries) {
TEST_F(SQLPTRepresentationTest, TimeoutResponse) {
const char* query =
- "UPDATE `module_config` SET `timeout_after_x_seconds` = 60";
- ASSERT_EQ(SQLITE_OK, sqlite3_exec(conn, query, NULL, NULL, NULL));
+ "UPDATE `module_config` SET `timeout_after_x_seconds` = 60";
+ ASSERT_TRUE(dbms->Exec(query));
EXPECT_EQ(60, reps->TimeoutResponse());
}
+#ifndef EXTENDED_POLICY
TEST_F(SQLPTRepresentationTest, SaveGenerateSnapshot) {
Json::Value expect(Json::objectValue);
expect["policy_table"] = Json::Value(Json::objectValue);
@@ -301,6 +347,7 @@ TEST_F(SQLPTRepresentationTest, SaveGenerateSnapshot) {
policy_table["device_data"] = Json::Value(Json::objectValue);
policy_table["functional_groupings"] = Json::Value(Json::objectValue);
policy_table["consumer_friendly_messages"] = Json::Value(Json::objectValue);
+ policy_table["app_policies"] = Json::Value(Json::objectValue);
Json::Value& module_config = policy_table["module_config"];
module_config["preloaded_pt"] = Json::Value(true);
@@ -313,31 +360,30 @@ TEST_F(SQLPTRepresentationTest, SaveGenerateSnapshot) {
module_config["seconds_between_retries"][1] = Json::Value(20);
module_config["seconds_between_retries"][2] = Json::Value(30);
module_config["endpoints"] = Json::Value(Json::objectValue);
- module_config["endpoints"]["default"] = Json::Value(Json::objectValue);
- module_config["endpoints"]["default"]["default"] = Json::Value(Json::arrayValue);
- module_config["endpoints"]["default"]["default"][0] = Json::Value(
- "http://ford.com/cloud/default");
+ module_config["endpoints"]["0x00"] = Json::Value(Json::objectValue);
+ module_config["endpoints"]["0x00"]["default"] = Json::Value(Json::arrayValue);
+ module_config["endpoints"]["0x00"]["default"][0] = Json::Value(
+ "http://ford.com/cloud/default");
module_config["notifications_per_minute_by_priority"] = Json::Value(
- Json::objectValue);
+ Json::objectValue);
module_config["notifications_per_minute_by_priority"]["emergency"] =
- Json::Value(1);
+ Json::Value(1);
module_config["notifications_per_minute_by_priority"]["navigation"] =
- Json::Value(2);
+ Json::Value(2);
module_config["notifications_per_minute_by_priority"]["voiceCommunication"] =
- Json::Value(3);
+ Json::Value(3);
module_config["notifications_per_minute_by_priority"]["communication"] =
- Json::Value(4);
+ Json::Value(4);
module_config["notifications_per_minute_by_priority"]["normal"] = Json::Value(
- 5);
+ 5);
module_config["notifications_per_minute_by_priority"]["none"] = Json::Value(
- 6);
+ 6);
module_config["vehicle_make"] = Json::Value("MakeT");
module_config["vehicle_model"] = Json::Value("ModelT");
- module_config["vehicle_year"] = Json::Value(14);
+ module_config["vehicle_year"] = Json::Value(2014);
Json::Value& usage_and_error_counts = policy_table["usage_and_error_counts"];
usage_and_error_counts["app_level"] = Json::Value(Json::objectValue);
- // this map is not mandatory but is_valid returns false if map is empty
usage_and_error_counts["app_level"]["12345"] = Json::Value(Json::objectValue);
Json::Value& device_data = policy_table["device_data"];
@@ -345,16 +391,18 @@ TEST_F(SQLPTRepresentationTest, SaveGenerateSnapshot) {
Json::Value& functional_groupings = policy_table["functional_groupings"];
functional_groupings["default"] = Json::Value(Json::objectValue);
-
- Json::Value& consumer_friendly_messages = policy_table["consumer_friendly_messages"];
+ Json::Value& default_group = functional_groupings["default"];
+ default_group["rpcs"] = Json::Value(Json::objectValue);
+ default_group["rpcs"]["Update"] = Json::Value(Json::objectValue);
+ default_group["rpcs"]["Update"]["hmi_levels"] = Json::Value(Json::arrayValue);
+ default_group["rpcs"]["Update"]["hmi_levels"][0] = Json::Value("FULL");
+ default_group["rpcs"]["Update"]["parameters"] = Json::Value(Json::arrayValue);
+ default_group["rpcs"]["Update"]["parameters"][0] = Json::Value("speed");
+
+ Json::Value& consumer_friendly_messages =
+ policy_table["consumer_friendly_messages"];
consumer_friendly_messages["version"] = Json::Value("1.2");
- Json::Value& default_policies = policy_table["app_policies"]["default"];
- default_policies["default_hmi"] = "BACKGROUND";
- default_policies["keep_context"] = false;
- default_policies["priority"] = "EMERGENCY";
- default_policies["steal_focus"] = false;
-
Json::Value& app12345counters = usage_and_error_counts["app_level"]["12345"];
app12345counters["app_registration_language_gui"] = "";
app12345counters["app_registration_language_vui"] = "";
@@ -372,15 +420,23 @@ TEST_F(SQLPTRepresentationTest, SaveGenerateSnapshot) {
app12345counters["minutes_in_hmi_limited"] = 0;
app12345counters["minutes_in_hmi_none"] = 0;
+ Json::Value& app_policies = policy_table["app_policies"];
+ app_policies["default"] = Json::Value(Json::objectValue);
+ app_policies["default"]["memory_kb"] = Json::Value(50);
+ app_policies["default"]["watchdog_timer_ms"] = Json::Value(100);
+ app_policies["default"]["groups"] = Json::Value(Json::arrayValue);
+ app_policies["default"]["groups"][0] = Json::Value("default");
+
policy_table::Table table(&expect);
- //TODO(KKolodiy): temporarily validation is turned off
- // EXPECT_TRUE(table.is_valid());
+ ASSERT_TRUE(IsValid(table));
ASSERT_TRUE(reps->Save(table));
utils::SharedPtr<policy_table::Table> snapshot = reps->GenerateSnapshot();
- // EXPECT_TRUE(snapshot->is_valid());
- EXPECT_EQ(expect.toStyledString(), snapshot->ToJsonValue().toStyledString());
+ EXPECT_TRUE(IsValid(*snapshot));
+ EXPECT_EQ(table.ToJsonValue().toStyledString(),
+ snapshot->ToJsonValue().toStyledString());
}
+#endif // EXTENDED_POLICY
} // namespace policy
} // namespace components
diff --git a/src/components/policy/test/policy/src/test_stress_policy_manager_impl.cc b/src/components/policy/test/policy/src/test_stress_policy_manager_impl.cc
index c63a45356..45607097f 100644
--- a/src/components/policy/test/policy/src/test_stress_policy_manager_impl.cc
+++ b/src/components/policy/test/policy/src/test_stress_policy_manager_impl.cc
@@ -30,14 +30,18 @@
*/
#include <gtest/gtest.h>
+#include <gmock/gmock.h>
#include <string>
#include <set>
#include <sstream>
#include <fstream>
#include "policy/policy_manager_impl.h"
+#include "mock_policy_listener.h"
-using policy::PolicyManagerImpl;
-using policy::BinaryMessage;
+using ::testing::_;
+using ::policy::PolicyManagerImpl;
+using ::policy::BinaryMessage;
+using ::policy::MockPolicyListener;
namespace test {
namespace components {
@@ -215,16 +219,34 @@ void PolicyManagerImplTest::CreateTable(std::ofstream& ofs) {
}
TEST_F(PolicyManagerImplTest, StressTestOneCheck) {
- EXPECT_TRUE(
- manager->CheckPermissions("2", "FULL", "Func-1").hmi_level_permitted);
+ MockPolicyListener mock_listener;
+
+ EXPECT_CALL(mock_listener, OnCurrentDeviceIdUpdateRequired("2")).Times(1);
+
+ manager->set_listener(&mock_listener);
+ ::policy::CheckPermissionResult output = manager->CheckPermissions("2",
+ "FULL",
+ "Func-1");
+ EXPECT_EQ(::policy::kRpcAllowed, output.hmi_level_permitted);
}
TEST_F(PolicyManagerImplTest, StressTestNoPermission) {
- EXPECT_FALSE(
- manager->CheckPermissions("150", "FULL", "Func-400").hmi_level_permitted);
+ MockPolicyListener mock_listener;
+
+ EXPECT_CALL(mock_listener, OnCurrentDeviceIdUpdateRequired("150")).Times(1);
+
+ manager->set_listener(&mock_listener);
+ ::policy::CheckPermissionResult output = manager->CheckPermissions(
+ "150", "FULL", "Func-400");
+ EXPECT_EQ(::policy::kRpcDisallowed, output.hmi_level_permitted);
}
TEST_F(PolicyManagerImplTest, StressTestFewChecks) {
+ MockPolicyListener mock_listener;
+
+ EXPECT_CALL(mock_listener, OnCurrentDeviceIdUpdateRequired(_)).Times(100);
+ manager->set_listener(&mock_listener);
+
const int kNumberOfCheckings = 100;
std::stringstream ss;
int app, func;
@@ -236,9 +258,10 @@ TEST_F(PolicyManagerImplTest, StressTestFewChecks) {
ss >> app_number;
ss << func << std::endl;
ss >> func_number;
- EXPECT_TRUE(
- manager->CheckPermissions(app_number, "FULL", "Func-" + func_number)
- .hmi_level_permitted);
+
+ ::policy::CheckPermissionResult output = manager->CheckPermissions(
+ app_number, "FULL", "Func-" + func_number);
+ EXPECT_EQ(::policy::kRpcAllowed, output.hmi_level_permitted);
}
}
diff --git a/src/components/policy/test/policy/test-qdb.ini b/src/components/policy/test/policy/test-qdb.ini
new file mode 100644
index 000000000..d54d2fce8
--- /dev/null
+++ b/src/components/policy/test/policy/test-qdb.ini
@@ -0,0 +1,10 @@
+# This config file for QDB
+# Format see in manual of QNX
+[policy]
+Filename=policy.sqlite
+
+[test-database]
+Filename=test-database.sqlite
+
+[test-query]
+Filename=test-query.sqlite \ No newline at end of file
diff --git a/src/components/policy/test/policy/valid_sdl_pt_update.json b/src/components/policy/test/policy/valid_sdl_pt_update.json
new file mode 100644
index 000000000..2d85459ad
--- /dev/null
+++ b/src/components/policy/test/policy/valid_sdl_pt_update.json
@@ -0,0 +1,1817 @@
+{
+ "policy_table" : {
+ "app_policies" : {
+ "1766825573" : {
+ "AppHMIType" : [ "MEDIA" ],
+ "certificate" : "akdjfhaliuygrglurng",
+ "default_hmi" : "BACKGROUND",
+ "groups" : [
+ "Notifications",
+ "Location-1",
+ "PropriataryData-1",
+ "Navigation-1",
+ "Base-4",
+ "VehicleInfo-3",
+ "DrivingCharacteristics-3",
+ "Emergency-1"
+ ],
+ "keep_context" : true,
+ "memory_kb" : 1000,
+ "nicknames" : [ "SyncProxyTester" ],
+ "priority" : "EMERGENCY",
+ "steal_focus" : true,
+ "watchdog_timer_ms" : 20000
+ },
+ "default" : {
+ "default_hmi" : "NONE",
+ "groups" : [ "Base-4" ],
+ "keep_context" : false,
+ "memory_kb" : 1000,
+ "priority" : "NONE",
+ "steal_focus" : false,
+ "watchdog_timer_ms" : 20000
+ },
+ "device" : {
+ "default_hmi" : "NONE",
+ "groups" : [ "Base-4" ],
+ "memory_kb" : 1000,
+ "watchdog_timer_ms" : 20000,
+ "keep_context" : false,
+ "priority" : "NONE",
+ "steal_focus" : false
+ },
+ "pre_DataConsent" : {
+ "default_hmi" : "NONE",
+ "groups" : [ "pre_Base-1" ],
+ "keep_context" : false,
+ "memory_kb" : 1000,
+ "priority" : "NONE",
+ "steal_focus" : false,
+ "watchdog_timer_ms" : 20000
+ }
+ },
+ "consumer_friendly_messages" : {
+ "messages" : {
+ "AppPermissions" : {
+ "languages" : {
+ "de-de" : {
+ "line1" : "Zugriffsanfrage(n)",
+ "line2" : "erlauben?",
+ "tts" : "%appName% benötigt die folgenden Fahrzeuginformationen und Zugriffsberechtigungen: %functionalGroupLabels%. Wenn Sie Ja drücken, erklären Sie sich damit einverstanden, dass %vehicleMake% nicht für Schäden oder Verletzungen der Privatsphäre haftet, die im Zusammenhang mit der Nutzung Ihrer Benutzerdaten durch %appName% entstehen. Mit Ja stimmen Sie zu; mit Nein lehnen Sie ab."
+ },
+ "en-au" : {
+ "line1" : "Grant requested",
+ "line2" : "permission(s)?",
+ "tts" : "%appName% is requesting the use of the following vehicle information and permissions: %functionalGroupLabels%. If you press Yes, you agree that %vehicleMake% will not be liable for any damages or loss of privacy related to %appName%'s use of your data. Please press Yes to allow or No to deny."
+ },
+ "en-gb" : {
+ "line1" : "Grant requested",
+ "line2" : "permission(s)?",
+ "tts" : "%appName% is requesting the use of the following vehicle information and permissions: %functionalGroupLabels%. If you press Yes, you agree that %vehicleMake% will not be liable for any damages or loss of privacy related to %appName%'s use of your data. Please press Yes to allow or No to deny."
+ },
+ "en-ie" : {
+ "line1" : "Grant requested",
+ "line2" : "permission(s)?",
+ "tts" : "%appName% is requesting the use of the following vehicle information and permissions: %functionalGroupLabels%. If you press Yes, you agree that %vehicleMake% will not be liable for any damages or loss of privacy related to %appName%'s use of your data. Please press Yes to allow or No to deny."
+ },
+ "en-us" : {
+ "line1" : "Grant Requested",
+ "line2" : "Permission(s)?",
+ "tts" : "%appName% is requesting the use of the following vehicle information and permissions: %functionalGroupLabels%. If you press yes, you agree that %vehicleMake% will not be liable for any damages or loss of privacy related to %appName%'s use of your data. Please press yes to allow or no to deny."
+ },
+ "es-en" : {
+ "line1" : "¿Otorgar permiso(s)",
+ "line2" : "solicitado(s)?",
+ "tts" : "%appName% solicita el uso de la siguiente información y permisos del vehículo: %functionalGroupLabels%. Si presiona Sí, acepta que %vehicleMake% no se hará responsable por los daños o pérdidas de privacidad relacionados con el uso que %appName% haga de sus datos. Presione Sí para permitir y No para denegar."
+ },
+ "es-es" : {
+ "line1" : "¿Conceder permisos",
+ "line2" : "solicitados?",
+ "tts" : "%appName% está solicitando el uso de los siguientes permisos e información del vehículo: %functionalGroupLabels%. Si pulsa sí, acepta que %vehicleMake% no será responsable de los daños o la pérdida de privacidad relacionados con el uso de sus datos por parte de %appName%. Pulse sí para permitir o no para denegar."
+ },
+ "es-mx" : {
+ "line1" : "¿Otorgar permiso(s)",
+ "line2" : "solicitado(s)?",
+ "tts" : "%appName% solicita el uso de la siguiente información y permisos del vehículo: %functionalGroupLabels%. Si presiona Sí, acepta que %vehicleMake% no se hará responsable por los daños o pérdidas de privacidad relacionados con el uso que %appName% haga de sus datos. Presione Sí para permitir y No para denegar."
+ },
+ "fr-ca" : {
+ "line1" : "Accorder permission(s)",
+ "line2" : "demandée(s)",
+ "tts" : "%appName% demande d’utiliser les informations du véhicule et les permissions suivantes : %functionalGroupLabels%. Si vous appuyez sur Oui, vous acceptez que %vehicleMake% ne sera pas responsable des dommages ou des pertes de confidentialité reliées à l’utilisation de vos données par %appName%. Veuillez appuyer sur Oui pour autoriser ou sur Non pour refuser."
+ },
+ "fr-fr" : {
+ "line1" : "Accorder permission(s)",
+ "line2" : "demandée(s)",
+ "tts" : "%appName% demande d’utiliser les informations du véhicule et les permissions suivantes : %functionalGroupLabels%. Si vous appuyez sur Oui, vous acceptez que %vehicleMake% ne sera pas responsable des dommages ou des pertes de confidentialité reliées à l’utilisation de vos données par %appName%. Veuillez appuyer sur Oui pour autoriser ou sur Non pour refuser."
+ },
+ "it-it" : {
+ "line1" : "Concedi autorizzaz.",
+ "line2" : "richiesta(e)?",
+ "tts" : "%appName% richiede l'uso delle seguenti informazioni e autorizzazioni sul veicolo: %functionalGroupLabels%. Se si preme Sì, si acconsente che %vehicleMake% non sarà responsabile per danni o perdita di privacy in relazione all'impiego dei dati da parte di %appName%. Premere Sì per consentire e No per negare."
+ },
+ "nl-nl" : {
+ "line1" : "Aangevraagde",
+ "line2" : "permissie(s) verlenen?",
+ "tts" : "%appName% vraagt gebruikmaking van de volgende voertuiginformatie en toestemmingen aan: %functionalGroupLabels%. Als u op Ja drukt, gaat u ermee akkoord dat %vehicleMake% in geen geval aansprakelijk gesteld kan worden voor schade of verlies van privacy als gevolg van het feit dat %appName% gebruik maakt van uw gegevens. Druk op Ja om dit toe te staan of Nee om te weigeren."
+ },
+ "pl-pl" : {
+ "line1" : "Udzielić żądanych",
+ "line2" : "pozwoleń?",
+ "tts" : "%appName% wymaga następujących informacji o pojeździe oraz pozwoleń: %functionalGroupLabels%. Naciśnięcie TAK oznacza zgodę na fakt, iż %vehicleMake% nie będzie ponosić odpowiedzialności za szkody ani utratę prywatności w związku z wykorzystaniem przez %appName% danych, należących do użytkownika. Naciśnij TAK w celu udzielenia zgody lub NIE w celu odrzucenia żądania."
+ },
+ "pt-br" : {
+ "line1" : "Conceder permissão",
+ "line2" : "solicitada?",
+ "tts" : "%appName% está solicitando o uso das seguintes informações e permissões do veículo: %functionalGroupLabels%. Se pressionar sim, você concorda que a %vehicleMake% não será responsável por danos ou perdas de privacidade relacionados ao uso dos seus dados por %appName%. Pressione sim para permitir ou não para negar."
+ },
+ "pt-pt" : {
+ "line1" : "Conceder permiss.",
+ "line2" : "solicitada(s)?",
+ "tts" : "%appName% está a solicitar a utilização das seguintes informações e permissões do veículo: %functionalGroupLabels%. Se premir “Sim”, concorda que %vehicleMake% não será responsável por quaisquer danos ou perda de privacidade relacionada com a utilização dos seus dados por parte de %appName%. Prima “Sim” para permitir ou “Não” para recusar."
+ },
+ "ru-ru" : {
+ "line1" : "Предост. заправш.",
+ "line2" : "разрешения?",
+ "tts" : "%appName% запрашивает следующую информацию об автомобиле и разрешения: %functionalGroupLabels%. Нажатием \"\"да\"\", Вы соглашаетесь, что %vehicleMake% не будет нести ответственность за какие-либо убытки или потерю прайвеси, связанные с использованием Ваших данных компанией %appName%. Нажмите \"\"Да\"\", если Вы согласны, или \"\"Нет\"\" - если не согласны."
+ },
+ "sv-se" : {
+ "line1" : "Vill du ge",
+ "line2" : "tillstånd?",
+ "tts" : "%appName% begär att få tillgång till följande fordonsinformation och tillstånd: %functionalGroupLabels%. Om du trycker Ja godkänner du att %vehicleMake% ska hållas skadeslös för alla skador som kan uppstå eller eventuella integritetsintrång som uppstår när %appName% använder dina data. Tryck Ja för att godkänna eller Nej för att neka."
+ },
+ "tr-tr" : {
+ "line1" : "İstenen izinler",
+ "line2" : "verilsin mi?",
+ "tts" : "%appName%, şu araç bilgilerini ve izinleri kullanma isteğinde bulunuyor: %functionalGroupLabels%. Evet'e basarsanız, %appName%'in verilerinizi kullanması sonucunda oluşabilecek hasarlardan veya gizlilik kaybından %vehicleMake%'in sorumlu olmayacağını kabul etmiş olacaksınız. Lütfen kabul etmek için Evet'e veya reddetmek için Hayır'a basın."
+ },
+ "zh-cn" : {
+ "line1" : "是否允许请求的",
+ "line2" : "权限?",
+ "tts" : "%appName% 正在请求使用下列车辆信息和权限: %functionalGroupLabels%。如果您按“是”,则表示您同意。 %vehicleMake% 将不会对因 %appName% 使用您的数据而引起的任何损毁或隐私损失负责。 请按“是”允许或按“否”拒绝。"
+ },
+ "zh-tw" : {
+ "line1" : "允許",
+ "line2" : "授權請求?",
+ "tts" : "%appName% 正請求使用 %functionalGroupLabels% 的車輛資訊和許可。按「是」,表示您同意,如因 %appName% 使用您的資料導致任何損害或損失,%vehicleMake% 將不負賠償責任。同意請按「是」,拒絕請按「否」。"
+ }
+ }
+ },
+ "AppPermissionsHelp" : {
+ "languages" : {
+ "de-de" : {
+ "tts" : "%appName% fordert folgende Fahrzeuginformationen und Zugriffsberechtigungen: %functionalGroupLabels%. Im Einstellungsmenü der mobilen Apps können Sie diese Berechtigungen ändern und sich detaillierte Beschreibungen anhören. Mit Ja stimmen Sie zu; mit Nein lehnen Sie ab."
+ },
+ "en-au" : {
+ "tts" : "%appName% is requesting the following vehicle information and permissions: %functionalGroupLabels%. You can change these permissions and hear detailed descriptions in the mobile apps settings menu. Please press Yes to grant permissions or No to deny."
+ },
+ "en-gb" : {
+ "tts" : "%appName% is requesting the following vehicle information and permissions: %functionalGroupLabels%. You can change these permissions and hear detailed descriptions in the mobile apps settings menu. Please press Yes to grant permissions or No to deny."
+ },
+ "en-ie" : {
+ "tts" : "%appName% is requesting the following vehicle information and permissions: %functionalGroupLabels%. You can change these permissions and hear detailed descriptions in the mobile apps settings menu. Please press Yes to grant permissions or No to deny."
+ },
+ "en-us" : {
+ "tts" : "%appName% is requesting the following vehicle information and permissions: %functionalGroupLabels%. You can change these permissions and hear detailed descriptions in the mobile apps settings menu. Please press yes to grant permissions or no to deny."
+ },
+ "es-en" : {
+ "tts" : "%appName% solicita la siguiente información y permisos del vehículo: %functionalGroupLabels%. Puede cambiar estos permisos y consultar descripciones detalladas en el menú de configuración de las aplicaciones móviles. Presione Sí para otorgar permisos y No para denegar."
+ },
+ "es-es" : {
+ "tts" : "%appName% está solicitando los siguientes permisos e información del vehículo: %functionalGroupLabels%. Puede cambiar estos permisos y escuchar descripciones detalladas en el menú de configuración de la aplicación móvil. Pulse sí para conceder el permiso o no para denegarlo."
+ },
+ "es-mx" : {
+ "tts" : "%appName% solicita la siguiente información y permisos del vehículo: %functionalGroupLabels%. Puede cambiar estos permisos y consultar descripciones detalladas en el menú de configuración de las aplicaciones móviles. Presione Sí para otorgar permisos y No para denegar."
+ },
+ "fr-ca" : {
+ "tts" : "%appName% demande d’utiliser les informations du véhicule et les permissions suivantes : %functionalGroupLabels%. Vous pouvez modifier ces permissions et entendre les descriptions détaillées dans le menu des réglages des applications mobiles. Veuillez appuyer sur Oui pour accorder les permissions ou sur Non pour refuser."
+ },
+ "fr-fr" : {
+ "tts" : "%appName% demande d’utiliser les informations du véhicule et les permissions suivantes : %functionalGroupLabels%. Vous pouvez modifier ces permissions et entendre les descriptions détaillées dans le menu des réglages des applications mobiles. Veuillez appuyer sur Oui pour accorder les permissions ou sur Non pour refuser."
+ },
+ "it-it" : {
+ "tts" : "%appName% richiede le seguenti informazioni e autorizzazioni riguardo il veicolo: %functionalGroupLabels%. È possibile modificare tali autorizzazioni e ascoltare descrizioni dettagliate nel menu impostazioni delle app mobili. Premere Sì per concedere le autorizzazioni e No per negarle."
+ },
+ "nl-nl" : {
+ "tts" : "%appName% vraagt gebruikmaking van de volgende voertuiginformatie en toestemmingen aan: %functionalGroupLabels%. U kunt deze toestemmingen wijzigen en gedetailleerde beschrijvingen beluisteren in het instellingenmenu voor mobiele apps. Druk op Ja om permissies te verlenen of op Nee om te weigeren."
+ },
+ "pl-pl" : {
+ "tts" : "%appName% wymaga następujących informacji o pojeździe oraz zezwoleń: %functionalGroupLabels%. W menu ustawień aplikacji mobilnych można zmienić owe zezwolenia i usłyszeć ich szczegółowy opis. Naciśnij TAK, aby wyrazić zgodę lub NIE w celu odrzucenia żądania."
+ },
+ "pt-br" : {
+ "tts" : "%appName% está solicitando as seguintes informações e permissões do veículo: %functionalGroupLabels%. Você pode alterar estas permissões e ouvir descrições detalhadas no menu de configurações de aplicativos móveis. Pressione sim para conceder as permissões ou não para negar."
+ },
+ "pt-pt" : {
+ "tts" : "%appName% está a solicitar as seguintes informações e permissões do veículo: %functionalGroupLabels%. Pode alterar estas permissões e ouvir descrições detalhadas no menu de definições das aplicações móveis. Prima \"\"Sim\"\" para permitir ou \"\"Não\"\" para recusar."
+ },
+ "ru-ru" : {
+ "tts" : "%appName% запрашивает следующую информацию об автомобиле и разрешения: %functionalGroupLabels%. Вы можете изменить эти разрешения и прослушать подробные их описания в меню настроек мобильного приложения. Нажмите \"\"да\"\", чтобы предоставить разрешения, или \"\"нет\"\", чтобы не предоставлять."
+ },
+ "sv-se" : {
+ "tts" : "%appName% begär tillgång till följande fordonsinformation och tillstånd: %functionalGroupLabels%. Du kan ändra tillstånden och höra detaljerade beskrivningar i menyn för mobilappsinställningar. Tryck Ja för att ge tillstånd eller Nej för att neka."
+ },
+ "tr-tr" : {
+ "tts" : "%appName%, şu araç bilgilerini ve izinleri istiyor: %functionalGroupLabels%. Bu izinleri değiştirebilir ve mobil uygulamalar ayarlar menüsünden ayrıntılı açıklamaları dinleyebilirsiniz. Lütfen izin vermek için Evet'e veya reddetmek için Hayır'a basın."
+ },
+ "zh-cn" : {
+ "tts" : "%appName% 正在请求下列车辆信息和权限: %functionalGroupLabels%。您可在移动应用程序设置菜单中更改这些权限,并听取详细说明。请按“是”允许权限或按“否”拒绝。"
+ },
+ "zh-tw" : {
+ "tts" : "%appName% 正請求使用 %functionalGroupLabels% 的車輛資訊和許可。您可在行動應用程式設定清單中更改這些許可,並聆聽詳細說明。給予許可請按「是」,拒絕請按「否」。"
+ }
+ }
+ },
+ "AppPermissionsRevoked" : {
+ "languages" : {
+ "de-de" : {
+ "tts" : "Die Autorisierungsdaten der App wurden geändert. %appName% hat keinen Zugriff auf %functionalGroupLabels% mehr. Installieren Sie die neueste Version der App auf Ihrem Gerät.."
+ },
+ "en-au" : {
+ "tts" : "App authorizations have changed. %appName% can no longer access %functionalGroupLabels%. Please ensure you have the most recent app version installed on your mobile device."
+ },
+ "en-gb" : {
+ "tts" : "App authorizations have changed. %appName% can no longer access %functionalGroupLabels%. Please ensure you have the most recent app version installed on your mobile device."
+ },
+ "en-ie" : {
+ "tts" : "App authorizations have changed. %appName% can no longer access %functionalGroupLabels%. Please ensure you have the most recent app version installed on your mobile device."
+ },
+ "en-us" : {
+ "tts" : "App authorizations have changed. %appName% can no longer access %functionalGroupLabels%. Please ensure you have the most recent app version installed on your mobile device."
+ },
+ "es-en" : {
+ "tts" : "Las autorizaciones de la aplicación han cambiado. %appName% ya no puede acceder a %functionalGroupLabels%. Asegúrese de haber instalado la versión más reciente de la aplicación en su dispositivo móvil."
+ },
+ "es-es" : {
+ "tts" : "Las autorizaciones de la aplicación han cambiado. %appName% ya no puede acceder a %functionalGroupLabels%. Asegúrese de que tiene la versión más reciente de la aplicación instalada en su dispositivo móvil."
+ },
+ "es-mx" : {
+ "tts" : "Las autorizaciones de la aplicación han cambiado. %appName% ya no puede acceder a %functionalGroupLabels%. Asegúrese de haber instalado la versión más reciente de la aplicación en su dispositivo móvil."
+ },
+ "fr-ca" : {
+ "tts" : "Les autorisations pour app ont changé. %appName% ne peut plus accéder à %functionalGroupLabels%. Veuillez vous assurer que la plus récente version de l’application est installée sur votre appareil mobile."
+ },
+ "fr-fr" : {
+ "tts" : "Les autorisations pour app ont changé. %appName% ne peut plus accéder à %functionalGroupLabels%. Veuillez vous assurer que la plus récente version de l’application est installée sur votre appareil mobile."
+ },
+ "it-it" : {
+ "tts" : "Le autorizzazioni dell'app sono cambiate. %appName% non è più in grado di accedere a %functionalGroupLabels%. Assicurarsi di avere la versione più recente dell'app installata sul dispositivo mobile."
+ },
+ "nl-nl" : {
+ "tts" : "De app-autorisaties zijn gewijzigd. %appName% heeft geen toegang meer tot %functionalGroupLabels%. Zorg ervoor dat u de meest recente app-versie op uw mobiele apparaat geïnstalleerd hebt."
+ },
+ "pl-pl" : {
+ "tts" : "Dane dostępu aplikacji zostały zmienione. %appName% nie ma już dostępu do %functionalGroupLabels%. Sprawdź, czy na telefonie komórkowym zainstalowano najnowszą wersję aplikacji."
+ },
+ "pt-br" : {
+ "tts" : "As autorizações dos aplicativos foram alteradas. %appName% não pode mais acessar %functionalGroupLabels%. Certifique-se de que a versão mais recente do aplicativo está instalada no seu dispositivo móvel."
+ },
+ "pt-pt" : {
+ "tts" : "As autorizações das aplicações mudaram. %appName% já não consegue aceder a %functionalGroupLabels%. Certifique-se de que tem a última versão da aplicação no seu dispositivo móvel."
+ },
+ "ru-ru" : {
+ "tts" : "Авторизации приложения изменены. %appName% больше не имеет доступа к %functionalGroupLabels%. Убедитесь, что на вашем мобильном устройстве установлена самая новая версия приложения."
+ },
+ "sv-se" : {
+ "tts" : "Appens behörigheter har ändrats. %appName% har inte längre åtkomst till %functionalGroupLabels%. Kontrollera att du har installerat den senaste versionen av appen på mobilenheten."
+ },
+ "tr-tr" : {
+ "tts" : "Uygulama yetkileri değişti. %appName% artık %functionalGroupLabels%'e erişemeyecek. Lütfen mobil aygıtınızda en son uygulama sürümünün yüklü olduğundan emin olun."
+ },
+ "zh-cn" : {
+ "tts" : "应用程序授权已变更。 %appName% 将不能再访问 %functionalGroupLabels%。 请确认您的移动设备上安装的应用程序是最新版本。"
+ },
+ "zh-tw" : {
+ "tts" : "應用程式授權已改變。%appName% 已無法進入 %functionalGroupLabels%。請確認您的行動裝置上安裝了最新版應用程式。"
+ }
+ }
+ },
+ "AppUnauthorized" : {
+ "languages" : {
+ "de-de" : {
+ "line1" : "nicht autorisiert",
+ "tts" : "Diese Version von %appName% ist nicht autorisiert und wird nicht mit SYNC funktionieren."
+ },
+ "en-au" : {
+ "line1" : "not authorized",
+ "tts" : "This version of %appName% is not authorized and will not work with SYNC."
+ },
+ "en-gb" : {
+ "line1" : "not authorized",
+ "tts" : "This version of %appName% is not authorized and will not work with SYNC."
+ },
+ "en-ie" : {
+ "line1" : "not authorized",
+ "tts" : "This version of %appName% is not authorized and will not work with SYNC."
+ },
+ "en-us" : {
+ "line1" : "Not Authorized",
+ "tts" : "This version of %appName% is not authorized and will not work with SYNC."
+ },
+ "es-en" : {
+ "line1" : "no autorizada",
+ "tts" : "Esta versión de %appName% no tiene autorización y no funcionará con SYNC."
+ },
+ "es-es" : {
+ "line1" : "No autorizada",
+ "tts" : "Esta versión de %appName% no está autorizada y no funcionará con SYNC."
+ },
+ "es-mx" : {
+ "line1" : "no autorizada",
+ "tts" : "Esta versión de %appName% no tiene autorización y no funcionará con SYNC."
+ },
+ "fr-ca" : {
+ "line1" : "non autorisée",
+ "tts" : "Cette version de %appName% n’est pas autorisée et ne fonctionnera pas avec SYNC."
+ },
+ "fr-fr" : {
+ "line1" : "non autorisée",
+ "tts" : "Cette version de %appName% n’est pas autorisée et ne fonctionnera pas avec SYNC."
+ },
+ "it-it" : {
+ "line1" : "non autorizzata",
+ "tts" : "Questa versione di %appName% non è autorizzata e non funziona con il SYNC."
+ },
+ "nl-nl" : {
+ "line1" : "niet geautoriseerd",
+ "tts" : "Deze versie van %appName% is niet geautoriseerd en werkt niet met SYNC."
+ },
+ "pl-pl" : {
+ "line1" : "brak autoryzacji",
+ "tts" : "Niniejsza wersja %appName% nie posiada autoryzacji i nie będzie działać z SYNC."
+ },
+ "pt-br" : {
+ "line1" : "não autorizado",
+ "tts" : "Esta versão do %appName% não tem autorização e não funcionará com o SYNC."
+ },
+ "pt-pt" : {
+ "line1" : "não autorizada",
+ "tts" : "Esta versão de %appName% não está autorizada e não funcionará com o SYNC."
+ },
+ "ru-ru" : {
+ "line1" : "не авторизировано",
+ "tts" : "Эта версия %appName% не авторизирована и не будет работать с SYNC."
+ },
+ "sv-se" : {
+ "line1" : "är ej godkänd",
+ "tts" : "Den här versionen av %appName% är inte godkänd och fungerar inte med SYNC."
+ },
+ "tr-tr" : {
+ "line1" : "için izin yok",
+ "tts" : "Bu %appName% sürümüne izin verilmediğinden SYNC ile çalışamaz."
+ },
+ "zh-cn" : {
+ "line1" : "未得到授权",
+ "tts" : "此版本的%appName% 未得到授权,无法在SYNC上使用。"
+ },
+ "zh-tw" : {
+ "line1" : "無授權",
+ "tts" : "%appName% 的版本未獲得授權,將無法透過 SYNC 使用。"
+ }
+ }
+ },
+ "AppUnsupported" : {
+ "languages" : {
+ "de-de" : {
+ "line1" : "nicht unterstützt",
+ "tts" : "Diese Version von %appName% wird von SYNC nicht unterstützt."
+ },
+ "en-au" : {
+ "line1" : "not supported",
+ "tts" : "This version of %appName% is not supported by SYNC."
+ },
+ "en-gb" : {
+ "line1" : "not supported",
+ "tts" : "This version of %appName% is not supported by SYNC."
+ },
+ "en-ie" : {
+ "line1" : "not supported",
+ "tts" : "This version of %appName% is not supported by SYNC."
+ },
+ "en-us" : {
+ "line1" : "Not Supported",
+ "tts" : "This version of %appName% is not supported by SYNC."
+ },
+ "es-en" : {
+ "line1" : "no compatible",
+ "tts" : "Esta versión de %appName% no es compatible con SYNC."
+ },
+ "es-es" : {
+ "line1" : "No compatible",
+ "tts" : "Esta versión de %appName% no es compatible con SYNC."
+ },
+ "es-mx" : {
+ "line1" : "no compatible",
+ "tts" : "Esta versión de %appName% no es compatible con SYNC."
+ },
+ "fr-ca" : {
+ "line1" : "incompatible",
+ "tts" : "Cette version de %appName% n’est pas prise en charge par SYNC."
+ },
+ "fr-fr" : {
+ "line1" : "incompatible",
+ "tts" : "Cette version de %appName% n’est pas prise en charge par SYNC."
+ },
+ "it-it" : {
+ "line1" : "non supportata",
+ "tts" : "Questa versione di %appName% non è supportata dal SYNC."
+ },
+ "nl-nl" : {
+ "line1" : "niet ondersteund",
+ "tts" : "Deze versie van %appName% wordt niet ondersteund door SYNC."
+ },
+ "pl-pl" : {
+ "line1" : "aplikacja nie obsług.",
+ "tts" : "Niniejsza wersja %appName% nie jest obsługiwana przez system SYNC."
+ },
+ "pt-br" : {
+ "line1" : "não suportado",
+ "tts" : "Esta versão do %appName% não é suportada pelo SYNC."
+ },
+ "pt-pt" : {
+ "line1" : "não suportada",
+ "tts" : "Esta versão de %appName% não é suportado pelo SYNC."
+ },
+ "ru-ru" : {
+ "line1" : "не поддерживается",
+ "tts" : "Эта версия %appName% не поддерживается SYNC."
+ },
+ "sv-se" : {
+ "line1" : "stöds ej",
+ "tts" : "SYNC har inte stöd för den här versionen av %appName%."
+ },
+ "tr-tr" : {
+ "line1" : "desteklenmiyor",
+ "tts" : "Bu %appName% sürümü SYNC tarafından desteklenmiyor."
+ },
+ "zh-cn" : {
+ "line1" : "不受支持",
+ "tts" : "SYNC不支持此版本的%appName%。"
+ },
+ "zh-tw" : {
+ "line1" : "不支援",
+ "tts" : "SYNC 不支援此版本的%appName% 。"
+ }
+ }
+ },
+ "DataConsent" : {
+ "languages" : {
+ "en-us" : {
+ "line1" : "Enable Mobile Apps",
+ "line2" : "on SYNC? (Uses Data)",
+ "tts" : "To use mobile apps with SYNC, SYNC will communicate with Ford at least once per month using your mobile device's data plan. Standard rates may apply. SYNC will send your VIN and SYNC module number to Ford U.S. Please press yes or no, or help for more information. "
+ }
+ }
+ },
+ "DataConsentHelp" : {
+ "languages" : {
+ "en-us" : {
+ "tts" : "Updates are about the size of an email, and the occurrence of updates depends on your vehicle usage and when a new app is found on your device. To turn on or off, visit the SYNC mobile apps settings menu. See your Owner Guide for more information. "
+ }
+ }
+ },
+ "DisableApps" : {
+ "languages" : {
+ "de-de" : {
+ "line1" : "Auto-Update",
+ "line2" : "und Mobile Apps deaktivieren",
+ "tts" : "Ausschalten der automatischen Updates führt zum Ausschalten von SYNC mobile Apps. Sie können Ihre mobilen Apps dann nicht mehr mit SYNC nutzen. Bitte drücken Sie Ja zur Bestätigung oder Nein, um abzubrechen."
+ },
+ "en-au" : {
+ "line1" : "Disable auto-updates",
+ "line2" : "and Mobile Apps?",
+ "tts" : "Disabling automatic updates will also disable SYNC mobile apps. You will not be able to use any mobile apps with SYNC. Please press Yes to confirm or No to cancel."
+ },
+ "en-gb" : {
+ "line1" : "Disable auto-updates",
+ "line2" : "and Mobile Apps?",
+ "tts" : "Disabling automatic updates will also disable SYNC mobile apps. You will not be able to use any mobile apps with SYNC. Please press Yes to confirm or No to cancel."
+ },
+ "en-ie" : {
+ "line1" : "Disable auto-updates",
+ "line2" : "and Mobile Apps?",
+ "tts" : "Disabling automatic updates will also disable SYNC mobile apps. You will not be able to use any mobile apps with SYNC. Please press Yes to confirm or No to cancel."
+ },
+ "en-us" : {
+ "line1" : "Disable Auto-Updates",
+ "line2" : "and Mobile Apps?",
+ "tts" : "Disabling automatic updates will also disable sync mobile apps. You will not be able to use any mobile apps with SYNC. Please press yes to confirm or no to cancel."
+ },
+ "es-en" : {
+ "line1" : "¿Deshab. actualiz.",
+ "line2" : "autom. y aplic. móv.?",
+ "tts" : "Si se desactivan las actualizaciones automáticas, también se desactivarán las aplicaciones móviles de SYNC. No podrá usar ninguna aplicación móvil con SYNC. Presione Sí para confirmar o No para cancelar."
+ },
+ "es-es" : {
+ "line1" : "¿Desact. actual. auto",
+ "line2" : "y apl. móviles?",
+ "tts" : "Si desactiva las actualizaciones automáticas, también se desactivará la sincronización de las aplicaciones móviles. No podrá utilizar ninguna aplicación móvil con SYNC. Pulse sí para confirmar o no para cancelar."
+ },
+ "es-mx" : {
+ "line1" : "¿Deshab. actualiz.",
+ "line2" : "autom. y aplic. móv.?",
+ "tts" : "Si se desactivan las actualizaciones automáticas, también se desactivarán las aplicaciones móviles de SYNC. No podrá usar ninguna aplicación móvil con SYNC. Presione Sí para confirmar o No para cancelar."
+ },
+ "fr-ca" : {
+ "line1" : "Désactiver màj autom.",
+ "line2" : "et app. mobiles?",
+ "tts" : "La désactivation des mises à jour automatiques désactivera aussi les applications mobiles SYNC. Vous ne pourrez pas utiliser d’application mobile avec SYNC. Veuillez appuyer sur Oui pour confirmer ou sur Non pour annuler."
+ },
+ "fr-fr" : {
+ "line1" : "Désactiver màj autom.",
+ "line2" : "et app. mobiles?",
+ "tts" : "La désactivation des mises à jour automatiques désactivera aussi les applications mobiles SYNC. Vous ne pourrez pas utiliser d’application mobile avec SYNC. Veuillez appuyer sur Oui pour confirmer ou sur Non pour annuler."
+ },
+ "it-it" : {
+ "line1" : "Disabilitare agg. aut.",
+ "line2" : "e app mobili?",
+ "tts" : "Disabilitando gli aggiornamenti automatici si disattiva anche la sincronizzazione delle app mobili. Non sarà possibile usare app mobili con il SYNC. Premere Sì per confermare e No per cancellare."
+ },
+ "nl-nl" : {
+ "line1" : "Auto-updates en mob.",
+ "line2" : "apps uitschakelen?",
+ "tts" : "Door automatische updates uit te schakelen, schakelt u ook SYNC-mobiele apps uit. U kunt dan geen mobiele apps meer gebruiken met SYNC. Druk op Ja om te bevestigen of op Nee om te annuleren."
+ },
+ "pl-pl" : {
+ "line1" : "Wył. automat. aktual.",
+ "line2" : "i aplikacje mobilne?",
+ "tts" : "Wyłączenie automatycznych aktualizacji spowoduje także wyłączenie aplikacji mobilnych SYNC. Korzystanie z mobilnych aplikacji za pomocą SYNC będzie niemożliwe. Naciśnij TAK, by potwierdzić lub NIE, by anulować."
+ },
+ "pt-br" : {
+ "line1" : "Desativar atualizações",
+ "line2" : "autom. e aplicativos?",
+ "tts" : "Se as atualizações automáticas forem desativadas, os aplicativos também serão desativados. Você não poderá usar nenhum aplicativo com o SYNC. Pressione sim para confirmar ou não para cancelar."
+ },
+ "pt-pt" : {
+ "line1" : "Desact. actual. autom.",
+ "line2" : "e aplicações móveis?",
+ "tts" : "A desactivação das actualizações automáticas desactiva igualmente as aplicações móveis do SYNC. Não poderá utilizar quaisquer aplicações móveis com o SYNC. Prima \"\"Sim\"\" para confirmar ou \"\"Não\"\" para cancelar."
+ },
+ "ru-ru" : {
+ "line1" : "Откл. автообновления",
+ "line2" : "и мобил. прилож.?",
+ "tts" : "При отключении автоматических обновлений также будут отключены мобильные приложения sync. Вы не сможете использовать какие-либо мобильные приложения с SYNC. Нажмите \"\"Да\"\" для подтверждения или \"\"Нет\"\" для отмены."
+ },
+ "sv-se" : {
+ "line1" : "Avaktiverar autouppdat.",
+ "line2" : "och mobilappar?",
+ "tts" : "Om du avaktiverar automatisk uppdatering avaktiverar du även synkning av mobilappar. Du kommer inte längre att kunna använda dina mobilappar med SYNC. Tryck Ja för att bekräfta eller Nej för att avbryta."
+ },
+ "tr-tr" : {
+ "line1" : "Oto. güncelleme ve",
+ "line2" : "mobil uygul. kapat?",
+ "tts" : "Otomatik güncellemeleri devre dışı bırakırsanız sync mobil uygulamalar da devre dışı kalır. SYNC ile mobil uygulama kullanmanız mümkün olmaz. Lütfen onaylamak için Evet'e veya iptal etmek için Hayır'a basın."
+ },
+ "zh-cn" : {
+ "line1" : "是否禁用自动更新和",
+ "line2" : "移动应用程序?",
+ "tts" : "禁用自动更新同时也会禁用SYNC移动应用程序。您将无法在 SYNC 中使用任何移动应用程序。请按“是”确认或按“否”取消。"
+ },
+ "zh-tw" : {
+ "line1" : "停用自動更新",
+ "line2" : "和行動應用程式?",
+ "tts" : "停用自動更新也將停用 sync 行動應用程式。您將無法透過 SYNC 使用任何行動應用程式。確認請按「是」,取消請按「否」。"
+ }
+ }
+ },
+ "DrivingCharacteristics" : {
+ "languages" : {
+ "de-de" : {
+ "label" : "Fahreigenschaften",
+ "tts" : "Eine App hat Zugriff auf die folgenden Fahreigenschaften: Kraftstoffverbrauch, MyKey, Sicherheitsgurtstatus."
+ },
+ "en-au" : {
+ "label" : "Driving characteristics",
+ "tts" : "An app can access the following driving characteristics: Fuel consumption, MyKey, Seat belt status."
+ },
+ "en-gb" : {
+ "label" : "Driving characteristics",
+ "tts" : "An app can access the following driving characteristics: Fuel consumption, MyKey, Seat belt status."
+ },
+ "en-ie" : {
+ "label" : "Driving characteristics",
+ "tts" : "An app can access the following driving characteristics: Fuel consumption, MyKey, Seat belt status."
+ },
+ "en-us" : {
+ "label" : "Driving Characteristics",
+ "tts" : "An app can access the following driving characteristics: Fuel Consumption, MyKey, Seat Belt Status."
+ },
+ "es-en" : {
+ "label" : "Características del manejo",
+ "tts" : "Las aplicaciones pueden acceder a las siguientes características del manejo: Consumo de combustible, MyKey, Estado del cinturón de seguridad."
+ },
+ "es-es" : {
+ "label" : "Características de conducción",
+ "tts" : "Una aplicación puede acceder a las siguientes características de conducción: Consumo de combustible, MyKey, Estado cinturones de seguridad."
+ },
+ "es-mx" : {
+ "label" : "Características del manejo",
+ "tts" : "Las aplicaciones pueden acceder a las siguientes características del manejo: Consumo de combustible, MyKey, Estado del cinturón de seguridad."
+ },
+ "fr-ca" : {
+ "label" : "Caractéristiques de conduite",
+ "tts" : "Une application peut accéder aux caractéristiques de conduite suivantes: Consommation de carburant, MyKey, État des ceintures de sécurité."
+ },
+ "fr-fr" : {
+ "label" : "Caractéristiques de conduite",
+ "tts" : "Une application peut accéder aux caractéristiques de conduite suivantes: Consommation de carburant, MyKey, État des ceintures de sécurité."
+ },
+ "it-it" : {
+ "label" : "Caratteristiche di guida",
+ "tts" : "Un'app può avere accesso alle seguenti caratteristiche di guida: Consumo carburante, MyKey, Stato cinture di sicurezza."
+ },
+ "nl-nl" : {
+ "label" : "Rijkenmerken",
+ "tts" : "Een app heeft toegang tot de volgende rijkenmerken: Brandstofverbruik, MyKey, Veiligheidsgordelstatus."
+ },
+ "pl-pl" : {
+ "label" : "Informacje dotyczące stylu jazdy",
+ "tts" : "Aplikacja może uzyskać dostęp do następujących informacji dotyczących jazdy: Zużycie paliwa, MyKey, Stan pasów bezpieczeństwa."
+ },
+ "pt-br" : {
+ "label" : "Características de condução",
+ "tts" : "Um aplicativo pode acessar as seguintes características de condução: Consumo de combustível, MyKey, Estado do cinto de segurança."
+ },
+ "pt-pt" : {
+ "label" : "Características de condução",
+ "tts" : "Uma aplicação consegue aceder às seguintes informações de condução: Consumo de combustível, MyKey, Estado dos cintos de segurança."
+ },
+ "ru-ru" : {
+ "label" : "Характеристики движения",
+ "tts" : "Приложение имеет доступ к следующим характеристикам движения: Расход топлива, MyKey, Состояние ремней безопасности."
+ },
+ "sv-se" : {
+ "label" : "Köregenskaper",
+ "tts" : "Appen kan komma åt följande köregenskaper: Bränsleförbrukning, MyKey, Bältesstatus."
+ },
+ "tr-tr" : {
+ "label" : "Sürüş karakteristikleri",
+ "tts" : "Bir uygulama şu sürüş karakteristiklerine erişebilir: Yakıt tüketimi, MyKey, Emniyet kemeri durumu."
+ },
+ "zh-cn" : {
+ "label" : "行驶特性",
+ "tts" : "移动应用程序可访问下列行驶特性: 油耗, MyKey, 安全带状态"
+ },
+ "zh-tw" : {
+ "label" : "駕駛特性",
+ "tts" : "應用程式可存取以下駕駛特性: 油耗, MyKey, 安全帶狀態"
+ }
+ }
+ },
+ "Location" : {
+ "languages" : {
+ "de-de" : {
+ "label" : "GPS und Geschwindigkeit",
+ "tts" : "Eine App hat Zugriff auf die GPS-Daten und die Geschwindigkeit des Fahrzeugs."
+ },
+ "en-au" : {
+ "label" : "GPS and speed",
+ "tts" : "An app can access vehicle GPS and speed."
+ },
+ "en-gb" : {
+ "label" : "GPS and speed",
+ "tts" : "An app can access vehicle GPS and speed."
+ },
+ "en-ie" : {
+ "label" : "GPS and speed",
+ "tts" : "An app can access vehicle GPS and speed."
+ },
+ "en-us" : {
+ "label" : "GPS and speed",
+ "tts" : "An app can access vehicle GPS and speed."
+ },
+ "es-en" : {
+ "label" : "GPS y velocidad",
+ "tts" : "Las aplicaciones pueden acceder al GPS y a la velocidad del vehículo."
+ },
+ "es-es" : {
+ "label" : "GPS y velocidad",
+ "tts" : "Una aplicación puede acceder al GPS y la velocidad del vehículo."
+ },
+ "es-mx" : {
+ "label" : "GPS y velocidad",
+ "tts" : "Las aplicaciones pueden acceder al GPS y a la velocidad del vehículo."
+ },
+ "fr-ca" : {
+ "label" : "GPS et vitesse",
+ "tts" : "Une application peut accéder au GPS et à la vitesse du véhicule."
+ },
+ "fr-fr" : {
+ "label" : "GPS et vitesse",
+ "tts" : "Une application peut accéder au GPS et à la vitesse du véhicule."
+ },
+ "it-it" : {
+ "label" : "GPS e velocità",
+ "tts" : "Un'app può avere accesso a GPS e velocità del veicolo."
+ },
+ "nl-nl" : {
+ "label" : "Gps en snelheid",
+ "tts" : "Een app heeft toegang tot gps en de snelheid van het voertuig."
+ },
+ "pl-pl" : {
+ "label" : "GPS i prędkość",
+ "tts" : "Aplikacja może uzyskać dostęp do modułu GPS i prędkości pojazdu."
+ },
+ "pt-br" : {
+ "label" : "GPS e velocidade",
+ "tts" : "Um aplicativo pode acessar o GPS e a velocidade do veículo."
+ },
+ "pt-pt" : {
+ "label" : "GPS e velocidade",
+ "tts" : "Uma aplicação consegue aceder ao GPS e à velocidade do veículo."
+ },
+ "ru-ru" : {
+ "label" : "GPS и скорость",
+ "tts" : "Приложение имеет доступ к GPS и скорости автомобиля."
+ },
+ "sv-se" : {
+ "label" : "GPS och hastighet",
+ "tts" : "Appen kan komma åt fordonets GPS och hastighetsmätare."
+ },
+ "tr-tr" : {
+ "label" : "GPS ve hız",
+ "tts" : "Bu uygulama aracın GPS ve hız bilgilerine erişebilir."
+ },
+ "zh-cn" : {
+ "label" : "GPS 和车速",
+ "tts" : "移动应用程序可以访问车辆 GPS 和车速信息。"
+ },
+ "zh-tw" : {
+ "label" : "GPS和車速",
+ "tts" : "應用程式可存取車輛的GPS和速度。"
+ }
+ }
+ },
+ "Notifications" : {
+ "languages" : {
+ "de-de" : {
+ "label" : "Push-Benachrichtigungen",
+ "tts" : "Läuft die App im Hintergrund, kann Sie Benachrichtigungen senden."
+ },
+ "en-au" : {
+ "label" : "Push notifications",
+ "tts" : "An app can send notifications when running in the background."
+ },
+ "en-gb" : {
+ "label" : "Push notifications",
+ "tts" : "An app can send notifications when running in the background."
+ },
+ "en-ie" : {
+ "label" : "Push notifications",
+ "tts" : "An app can send notifications when running in the background."
+ },
+ "en-us" : {
+ "label" : "Push notifications",
+ "tts" : "An app can send notifications when running in the background."
+ },
+ "es-en" : {
+ "label" : "Notificaciones tipo Push",
+ "tts" : "Las aplicaciones pueden enviar notificaciones cuando se ejecutan en segundo plano."
+ },
+ "es-es" : {
+ "label" : "Notificaciones push",
+ "tts" : "Una aplicación puede enviar notificaciones cuando se está ejecutando en segundo plano."
+ },
+ "es-mx" : {
+ "label" : "Notificaciones tipo Push",
+ "tts" : "Las aplicaciones pueden enviar notificaciones cuando se ejecutan en segundo plano."
+ },
+ "fr-ca" : {
+ "label" : "Notifications instantanées",
+ "tts" : "Une application peut envoyer des avis lorsqu’elle fonctionne en arrière-plan."
+ },
+ "fr-fr" : {
+ "label" : "Notifications push",
+ "tts" : "Une application peut envoyer des avis lorsqu’elle fonctionne en arrière-plan."
+ },
+ "it-it" : {
+ "label" : "Notifiche push",
+ "tts" : "Un'app può inviare notifiche se eseguita in background."
+ },
+ "nl-nl" : {
+ "label" : "Push-meldingen",
+ "tts" : "Een app kan meldingen versturen als deze op de achtergrond actief is."
+ },
+ "pl-pl" : {
+ "label" : "Powiadomienia Push",
+ "tts" : "Aplikacja może wysyłać powiadomienia, działając w tle."
+ },
+ "pt-br" : {
+ "label" : "Notificações Push",
+ "tts" : "Um aplicativo pode enviar notificações quando estiver sendo executado em segundo plano."
+ },
+ "pt-pt" : {
+ "label" : "Notificações push",
+ "tts" : "Uma aplicação consegue enviar notificações quando está activa em segundo plano."
+ },
+ "ru-ru" : {
+ "label" : "Оповещения о пересылке",
+ "tts" : "Если приложение работает в фоновом режиме, оно может отправлять оповещения."
+ },
+ "sv-se" : {
+ "label" : "Push-notiser",
+ "tts" : "Appen kan skicka meddelanden när den körs i bakgrunden."
+ },
+ "tr-tr" : {
+ "label" : "Anlık bildirimleri",
+ "tts" : "Bir uygulama arka planda çalışırken bildirim gönderebilir."
+ },
+ "zh-cn" : {
+ "label" : "推送通知",
+ "tts" : "移动应用程序在后台运行时可推送通知。"
+ },
+ "zh-tw" : {
+ "label" : "傳送通知",
+ "tts" : "車輛行進時,應用程式可在背景中傳送通知。"
+ }
+ }
+ },
+ "SettingDisableUpdates" : {
+ "languages" : {
+ "de-de" : {
+ "line1" : "Updates deakt."
+ },
+ "en-au" : {
+ "line1" : "Disable updates"
+ },
+ "en-gb" : {
+ "line1" : "Disable updates"
+ },
+ "en-ie" : {
+ "line1" : "Disable updates"
+ },
+ "en-us" : {
+ "line1" : "Disable Updates"
+ },
+ "es-en" : {
+ "line1" : "Deshab. actual."
+ },
+ "es-es" : {
+ "line1" : "Desact. actual."
+ },
+ "es-mx" : {
+ "line1" : "Deshab. actual."
+ },
+ "fr-ca" : {
+ "line1" : "Désactiver MAJ"
+ },
+ "fr-fr" : {
+ "line1" : "Désactiver màj"
+ },
+ "it-it" : {
+ "line1" : "Disabilita agg."
+ },
+ "nl-nl" : {
+ "line1" : "Upd. uitschak."
+ },
+ "pl-pl" : {
+ "line1" : "Wyłącz aktual."
+ },
+ "pt-br" : {
+ "line1" : "Desat. atualiz."
+ },
+ "pt-pt" : {
+ "line1" : "Desact. actualiz."
+ },
+ "ru-ru" : {
+ "line1" : "Откл. обновл."
+ },
+ "sv-se" : {
+ "line1" : "Inaktivera uppd."
+ },
+ "tr-tr" : {
+ "line1" : "Güncell. Kapat"
+ },
+ "zh-cn" : {
+ "line1" : "禁用更新"
+ },
+ "zh-tw" : {
+ "line1" : "停用更新"
+ }
+ }
+ },
+ "SettingEnableUpdates" : {
+ "languages" : {
+ "de-de" : {
+ "line1" : "Apps aktivieren"
+ },
+ "en-au" : {
+ "line1" : "Enable Apps"
+ },
+ "en-gb" : {
+ "line1" : "Enable Apps"
+ },
+ "en-ie" : {
+ "line1" : "Enable Apps"
+ },
+ "en-us" : {
+ "line1" : "Enable Apps"
+ },
+ "es-en" : {
+ "line1" : "Hab. aplic."
+ },
+ "es-es" : {
+ "line1" : "Activar apl."
+ },
+ "es-mx" : {
+ "line1" : "Hab. aplic."
+ },
+ "fr-ca" : {
+ "line1" : "Activer app."
+ },
+ "fr-fr" : {
+ "line1" : "Activer app."
+ },
+ "it-it" : {
+ "line1" : "Abilita app"
+ },
+ "nl-nl" : {
+ "line1" : "Apps inschak."
+ },
+ "pl-pl" : {
+ "line1" : "Włącz aplikacje"
+ },
+ "pt-br" : {
+ "line1" : "Ativar aplic."
+ },
+ "pt-pt" : {
+ "line1" : "Activar actualiz."
+ },
+ "ru-ru" : {
+ "line1" : "Вкл. прилож."
+ },
+ "sv-se" : {
+ "line1" : "Aktivera appar"
+ },
+ "tr-tr" : {
+ "line1" : "Uygulamaları aç"
+ },
+ "zh-cn" : {
+ "line1" : "启用应用程序"
+ },
+ "zh-tw" : {
+ "line1" : "啟用應用程式"
+ }
+ }
+ },
+ "SettingUpdateAuto" : {
+ "languages" : {
+ "de-de" : {
+ "line1" : "Update anford."
+ },
+ "en-au" : {
+ "line1" : "Request update"
+ },
+ "en-gb" : {
+ "line1" : "Request update"
+ },
+ "en-ie" : {
+ "line1" : "Request update"
+ },
+ "en-us" : {
+ "line1" : "Request Update"
+ },
+ "es-en" : {
+ "line1" : "Solicit. actualiz."
+ },
+ "es-es" : {
+ "line1" : "Solicitar actual."
+ },
+ "es-mx" : {
+ "line1" : "Solicit. actualiz."
+ },
+ "fr-ca" : {
+ "line1" : "Demander MAJ"
+ },
+ "fr-fr" : {
+ "line1" : "Demander màj"
+ },
+ "it-it" : {
+ "line1" : "Rich. aggiorn."
+ },
+ "nl-nl" : {
+ "line1" : "Upd. aanvragen"
+ },
+ "pl-pl" : {
+ "line1" : "Zażądaj aktual."
+ },
+ "pt-br" : {
+ "line1" : "Solicitar atualiz."
+ },
+ "pt-pt" : {
+ "line1" : "Solicit. actualiz."
+ },
+ "ru-ru" : {
+ "line1" : "Запрос на обн."
+ },
+ "sv-se" : {
+ "line1" : "Begär uppdat."
+ },
+ "tr-tr" : {
+ "line1" : "Güncelleme iste"
+ },
+ "zh-cn" : {
+ "line1" : "请求更新"
+ },
+ "zh-tw" : {
+ "line1" : "請求更新"
+ }
+ }
+ },
+ "StatusNeeded" : {
+ "languages" : {
+ "de-de" : {
+ "line1" : "Update benötigt"
+ },
+ "en-au" : {
+ "line1" : "Update needed"
+ },
+ "en-gb" : {
+ "line1" : "Update needed"
+ },
+ "en-ie" : {
+ "line1" : "Update needed"
+ },
+ "en-us" : {
+ "line1" : "Update Needed"
+ },
+ "es-en" : {
+ "line1" : "Actualiz. neces."
+ },
+ "es-es" : {
+ "line1" : "Actu. necesaria"
+ },
+ "es-mx" : {
+ "line1" : "Actualiz. neces."
+ },
+ "fr-ca" : {
+ "line1" : "Màj requise"
+ },
+ "fr-fr" : {
+ "line1" : "Mise à jour requise"
+ },
+ "it-it" : {
+ "line1" : "Necess. aggiorn."
+ },
+ "nl-nl" : {
+ "line1" : "Update nodig"
+ },
+ "pl-pl" : {
+ "line1" : "Potrzeba aktual."
+ },
+ "pt-br" : {
+ "line1" : "Atualiz. necess."
+ },
+ "pt-pt" : {
+ "line1" : "Actual. necess."
+ },
+ "ru-ru" : {
+ "line1" : "Необх. обновл."
+ },
+ "sv-se" : {
+ "line1" : "Uppdat. krävs"
+ },
+ "tr-tr" : {
+ "line1" : "Güncellenmeli"
+ },
+ "zh-cn" : {
+ "line1" : "需要进行更新"
+ },
+ "zh-tw" : {
+ "line1" : "需更新"
+ }
+ }
+ },
+ "StatusPending" : {
+ "languages" : {
+ "de-de" : {
+ "line1" : "Aktualisieren..."
+ },
+ "en-au" : {
+ "line1" : "Updating..."
+ },
+ "en-gb" : {
+ "line1" : "Updating..."
+ },
+ "en-ie" : {
+ "line1" : "Updating..."
+ },
+ "en-us" : {
+ "line1" : "Updating..."
+ },
+ "es-en" : {
+ "line1" : "Actualizando..."
+ },
+ "es-es" : {
+ "line1" : "Actualizando..."
+ },
+ "es-mx" : {
+ "line1" : "Actualizando..."
+ },
+ "fr-ca" : {
+ "line1" : "MAJ en cours..."
+ },
+ "fr-fr" : {
+ "line1" : "Màj en cours..."
+ },
+ "it-it" : {
+ "line1" : "Aggiornamento"
+ },
+ "nl-nl" : {
+ "line1" : "Updaten..."
+ },
+ "pl-pl" : {
+ "line1" : "Aktualizowanie"
+ },
+ "pt-br" : {
+ "line1" : "Atualizando..."
+ },
+ "pt-pt" : {
+ "line1" : "A actualizar..."
+ },
+ "ru-ru" : {
+ "line1" : "Обновление..."
+ },
+ "sv-se" : {
+ "line1" : "Uppdaterar..."
+ },
+ "tr-tr" : {
+ "line1" : "Güncelleniyor..."
+ },
+ "zh-cn" : {
+ "line1" : "正在更新......"
+ },
+ "zh-tw" : {
+ "line1" : "更新中..."
+ }
+ }
+ },
+ "StatusUpToDate" : {
+ "languages" : {
+ "de-de" : {
+ "line1" : "Aktuelle Version"
+ },
+ "en-au" : {
+ "line1" : "Up-to-date"
+ },
+ "en-gb" : {
+ "line1" : "Up-to-date"
+ },
+ "en-ie" : {
+ "line1" : "Up-to-date"
+ },
+ "en-us" : {
+ "line1" : "Up-To-Date"
+ },
+ "es-en" : {
+ "line1" : "Actualizado"
+ },
+ "es-es" : {
+ "line1" : "Actualizada"
+ },
+ "es-mx" : {
+ "line1" : "Actualizado"
+ },
+ "fr-ca" : {
+ "line1" : "Déjà à jour"
+ },
+ "fr-fr" : {
+ "line1" : "Déjà à jour"
+ },
+ "it-it" : {
+ "line1" : "più recente"
+ },
+ "nl-nl" : {
+ "line1" : "Up-to-date"
+ },
+ "pl-pl" : {
+ "line1" : "Aktualne"
+ },
+ "pt-br" : {
+ "line1" : "Atualizado"
+ },
+ "pt-pt" : {
+ "line1" : "Actualizado"
+ },
+ "ru-ru" : {
+ "line1" : "Обновлено"
+ },
+ "sv-se" : {
+ "line1" : "Uppdat. krävs ej"
+ },
+ "tr-tr" : {
+ "line1" : "Güncel"
+ },
+ "zh-cn" : {
+ "line1" : "最新更新"
+ },
+ "zh-tw" : {
+ "line1" : "更新最新"
+ }
+ }
+ },
+ "VehicleInfo" : {
+ "languages" : {
+ "de-de" : {
+ "label" : "Fahrzeuginformationen",
+ "tts" : "Eine App hat Zugriff auf die folgenden Fahrzeuginformationen: Kraftstoff-Füllstand, Kraftstoffverbrauch, Motordrehzahl, Kilometerzähler, FIN, Außentemperatur, Gangstellung, Reifenluftdruck."
+ },
+ "en-au" : {
+ "label" : "Vehicle information",
+ "tts" : "An app can access the following vehicle information: Fuel level, Fuel economy, Engine RPMs, Odometer, VIN, Outside air temperature, Gear position, Tyre pressure."
+ },
+ "en-gb" : {
+ "label" : "Vehicle information",
+ "tts" : "An app can access the following vehicle information: Fuel level, Fuel economy, Engine RPMs, Odometer, VIN, Outside air temperature, Gear position, Tyre pressure."
+ },
+ "en-ie" : {
+ "label" : "Vehicle information",
+ "tts" : "An app can access the following vehicle information: Fuel level, Fuel economy, Engine RPMs, Odometer, VIN, Outside air temperature, Gear position, Tyre pressure."
+ },
+ "en-us" : {
+ "label" : "Vehicle information",
+ "tts" : "An app can access the following vehicle information: Fuel Level, Fuel Economy, Engine RPMs, Odometer, VIN, External Temperature, Gear Position, Tire Pressure."
+ },
+ "es-en" : {
+ "label" : "Información del vehículo",
+ "tts" : "Las aplicaciones pueden acceder a la siguiente información del vehículo: Nivel de combustible, Economía de combustible, RPM del motor, Cuentakilómetros, Número de identificación del vehículo, Temperatura externa, Posición del cambio, Presión de los neumáticos."
+ },
+ "es-es" : {
+ "label" : "Información del vehículo",
+ "tts" : "Una aplicación puede acceder a la siguiente información del vehículo: Nivel de combustible, Ahorro de combustible, RPM del motor, Cuentakilómetros, VIN, Temperatura aire exterior, Marcha engranada, Presión de neumáticos."
+ },
+ "es-mx" : {
+ "label" : "Información del vehículo",
+ "tts" : "Las aplicaciones pueden acceder a la siguiente información del vehículo: Nivel de combustible, Economía de combustible, RPM del motor, Cuentakilómetros, Número de identificación del vehículo, Temperatura externa, Posición del cambio, Presión de los neumáticos."
+ },
+ "fr-ca" : {
+ "label" : "Renseignements du véhicule",
+ "tts" : "Une application peut accéder aux informations suivantes du véhicule: Niveau de carburant, Économie de carburant, Au régime du moteur, Odomètre, NIV, Température extérieure, Position d’embrayage, Pression des pneus."
+ },
+ "fr-fr" : {
+ "label" : "Renseignements du véhicule",
+ "tts" : "Une application peut accéder aux informations suivantes du véhicule: Niveau de carburant, Économie de carburant, Vitesse de moteur, Compteur kilométrique, NIV, Température extérieure, Position de vitesse, Pression des pneus."
+ },
+ "it-it" : {
+ "label" : "Informazioni sul veicolo",
+ "tts" : "Un'app può avere accesso alle seguenti informazioni del veicolo: Livello carburante, Consumi carburante, Numero giri motore, Contachilometri, VIN, Temperatura esterna, Posizione marcia, Pressione pneumatici."
+ },
+ "nl-nl" : {
+ "label" : "Voertuiginformatie",
+ "tts" : "Een app heeft toegang tot de volgende voertuiginformatie: Brandstofpeil, Brandstofverbruik, Motortoerental, Kilometerteller, VIN, Buitentemperatuur, Versnellingsstand, Bandenspanning."
+ },
+ "pl-pl" : {
+ "label" : "Informacje o pojeździe",
+ "tts" : "Aplikacja może uzyskać dostęp do następujących informacji o pojeździe: Poziom paliwa, Zużycie paliwa, Obroty silnika, Licznik przebiegu, Numer VIN, Temperatura zewnętrzna, Aktualny bieg, Ciśnienie opon."
+ },
+ "pt-br" : {
+ "label" : "Informações sobre o veículo",
+ "tts" : "Um aplicativo pode acessar as seguintes informações sobre o veículo: Nível de combustível, Economia de combustível, RPM do motor, Hodômetro, VIN, Temperatura externa, Posição das marchas, Pressão dos pneus."
+ },
+ "pt-pt" : {
+ "label" : "Informações do veículo",
+ "tts" : "Uma aplicação consegue aceder às seguintes informações do veículo: Nível de combustível, Poupança de combustível, RPM do motor, Conta-quilómetros, VIN, Temperatura exterior, Posição da mudança de velocidade, Pressão dos pneus."
+ },
+ "ru-ru" : {
+ "label" : "Информация об автомобиле",
+ "tts" : "Приложение имеет доступ к следующим данным автомобиля: Уровень топлива, Економия топлива, Число оборотов двигателя, Одометр, Номер VIN, Температура за бортом, Положение передачи, Давление шин."
+ },
+ "sv-se" : {
+ "label" : "Fordonsinformation",
+ "tts" : "Appen kan komma åt följande fordonsinformation: Bränslenivå, Bränsleekonomi, Motorns varvtal, Vägmätare, VIN, Utetemperatur, Växelläge, Däcktryck."
+ },
+ "tr-tr" : {
+ "label" : "Araç bilgisi",
+ "tts" : "Bir uygulama şu araç bilgilerine erişebilir: Yakıt seviyesi, Yakıt ekonomisi, Motor devirleri, Kilometre sayacı, VIN, Dış sıcaklık, Vites konumu, Lastik basıncı."
+ },
+ "zh-cn" : {
+ "label" : "车辆信息",
+ "tts" : "移动应用程序可访问下列车辆信息 : 燃油量, 燃油经济性, 发动机转速(RPM), 里程表, VIN, 车外温度, 档位, 胎压."
+ },
+ "zh-tw" : {
+ "label" : "車輛資訊",
+ "tts" : "一個應用程式可存取以下車輛資訊 : 燃油存量, 燃油經濟性, 引擎轉速, 里程表, 車輛識別號碼, 車外溫度, 檔位, 胎壓."
+ }
+ }
+ }
+ },
+ "version" : "001.001.015"
+ },
+ "device_data" : {
+ "H32L41K32JH4L1K234H3K4HUU40DAS7F970UEI17A73J" : {
+ "carrier" : null,
+ "firmware_rev" : null,
+ "hardware" : "Motorola Atrix 4G",
+ "max_number_rfcom_ports" : 15,
+ "os" : "Android",
+ "os_version" : "2.3.4",
+ "user_consent_records" : {
+ "device" : {
+ "consent_groups" : {
+ "DataConsent-1" : true
+ },
+ "input" : "VUI",
+ "time_stamp" : "4/25/2012 11:56:00 AM"
+ }
+ }
+ },
+ "HUU40DAS7F970UEI17A73JH32L41K32JH4L1K234H3K4" : {
+ "carrier" : "Verizon",
+ "firmware_rev" : null,
+ "hardware" : "HTC Incredible",
+ "max_number_rfcom_ports" : 20,
+ "os" : "Android",
+ "os_version" : "2.3.3",
+ "user_consent_records" : {
+ "device" : {
+ "consent_groups" : {
+ "DataConsent-1" : true
+ },
+ "input" : "GUI",
+ "time_stamp" : "4/11/2012 6:57:00 AM"
+ }
+ }
+ },
+ "UEI17A73JH32L41K32JH4L1K234H3K4HUU40DAS7F970" : {
+ "carrier" : "AT&T",
+ "firmware_rev" : null,
+ "hardware" : "iPhone 4S",
+ "max_number_rfcom_ports" : 25,
+ "os" : "iOS",
+ "os_version" : "5",
+ "user_consent_records" : {
+ "584421907" : {
+ "consent_groups" : {
+ "DrivingData-1" : false,
+ "Location-1" : true
+ },
+ "input" : "VUI",
+ "time_stamp" : "3/26/2012 10:41:00 AM "
+ },
+ "device" : {
+ "consent_groups" : {
+ "DataConsent-1" : true
+ },
+ "input" : "VUI",
+ "time_stamp" : "4/24/2012 12:30:00 PM"
+ }
+ }
+ }
+ },
+ "functional_groupings" : {
+ "Base-4" : {
+ "rpcs" : {
+ "AddCommand" : {
+ "hmi_levels" : [ "BACKGROUND", "FULL", "LIMITED" ]
+ },
+ "AddSubMenu" : {
+ "hmi_levels" : [ "BACKGROUND", "FULL", "LIMITED" ]
+ },
+ "Alert" : {
+ "hmi_levels" : [ "FULL", "LIMITED" ]
+ },
+ "ChangeRegistration" : {
+ "hmi_levels" : [ "BACKGROUND", "FULL", "LIMITED", "NONE" ]
+ },
+ "CreateInteractionChoiceSet" : {
+ "hmi_levels" : [ "BACKGROUND", "FULL", "LIMITED" ]
+ },
+ "DeleteCommand" : {
+ "hmi_levels" : [ "BACKGROUND", "FULL", "LIMITED" ]
+ },
+ "DeleteFile" : {
+ "hmi_levels" : [ "BACKGROUND", "FULL", "LIMITED", "NONE" ]
+ },
+ "DeleteInteractionChoiceSet" : {
+ "hmi_levels" : [ "BACKGROUND", "FULL", "LIMITED" ]
+ },
+ "DeleteSubMenu" : {
+ "hmi_levels" : [ "BACKGROUND", "FULL", "LIMITED" ]
+ },
+ "EncodedSyncPData" : {
+ "hmi_levels" : [ "BACKGROUND", "FULL", "LIMITED", "NONE" ]
+ },
+ "EndAudioPassThru" : {
+ "hmi_levels" : [ "BACKGROUND", "FULL", "LIMITED" ]
+ },
+ "GenericResponse" : {
+ "hmi_levels" : [ "BACKGROUND", "FULL", "LIMITED" ]
+ },
+ "ListFiles" : {
+ "hmi_levels" : [ "BACKGROUND", "FULL", "LIMITED", "NONE" ]
+ },
+ "OnAppInterfaceUnregistered" : {
+ "hmi_levels" : [ "BACKGROUND", "FULL", "LIMITED", "NONE" ]
+ },
+ "OnAudioPassThru" : {
+ "hmi_levels" : [ "BACKGROUND", "FULL", "LIMITED" ]
+ },
+ "OnButtonEvent" : {
+ "hmi_levels" : [ "FULL", "LIMITED" ]
+ },
+ "OnButtonPress" : {
+ "hmi_levels" : [ "FULL", "LIMITED" ]
+ },
+ "OnCommand" : {
+ "hmi_levels" : [ "FULL", "LIMITED" ]
+ },
+ "OnDriverDistraction" : {
+ "hmi_levels" : [ "BACKGROUND", "FULL", "LIMITED" ]
+ },
+ "OnEncodedSyncPData" : {
+ "hmi_levels" : [ "BACKGROUND", "FULL", "LIMITED", "NONE" ]
+ },
+ "OnHMIStatus" : {
+ "hmi_levels" : [ "BACKGROUND", "FULL", "LIMITED", "NONE" ]
+ },
+ "OnLanguageChange" : {
+ "hmi_levels" : [ "BACKGROUND", "FULL", "LIMITED", "NONE" ]
+ },
+ "OnPermissionsChange" : {
+ "hmi_levels" : [ "BACKGROUND", "FULL", "LIMITED", "NONE" ]
+ },
+ "OnSyncPData" : {
+ "hmi_levels" : [ "BACKGROUND", "FULL", "LIMITED", "NONE" ]
+ },
+ "OnTBTClientState" : {
+ "hmi_levels" : [ "BACKGROUND", "FULL", "LIMITED" ]
+ },
+ "PerformAudioPassThru" : {
+ "hmi_levels" : [ "FULL", "LIMITED" ]
+ },
+ "PerformInteraction" : {
+ "hmi_levels" : [ "FULL", "LIMITED" ]
+ },
+ "PutFile" : {
+ "hmi_levels" : [ "BACKGROUND", "FULL", "LIMITED", "NONE" ]
+ },
+ "RegisterAppInterface" : {
+ "hmi_levels" : [ "BACKGROUND", "FULL", "LIMITED", "NONE" ]
+ },
+ "ResetGlobalProperties" : {
+ "hmi_levels" : [ "BACKGROUND", "FULL", "LIMITED" ]
+ },
+ "ScrollableMessage" : {
+ "hmi_levels" : [ "FULL" ]
+ },
+ "SetAppIcon" : {
+ "hmi_levels" : [ "BACKGROUND", "FULL", "LIMITED", "NONE" ]
+ },
+ "SetDisplayLayout" : {
+ "hmi_levels" : [ "BACKGROUND", "FULL", "LIMITED", "NONE" ]
+ },
+ "SetGlobalProperties" : {
+ "hmi_levels" : [ "BACKGROUND", "FULL", "LIMITED" ]
+ },
+ "SetMediaClockTimer" : {
+ "hmi_levels" : [ "FULL", "LIMITED" ]
+ },
+ "Show" : {
+ "hmi_levels" : [ "BACKGROUND", "FULL", "LIMITED" ]
+ },
+ "Slider" : {
+ "hmi_levels" : [ "FULL" ]
+ },
+ "Speak" : {
+ "hmi_levels" : [ "FULL", "LIMITED" ]
+ },
+ "SubscribeButton" : {
+ "hmi_levels" : [ "BACKGROUND", "FULL", "LIMITED" ]
+ },
+ "SyncPData" : {
+ "hmi_levels" : [ "BACKGROUND", "FULL", "LIMITED", "NONE" ]
+ },
+ "UnregisterAppInterface" : {
+ "hmi_levels" : [ "BACKGROUND", "FULL", "LIMITED", "NONE" ]
+ },
+ "UnsubscribeButton" : {
+ "hmi_levels" : [ "BACKGROUND", "FULL", "LIMITED" ]
+ }
+ }
+ },
+ "DrivingCharacteristics-3" : {
+ "rpcs" : {
+ "GetVehicleData" : {
+ "hmi_levels" : [ "BACKGROUND", "FULL", "LIMITED" ],
+ "parameters" : [
+ "accPedalPosition",
+ "beltStatus",
+ "driverBraking",
+ "myKey",
+ "prndl",
+ "rpm",
+ "steeringWheelAngle"
+ ]
+ },
+ "OnVehicleData" : {
+ "hmi_levels" : [ "BACKGROUND", "FULL", "LIMITED" ],
+ "parameters" : [
+ "accPedalPosition",
+ "beltStatus",
+ "driverBraking",
+ "myKey",
+ "prndl",
+ "rpm",
+ "steeringWheelAngle"
+ ]
+ },
+ "SubscribeVehicleData" : {
+ "hmi_levels" : [ "BACKGROUND", "FULL", "LIMITED" ],
+ "parameters" : [
+ "accPedalPosition",
+ "beltStatus",
+ "driverBraking",
+ "myKey",
+ "prndl",
+ "rpm",
+ "steeringWheelAngle"
+ ]
+ },
+ "UnsubscribeVehicleData" : {
+ "hmi_levels" : [ "BACKGROUND", "FULL", "LIMITED" ],
+ "parameters" : [
+ "accPedalPosition",
+ "beltStatus",
+ "driverBraking",
+ "myKey",
+ "prndl",
+ "rpm",
+ "steeringWheelAngle"
+ ]
+ }
+ },
+ "user_consent_prompt" : "DrivingCharacteristics"
+ },
+ "Emergency-1" : {
+ "rpcs" : {
+ "GetVehicleData" : {
+ "hmi_levels" : [ "BACKGROUND", "FULL", "LIMITED" ],
+ "parameters" : [
+ "airbagStatus",
+ "bodyInformation",
+ "clusterModeStatus",
+ "deviceStatus",
+ "eCallInfo",
+ "emergencyEvent"
+ ]
+ },
+ "OnVehicleData" : {
+ "hmi_levels" : [ "BACKGROUND", "FULL", "LIMITED" ],
+ "parameters" : [
+ "airbagStatus",
+ "bodyInformation",
+ "clusterModeStatus",
+ "deviceStatus",
+ "eCallInfo",
+ "emergencyEvent"
+ ]
+ },
+ "SubscribeVehicleData" : {
+ "hmi_levels" : [ "BACKGROUND", "FULL", "LIMITED" ],
+ "parameters" : [
+ "airbagStatus",
+ "bodyInformation",
+ "clusterModeStatus",
+ "deviceStatus",
+ "eCallInfo",
+ "emergencyEvent"
+ ]
+ },
+ "UnsubscribeVehicleData" : {
+ "hmi_levels" : [ "BACKGROUND", "FULL", "LIMITED" ],
+ "parameters" : [
+ "airbagStatus",
+ "bodyInformation",
+ "clusterModeStatus",
+ "deviceStatus",
+ "eCallInfo",
+ "emergencyEvent"
+ ]
+ }
+ }
+ },
+ "Location-1" : {
+ "rpcs" : {
+ "GetVehicleData" : {
+ "hmi_levels" : [ "BACKGROUND", "FULL", "LIMITED" ],
+ "parameters" : [ "gps", "speed" ]
+ },
+ "OnVehicleData" : {
+ "hmi_levels" : [ "BACKGROUND", "FULL", "LIMITED" ],
+ "parameters" : [ "gps", "speed" ]
+ },
+ "SubscribeVehicleData" : {
+ "hmi_levels" : [ "BACKGROUND", "FULL", "LIMITED" ],
+ "parameters" : [ "gps", "speed" ]
+ },
+ "UnsubscribeVehicleData" : {
+ "hmi_levels" : [ "BACKGROUND", "FULL", "LIMITED" ],
+ "parameters" : [ "gps", "speed" ]
+ }
+ },
+ "user_consent_prompt" : "Location"
+ },
+ "Navigation-1" : {
+ "rpcs" : {
+ "AlertManeuver" : {
+ "hmi_levels" : [ "BACKGROUND", "FULL", "LIMITED" ]
+ },
+ "ShowConstantTBT" : {
+ "hmi_levels" : [ "BACKGROUND", "FULL", "LIMITED" ]
+ },
+ "UpdateTurnList" : {
+ "hmi_levels" : [ "BACKGROUND", "FULL", "LIMITED" ]
+ }
+ }
+ },
+ "Notifications" : {
+ "rpcs" : {
+ "Alert" : {
+ "hmi_levels" : [ "BACKGROUND" ]
+ }
+ },
+ "user_consent_prompt" : "Notifications"
+ },
+ "PropriataryData-1" : {
+ "rpcs" : {
+ "DiagnosticMessage" : {
+ "hmi_levels" : [ "BACKGROUND", "FULL", "LIMITED" ]
+ },
+ "GetDTCs" : {
+ "hmi_levels" : [ "BACKGROUND", "FULL", "LIMITED" ]
+ },
+ "ReadDID" : {
+ "hmi_levels" : [ "BACKGROUND", "FULL", "LIMITED" ]
+ }
+ }
+ },
+ "VehicleInfo-3" : {
+ "rpcs" : {
+ "GetVehicleData" : {
+ "hmi_levels" : [ "BACKGROUND", "FULL", "LIMITED" ],
+ "parameters" : [
+ "engineTorque",
+ "externalTemperature",
+ "fuelLevel",
+ "fuelLevel_State",
+ "headLampStatus",
+ "instantFuelConsumption",
+ "odometer",
+ "tirePressure",
+ "vin",
+ "wiperStatus"
+ ]
+ },
+ "OnVehicleData" : {
+ "hmi_levels" : [ "BACKGROUND", "FULL", "LIMITED" ],
+ "parameters" : [
+ "engineTorque",
+ "externalTemperature",
+ "fuelLevel",
+ "fuelLevel_State",
+ "headLampStatus",
+ "instantFuelConsumption",
+ "odometer",
+ "tirePressure",
+ "vin",
+ "wiperStatus"
+ ]
+ },
+ "SubscribeVehicleData" : {
+ "hmi_levels" : [ "BACKGROUND", "FULL", "LIMITED" ],
+ "parameters" : [
+ "engineTorque",
+ "externalTemperature",
+ "fuelLevel",
+ "fuelLevel_State",
+ "headLampStatus",
+ "instantFuelConsumption",
+ "odometer",
+ "tirePressure",
+ "wiperStatus"
+ ]
+ },
+ "UnsubscribeVehicleData" : {
+ "hmi_levels" : [ "BACKGROUND", "FULL", "LIMITED" ],
+ "parameters" : [
+ "engineTorque",
+ "externalTemperature",
+ "fuelLevel",
+ "fuelLevel_State",
+ "headLampStatus",
+ "instantFuelConsumption",
+ "odometer",
+ "tirePressure",
+ "wiperStatus"
+ ]
+ }
+ },
+ "user_consent_prompt" : "VehicleInfo"
+ },
+ "pre_Base-1" : {
+ "rpcs" : {
+ "ChangeRegistration" : {
+ "hmi_levels" : [ "BACKGROUND", "FULL", "LIMITED", "NONE" ]
+ },
+ "DeleteFile" : {
+ "hmi_levels" : [ "BACKGROUND", "FULL", "LIMITED", "NONE" ]
+ },
+ "GenericResponse" : {
+ "hmi_levels" : [ "BACKGROUND", "FULL", "LIMITED" ]
+ },
+ "ListFiles" : {
+ "hmi_levels" : [ "BACKGROUND", "FULL", "LIMITED", "NONE" ]
+ },
+ "OnAppInterfaceUnregistered" : {
+ "hmi_levels" : [ "BACKGROUND", "FULL", "LIMITED", "NONE" ]
+ },
+ "OnLanguageChange" : {
+ "hmi_levels" : [ "BACKGROUND", "FULL", "LIMITED", "NONE" ]
+ },
+ "OnPermissionsChange" : {
+ "hmi_levels" : [ "BACKGROUND", "FULL", "LIMITED", "NONE" ]
+ },
+ "PutFile" : {
+ "hmi_levels" : [ "BACKGROUND", "FULL", "LIMITED", "NONE" ]
+ },
+ "RegisterAppInterface" : {
+ "hmi_levels" : [ "BACKGROUND", "FULL", "LIMITED", "NONE" ]
+ },
+ "ResetGlobalProperties" : {
+ "hmi_levels" : [ "BACKGROUND", "FULL", "LIMITED" ]
+ },
+ "SetAppIcon" : {
+ "hmi_levels" : [ "BACKGROUND", "FULL", "LIMITED", "NONE" ]
+ },
+ "SetDisplayLayout" : {
+ "hmi_levels" : [ "BACKGROUND", "FULL", "LIMITED", "NONE" ]
+ },
+ "SetGlobalProperties" : {
+ "hmi_levels" : [ "BACKGROUND", "FULL", "LIMITED" ]
+ },
+ "UnregisterAppInterface" : {
+ "hmi_levels" : [ "BACKGROUND", "FULL", "LIMITED", "NONE" ]
+ }
+ }
+ }
+ },
+ "module_config" : {
+ "device_certificates" : {
+ "HUU40DAS7F970UEI17A73JH32L41K32JH4L1K234H3K4" : "aldhfkahfgkafrblgjr"
+ },
+ "endpoints" : {
+ "0x07" : {
+ "default" : [ "http://policies.telematics.ford.com/api/policies" ]
+ }
+ },
+ "exchange_after_x_days" : 30,
+ "exchange_after_x_ignition_cycles" : 100,
+ "exchange_after_x_kilometers" : 1800,
+ "notifications_per_minute_by_priority" : {
+ "COMMUNICATION" : 6,
+ "EMERGENCY" : 60,
+ "NAVIGATION" : 15,
+ "NONE" : 0,
+ "NORMAL" : 4,
+ "voiceCommunication" : 10
+ },
+ "preloaded_pt" : true,
+ "seconds_between_retries" : [ 1, 5, 25, 125, 625 ],
+ "timeout_after_x_seconds" : 60,
+ "vehicle_make" : "Stark Industries",
+ "vehicle_model" : "E-Tron",
+ "vehicle_year" : 1992
+ },
+ "module_meta" : {
+ "ccpu_version" : "4.1.2.B_EB355B",
+ "ignition_cycles_since_last_exchange" : 50,
+ "language" : "en-us",
+ "pt_exchanged_at_odometer_x" : 1903,
+ "pt_exchanged_x_days_after_epoch" : 46684,
+ "vin" : "1FAPP6242VH100001",
+ "wers_country_code" : "WAEGB"
+ },
+ "usage_and_error_counts" : {
+ "app_level" : {
+ "584421907" : {
+ "app_registration_language_gui" : "en-us",
+ "app_registration_language_vui" : "en-us",
+ "count_of_rejected_rpc_calls" : 9,
+ "count_of_rejections_duplicate_name" : 2,
+ "count_of_rejections_nickname_mismatch" : 1,
+ "count_of_rejections_sync_out_of_memory" : 0,
+ "count_of_removals_for_bad_behavior" : 6,
+ "count_of_rfcom_limit_reached" : 1,
+ "count_of_rpcs_sent_in_hmi_none" : 7,
+ "count_of_run_attempts_while_revoked" : 0,
+ "count_of_user_selections" : 7,
+ "minutes_in_hmi_background" : 123,
+ "minutes_in_hmi_full" : 123,
+ "minutes_in_hmi_limited" : 456,
+ "minutes_in_hmi_none" : 456
+ }
+ },
+ "count_of_iap_buffer_full" : 1,
+ "count_of_sync_reboots" : 123,
+ "count_sync_out_of_memory" : 3
+ }
+ }
+}