From 16891012aadef1839f460ddae51d7ee71c2d6ff0 Mon Sep 17 00:00:00 2001 From: Alexander Kutsan Date: Fri, 18 Nov 2016 18:12:45 +0200 Subject: Fix usages of policy in code --- src/appMain/CMakeLists.txt | 3 +- src/components/CMakeLists.txt | 12 +- src/components/application_manager/CMakeLists.txt | 8 +- .../include/application_manager/application.h | 11 +- .../include/application_manager/application_impl.h | 1 + .../application_manager/application_manager.h | 4 +- .../application_manager/application_manager_impl.h | 1 - .../application_manager/commands/command_impl.h | 6 +- .../application_manager/commands/hmi/get_urls.h | 10 +- .../commands/hmi/request_from_hmi.h | 10 + .../mobile/on_system_request_notification.h | 2 +- .../include/application_manager/message_helper.h | 7 + .../policies/delegates/app_permission_delegate.h | 87 +----- .../policies/delegates/statistics_delegate.h | 91 +----- .../policies/policy_event_observer.h | 68 +---- .../application_manager/policies/policy_handler.h | 67 +++-- .../policies/policy_handler_observer.h | 58 +--- .../policies/policy_retry_sequence.h | 59 +--- .../policies/pt_exchange_handler.h | 52 +--- .../policies/pt_exchange_handler_ext.h | 57 +--- .../policies/pt_exchange_handler_impl.h | 66 +---- .../application_manager/smart_object_keys.h | 1 + .../application_manager/src/application_impl.cc | 5 + .../src/application_manager_impl.cc | 2 +- .../src/commands/command_request_impl.cc | 19 +- .../src/commands/hmi/get_urls.cc | 158 +++++------ .../src/commands/hmi/on_received_policy_update.cc | 2 +- .../src/commands/hmi/request_from_hmi.cc | 29 +- .../src/commands/hmi/sdl_activate_app_request.cc | 50 +++- .../src/commands/hmi/sdl_policy_update.cc | 2 +- .../mobile/on_system_request_notification.cc | 4 +- .../src/commands/mobile/send_location_request.cc | 3 +- .../application_manager/src/hmi_command_factory.cc | 17 ++ .../src/message_helper/message_helper.cc | 58 +++- .../src/policies/policy_handler.cc | 304 +++++++++++++++++++-- .../application_manager/src/smart_object_keys.cc | 3 +- .../application_manager/test/CMakeLists.txt | 7 +- .../test/application_impl_test.cc | 2 +- .../test/commands/command_request_impl_test.cc | 12 +- .../mobile/get_vehicle_data_request_test.cc | 7 +- .../mobile/on_system_request_notification_test.cc | 4 +- .../include/application_manager/mock_application.h | 1 + .../application_manager/mock_message_helper.h | 3 + .../policy_handler_interface_mock.h | 1 + .../test/mock_message_helper.cc | 6 + .../test/policy_event_observer_test.cc | 2 +- .../test/policy_handler_test.cc | 149 +++++++--- .../test/state_controller/CMakeLists.txt | 1 + .../test/usage_statistics_test.cc | 4 +- src/components/config_profile/CMakeLists.txt | 3 +- .../policies/policy_handler_interface.h | 31 ++- .../policies/policy_handler_observer.h | 53 ++++ .../policies/mock_policy_handler_interface.h | 18 +- src/components/media_manager/CMakeLists.txt | 3 +- .../rpc_base/include/rpc_base/rpc_base.h | 2 +- src/components/telemetry_monitor/CMakeLists.txt | 4 +- src/components/transport_manager/CMakeLists.txt | 1 + .../utils/src/sqlite_wrapper/sql_database.cc | 3 + src/components/utils/test/CMakeLists.txt | 2 +- 59 files changed, 888 insertions(+), 768 deletions(-) create mode 100644 src/components/include/application_manager/policies/policy_handler_observer.h (limited to 'src') diff --git a/src/appMain/CMakeLists.txt b/src/appMain/CMakeLists.txt index 84b2c847bd..a6774ec6f3 100644 --- a/src/appMain/CMakeLists.txt +++ b/src/appMain/CMakeLists.txt @@ -120,7 +120,8 @@ include_directories ( ${COMPONENTS_DIR}/smart_objects/include/ ${COMPONENTS_DIR}/media_manager/include/ ${COMPONENTS_DIR}/telemetry_monitor/include - ${COMPONENTS_DIR}/policy/include/ + ${POLICY_PATH}/include/ + ${POLICY_GLOBAL_INCLUDE_PATH}/ ${COMPONENTS_DIR}/resumption/include/ ${MESSAGE_BROKER_INCLUDE_DIRECTORY} ${ENCRYPTION_INCLUDE_DIRECTORY} diff --git a/src/components/CMakeLists.txt b/src/components/CMakeLists.txt index d31141b36c..24449143e4 100644 --- a/src/components/CMakeLists.txt +++ b/src/components/CMakeLists.txt @@ -58,9 +58,15 @@ add_subdirectory(./utils) if(ENABLE_SECURITY) add_subdirectory(./security_manager) endif() -# -# --- Policy_impl -add_subdirectory(./policy) + + +if (${EXTENDED_POLICY} STREQUAL "EXTENDED_PROPRIETARY") + add_subdirectory(./policy/policy_premium/) + message(STATUS "Use premium policy") +else() + add_subdirectory(./policy/policy_regular/) + message(STATUS "Use promium policy") +endif() # --- Validated types add_subdirectory(./rpc_base) diff --git a/src/components/application_manager/CMakeLists.txt b/src/components/application_manager/CMakeLists.txt index 32848b1c6d..da68a64400 100644 --- a/src/components/application_manager/CMakeLists.txt +++ b/src/components/application_manager/CMakeLists.txt @@ -49,8 +49,10 @@ include_directories ( ${COMPONENTS_DIR}/app_launch/include/ ${COMPONENTS_DIR}/rpc_base/include/ ${COMPONENTS_DIR}/interfaces + ${POLICY_PATH}/include/ + ${POLICY_GLOBAL_INCLUDE_PATH}/ ${CMAKE_BINARY_DIR}/src/components/ - ${COMPONENTS_DIR}/policy/include/ + ${POLICY_INCLUDE_PATH}/ ${JSONCPP_INCLUDE_DIRECTORY} ${ENCRYPTION_INCLUDE_DIRECTORY} ${MESSAGE_BROKER_INCLUDE_DIRECTORY} @@ -86,7 +88,7 @@ ${AM_SOURCE_DIR}/src/policies/delegates/statistics_delegate.cc ) include_directories( - ${COMPONENTS_DIR}/policy/src/policy/policy_table/table_struct + ${POLICY_PATH}/src/policy/policy_table/table_struct ) file (GLOB EVENT_ENGINE ${AM_SOURCE_DIR}/src/event_engine/* @@ -127,6 +129,8 @@ file (GLOB MOBILE_COMMANDS_SOURCES ${COMMANDS_SOURCE_DIR}/hmi/activate_app_response.cc ${COMMANDS_SOURCE_DIR}/hmi/get_system_info_request.cc ${COMMANDS_SOURCE_DIR}/hmi/get_system_info_response.cc + ${COMMANDS_SOURCE_DIR}/hmi/decrypt_certificate_request.cc + ${COMMANDS_SOURCE_DIR}/hmi/decrypt_certificate_response.cc ${COMMANDS_SOURCE_DIR}/hmi/sdl_get_list_of_permissions_request.cc ${COMMANDS_SOURCE_DIR}/hmi/sdl_get_list_of_permissions_response.cc ${COMMANDS_SOURCE_DIR}/hmi/sdl_get_user_friendly_message_request.cc diff --git a/src/components/application_manager/include/application_manager/application.h b/src/components/application_manager/include/application_manager/application.h index cea04f1470..08581b43c1 100644 --- a/src/components/application_manager/include/application_manager/application.h +++ b/src/components/application_manager/include/application_manager/application.h @@ -209,9 +209,16 @@ class DynamicApplicationData { virtual void set_video_stream_retry_number( const uint32_t& video_stream_retry_number) = 0; - /* - * @brief Adds a command to the in application menu + /** + * @brief Checks if application is media, voice communication or navigation + * @return true if application is media, voice communication or navigation, + * false otherwise */ + virtual bool is_audio() const = 0; + + /* + * @brief Adds a command to the in application menu + */ virtual void AddCommand(uint32_t cmd_id, const smart_objects::SmartObject& command) = 0; diff --git a/src/components/application_manager/include/application_manager/application_impl.h b/src/components/application_manager/include/application_manager/application_impl.h index 8658963aef..ae63a2f8ae 100644 --- a/src/components/application_manager/include/application_manager/application_impl.h +++ b/src/components/application_manager/include/application_manager/application_impl.h @@ -156,6 +156,7 @@ class ApplicationImpl : public virtual InitialApplicationDataImpl, void set_device(connection_handler::DeviceHandle device); virtual uint32_t get_grammar_id() const; virtual void set_grammar_id(uint32_t value); + bool is_audio() const OVERRIDE; virtual void set_protocol_version(const ProtocolVersion& protocol_version); virtual ProtocolVersion protocol_version() const; diff --git a/src/components/application_manager/include/application_manager/application_manager.h b/src/components/application_manager/include/application_manager/application_manager.h index e67864b9b1..d386118e22 100644 --- a/src/components/application_manager/include/application_manager/application_manager.h +++ b/src/components/application_manager/include/application_manager/application_manager.h @@ -48,6 +48,7 @@ #include "application_manager/application_manager_settings.h" #include "application_manager/state_controller.h" #include "application_manager/hmi_interfaces.h" +#include "policy/policy_types.h" namespace resumption { class LastState; @@ -83,8 +84,7 @@ class EventDispatcher; class Application; class StateControllerImpl; struct CommandParametersPermissions; -typedef std::vector RPCParams; - +using policy::RPCParams; struct ApplicationsAppIdSorter { bool operator()(const ApplicationSharedPtr lhs, const ApplicationSharedPtr rhs) const { diff --git a/src/components/application_manager/include/application_manager/application_manager_impl.h b/src/components/application_manager/include/application_manager/application_manager_impl.h index d2b280d098..0c576fa9ce 100644 --- a/src/components/application_manager/include/application_manager/application_manager_impl.h +++ b/src/components/application_manager/include/application_manager/application_manager_impl.h @@ -187,7 +187,6 @@ typedef std::queue RawAudioDataQueue; typedef threads::MessageLoopThread AudioPassThruQueue; } CREATE_LOGGERPTR_GLOBAL(logger_, "ApplicationManager") -typedef std::vector RPCParams; typedef utils::SharedPtr TimerSPtr; class ApplicationManagerImpl diff --git a/src/components/application_manager/include/application_manager/commands/command_impl.h b/src/components/application_manager/include/application_manager/commands/command_impl.h index 439b1756ef..66456dfdb1 100644 --- a/src/components/application_manager/include/application_manager/commands/command_impl.h +++ b/src/components/application_manager/include/application_manager/commands/command_impl.h @@ -46,9 +46,9 @@ namespace application_manager { * table */ struct CommandParametersPermissions { - std::vector allowed_params; - std::vector disallowed_params; - std::vector undefined_params; + RPCParams allowed_params; + RPCParams disallowed_params; + RPCParams undefined_params; }; namespace commands { diff --git a/src/components/application_manager/include/application_manager/commands/hmi/get_urls.h b/src/components/application_manager/include/application_manager/commands/hmi/get_urls.h index 41160f2ae7..38c65a3d90 100644 --- a/src/components/application_manager/include/application_manager/commands/hmi/get_urls.h +++ b/src/components/application_manager/include/application_manager/commands/hmi/get_urls.h @@ -69,7 +69,7 @@ class GetUrls : public RequestFromHMI { * @param endpoints Endpoints section of policy table */ void ProcessPolicyServiceURLs(const policy::EndpointUrls& endpoints); -#endif +#endif //EXTENDED_POLICY /** * @brief Process URLs collecting for service @@ -83,14 +83,6 @@ class GetUrls : public RequestFromHMI { */ void SendResponseToHMI(hmi_apis::Common_Result::eType result); - /** - * @brief fills structure for sending to HMI with default urls - * @param urls structure for filling - * @param endpoints Endpoints section of policy table - */ - void FillSODefaultUrls(smart_objects::SmartObject& urls, - const policy::EndpointUrls& endpoints); - DISALLOW_COPY_AND_ASSIGN(GetUrls); }; diff --git a/src/components/application_manager/include/application_manager/commands/hmi/request_from_hmi.h b/src/components/application_manager/include/application_manager/commands/hmi/request_from_hmi.h index 0f3b8bf1e4..2944d2038e 100644 --- a/src/components/application_manager/include/application_manager/commands/hmi/request_from_hmi.h +++ b/src/components/application_manager/include/application_manager/commands/hmi/request_from_hmi.h @@ -63,6 +63,16 @@ class RequestFromHMI : public CommandImpl, public event_engine::EventObserver { const hmi_apis::FunctionID::eType function_id, const hmi_apis::Common_Result::eType result_code); + /** + * @brief SendResponse allows to send error response to hmi + * @param correlation_id the correlation id for the response. + * @param function_id the function id for which response will be sent + * @param result_code the result code. + */ + void SendErrorResponse(uint32_t correlation_id, + hmi_apis::FunctionID::eType function_id, + hmi_apis::Common_Result::eType result_code); + void FillCommonParametersOfSO(smart_objects::SmartObject* message, uint32_t correlation_id, hmi_apis::FunctionID::eType function_id); diff --git a/src/components/application_manager/include/application_manager/commands/mobile/on_system_request_notification.h b/src/components/application_manager/include/application_manager/commands/mobile/on_system_request_notification.h index 143b076033..4613fef548 100644 --- a/src/components/application_manager/include/application_manager/commands/mobile/on_system_request_notification.h +++ b/src/components/application_manager/include/application_manager/commands/mobile/on_system_request_notification.h @@ -74,7 +74,7 @@ class OnSystemRequestNotification : public CommandNotificationImpl { */ void AddHeader(BinaryMessage& message) const; size_t ParsePTString(std::string& pt_string) const; -#endif +#endif //EXTENDED_POLICY DISALLOW_COPY_AND_ASSIGN(OnSystemRequestNotification); }; diff --git a/src/components/application_manager/include/application_manager/message_helper.h b/src/components/application_manager/include/application_manager/message_helper.h index 2a4805bd4b..1484fd6113 100644 --- a/src/components/application_manager/include/application_manager/message_helper.h +++ b/src/components/application_manager/include/application_manager/message_helper.h @@ -97,6 +97,13 @@ class MessageHelper { */ static void SendOnLanguageChangeToMobile(uint32_t connection_key); + /** + * @brief Sends DecryptCertificate request to HMI + * @param file_name path to file containing encrypted certificate + */ + static void SendDecryptCertificateToHMI(const std::string& file_name, + ApplicationManager& app_mngr); + /* * @brief Retrieve vehicle data map for param name in mobile request * to VehicleDataType diff --git a/src/components/application_manager/include/application_manager/policies/delegates/app_permission_delegate.h b/src/components/application_manager/include/application_manager/policies/delegates/app_permission_delegate.h index 6913f5038e..cca848e184 100644 --- a/src/components/application_manager/include/application_manager/policies/delegates/app_permission_delegate.h +++ b/src/components/application_manager/include/application_manager/policies/delegates/app_permission_delegate.h @@ -1,82 +1,5 @@ -/* - 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 SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_DELEGATES_APP_PERMISSION_DELEGATE_H_ -#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_DELEGATES_APP_PERMISSION_DELEGATE_H_ - -#include "utils/threads/thread.h" -#include "utils/threads/thread_delegate.h" -#include "utils/conditional_variable.h" - -#include "policy/policy_types.h" -#include "application_manager/policies/policy_handler_interface.h" - -namespace policy { -/** -*@brief The AppPermissionDelegate class allows to call OnAppPermissionConsent -*in async way. -*/ -class AppPermissionDelegate : public threads::ThreadDelegate { - public: - /** - * @brief AppPermissionDelegate constructor, contains parameters - * which will be pass to the called function. - * - * @param connection_key connection key. - * - * @param permissions new permissions - */ - AppPermissionDelegate(const uint32_t connection_key, - const PermissionConsent& permissions, - policy::PolicyHandlerInterface& policy_handler); - - /** - * @brief threadMain run the needed function. - */ - virtual void threadMain(); - - /** - * @brief exitThreadMain do some stuff before exit from thread - * - * @return true in case when thread has been finished properly - */ - virtual void exitThreadMain(); - - private: - uint32_t connection_key_; - PermissionConsent permissions_; - policy::PolicyHandlerInterface& policy_handler_; -}; - -} // namespace policy - -#endif // SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_DELEGATES_APP_PERMISSION_DELEGATE_H_ +#ifdef EXTENDED_PROPRIETARY +#include "application_manager/policies/premium/delegates/app_permission_delegate.h" +#else +#include "application_manager/policies/regular/delegates/app_permission_delegate.h" +#endif \ No newline at end of file diff --git a/src/components/application_manager/include/application_manager/policies/delegates/statistics_delegate.h b/src/components/application_manager/include/application_manager/policies/delegates/statistics_delegate.h index 3dc9ad925c..a415b3037e 100644 --- a/src/components/application_manager/include/application_manager/policies/delegates/statistics_delegate.h +++ b/src/components/application_manager/include/application_manager/policies/delegates/statistics_delegate.h @@ -1,86 +1,5 @@ -/* - 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 SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_DELEGATES_STATISTICS_DELEGATE_H_ -#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_DELEGATES_STATISTICS_DELEGATE_H_ - -#include - -#include "utils/threads/thread.h" -#include "utils/threads/thread_delegate.h" -#include "utils/conditional_variable.h" -#include "application_manager/usage_statistics.h" - -namespace policy { - -class PolicyHandler; - -class StatisticsDelegate : public threads::ThreadDelegate { - enum StatisticType { INCREMENT_GLOBAL, INCREMENT_APP, SET, ADD }; - - public: - StatisticsDelegate(PolicyHandler& policy_handler, - usage_statistics::GlobalCounterId type); - - StatisticsDelegate(PolicyHandler& policy_handler, - const std::string& app_id, - usage_statistics::AppCounterId type); - - StatisticsDelegate(PolicyHandler& policy_handler, - const std::string& app_id, - usage_statistics::AppInfoId type, - const std::string& value); - - StatisticsDelegate(PolicyHandler& policy_handler, - const std::string& app_id, - usage_statistics::AppStopwatchId type, - int32_t timespan_seconds); - - virtual void threadMain(); - - virtual void exitThreadMain(); - - private: - StatisticType type_; - usage_statistics::GlobalCounterId global_counter_; - usage_statistics::AppCounterId app_counter_; - usage_statistics::AppInfoId app_info_; - usage_statistics::AppStopwatchId stop_watch_; - - std::string app_id_; - std::string value_; - int32_t timespan_seconds_; - PolicyHandler& policy_handler_; -}; -} // namespace policy - -#endif // SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_DELEGATES_STATISTICS_DELEGATE_H_ +#ifdef EXTENDED_PROPRIETARY +#include "application_manager/policies/premium/delegates/statistics_delegate.h" +#else +#include "application_manager/policies/regular/delegates/statistics_delegate.h" +#endif \ No newline at end of file diff --git a/src/components/application_manager/include/application_manager/policies/policy_event_observer.h b/src/components/application_manager/include/application_manager/policies/policy_event_observer.h index 56513aa95b..99ed20b69f 100644 --- a/src/components/application_manager/include/application_manager/policies/policy_event_observer.h +++ b/src/components/application_manager/include/application_manager/policies/policy_event_observer.h @@ -1,63 +1,5 @@ -/* - 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. - */ - -#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_POLICIES_POLICY_EVENT_OBSERVER_H_ -#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_POLICIES_POLICY_EVENT_OBSERVER_H_ - -#include "application_manager/event_engine/event_observer.h" -#include "smart_objects/smart_object.h" -#include "utils/lock.h" - -namespace policy { - -class PolicyHandlerInterface; - -class PolicyEventObserver - : public application_manager::event_engine::EventObserver { - public: - PolicyEventObserver( - policy::PolicyHandlerInterface* const policy_handler, - application_manager::event_engine::EventDispatcher& event_dispatcher); - void set_policy_handler(policy::PolicyHandlerInterface* const policy_handler); - void on_event(const application_manager::event_engine::Event& event); - void subscribe_on_event( - const application_manager::event_engine::Event::EventID& event_id, - int32_t hmi_correlation_id = 0); - - private: - sync_primitives::Lock policy_handler_lock_; - PolicyHandlerInterface* policy_handler_; - void ProcessOdometerEvent(const smart_objects::SmartObject& message); -}; - -} // namespace policy -#endif // SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_POLICIES_POLICY_EVENT_OBSERVER_H_ +#ifdef EXTENDED_PROPRIETARY +#include "application_manager/policies/premium/policy_event_observer.h" +#else +#include "application_manager/policies/regular/policy_event_observer.h" +#endif \ No newline at end of file diff --git a/src/components/application_manager/include/application_manager/policies/policy_handler.h b/src/components/application_manager/include/application_manager/policies/policy_handler.h index 6f36408444..06fca0eec8 100644 --- a/src/components/application_manager/include/application_manager/policies/policy_handler.h +++ b/src/components/application_manager/include/application_manager/policies/policy_handler.h @@ -30,8 +30,8 @@ POSSIBILITY OF SUCH DAMAGE. */ -#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_POLICY_HANDLER_H_ -#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_POLICY_HANDLER_H_ +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_POLICIES_POLICY_HANDLER_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_POLICIES_POLICY_HANDLER_H_ #include #include @@ -92,8 +92,13 @@ class PolicyHandler : public PolicyHandlerInterface, virtual void OnPermissionsUpdated(const std::string& policy_app_id, const Permissions& permissions) OVERRIDE; - virtual void OnSnapshotCreated(const BinaryMessage& pt_string) OVERRIDE; - +#ifdef EXTENDED_PROPRIETARY + void OnSnapshotCreated(const BinaryMessage& pt_string, + const std::vector& retry_delay_seconds, + int timeout_exchange) OVERRIDE; +#else // EXTENDED_PROPRIETARY + void OnSnapshotCreated(const BinaryMessage& pt_string) OVERRIDE; +#endif // EXTENDED_PROPRIETARY virtual bool GetPriority(const std::string& policy_app_id, std::string* priority) const OVERRIDE; void CheckPermissions(const PTString& app_id, @@ -110,8 +115,10 @@ class PolicyHandler : public PolicyHandlerInterface, bool GetInitialAppData(const std::string& application_id, StringArray* nicknames = NULL, StringArray* app_hmi_types = NULL) OVERRIDE; - void GetServiceUrls(const std::string& service_type, - EndpointUrls& end_points) OVERRIDE; + void GetUpdateUrls(const std::string& service_type, + EndpointUrls& out_end_points) OVERRIDE; + void GetUpdateUrls(const uint32_t service_type, + EndpointUrls& out_end_points) OVERRIDE; virtual std::string GetLockScreenIconUrl() const OVERRIDE; void ResetRetrySequence() OVERRIDE; uint32_t NextRetryTimeout() OVERRIDE; @@ -154,7 +161,7 @@ class PolicyHandler : public PolicyHandlerInterface, * @param User consent from response */ void OnAllowSDLFunctionalityNotification( - bool is_allowed, const std::string& device_id) OVERRIDE; + bool is_allowed, const std::string& device_mac) OVERRIDE; /** * @brief Increment counter for ignition cycles @@ -300,7 +307,9 @@ class PolicyHandler : public PolicyHandlerInterface, virtual void OnCertificateUpdated( const std::string& certificate_data) OVERRIDE; - +#ifdef EXTENDED_PROPRIETARY + void OnCertificateDecrypted(bool is_succeeded) OVERRIDE; +#endif // EXTENDED_PROPRIETARY virtual bool CanUpdate() OVERRIDE; virtual void OnDeviceConsentChanged(const std::string& device_id, @@ -356,6 +365,15 @@ class PolicyHandler : public PolicyHandlerInterface, */ void OnAppsSearchCompleted() OVERRIDE; + /** + * @brief OnAppRegisteredOnMobile allows to handle event when application were + * succesfully registered on mobile device. + * It will send OnAppPermissionSend notification and will try to start PTU. + * + * @param application_id registered application. + */ + void OnAppRegisteredOnMobile(const std::string& application_id) OVERRIDE; + /** * @brief Checks if certain request type is allowed for application * @param policy_app_id Unique applicaion id @@ -380,14 +398,13 @@ class PolicyHandler : public PolicyHandlerInterface, */ const VehicleInfo GetVehicleInfo() const OVERRIDE; +#ifdef EXTENDED_PROPRIETARY /** - * @brief OnAppRegisteredOnMobile allows to handle event when application were - * succesfully registered on mobile device. - * It will send OnAppPermissionSend notification and will try to start PTU. - * - * @param application_id registered application. + * @brief Gets meta information + * @return meta information */ - void OnAppRegisteredOnMobile(const std::string& application_id) OVERRIDE; + const policy::MetaInfo GetMetaInfo() const OVERRIDE; +#endif // EXTENDED_PROPRIETARY // TODO(AKutsan) REMOVE THIS UGLY HOTFIX virtual void Increment(usage_statistics::GlobalCounterId type) OVERRIDE; @@ -466,22 +483,22 @@ class PolicyHandler : public PolicyHandlerInterface, policy_handler_->AsyncRun(new StatisticsDelegate(*policy_handler_, type)); } - void Increment(const std::string& app_id, - usage_statistics::AppCounterId type) { + virtual void Increment(const std::string& app_id, + usage_statistics::AppCounterId type) { policy_handler_->AsyncRun( new StatisticsDelegate(*policy_handler_, app_id, type)); } - void Set(const std::string& app_id, - usage_statistics::AppInfoId type, - const std::string& value) { + virtual void Set(const std::string& app_id, + usage_statistics::AppInfoId type, + const std::string& value) { policy_handler_->AsyncRun( new StatisticsDelegate(*policy_handler_, app_id, type, value)); } - void Add(const std::string& app_id, - usage_statistics::AppStopwatchId type, - int32_t timespan_seconds) { + virtual void Add(const std::string& app_id, + usage_statistics::AppStopwatchId type, + int32_t timespan_seconds) { policy_handler_->AsyncRun(new StatisticsDelegate( *policy_handler_, app_id, type, timespan_seconds)); } @@ -489,7 +506,9 @@ class PolicyHandler : public PolicyHandlerInterface, private: PolicyHandler* policy_handler_; }; - +#ifdef EXTENDED_PROPRIETARY + void OnEmptyCertificateArrived() const; +#endif // EXTENDED_PROPRIETARY bool SaveSnapshot(const BinaryMessage& pt_string, std::string& snap_path); static const std::string kLibrary; mutable sync_primitives::RWLock policy_manager_lock_; @@ -508,7 +527,7 @@ class PolicyHandler : public PolicyHandlerInterface, typedef std::list HandlersCollection; HandlersCollection listeners_; - sync_primitives::Lock listeners_lock_; + mutable sync_primitives::Lock listeners_lock_; /** * @brief Application-to-device map is used for getting/setting user consents diff --git a/src/components/application_manager/include/application_manager/policies/policy_handler_observer.h b/src/components/application_manager/include/application_manager/policies/policy_handler_observer.h index 794da0cdfb..81d8db63dc 100644 --- a/src/components/application_manager/include/application_manager/policies/policy_handler_observer.h +++ b/src/components/application_manager/include/application_manager/policies/policy_handler_observer.h @@ -1,53 +1,5 @@ -/* - 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. - */ - -#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_POLICY_HANDLER_OBSERVER_H_ -#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_POLICY_HANDLER_OBSERVER_H_ - -#include -#include -#include - -namespace policy { - -class PolicyHandlerObserver { - public: - virtual void OnUpdateHMIAppType( - std::map > app_hmi_types) {} - virtual bool OnCertificateUpdated(const std::string& certificate_data) { - return false; - } - virtual ~PolicyHandlerObserver() {} -}; -} // namespace policy - -#endif // SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_POLICY_HANDLER_OBSERVER_H_ +#ifdef EXTENDED_PROPRIETARY +#error "policy_handler_observer.h is not available in policy premium" +#else +#include "application_manager/policies/regular/policy_handler_observer.h" +#endif \ No newline at end of file diff --git a/src/components/application_manager/include/application_manager/policies/policy_retry_sequence.h b/src/components/application_manager/include/application_manager/policies/policy_retry_sequence.h index f1a9ff55b8..81d8db63dc 100644 --- a/src/components/application_manager/include/application_manager/policies/policy_retry_sequence.h +++ b/src/components/application_manager/include/application_manager/policies/policy_retry_sequence.h @@ -1,54 +1,5 @@ -/* - 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. - */ - -#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_POLICY_RETRY_SEQUENCE_H_ -#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_POLICY_RETRY_SEQUENCE_H_ - -#include "utils/threads/thread_delegate.h" - -namespace policy { - -class PolicyHandler; - -class RetrySequence : public threads::ThreadDelegate { - public: - explicit RetrySequence(PolicyHandler* const policy_handler); - void threadMain(); - - private: - PolicyHandler* const policy_handler_; - void StartNextRetry(); -}; - -} // namespace policy - -#endif // SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_POLICY_RETRY_SEQUENCE_H_ +#ifdef EXTENDED_PROPRIETARY +#error "policy_handler_observer.h is not available in policy premium" +#else +#include "application_manager/policies/regular/policy_handler_observer.h" +#endif \ No newline at end of file diff --git a/src/components/application_manager/include/application_manager/policies/pt_exchange_handler.h b/src/components/application_manager/include/application_manager/policies/pt_exchange_handler.h index 4e543eae96..765e5343c2 100644 --- a/src/components/application_manager/include/application_manager/policies/pt_exchange_handler.h +++ b/src/components/application_manager/include/application_manager/policies/pt_exchange_handler.h @@ -1,47 +1,5 @@ -/* - 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. - */ - -#ifndef SRC_COMPONENTS_POLICY_INCLUDE_POLICY_PT_EXCHANGE_HANDLER_H_ -#define SRC_COMPONENTS_POLICY_INCLUDE_POLICY_PT_EXCHANGE_HANDLER_H_ - -#include "policy/policy_manager.h" - -namespace policy { -class PTExchangeHandler { - public: - virtual ~PTExchangeHandler(){}; - virtual void Start() = 0; - virtual void Stop() = 0; -}; -} // namespace policy - -#endif // SRC_COMPONENTS_POLICY_INCLUDE_POLICY_PT_EXCHANGE_HANDLER_H_ +#ifdef EXTENDED_PROPRIETARY +#error "pt_exchange_handler.h is not available in policy premium" +#else +#include "application_manager/policies/regular/pt_exchange_handler.h" +#endif \ No newline at end of file diff --git a/src/components/application_manager/include/application_manager/policies/pt_exchange_handler_ext.h b/src/components/application_manager/include/application_manager/policies/pt_exchange_handler_ext.h index 05aec0c3e9..59f8714402 100644 --- a/src/components/application_manager/include/application_manager/policies/pt_exchange_handler_ext.h +++ b/src/components/application_manager/include/application_manager/policies/pt_exchange_handler_ext.h @@ -1,52 +1,5 @@ -/* - 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. - */ - -#ifndef SRC_COMPONENTS_POLICY_INCLUDE_POLICY_PT_EXCHANGE_HANDLER_EXT_H_ -#define SRC_COMPONENTS_POLICY_INCLUDE_POLICY_PT_EXCHANGE_HANDLER_EXT_H_ - -#include "application_manager/policies/pt_exchange_handler.h" -#include "application_manager/policies/policy_handler.h" - -namespace policy { -class PTExchangeHandlerExt : public PTExchangeHandler { - public: - PTExchangeHandlerExt(PolicyHandler* policy_handler); - ~PTExchangeHandlerExt(); - virtual void Start(); - virtual void Stop(); - - private: - PolicyHandler* policy_handler_; -}; -} // namespace policy - -#endif // SRC_COMPONENTS_POLICY_INCLUDE_POLICY_PT_EXCHANGE_HANDLER_EXT_H_ +#ifdef EXTENDED_PROPRIETARY +#error "pt_exchange_handler_ext.h is not available in policy premium" +#else +#include "application_manager/policies/regular/pt_exchange_handler_ext.h" +#endif diff --git a/src/components/application_manager/include/application_manager/policies/pt_exchange_handler_impl.h b/src/components/application_manager/include/application_manager/policies/pt_exchange_handler_impl.h index 29c74aa96e..106bfaccef 100644 --- a/src/components/application_manager/include/application_manager/policies/pt_exchange_handler_impl.h +++ b/src/components/application_manager/include/application_manager/policies/pt_exchange_handler_impl.h @@ -1,61 +1,5 @@ -/* - 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. - */ - -#ifndef SRC_COMPONENTS_POLICY_INCLUDE_POLICY_PT_EXCHANGE_IMPL_H_ -#define SRC_COMPONENTS_POLICY_INCLUDE_POLICY_PT_EXCHANGE_IMPL_H_ - -#include "application_manager/policies/pt_exchange_handler.h" -#include "utils/lock.h" -#include "utils/threads/thread.h" - -namespace policy { - -class PolicyHandler; - -class PTExchangeHandlerImpl : public PTExchangeHandler { - public: - PTExchangeHandlerImpl(PolicyHandler* handler); - virtual ~PTExchangeHandlerImpl(); - virtual void Start(); - virtual void Stop(); - - protected: - PolicyHandler* policy_handler_; - threads::Thread* retry_sequence_; - sync_primitives::Lock retry_sequence_lock_; - - friend class RetrySequence; -}; - -} // namespace policy - -#endif // SRC_COMPONENTS_POLICY_INCLUDE_POLICY_PT_EXCHANGE_IMPL_H_ +#ifdef EXTENDED_PROPRIETARY +#error "pt_exchange_handler_impl.h is not available in policy premium" +#else +#include "application_manager/policies/regular/pt_exchange_handler_impl.h" +#endif \ No newline at end of file diff --git a/src/components/application_manager/include/application_manager/smart_object_keys.h b/src/components/application_manager/include/application_manager/smart_object_keys.h index a1639eebd8..9a9e5933bf 100644 --- a/src/components/application_manager/include/application_manager/smart_object_keys.h +++ b/src/components/application_manager/include/application_manager/smart_object_keys.h @@ -380,6 +380,7 @@ extern const char* keyboard_layout; extern const char* limited_character_list; extern const char* auto_complete_text; extern const char* file; +extern const char* file_name; extern const char* retry; extern const char* service; } // namespace hmi_request diff --git a/src/components/application_manager/src/application_impl.cc b/src/components/application_manager/src/application_impl.cc index e06497f1da..5f9c4386f5 100644 --- a/src/components/application_manager/src/application_impl.cc +++ b/src/components/application_manager/src/application_impl.cc @@ -171,6 +171,11 @@ bool ApplicationImpl::IsFullscreen() const { return mobile_api::HMILevel::HMI_FULL == hmi_level(); } +bool ApplicationImpl::is_audio() const { + return is_media_application() || is_voice_communication_supported() || + is_navi(); +} + void ApplicationImpl::ChangeSupportingAppHMIType() { is_navi_ = false; is_voice_communication_application_ = false; diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index 46c952d8aa..5d04c36a69 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -1404,7 +1404,7 @@ void ApplicationManagerImpl::SendMessageToMobile( for (; iter != iter_end; ++iter) { if (true == iter->second.asBool()) { LOG4CXX_INFO(logger_, "Request's param: " << iter->first); - params.push_back(iter->first); + params.insert(iter->first); } } } diff --git a/src/components/application_manager/src/commands/command_request_impl.cc b/src/components/application_manager/src/commands/command_request_impl.cc index d8f14fa844..2c57773a8f 100644 --- a/src/components/application_manager/src/commands/command_request_impl.cc +++ b/src/components/application_manager/src/commands/command_request_impl.cc @@ -510,7 +510,7 @@ bool CommandRequestImpl::CheckAllowedParameters() { for (; iter != iter_end; ++iter) { if (true == iter->second.asBool()) { LOG4CXX_DEBUG(logger_, "Request's param: " << iter->first); - params.push_back(iter->first); + params.insert(iter->first); } } } @@ -556,15 +556,14 @@ void CommandRequestImpl::RemoveDisallowedParameters() { smart_objects::SmartObject& params = (*message_)[strings::msg_params]; // Remove from request all disallowed parameters - std::vector::const_iterator it_disallowed = + RPCParams::const_iterator it_disallowed = parameters_permissions_.disallowed_params.begin(); - std::vector::const_iterator it_disallowed_end = + RPCParams::const_iterator it_disallowed_end = parameters_permissions_.disallowed_params.end(); for (; it_disallowed != it_disallowed_end; ++it_disallowed) { if (params.keyExists(*it_disallowed)) { params.erase(*it_disallowed); - removed_parameters_permissions_.disallowed_params.push_back( - *it_disallowed); + removed_parameters_permissions_.disallowed_params.insert(*it_disallowed); LOG4CXX_INFO( logger_, "Following parameter is disallowed by user: " << *it_disallowed); @@ -572,14 +571,14 @@ void CommandRequestImpl::RemoveDisallowedParameters() { } // Remove from request all undefined yet parameters - std::vector::const_iterator it_undefined = + RPCParams::const_iterator it_undefined = parameters_permissions_.undefined_params.begin(); - std::vector::const_iterator it_undefined_end = + RPCParams::const_iterator it_undefined_end = parameters_permissions_.undefined_params.end(); for (; it_undefined != it_undefined_end; ++it_undefined) { if (params.keyExists(*it_undefined)) { params.erase(*it_undefined); - removed_parameters_permissions_.undefined_params.push_back(*it_undefined); + removed_parameters_permissions_.undefined_params.insert(*it_undefined); LOG4CXX_INFO( logger_, "Following parameter is disallowed by policy: " << *it_undefined); @@ -600,7 +599,7 @@ void CommandRequestImpl::RemoveDisallowedParameters() { parameters_permissions_.allowed_params.end(), key)) { params.erase(key); - removed_parameters_permissions_.undefined_params.push_back(key); + removed_parameters_permissions_.undefined_params.insert(key); LOG4CXX_INFO(logger_, "Following parameter is not found among allowed parameters '" << key << "' and will be treated as disallowed."); @@ -622,7 +621,7 @@ void CommandRequestImpl::AddDisallowedParametersToInfo( smart_objects::SmartObject& response) const { std::string info; - std::vector::const_iterator it = + RPCParams::const_iterator it = removed_parameters_permissions_.disallowed_params.begin(); for (; it != removed_parameters_permissions_.disallowed_params.end(); ++it) { AddDissalowedParameterToInfoString(info, (*it)); diff --git a/src/components/application_manager/src/commands/hmi/get_urls.cc b/src/components/application_manager/src/commands/hmi/get_urls.cc index af220051d4..3ac46a74d8 100644 --- a/src/components/application_manager/src/commands/hmi/get_urls.cc +++ b/src/components/application_manager/src/commands/hmi/get_urls.cc @@ -35,18 +35,6 @@ #include "application_manager/application_manager.h" #include "application_manager/policies/policy_handler.h" -namespace { -struct PolicyAppIdComparator { - PolicyAppIdComparator(const std::string& policy_app_id) - : policy_app_id_(policy_app_id) {} - - bool operator()(const policy::EndpointData& data) { - return data.app_id == policy_app_id_; - } - std::string policy_app_id_; -}; -} - namespace application_manager { namespace commands { @@ -58,23 +46,21 @@ GetUrls::~GetUrls() {} void GetUrls::Run() { LOG4CXX_AUTO_TRACE(logger_); - using namespace smart_objects; - using namespace application_manager; - using namespace strings; - using namespace hmi_apis; + namespace Common_Result = hmi_apis::Common_Result; + using policy::EndpointUrls; if (!application_manager_.GetPolicyHandler().PolicyEnabled()) { SendResponseToHMI(Common_Result::DATA_NOT_AVAILABLE); return; } - SmartObject& object = *message_; - const std::string service_to_check = - object[msg_params][hmi_request::service].asString(); + const uint32_t service_to_check = + (*message_)[strings::msg_params][hmi_request::service].asUInt(); + + EndpointUrls endpoints; + application_manager_.GetPolicyHandler().GetUpdateUrls(service_to_check, + endpoints); - policy::EndpointUrls endpoints; - application_manager_.GetPolicyHandler().GetServiceUrls( - object[strings::msg_params][hmi_request::service].asString(), endpoints); if (endpoints.empty()) { LOG4CXX_ERROR(logger_, "No URLs for service " << service_to_check); SendResponseToHMI(Common_Result::DATA_NOT_AVAILABLE); @@ -82,17 +68,88 @@ void GetUrls::Run() { } #ifdef EXTENDED_POLICY - const std::string policy_service = "7"; + const uint32_t policy_service = 7; if (policy_service == service_to_check) { ProcessPolicyServiceURLs(endpoints); return; } -#endif +#endif //EXTENDED_POLICY + ProcessServiceURLs(endpoints); } +void GetUrls::ProcessServiceURLs(const policy::EndpointUrls& endpoints) { + namespace Common_Result = hmi_apis::Common_Result; + using smart_objects::SmartObject; + + (*message_)[strings::msg_params].erase(hmi_request::service); + SmartObject& urls = (*message_)[strings::msg_params][hmi_response::urls]; + + size_t index = 0; + for (size_t e = 0; e < endpoints.size(); ++e) { + for (size_t u = 0; u < endpoints[e].url.size(); ++u, ++index) { + const std::string app_url = endpoints[e].url[u]; + + SmartObject& service_info = urls[index]; + + service_info[strings::url] = app_url; + if (policy::kDefaultId != endpoints[e].app_id) { +#ifndef EXTENDED_PROPRIETARY + service_info[hmi_response::policy_app_id] = endpoints[e].app_id; +#else // EXTENDED_PROPRIETARY + ApplicationSharedPtr app = + application_manager_.application_by_policy_id(endpoints[e].app_id); + + if (!app) { + LOG4CXX_ERROR(logger_, + "Can't find application with policy id " + << endpoints[e].app_id + << " URLs adding for this appliation is skipped."); + continue; + } + + service_info[strings::app_id] = app->hmi_app_id(); +#endif // EXTENDED_PROPRIETARY + } + } + } + SendResponseToHMI(Common_Result::SUCCESS); +} + +void GetUrls::SendResponseToHMI(hmi_apis::Common_Result::eType result) { + (*message_)[strings::params][strings::message_type] = MessageType::kResponse; + (*message_)[strings::params][hmi_response::code] = result; + application_manager_.ManageHMICommand(message_); +} + #ifdef EXTENDED_POLICY +struct PolicyAppIdComparator { + PolicyAppIdComparator(const std::string& policy_app_id) + : policy_app_id_(policy_app_id) {} + + bool operator()(const policy::EndpointData& data) { + return data.app_id == policy_app_id_; + } + std::string policy_app_id_; +}; + +void FillSODefaultUrls(smart_objects::SmartObject& urls, + const policy::EndpointUrls& endpoints) { + using smart_objects::SmartObject; + PolicyAppIdComparator comparator(policy::kDefaultId); + policy::EndpointUrls::const_iterator it = + std::find_if(endpoints.begin(), endpoints.end(), comparator); + if (it == endpoints.end()) { + return; + } + SmartObject service_info = SmartObject(smart_objects::SmartType_Map); + for (size_t i = 0; i < (*it).url.size(); ++i) { + service_info[strings::url] = (*it).url[i]; + urls[i] = service_info; + } +} + void GetUrls::ProcessPolicyServiceURLs(const policy::EndpointUrls& endpoints) { LOG4CXX_AUTO_TRACE(logger_); using namespace smart_objects; @@ -162,58 +219,7 @@ void GetUrls::ProcessPolicyServiceURLs(const policy::EndpointUrls& endpoints) { SendResponseToHMI(Common_Result::SUCCESS); return; } -#endif - -void GetUrls::ProcessServiceURLs(const policy::EndpointUrls& endpoints) { - using namespace smart_objects; - using namespace strings; - using namespace hmi_apis; - - SmartObject& object = *message_; - object[msg_params].erase(hmi_request::service); - object[msg_params][hmi_response::urls] = SmartObject(SmartType_Array); - - SmartObject& urls = object[msg_params][hmi_response::urls]; - - size_t index = 0; - for (size_t e = 0; e < endpoints.size(); ++e) { - for (size_t u = 0; u < endpoints[e].url.size(); ++u, ++index) { - const std::string app_url = endpoints[e].url[u]; - - urls[index] = SmartObject(SmartType_Map); - SmartObject& service_info = urls[index]; - - service_info[url] = app_url; - if (policy::kDefaultId != endpoints[e].app_id) { - service_info[hmi_response::policy_app_id] = endpoints[e].app_id; - } - } - } - SendResponseToHMI(Common_Result::SUCCESS); -} - -void GetUrls::FillSODefaultUrls(smart_objects::SmartObject& urls, - const policy::EndpointUrls& endpoints) { - using namespace smart_objects; - LOG4CXX_AUTO_TRACE(logger_); - PolicyAppIdComparator comparator(policy::kDefaultId); - policy::EndpointUrls::const_iterator it = - std::find_if(endpoints.begin(), endpoints.end(), comparator); - if (it == endpoints.end()) { - return; - } - SmartObject service_info = SmartObject(SmartType_Map); - for (size_t i = 0; i < (*it).url.size(); ++i) { - service_info[strings::url] = (*it).url[i]; - urls[i] = service_info; - } -} - -void GetUrls::SendResponseToHMI(hmi_apis::Common_Result::eType result) { - (*message_)[strings::params][strings::message_type] = MessageType::kResponse; - (*message_)[strings::params][hmi_response::code] = result; - application_manager_.ManageHMICommand(message_); -} +#endif //EXTENDED_POLICY } // namespace commands } // namespace application_manager diff --git a/src/components/application_manager/src/commands/hmi/on_received_policy_update.cc b/src/components/application_manager/src/commands/hmi/on_received_policy_update.cc index 03c0bc7378..c67158bab6 100644 --- a/src/components/application_manager/src/commands/hmi/on_received_policy_update.cc +++ b/src/components/application_manager/src/commands/hmi/on_received_policy_update.cc @@ -47,7 +47,7 @@ OnReceivedPolicyUpdate::~OnReceivedPolicyUpdate() {} void OnReceivedPolicyUpdate::Run() { LOG4CXX_AUTO_TRACE(logger_); -#ifdef EXTENDED_POLICY +#if defined(EXTENDED_POLICY) || defined(EXTENDED_PROPRIETARY) const std::string& file_path = (*message_)[strings::msg_params][hmi_notification::policyfile].asString(); policy::BinaryMessage file_content; diff --git a/src/components/application_manager/src/commands/hmi/request_from_hmi.cc b/src/components/application_manager/src/commands/hmi/request_from_hmi.cc index be3cd6314c..815c88d780 100644 --- a/src/components/application_manager/src/commands/hmi/request_from_hmi.cc +++ b/src/components/application_manager/src/commands/hmi/request_from_hmi.cc @@ -76,21 +76,20 @@ void RequestFromHMI::SendResponse( application_manager_.ManageHMICommand(message); } -// void RequestFromHMI::SendErrorResponse(uint32_t correlation_id, -// hmi_apis::FunctionID::eType -// function_id, -// hmi_apis::Common_Result::eType -// result_code) { -// smart_objects::SmartObject* message = new smart_objects::SmartObject( -// smart_objects::SmartType_Map); -// FillCommonParametersOfSO(message, correlation_id, function_id); -// (*message)[strings::params][strings::message_type] = -// MessageType::kErrorResponse; -// (*message)[strings::params][hmi_response::code] = result_code; -// (*message)[strings::params][strings::error_msg] = "HMIDeactivate is active"; - -// application_manager_.ManageHMICommand(message); -//} +void RequestFromHMI::SendErrorResponse( + uint32_t correlation_id, + hmi_apis::FunctionID::eType function_id, + hmi_apis::Common_Result::eType result_code) { + smart_objects::SmartObject* message = + new smart_objects::SmartObject(smart_objects::SmartType_Map); + FillCommonParametersOfSO(message, correlation_id, function_id); + (*message)[strings::params][strings::message_type] = + MessageType::kErrorResponse; + (*message)[strings::params][hmi_response::code] = result_code; + (*message)[strings::params][strings::error_msg] = "HMIDeactivate is active"; + + application_manager_.ManageHMICommand(message); +} void RequestFromHMI::FillCommonParametersOfSO( smart_objects::SmartObject* message, diff --git a/src/components/application_manager/src/commands/hmi/sdl_activate_app_request.cc b/src/components/application_manager/src/commands/hmi/sdl_activate_app_request.cc index 30ea41e0b0..a6dbb2dc71 100644 --- a/src/components/application_manager/src/commands/hmi/sdl_activate_app_request.cc +++ b/src/components/application_manager/src/commands/hmi/sdl_activate_app_request.cc @@ -84,6 +84,41 @@ SDLActivateAppRequest::SDLActivateAppRequest( SDLActivateAppRequest::~SDLActivateAppRequest() {} +uint32_t SDLActivateAppRequest::app_id() const { + using namespace strings; + if (!(*message_).keyExists(msg_params)) { + LOG4CXX_DEBUG(logger_, msg_params << " section is absent in the message."); + return 0; + } + if (!(*message_)[msg_params].keyExists(strings::app_id)) { + LOG4CXX_DEBUG(logger_, + strings::app_id << " section is absent in the message."); + return 0; + } + return (*message_)[msg_params][strings::app_id].asUInt(); +} + +#ifdef EXTENDED_PROPRIETARY +void SDLActivateAppRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + using namespace hmi_apis::FunctionID; + + if (application_manager_.state_controller().IsStateActive( + HmiState::STATE_ID_DEACTIVATE_HMI)) { + LOG4CXX_DEBUG(logger_, + "DeactivateHmi state is active. " + "Sends response with result code REJECTED"); + SendErrorResponse(correlation_id(), + static_cast(function_id()), + hmi_apis::Common_Result::REJECTED); + } else { + const uint32_t application_id = app_id(); + application_manager_.GetPolicyHandler().OnActivateApp(application_id, + correlation_id()); + } +} + +#else // EXTENDED_PROPRIETARY void SDLActivateAppRequest::Run() { LOG4CXX_AUTO_TRACE(logger_); using namespace hmi_apis::FunctionID; @@ -160,6 +195,7 @@ void SDLActivateAppRequest::Run() { subscribe_on_event(BasicCommunication_OnAppRegistered); } +#endif // EXTENDED_PROPRIETARY void SDLActivateAppRequest::onTimeOut() { using namespace hmi_apis::FunctionID; using namespace hmi_apis::Common_Result; @@ -192,20 +228,6 @@ void SDLActivateAppRequest::on_event(const event_engine::Event& event) { correlation_id()); } -uint32_t SDLActivateAppRequest::app_id() const { - using namespace strings; - if (!(*message_).keyExists(msg_params)) { - LOG4CXX_DEBUG(logger_, msg_params << " section is absent in the message."); - return 0; - } - if (!(*message_)[msg_params].keyExists(strings::app_id)) { - LOG4CXX_DEBUG(logger_, - strings::app_id << " section is absent in the message."); - return 0; - } - return (*message_)[msg_params][strings::app_id].asUInt(); -} - uint32_t SDLActivateAppRequest::hmi_app_id( const smart_objects::SmartObject& so) const { using namespace strings; diff --git a/src/components/application_manager/src/commands/hmi/sdl_policy_update.cc b/src/components/application_manager/src/commands/hmi/sdl_policy_update.cc index e79bca14de..a0a42aa1a5 100644 --- a/src/components/application_manager/src/commands/hmi/sdl_policy_update.cc +++ b/src/components/application_manager/src/commands/hmi/sdl_policy_update.cc @@ -44,7 +44,7 @@ SDLPolicyUpdate::~SDLPolicyUpdate() {} void SDLPolicyUpdate::Run() { LOG4CXX_AUTO_TRACE(logger_); -#ifdef EXTENDED_POLICY +#if defined(EXTENDED_POLICY) || defined(EXTENDED_PROPRIETARY) SendRequest(); #else LOG4CXX_WARN(logger_, diff --git a/src/components/application_manager/src/commands/mobile/on_system_request_notification.cc b/src/components/application_manager/src/commands/mobile/on_system_request_notification.cc index 03d9b47406..9d19ef765c 100644 --- a/src/components/application_manager/src/commands/mobile/on_system_request_notification.cc +++ b/src/components/application_manager/src/commands/mobile/on_system_request_notification.cc @@ -92,7 +92,7 @@ void OnSystemRequestNotification::Run() { file_system::ReadBinaryFile(filename, binary_data); AddHeader(binary_data); (*message_)[strings::params][strings::binary_data] = binary_data; -#endif +#endif //EXTENDED_POLICY (*message_)[strings::msg_params][strings::file_type] = FileType::JSON; } else if (RequestType::HTTP == request_type) { (*message_)[strings::msg_params][strings::file_type] = FileType::BINARY; @@ -184,7 +184,7 @@ size_t OnSystemRequestNotification::ParsePTString( pt_string = result; return result_length; } -#endif +#endif //EXTENDED_POLICY } // namespace mobile diff --git a/src/components/application_manager/src/commands/mobile/send_location_request.cc b/src/components/application_manager/src/commands/mobile/send_location_request.cc index 7b9ec53c3a..a8511fadd3 100644 --- a/src/components/application_manager/src/commands/mobile/send_location_request.cc +++ b/src/components/application_manager/src/commands/mobile/send_location_request.cc @@ -62,8 +62,7 @@ void SendLocationRequest::Run() { smart_objects::SmartObject& msg_params = (*message_)[strings::msg_params]; if (msg_params.keyExists(strings::delivery_mode)) { - const std::vector& allowed_params = - parameters_permissions().allowed_params; + const RPCParams& allowed_params = parameters_permissions().allowed_params; if (allowed_params.end() == std::find(allowed_params.begin(), allowed_params.end(), strings::delivery_mode)) { diff --git a/src/components/application_manager/src/hmi_command_factory.cc b/src/components/application_manager/src/hmi_command_factory.cc index 67625fde88..77963d0aea 100644 --- a/src/components/application_manager/src/hmi_command_factory.cc +++ b/src/components/application_manager/src/hmi_command_factory.cc @@ -157,6 +157,11 @@ #include "application_manager/commands/hmi/on_app_permission_changed_notification.h" #include "application_manager/commands/hmi/on_event_changed_notification.h" +#ifdef EXTENDED_PROPRIETARY +#include "application_manager/commands/hmi/decrypt_certificate_request.h" +#include "application_manager/commands/hmi/decrypt_certificate_response.h" +#endif // EXTENDED_PROPRIETARY + #ifdef HMI_DBUS_API #include "application_manager/commands/hmi/vi_get_vehicle_data_request_template.h" #include "application_manager/commands/hmi/vi_get_vehicle_data_response_template.h" @@ -328,6 +333,18 @@ CommandSharedPtr HMICommandFactory::CreateCommand( } break; } +#ifdef EXTENDED_PROPRIETARY + case hmi_apis::FunctionID::BasicCommunication_DecryptCertificate: { + if (is_response) { + command.reset(new commands::DecryptCertificateResponse( + message, application_manager)); + } else { + command.reset(new commands::DecryptCertificateRequest( + message, application_manager)); + } + break; + } +#endif // EXTENDED_PROPRIETARY case hmi_apis::FunctionID::BasicCommunication_GetSystemInfo: { if (is_response) { command.reset( diff --git a/src/components/application_manager/src/message_helper/message_helper.cc b/src/components/application_manager/src/message_helper/message_helper.cc index a764c574d0..ae4205d051 100644 --- a/src/components/application_manager/src/message_helper/message_helper.cc +++ b/src/components/application_manager/src/message_helper/message_helper.cc @@ -251,6 +251,25 @@ smart_objects::SmartObjectSPtr MessageHelper::CreateHashUpdateNotification( return message; } +void MessageHelper::SendDecryptCertificateToHMI(const std::string& file_name, + ApplicationManager& app_mngr) { + using namespace smart_objects; + SmartObjectSPtr message = + CreateRequestObject(app_mngr.GetNextHMICorrelationID()); + DCHECK(message); + + SmartObject& object = *message; + object[strings::params][strings::function_id] = + hmi_apis::FunctionID::BasicCommunication_DecryptCertificate; + + SmartObject msg_params = SmartObject(SmartType_Map); + + msg_params[hmi_request::file_name] = file_name; + object[strings::msg_params] = msg_params; + + app_mngr.ManageHMICommand(message); +} + void MessageHelper::SendHashUpdateNotification(const uint32_t app_id, ApplicationManager& app_mngr) { LOG4CXX_AUTO_TRACE(logger_); @@ -1451,12 +1470,12 @@ void MessageHelper::SendSDLActivateAppResponse( GetPriorityCode(permissions.priority); } + app_mngr.ManageHMICommand(message); + // If application is revoked it should not be activated if (permissions.appRevoked || !permissions.isSDLAllowed) { return; } - - app_mngr.ManageHMICommand(message); } void MessageHelper::SendOnSDLConsentNeeded( @@ -1496,15 +1515,16 @@ void MessageHelper::SendPolicyUpdate(const std::string& file_path, } app_mngr.ManageHMICommand(message); } - void MessageHelper::SendGetUserFriendlyMessageResponse( const std::vector& msg, - uint32_t correlation_id, + const uint32_t correlation_id, ApplicationManager& app_mngr) { LOG4CXX_AUTO_TRACE(logger_); smart_objects::SmartObjectSPtr message = - utils::MakeShared( - smart_objects::SmartType_Map); + new smart_objects::SmartObject(smart_objects::SmartType_Map); + if (!message) { + return; + } (*message)[strings::params][strings::function_id] = hmi_apis::FunctionID::SDL_GetUserFriendlyMessage; @@ -1524,9 +1544,14 @@ void MessageHelper::SendGetUserFriendlyMessageResponse( smart_objects::SmartObject& user_friendly_messages = (*message)[strings::msg_params][messages]; - +#ifdef EXTENDED_PROPRIETARY + const std::string tts = "ttsString"; + const std::string label = "label"; + const std::string line1 = "line1"; + const std::string line2 = "line2"; + const std::string textBody = "textBody"; +#endif // EXTENDED_PROPRIETARY const std::string message_code = "messageCode"; - std::vector::const_iterator it = msg.begin(); std::vector::const_iterator it_end = msg.end(); for (uint32_t index = 0; it != it_end; ++it, ++index) { @@ -1535,6 +1560,23 @@ void MessageHelper::SendGetUserFriendlyMessageResponse( smart_objects::SmartObject& obj = user_friendly_messages[index]; obj[message_code] = it->message_code; +#ifdef EXTENDED_PROPRIETARY + if (!it->tts.empty()) { + obj[tts] = it->tts; + } + if (!it->label.empty()) { + obj[label] = it->label; + } + if (!it->line1.empty()) { + obj[line1] = it->line1; + } + if (!it->line2.empty()) { + obj[line2] = it->line2; + } + if (!it->text_body.empty()) { + obj[textBody] = it->text_body; + } +#endif // EXTENDED_PROPRIETARY } app_mngr.ManageHMICommand(message); diff --git a/src/components/application_manager/src/policies/policy_handler.cc b/src/components/application_manager/src/policies/policy_handler.cc index 23f5227667..5be928fc5d 100644 --- a/src/components/application_manager/src/policies/policy_handler.cc +++ b/src/components/application_manager/src/policies/policy_handler.cc @@ -296,6 +296,10 @@ PolicyHandler::PolicyHandler(const PolicySettings& settings, PolicyHandler::~PolicyHandler() {} +bool PolicyHandler::PolicyEnabled() const { + return get_settings().enable_policy(); +} + bool PolicyHandler::LoadPolicyLibrary() { LOG4CXX_AUTO_TRACE(logger_); sync_primitives::AutoWriteLock lock(policy_manager_lock_); @@ -304,11 +308,11 @@ bool PolicyHandler::LoadPolicyLibrary() { "System is configured to work without policy " "functionality."); policy_manager_.reset(); - return NULL; + return false; } dl_handle_ = dlopen(kLibrary.c_str(), RTLD_LAZY); - char* error = dlerror(); + const char* error = dlerror(); if (!error) { if (CreateManager()) { policy_manager_->set_listener(this); @@ -323,10 +327,6 @@ bool PolicyHandler::LoadPolicyLibrary() { return policy_manager_.valid(); } -bool PolicyHandler::PolicyEnabled() const { - return get_settings().enable_policy(); -} - bool PolicyHandler::CreateManager() { typedef PolicyManager* (*CreateManager)(); typedef void (*DeleteManager)(PolicyManager*); @@ -355,7 +355,7 @@ bool PolicyHandler::InitPolicyTable() { // info necessary for policy table event_observer_->subscribe_on_event( hmi_apis::FunctionID::BasicCommunication_OnReady); - const std::string& preloaded_file = get_settings().preloaded_pt_file(); + std::string preloaded_file = get_settings().preloaded_pt_file(); if (file_system::FileExists(preloaded_file)) { return policy_manager_->InitPT(preloaded_file, &get_settings()); } @@ -366,7 +366,7 @@ bool PolicyHandler::InitPolicyTable() { bool PolicyHandler::ResetPolicyTable() { LOG4CXX_TRACE(logger_, "Reset policy table."); POLICY_LIB_CHECK(false); - const std::string& preloaded_file = get_settings().preloaded_pt_file(); + std::string preloaded_file = get_settings().preloaded_pt_file(); if (file_system::FileExists(preloaded_file)) { return policy_manager_->ResetPT(preloaded_file); } @@ -601,13 +601,15 @@ void PolicyHandler::OnGetListOfPermissions(const uint32_t connection_key, if (!connection_key) { sync_primitives::AutoLock lock(app_to_device_link_lock_); LinkAppToDevice linker(app_to_device_link_, application_manager_); - const ApplicationSet& accessor = - application_manager_.applications().GetData(); - ApplicationSetConstIt it_app = accessor.begin(); - ApplicationSetConstIt it_app_end = accessor.end(); - - // Add all currently registered applications - std::for_each(it_app, it_app_end, linker); + { + const ApplicationSet& accessor = + application_manager_.applications().GetData(); + ApplicationSetConstIt it_app = accessor.begin(); + ApplicationSetConstIt it_app_end = accessor.end(); + + // Add all currently registered applications + std::for_each(it_app, it_app_end, linker); + } PermissionsConsolidator consolidator; std::vector group_permissions; @@ -728,6 +730,21 @@ void PolicyHandler::OnVIIsReady() { void PolicyHandler::OnVehicleDataUpdated( const smart_objects::SmartObject& message) { POLICY_LIB_CHECK_VOID(); +#ifdef EXTENDED_PROPRIETARY + if (!message.keyExists(strings::msg_params)) { + LOG4CXX_ERROR(logger_, + "Message does not contains mandatory section " + << strings::msg_params); + return; + } + if (message[strings::msg_params].keyExists(strings::vin)) { + policy_manager_->SetVINValue( + message[strings::msg_params][strings::vin].asString()); + } +#else + LOG4CXX_DEBUG(logger_, + "This functionality is not available for not premium policy"); +#endif } void PolicyHandler::OnPendingPermissionChange( @@ -897,6 +914,45 @@ bool PolicyHandler::UnloadPolicyLibrary() { return ret; } +#ifdef EXTENDED_PROPRIETARY +struct SDLAlowedNotification { + SDLAlowedNotification(const connection_handler::DeviceHandle& device_id, + PolicyManager* policy_manager, + StateController& state_controller) + : device_id_(device_id) + , policy_manager_(policy_manager) + , state_controller_(state_controller) {} + + void operator()(const ApplicationSharedPtr& app) { + if (!policy_manager_) { + return; + } + if (device_id_ == app->device()) { + std::string hmi_level; + mobile_apis::HMILevel::eType default_mobile_hmi; + policy_manager_->GetDefaultHmi(app->policy_app_id(), &hmi_level); + if ("BACKGROUND" == hmi_level) { + default_mobile_hmi = mobile_apis::HMILevel::HMI_BACKGROUND; + } else if ("FULL" == hmi_level) { + default_mobile_hmi = mobile_apis::HMILevel::HMI_FULL; + } else if ("LIMITED" == hmi_level) { + default_mobile_hmi = mobile_apis::HMILevel::HMI_LIMITED; + } else if ("NONE" == hmi_level) { + default_mobile_hmi = mobile_apis::HMILevel::HMI_NONE; + } else { + return; + } + state_controller_.SetRegularState(app, default_mobile_hmi, true); + } + } + + private: + connection_handler::DeviceHandle device_id_; + PolicyManager* policy_manager_; + StateController& state_controller_; +}; +#endif // EXTENDED_PROPRIETARY + void PolicyHandler::OnAllowSDLFunctionalityNotification( bool is_allowed, const std::string& device_mac) { LOG4CXX_AUTO_TRACE(logger_); @@ -929,11 +985,28 @@ void PolicyHandler::OnAllowSDLFunctionalityNotification( LOG4CXX_WARN(logger_, "Device hadle with mac " << device_mac << " wasn't found."); } +#ifdef EXTENDED_PROPRIETARY + DataAccessor accessor = application_manager_.applications(); + if (!is_allowed) { + std::for_each( + accessor.GetData().begin(), + accessor.GetData().end(), + DeactivateApplication(device_handle, + application_manager_.state_controller())); + } else { + std::for_each( + accessor.GetData().begin(), + accessor.GetData().end(), + SDLAlowedNotification(device_handle, + policy_manager_.get(), + application_manager_.state_controller())); + } +#endif // EXTENDED_PROPRIETARY } // Case, when specific device was changed if (device_specific) { - uint32_t device_handle = 0; + uint32_t device_handle = 0u; if (!connection_handler.GetDeviceID(device_mac, &device_handle)) { LOG4CXX_WARN(logger_, "Device hadle with mac " << device_mac << " wasn't found."); @@ -948,6 +1021,31 @@ void PolicyHandler::OnAllowSDLFunctionalityNotification( pending_device_handles_.erase(it); } +#ifdef EXTENDED_PROPRIETARY + if (is_allowed && last_activated_app_id_) { + ApplicationSharedPtr app = + application_manager_.application(last_activated_app_id_); + + if (!app) { + LOG4CXX_WARN(logger_, + "Application with id '" + << last_activated_app_id_ + << "' not found within registered applications."); + return; + } + if (app) { + // Send HMI status notification to mobile + // Put application in full + AudioStreamingState::eType state = app->is_audio() + ? AudioStreamingState::AUDIBLE + : AudioStreamingState::NOT_AUDIBLE; + + application_manager_.state_controller().SetRegularState( + app, mobile_apis::HMILevel::HMI_FULL, state, true); + last_activated_app_id_ = 0; + } + } +#endif // EXTENDED_PROPRIETARY } void PolicyHandler::OnIgnitionCycleOver() { @@ -977,8 +1075,44 @@ void PolicyHandler::OnActivateApp(uint32_t connection_key, } } else { permissions = policy_manager_->GetAppPermissionsChanges(policy_app_id); +#ifdef EXTENDED_PROPRIETARY + UsageStatistics& usage = app->usage_report(); + + usage.RecordAppUserSelection(); + DeviceParams device_params = GetDeviceParams( + app->device(), + application_manager_.connection_handler().get_session_observer()); + permissions.deviceInfo = device_params; + + DeviceConsent consent = policy_manager_->GetUserConsentForDevice( + permissions.deviceInfo.device_mac_address); + permissions.isSDLAllowed = kDeviceAllowed == consent ? true : false; + + // According to the SDLAQ-CRS-2794, p.9 + // 'priority' should be ommited in case when device + // is not allowed. + if (permissions.isSDLAllowed == false) { + permissions.priority.clear(); + last_activated_app_id_ = connection_key; + } + if (permissions.appRevoked) { + usage.RecordRunAttemptsWhileRevoked(); + } + + // If isSDLAllowed is false, we should provide device params for user + // consent + if (!permissions.isSDLAllowed) { + pending_device_handles_.push_back(permissions.deviceInfo.device_handle); + } + + if (permissions.appPermissionsConsentNeeded) { + MessageHelper::SendOnAppPermissionsChangedNotification( + app->app_id(), permissions, application_manager_); + } +#else // EXTENDED_PROPRIETARY permissions.isSDLAllowed = true; +#endif // EXTENDED_PROPRIETARY policy_manager_->RemovePendingPermissionChanges(policy_app_id); } // If application is revoked it should not be activated @@ -1091,8 +1225,8 @@ void PolicyHandler::OnPermissionsUpdated(const std::string& policy_app_id, bool PolicyHandler::SaveSnapshot(const BinaryMessage& pt_string, std::string& snap_path) { const std::string& policy_snapshot_file_name = - settings_.policies_snapshot_file_name(); - const std::string& system_files_path = settings_.system_files_path(); + get_settings().policies_snapshot_file_name(); + const std::string& system_files_path = get_settings().system_files_path(); snap_path = system_files_path + '/' + policy_snapshot_file_name; bool result = false; @@ -1107,6 +1241,20 @@ bool PolicyHandler::SaveSnapshot(const BinaryMessage& pt_string, return result; } +#ifdef EXTENDED_PROPRIETARY +void PolicyHandler::OnSnapshotCreated( + const BinaryMessage& pt_string, + const std::vector& retry_delay_seconds, + int timeout_exchange) { + std::string policy_snapshot_full_path; + if (SaveSnapshot(pt_string, policy_snapshot_full_path)) { + MessageHelper::SendPolicyUpdate(policy_snapshot_full_path, + timeout_exchange, + retry_delay_seconds, + application_manager_); + } +} +#else // EXTENDED_PROPRIETARY void PolicyHandler::OnSnapshotCreated(const BinaryMessage& pt_string) { LOG4CXX_AUTO_TRACE(logger_); POLICY_LIB_CHECK_VOID(); @@ -1120,19 +1268,21 @@ void PolicyHandler::OnSnapshotCreated(const BinaryMessage& pt_string) { policy_manager_->TimeoutExchange(), policy_manager_->RetrySequenceDelaysSeconds(), application_manager_); -#else +#else // EXTENDED_POLICY + LOG4CXX_ERROR(logger_, "HTTP policy"); EndpointUrls urls; - policy_manager_->GetServiceUrls("0x07", urls); + policy_manager_->GetUpdateUrls("0x07", urls); if (urls.empty()) { LOG4CXX_ERROR(logger_, "Service URLs are empty! NOT sending PT to mobile!"); return; } SendMessageToSDK(pt_string, urls.front().url.front()); -#endif +#endif // EXTENDED_POLICY // reset update required false OnUpdateRequestSentToMobile(); } +#endif // EXTENDED_PROPRIETARY bool PolicyHandler::GetPriority(const std::string& policy_app_id, std::string* priority) const { @@ -1175,10 +1325,16 @@ bool PolicyHandler::GetInitialAppData(const std::string& application_id, application_id, nicknames, app_hmi_types); } -void PolicyHandler::GetServiceUrls(const std::string& service_type, - EndpointUrls& end_points) { +void PolicyHandler::GetUpdateUrls(const std::string& service_type, + EndpointUrls& out_end_points) { + POLICY_LIB_CHECK_VOID(); + policy_manager_->GetUpdateUrls(service_type, out_end_points); +} + +void PolicyHandler::GetUpdateUrls(const uint32_t service_type, + EndpointUrls& out_end_points) { POLICY_LIB_CHECK_VOID(); - policy_manager_->GetServiceUrls(service_type, end_points); + policy_manager_->GetUpdateUrls(service_type, out_end_points); } std::string PolicyHandler::GetLockScreenIconUrl() const { @@ -1292,7 +1448,84 @@ void PolicyHandler::OnUpdateHMIAppType( (*it)->OnUpdateHMIAppType(app_hmi_types); } } +#ifdef EXTENDED_PROPRIETARY + +void PolicyHandler::OnCertificateUpdated(const std::string& certificate_data) { + LOG4CXX_AUTO_TRACE(logger_); + if (certificate_data.empty()) { + OnEmptyCertificateArrived(); + return; + } + + const std::string file_name = + file_system::GetAbsolutePath(get_settings().app_storage_folder()) + "/" + + kCerficateFileName; + const bool is_written = file_system::Write( + file_name, + std::vector(certificate_data.begin(), certificate_data.end())); + LOG4CXX_DEBUG(logger_, + "Saving encrypted certificate data: \"" << certificate_data + << '"'); + if (!is_written) { + LOG4CXX_ERROR(logger_, + "Unable to save encrypted certificate to file " << file_name); + return; + } + LOG4CXX_DEBUG(logger_, "Saved encrypted certificate data" << file_name); + + MessageHelper::SendDecryptCertificateToHMI(file_name, application_manager_); +} + +void PolicyHandler::OnEmptyCertificateArrived() const { + LOG4CXX_DEBUG(logger_, "Empty certificate arrived"); + const std::string empty_certificate = ""; + sync_primitives::AutoLock lock(listeners_lock_); + std::for_each( + listeners_.begin(), + listeners_.end(), + std::bind2nd(std::mem_fun(&PolicyHandlerObserver::OnCertificateUpdated), + empty_certificate)); +} + +void PolicyHandler::OnCertificateDecrypted(bool is_succeeded) { + LOG4CXX_AUTO_TRACE(logger_); + POLICY_LIB_CHECK_VOID(); + + const std::string file_name = + file_system::GetAbsolutePath(get_settings().app_storage_folder()) + +"/" + + kCerficateFileName; + + LOG4CXX_DEBUG(logger_, "Loading certificate data from file " << file_name); + + utils::ScopeGuard file_deleter = + utils::MakeGuard(file_system::DeleteFile, file_name); + UNUSED(file_deleter); + if (!is_succeeded) { + LOG4CXX_ERROR(logger_, "Couldn't delete file " << file_name); + return; + } + + std::string certificate_data; + if (!file_system::ReadFile(file_name, certificate_data)) { + LOG4CXX_ERROR(logger_, + "Unable to read certificate from file " << file_name); + return; + } + LOG4CXX_DEBUG(logger_, + "Loaded decrypted certificate data: \"" << certificate_data + << '"'); + + policy_manager_->SetDecryptedCertificate(certificate_data); + + sync_primitives::AutoLock lock(listeners_lock_); + std::for_each( + listeners_.begin(), + listeners_.end(), + std::bind2nd(std::mem_fun(&PolicyHandlerObserver::OnCertificateUpdated), + certificate_data)); +} +#else // EXTENDED_PROPRIETARY void PolicyHandler::OnCertificateUpdated(const std::string& certificate_data) { LOG4CXX_AUTO_TRACE(logger_); sync_primitives::AutoLock lock(listeners_lock_); @@ -1302,6 +1535,7 @@ void PolicyHandler::OnCertificateUpdated(const std::string& certificate_data) { observer->OnCertificateUpdated(certificate_data); } } +#endif // EXTENDED_PROPRIETARY bool PolicyHandler::CanUpdate() { return 0 != GetAppIdForSending(); @@ -1312,6 +1546,17 @@ void PolicyHandler::RemoveDevice(const std::string& device_id) { POLICY_LIB_CHECK_VOID(); policy_manager_->MarkUnpairedDevice(device_id); +#ifdef EXTENDED_PROPRIETARY + connection_handler::DeviceHandle device_uid; + if (application_manager_.connection_handler().GetDeviceID(device_id, + &device_uid)) { + DataAccessor accessor = application_manager_.applications(); + std::for_each(accessor.GetData().begin(), + accessor.GetData().end(), + DeactivateApplication( + device_uid, application_manager_.state_controller())); + } +#endif // EXTENDED_PROPRIETARY } bool PolicyHandler::IsApplicationRevoked(const std::string& app_id) { @@ -1365,7 +1610,7 @@ const std::string PolicyHandler::RemoteAppsUrl() const { const std::string default_url; POLICY_LIB_CHECK(default_url); EndpointUrls endpoints; - policy_manager_->GetServiceUrls("queryAppsUrl", endpoints); + policy_manager_->GetUpdateUrls("queryAppsUrl", endpoints); if (endpoints.empty() || endpoints[0].url.empty()) { return default_url; } @@ -1373,7 +1618,7 @@ const std::string PolicyHandler::RemoteAppsUrl() const { return endpoints[0].url[0]; } -void policy::PolicyHandler::OnAppsSearchStarted() { +void PolicyHandler::OnAppsSearchStarted() { POLICY_LIB_CHECK(); policy_manager_->OnAppsSearchStarted(); } @@ -1424,6 +1669,13 @@ const VehicleInfo policy::PolicyHandler::GetVehicleInfo() const { return policy_manager_->GetVehicleInfo(); } +#ifdef EXTENDED_PROPRIETARY +const MetaInfo PolicyHandler::GetMetaInfo() const { + POLICY_LIB_CHECK(MetaInfo()); + return policy_manager_->GetMetaInfo(); +} +#endif // EXTENDED_PROPRIETARY + void PolicyHandler::Increment(usage_statistics::GlobalCounterId type) { POLICY_LIB_CHECK(); policy_manager_->Increment(type); diff --git a/src/components/application_manager/src/smart_object_keys.cc b/src/components/application_manager/src/smart_object_keys.cc index 68a3a7d424..558aecd0fd 100644 --- a/src/components/application_manager/src/smart_object_keys.cc +++ b/src/components/application_manager/src/smart_object_keys.cc @@ -346,6 +346,7 @@ const char* keyboard_layout = "keyboardLayout"; const char* limited_character_list = "limitedCharacterList"; const char* auto_complete_text = "autoCompleteText"; const char* file = "file"; +const char* file_name = "fileName"; const char* retry = "retry"; const char* service = "service"; } // namespace hmi_request @@ -406,4 +407,4 @@ const char* event_name = "eventName"; } // namespace hmi_notification -} // namespace application_manager \ No newline at end of file +} // namespace application_manager diff --git a/src/components/application_manager/test/CMakeLists.txt b/src/components/application_manager/test/CMakeLists.txt index ba5d684df8..4ce8760006 100644 --- a/src/components/application_manager/test/CMakeLists.txt +++ b/src/components/application_manager/test/CMakeLists.txt @@ -40,10 +40,11 @@ if (BUILD_TESTS) ${COMPONENTS_DIR}/utils/include/ ${COMPONENTS_DIR}/resumption/include/ ${COMPONENTS_DIR}/utils/include/ - ${COMPONENTS_DIR}/policy/include/ + ${POLICY_PATH}/include/ ${COMPONENTS_DIR}/media_manager/include/ ${COMPONENTS_DIR}/security_manager/include/ - ${COMPONENTS_DIR}/policy/test/include/ + ${POLICY_PATH}/policy/test/include/ + ${POLICY_MOCK_INCLUDE_PATH}/ ${COMPONENTS_DIR}/application_manager/test/include/ ) @@ -148,7 +149,7 @@ endif() add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/libPolicy.so COMMAND ${CMAKE_COMMAND} -E - copy ${COMPONENTS_DIR}/policy/libPolicy.so ${CMAKE_CURRENT_BINARY_DIR}) + copy ${POLICY_PATH}/libPolicy.so ${CMAKE_CURRENT_BINARY_DIR}) set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-rpath=${CMAKE_CURRENT_BINARY_DIR}") create_test("application_manager_test" "${testSources}" "${testLibraries}" ) diff --git a/src/components/application_manager/test/application_impl_test.cc b/src/components/application_manager/test/application_impl_test.cc index e88bdbfa62..54414a93de 100644 --- a/src/components/application_manager/test/application_impl_test.cc +++ b/src/components/application_manager/test/application_impl_test.cc @@ -50,7 +50,7 @@ #include "resumption/last_state.h" #include "application_manager/resumption/resume_ctrl.h" #include "application_manager/policies/mock_policy_handler_interface.h" -#include "policy/mock_statistics_manager.h" +#include "policy/usage_statistics/mock_statistics_manager.h" #include "smart_objects/smart_object.h" namespace test { diff --git a/src/components/application_manager/test/commands/command_request_impl_test.cc b/src/components/application_manager/test/commands/command_request_impl_test.cc index 28bdef4a22..2471ec1165 100644 --- a/src/components/application_manager/test/commands/command_request_impl_test.cc +++ b/src/components/application_manager/test/commands/command_request_impl_test.cc @@ -320,10 +320,10 @@ TEST_F(CommandRequestImplTest, RemoveDisallowedParameters_SUCCESS) { CommandPtr command = CreateCommand(msg); CommandParametersPermissions& permission = command->parameters_permissions(); - permission.disallowed_params.push_back(kDisallowedParam1); - permission.disallowed_params.push_back(kDisallowedParam2); - permission.allowed_params.push_back(kAllowedParam); - permission.undefined_params.push_back(kUndefinedParam); + permission.disallowed_params.insert(kDisallowedParam1); + permission.disallowed_params.insert(kDisallowedParam2); + permission.allowed_params.insert(kAllowedParam); + permission.undefined_params.insert(kUndefinedParam); command->RemoveDisallowedParameters(); @@ -445,7 +445,7 @@ TEST_F(CommandRequestImplTest, AddDisallowedParameters_SUCCESS) { CommandPtr command = CreateCommand(msg); - command->removed_parameters_permissions().disallowed_params.push_back( + command->removed_parameters_permissions().disallowed_params.insert( kDisallowedParam1); command->AddDisallowedParameters(*msg); @@ -499,7 +499,7 @@ TEST_F(CommandRequestImplTest, CommandPtr command = CreateCommand(msg); - command->removed_parameters_permissions().disallowed_params.push_back( + command->removed_parameters_permissions().disallowed_params.insert( kDisallowedParam1); MessageSharedPtr result; diff --git a/src/components/application_manager/test/commands/mobile/get_vehicle_data_request_test.cc b/src/components/application_manager/test/commands/mobile/get_vehicle_data_request_test.cc index 61f6c60b2d..a851a72f8e 100644 --- a/src/components/application_manager/test/commands/mobile/get_vehicle_data_request_test.cc +++ b/src/components/application_manager/test/commands/mobile/get_vehicle_data_request_test.cc @@ -90,7 +90,7 @@ class UnwrappedGetVehicleDataRequest : public GetVehicleDataRequest { am::ApplicationManager& application_manager) : GetVehicleDataRequest(message, application_manager) {} - std::vector& get_disallowed_params() { + policy::RPCParams& get_disallowed_params() { return removed_parameters_permissions_.disallowed_params; } @@ -176,9 +176,8 @@ TEST_F(GetVehicleDataRequestTest, EXPECT_CALL(mock_message_helper_, vehicle_data()) .WillRepeatedly(ReturnRef(kEmptyVehicleData)); - std::vector& disallowed_params = - command->get_disallowed_params(); - disallowed_params.push_back("test_param"); + policy::RPCParams& disallowed_params = command->get_disallowed_params(); + disallowed_params.insert("test_param"); MockAppPtr app(CreateMockApp()); EXPECT_CALL(app_mngr_, application(kConnectionKey)).WillOnce(Return(app)); diff --git a/src/components/application_manager/test/commands/mobile/on_system_request_notification_test.cc b/src/components/application_manager/test/commands/mobile/on_system_request_notification_test.cc index 7aab4b1b37..3548dfe445 100644 --- a/src/components/application_manager/test/commands/mobile/on_system_request_notification_test.cc +++ b/src/components/application_manager/test/commands/mobile/on_system_request_notification_test.cc @@ -100,12 +100,12 @@ TEST_F(OnSystemRequestNotificationTest, Run_ProprietaryType_SUCCESS) { EXPECT_CALL(mock_policy_handler, IsRequestTypeAllowed(_, _)) .WillOnce(Return(true)); -#ifdef EXTENDED_POLICY +#if defined(EXTENDED_POLICY) || defined(EXTENDED_PROPRIETARY) EXPECT_CALL(app_mngr_, GetPolicyHandler()) .Times(2) .WillRepeatedly(ReturnRef(mock_policy_handler)); EXPECT_CALL(mock_policy_handler, TimeoutExchange()).WillOnce(Return(5u)); -#endif +#endif // EXTENDED_POLICY || EXTENDED_PROPRIETARY EXPECT_CALL(message_helper_, PrintSmartObject(_)).WillOnce(Return(false)); EXPECT_CALL(app_mngr_, SendMessageToMobile(msg, _)); diff --git a/src/components/application_manager/test/include/application_manager/mock_application.h b/src/components/application_manager/test/include/application_manager/mock_application.h index 68f362746a..e03635605d 100644 --- a/src/components/application_manager/test/include/application_manager/mock_application.h +++ b/src/components/application_manager/test/include/application_manager/mock_application.h @@ -67,6 +67,7 @@ class MockApplication : public ::application_manager::Application { MOCK_METHOD1(set_video_streaming_allowed, void(bool state)); MOCK_CONST_METHOD0(audio_streaming_allowed, bool()); MOCK_METHOD1(set_audio_streaming_allowed, void(bool state)); + MOCK_CONST_METHOD0(is_audio, bool()); MOCK_METHOD1(StartStreaming, void(protocol_handler::ServiceType service_type)); MOCK_METHOD1(StopStreaming, void(protocol_handler::ServiceType service_type)); diff --git a/src/components/application_manager/test/include/application_manager/mock_message_helper.h b/src/components/application_manager/test/include/application_manager/mock_message_helper.h index 01320370a0..35ffd6379a 100644 --- a/src/components/application_manager/test/include/application_manager/mock_message_helper.h +++ b/src/components/application_manager/test/include/application_manager/mock_message_helper.h @@ -113,6 +113,9 @@ class MockMessageHelper { int timeout, const std::vector& retries, ApplicationManager& app_mngr)); + MOCK_METHOD2(SendDecryptCertificateToHMI, + void(const std::string& file_name, + ApplicationManager& app_mngr)); MOCK_METHOD3( SendGetListOfPermissionsResponse, void(const std::vector& permissions, diff --git a/src/components/application_manager/test/include/application_manager/policy_handler_interface_mock.h b/src/components/application_manager/test/include/application_manager/policy_handler_interface_mock.h index 6f3748e317..9f768a11a7 100644 --- a/src/components/application_manager/test/include/application_manager/policy_handler_interface_mock.h +++ b/src/components/application_manager/test/include/application_manager/policy_handler_interface_mock.h @@ -35,6 +35,7 @@ #include "application_manager/policies/policy_handler_interface.h" #include "gmock/gmock.h" + #include "policy/policy_types.h" #include "smart_objects/smart_object.h" diff --git a/src/components/application_manager/test/mock_message_helper.cc b/src/components/application_manager/test/mock_message_helper.cc index 57cfa5a26e..249207a62d 100644 --- a/src/components/application_manager/test/mock_message_helper.cc +++ b/src/components/application_manager/test/mock_message_helper.cc @@ -68,6 +68,12 @@ void MessageHelper::SendOnDataStreaming(protocol_handler::ServiceType service, service, available, app_mngr); } +void MessageHelper::SendDecryptCertificateToHMI(const std::string& file_name, + ApplicationManager& app_mngr) { + MockMessageHelper::message_helper_mock()->SendDecryptCertificateToHMI( + file_name, app_mngr); +} + smart_objects::SmartObjectSPtr GetHashUpdateNotification( const uint32_t app_id) { return MockMessageHelper::message_helper_mock()->GetHashUpdateNotification( diff --git a/src/components/application_manager/test/policy_event_observer_test.cc b/src/components/application_manager/test/policy_event_observer_test.cc index d62efab460..b13c9a03c5 100644 --- a/src/components/application_manager/test/policy_event_observer_test.cc +++ b/src/components/application_manager/test/policy_event_observer_test.cc @@ -46,7 +46,7 @@ using application_manager::event_engine::Event; using namespace policy; using testing::_; -using ::testing::Return; +namespace smart_objects = ::smart_objects; class PolicyEventObserverTest : public ::testing::Test { public: diff --git a/src/components/application_manager/test/policy_handler_test.cc b/src/components/application_manager/test/policy_handler_test.cc index 44b4791f85..bd3ef80634 100644 --- a/src/components/application_manager/test/policy_handler_test.cc +++ b/src/components/application_manager/test/policy_handler_test.cc @@ -57,6 +57,7 @@ #include "policy/usage_statistics/statistics_manager.h" #include "interfaces/MOBILE_API.h" #include "policy/mock_policy_settings.h" +#include "utils/make_shared.h" #include "application_manager/mock_application.h" #include "policy/usage_statistics/mock_statistics_manager.h" #include "protocol_handler/mock_session_observer.h" @@ -179,9 +180,11 @@ class PolicyHandlerTest : public ::testing::Test { .WillOnce(ReturnRef(kSnapshotFile_)); EXPECT_CALL(policy_settings_, system_files_path()) .WillOnce(ReturnRef(kSnapshotStorage_)); +#ifdef EXTENDED_POLICY EXPECT_CALL(*mock_policy_manager_, TimeoutExchange()).WillOnce(Return(1)); EXPECT_CALL(*mock_policy_manager_, RetrySequenceDelaysSeconds()) .WillOnce(Return(retry_sequence_delay_seconds)); +#endif // EXTENDED_POLICY EXPECT_CALL(*MockMessageHelper::message_helper_mock(), SendPolicyUpdate(_, _, _, _)); } @@ -220,6 +223,16 @@ TEST_F(PolicyHandlerTest, EXPECT_FALSE(policy_handler_.ResetPolicyTable()); } +#ifdef EXTENDED_PROPRIETARY +TEST_F(PolicyHandlerTest, ResetPolicyTable_PTNotInitialised_PTNotReset) { + // Arrange + EXPECT_CALL(app_manager_, event_dispatcher()); + EnablePolicy(); + EXPECT_TRUE(policy_handler_.LoadPolicyLibrary()); + // Check + EXPECT_FALSE(policy_handler_.ResetPolicyTable()); +} +#else TEST_F(PolicyHandlerTest, ResetPolicyTable_PTNotInitialised_PTNotReset) { // Arrange EnablePolicy(); @@ -228,6 +241,8 @@ TEST_F(PolicyHandlerTest, ResetPolicyTable_PTNotInitialised_PTNotReset) { EXPECT_TRUE(policy_handler_.ResetPolicyTable()); } +#endif + TEST_F(PolicyHandlerTest, ResetPolicyTable_WithPreloadedFile_ExpectPolicyTableReset) { // Arrange @@ -465,15 +480,15 @@ TEST_F(PolicyHandlerTest, GetInitialAppData) { policy_handler_.GetInitialAppData(kPolicyAppId_, nicknames, app_hmi_types); } -TEST_F(PolicyHandlerTest, GetServiceUrls) { +TEST_F(PolicyHandlerTest, GetUpdateUrls) { // Arrange EnablePolicyAndPolicyManagerMock(); EndpointUrls endpoints; const std::string service_type_ = "0x0"; // Check expectations - EXPECT_CALL(*mock_policy_manager_, GetServiceUrls(service_type_, _)); + EXPECT_CALL(*mock_policy_manager_, GetUpdateUrls(service_type_, _)); // Act - policy_handler_.GetServiceUrls(service_type_, endpoints); + policy_handler_.GetUpdateUrls(service_type_, endpoints); } TEST_F(PolicyHandlerTest, ResetRetrySequence) { @@ -611,7 +626,35 @@ void PolicyHandlerTest::TestActivateApp(const uint32_t connection_key, AppPermissions permissions(kPolicyAppId_); permissions.appPermissionsConsentNeeded = true; - // Check expectations +// Check expectations +#ifdef EXTENDED_PROPRIETARY + const connection_handler::DeviceHandle device_handle = 0u; + EXPECT_CALL(app_manager_, connection_handler()) + .WillRepeatedly(ReturnRef(conn_handler)); + EXPECT_CALL(conn_handler, get_session_observer()) + .WillOnce(ReturnRef(mock_session_observer)); + utils::SharedPtr + mock_statistics_manager = + utils::MakeShared(); + UsageStatistics usage_stats( + "0", + utils::SharedPtr( + mock_statistics_manager)); + EXPECT_CALL(*application1, usage_report()).WillOnce(ReturnRef(usage_stats)); + EXPECT_CALL(*mock_policy_manager_, GetUserConsentForDevice(_)) + .WillOnce(Return(DeviceConsent::kDeviceHasNoConsent)); + EXPECT_CALL(app_manager_, state_controller()) + .WillRepeatedly(ReturnRef(mock_state_controller)); + EXPECT_CALL(*mock_statistics_manager, Increment(_, _)) + .WillRepeatedly(Return()); + EXPECT_CALL(*application1, device()).WillRepeatedly(Return(device_handle)); + EXPECT_CALL(*application1, is_audio()).WillRepeatedly(Return(false)); + EXPECT_CALL(*MockMessageHelper::message_helper_mock(), + SendOnAppPermissionsChangedNotification(kAppId_, _, _)); + EXPECT_CALL(mock_session_observer, + GetDataOnDeviceID(device_handle, _, _, _, _)); +#endif // EXTENDED_PROPRIETARY + EXPECT_CALL(*application1, policy_app_id()).WillOnce(Return(kPolicyAppId_)); EXPECT_CALL(*mock_policy_manager_, GetAppPermissionsChanges(_)) .WillOnce(Return(permissions)); @@ -1218,16 +1261,61 @@ TEST_F(PolicyHandlerTest, OnSnapshotCreated_UrlNotAdded) { EnablePolicyAndPolicyManagerMock(); BinaryMessage msg; EndpointUrls test_data; -#ifdef EXTENDED_POLICY +#if defined(EXTENDED_POLICY) || defined(EXTENDED_PROPRIETARY) ExtendedPolicyExpectations(); -#else - EXPECT_CALL(*mock_policy_manager_, GetServiceUrls(_, _)) +#endif // EXTENDED_POLICY || EXTENDED_PROPRIETARY +#ifdef EXTENDED_PROPRIETARY + std::vector retry_delay_seconds; + const int timeout_exchange = 10; + // TODO(AKutsan): Policy move issues + EXPECT_CALL(*mock_policy_manager_, GetUpdateUrls("0x07", _)) .WillRepeatedly(SetArgReferee<1>(test_data)); -#endif // EXTENDED_POLICY - + policy_handler_.OnSnapshotCreated(msg, retry_delay_seconds, timeout_exchange); +#else // EXTENDED_PROPRIETARY policy_handler_.OnSnapshotCreated(msg); +#endif // EXTENDED_PROPRIETARY +} + +TEST_F(PolicyHandlerTest, + OnAllowSDLFunctionalityNotification_AllowedWithDevId_AppActivated) { + // Arrange + + EnablePolicyAndPolicyManagerMock(); + const uint32_t connection_key = 1; + const uint32_t correlation_id = 2; + TestActivateApp(connection_key, correlation_id); + + const bool is_allowed = true; + std::vector device_macs; + device_macs.push_back(kPolicyAppId_); + + // Not called because id was setted + EXPECT_CALL(conn_handler, GetConnectedDevicesMAC(_)).Times(0); + EXPECT_CALL(conn_handler, GetDeviceID(kPolicyAppId_, _)) + .WillRepeatedly(Return(true)); + + policy_handler_.OnAllowSDLFunctionalityNotification(is_allowed, + kPolicyAppId_); } +#ifdef EXTENDED_PROPRIETARY +TEST_F(PolicyHandlerTest, OnSnapshotCreated_UrlAdded) { + EnablePolicyAndPolicyManagerMock(); + BinaryMessage msg; + EndpointUrls test_data; + EndpointData data("some_data"); + std::vector retry_delay_seconds; + const int timeout_exchange = 10; + test_data.push_back(data); + ExtendedPolicyExpectations(); + + EXPECT_CALL(*MockMessageHelper::message_helper_mock(), SendPolicySnapshotNotification(_, _, _, _)); + EXPECT_CALL(app_manager_, application(kAppId_)) + .WillRepeatedly(Return(mock_app_)); + + policy_handler_.OnSnapshotCreated(msg, retry_delay_seconds, timeout_exchange); +} +#else //EXTENDED_PROPRIETARY TEST_F(PolicyHandlerTest, OnSnapshotCreated_UrlAdded) { EnablePolicyAndPolicyManagerMock(); BinaryMessage msg; @@ -1238,7 +1326,7 @@ TEST_F(PolicyHandlerTest, OnSnapshotCreated_UrlAdded) { #ifdef EXTENDED_POLICY ExtendedPolicyExpectations(); #else - EXPECT_CALL(*mock_policy_manager_, GetServiceUrls(_, _)) + EXPECT_CALL(*mock_policy_manager_, GetUpdateUrls("0x07", _)) .WillRepeatedly(SetArgReferee<1>(test_data)); EXPECT_CALL(app_manager_, connection_handler()) .WillOnce(ReturnRef(conn_handler)); @@ -1258,28 +1346,7 @@ TEST_F(PolicyHandlerTest, OnSnapshotCreated_UrlAdded) { policy_handler_.OnSnapshotCreated(msg); } - -TEST_F(PolicyHandlerTest, - OnAllowSDLFunctionalityNotification_AllowedWithDevId_AppActivated) { - // Arrange - - EnablePolicyAndPolicyManagerMock(); - const uint32_t connection_key = 1; - const uint32_t correlation_id = 2; - TestActivateApp(connection_key, correlation_id); - - const bool is_allowed = true; - std::vector device_macs; - device_macs.push_back(kPolicyAppId_); - - // Not called because id was setted - EXPECT_CALL(conn_handler, GetConnectedDevicesMAC(_)).Times(0); - EXPECT_CALL(conn_handler, GetDeviceID(kPolicyAppId_, _)) - .WillRepeatedly(Return(true)); - - policy_handler_.OnAllowSDLFunctionalityNotification(is_allowed, - kPolicyAppId_); -} +#endif // EXTENDED_PROPRIETARY TEST_F(PolicyHandlerTest, OnAllowSDLFunctionalityNotification_Allowed_WithoutDevId_AppActivated) { @@ -1385,14 +1452,32 @@ TEST_F(PolicyHandlerTest, OnDeviceConsentChanged_PredatePolicyNotAllowed) { policy_handler_.OnDeviceConsentChanged(kPolicyAppId_, is_allowed); } +#ifdef EXTENDED_PROPRIETARY +TEST_F(PolicyHandlerTest, OnCertificateUpdated) { + const std::string app_storage = "storage"; + file_system::CreateFile("storage/certificate"); + EXPECT_CALL(policy_settings_, app_storage_folder()) + .WillOnce(ReturnRef(app_storage)); + std::string cert_data = "data"; + + const std::string full_file_name = + file_system::GetAbsolutePath(app_storage) + "/certificate"; + EXPECT_CALL(*MockMessageHelper::message_helper_mock(), + SendDecryptCertificateToHMI(full_file_name, _)); + policy_handler_.OnCertificateUpdated(cert_data); +} +#else TEST_F(PolicyHandlerTest, OnCertificateUpdated) { application_manager_test::MockPolicyHandlerObserver policy_handler_observer; policy_handler_.add_listener(&policy_handler_observer); std::string cert_data = "data"; + EnablePolicy(); + EXPECT_CALL(policy_handler_observer, OnCertificateUpdated(cert_data)); policy_handler_.OnCertificateUpdated(cert_data); } +#endif TEST_F(PolicyHandlerTest, GetAppIdForSending_WithoutApps) { // Arrange diff --git a/src/components/application_manager/test/state_controller/CMakeLists.txt b/src/components/application_manager/test/state_controller/CMakeLists.txt index 50dd931309..0b8addcc6a 100644 --- a/src/components/application_manager/test/state_controller/CMakeLists.txt +++ b/src/components/application_manager/test/state_controller/CMakeLists.txt @@ -33,6 +33,7 @@ if(BUILD_TESTS) include_directories( ${GMOCK_INCLUDE_DIRECTORY} ${COMPONENTS_DIR}/application_manager/test/include + ${POLICY_MOCK_INCLUDE_PATH} ) set(LIBRARIES diff --git a/src/components/application_manager/test/usage_statistics_test.cc b/src/components/application_manager/test/usage_statistics_test.cc index b5d1da0992..6efef83052 100644 --- a/src/components/application_manager/test/usage_statistics_test.cc +++ b/src/components/application_manager/test/usage_statistics_test.cc @@ -34,8 +34,8 @@ #include #include "gmock/gmock.h" #include "smart_objects/enum_schema_item.h" -#include "policy/mock_statistics_manager.h" -#include "mock_app_stopwatch.h" +#include "policy/usage_statistics/mock_statistics_manager.h" +#include "policy/usage_statistics/mock_app_stopwatch.h" #include "utils/make_shared.h" #include "utils/shared_ptr.h" diff --git a/src/components/config_profile/CMakeLists.txt b/src/components/config_profile/CMakeLists.txt index 107fd58127..e441375336 100644 --- a/src/components/config_profile/CMakeLists.txt +++ b/src/components/config_profile/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2014, Ford Motor Company +# Copyright (c) 2016, Ford Motor Company # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -32,6 +32,7 @@ include_directories ( include ${COMPONENTS_DIR}/utils/include/ + ${POLICY_GLOBAL_INCLUDE_PATH}/ ${LOG4CXX_INCLUDE_DIRECTORY} ) diff --git a/src/components/include/application_manager/policies/policy_handler_interface.h b/src/components/include/application_manager/policies/policy_handler_interface.h index cf93f78405..0bfdf73e4b 100644 --- a/src/components/include/application_manager/policies/policy_handler_interface.h +++ b/src/components/include/application_manager/policies/policy_handler_interface.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Ford Motor Company + * Copyright (c) 2016, Ford Motor Company * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -68,6 +68,14 @@ class PolicyHandlerInterface { virtual void OnPermissionsUpdated(const std::string& policy_app_id, const Permissions& permissions) = 0; +#ifdef EXTENDED_PROPRIETARY + virtual void OnSnapshotCreated(const BinaryMessage& pt_string, + const std::vector& retry_delay_seconds, + int timeout_exchange) = 0; +#else // EXTENDED_PROPRIETARY + virtual void OnSnapshotCreated(const BinaryMessage& pt_string) = 0; +#endif // EXTENDED_PROPRIETARY + virtual bool GetPriority(const std::string& policy_app_id, std::string* priority) const = 0; virtual void CheckPermissions(const PTString& app_id, @@ -75,7 +83,6 @@ class PolicyHandlerInterface { const PTString& rpc, const RPCParams& rpc_params, CheckPermissionResult& result) = 0; - virtual uint32_t GetNotificationsNumber( const std::string& priority) const = 0; virtual DeviceConsent GetUserConsentForDevice( @@ -85,8 +92,10 @@ class PolicyHandlerInterface { virtual bool GetInitialAppData(const std::string& application_id, StringArray* nicknames = NULL, StringArray* app_hmi_types = NULL) = 0; - virtual void GetServiceUrls(const std::string& service_type, - EndpointUrls& end_points) = 0; + virtual void GetUpdateUrls(const std::string& service_type, + EndpointUrls& out_end_points) = 0; + virtual void GetUpdateUrls(const uint32_t service_type, + EndpointUrls& out_end_points) = 0; virtual std::string GetLockScreenIconUrl() const = 0; virtual void ResetRetrySequence() = 0; virtual uint32_t NextRetryTimeout() = 0; @@ -134,7 +143,7 @@ class PolicyHandlerInterface { * @param User consent from response */ virtual void OnAllowSDLFunctionalityNotification( - bool is_allowed, const std::string& device_id) = 0; + bool is_allowed, const std::string& device_mac) = 0; /** * @brief Increment counter for ignition cycles @@ -280,7 +289,9 @@ class PolicyHandlerInterface { std::map app_hmi_types) = 0; virtual void OnCertificateUpdated(const std::string& certificate_data) = 0; - +#ifdef EXTENDED_PROPRIETARY + virtual void OnCertificateDecrypted(bool is_succeeded) = 0; +#endif // EXTENDED_PROPRIETARY virtual bool CanUpdate() = 0; virtual void OnDeviceConsentChanged(const std::string& device_id, @@ -359,7 +370,13 @@ class PolicyHandlerInterface { * @return Structure with vehicle information */ virtual const VehicleInfo GetVehicleInfo() const = 0; - +#ifdef EXTENDED_PROPRIETARY + /** + * @brief Gets meta information + * @return meta information + */ + virtual const policy::MetaInfo GetMetaInfo() const = 0; +#endif // EXTENDED_PROPRIETARY virtual void Increment(usage_statistics::GlobalCounterId type) = 0; virtual void Increment(const std::string& app_id, usage_statistics::AppCounterId type) = 0; diff --git a/src/components/include/application_manager/policies/policy_handler_observer.h b/src/components/include/application_manager/policies/policy_handler_observer.h new file mode 100644 index 0000000000..6c0ff758bb --- /dev/null +++ b/src/components/include/application_manager/policies/policy_handler_observer.h @@ -0,0 +1,53 @@ +/* + Copyright (c) 2015, 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 SRC_COMPONENTS_INCLUDE_APPLICATION_MANAGER_POLICIES_POLICY_HANDLER_OBSERVER_H_ +#define SRC_COMPONENTS_INCLUDE_APPLICATION_MANAGER_POLICIES_POLICY_HANDLER_OBSERVER_H_ + +#include +#include +#include + +namespace policy { + +class PolicyHandlerObserver { + public: + virtual void OnUpdateHMIAppType( + std::map > app_hmi_types) {} + virtual bool OnCertificateUpdated(const std::string& certificate_data) { + return false; + } + virtual ~PolicyHandlerObserver() {} +}; +} // namespace policy + +#endif // SRC_COMPONENTS_INCLUDE_APPLICATION_MANAGER_POLICIES_POLICY_HANDLER_OBSERVER_H_ diff --git a/src/components/include/test/application_manager/policies/mock_policy_handler_interface.h b/src/components/include/test/application_manager/policies/mock_policy_handler_interface.h index 3c878daf7c..199544e5f7 100644 --- a/src/components/include/test/application_manager/policies/mock_policy_handler_interface.h +++ b/src/components/include/test/application_manager/policies/mock_policy_handler_interface.h @@ -63,10 +63,16 @@ class MockPolicyHandlerInterface : public policy::PolicyHandlerInterface { MOCK_METHOD2(OnPermissionsUpdated, void(const std::string& policy_app_id, const policy::Permissions& permissions)); + +#ifdef EXTENDED_PROPRIETARY MOCK_METHOD3(OnSnapshotCreated, void(const policy::BinaryMessage& pt_string, const std::vector& retry_delay_seconds, int timeout_exchange)); +#else // EXTENDED_PROPRIETARY + MOCK_METHOD1(OnSnapshotCreated, void(const policy::BinaryMessage& pt_string)); +#endif // EXTENDED_PROPRIETARY + MOCK_CONST_METHOD2(GetPriority, bool(const std::string& policy_app_id, std::string* priority)); @@ -93,7 +99,8 @@ class MockPolicyHandlerInterface : public policy::PolicyHandlerInterface { policy::StringArray* nicknames)); MOCK_METHOD1(GetInitialAppData, bool(const std::string& application_id)); MOCK_METHOD2(GetUpdateUrls, - void(int service_type, policy::EndpointUrls& end_points)); + void(const uint32_t service_type, + policy::EndpointUrls& end_points)); MOCK_CONST_METHOD0(GetLockScreenIconUrl, std::string()); MOCK_METHOD0(ResetRetrySequence, void()); MOCK_METHOD0(NextRetryTimeout, uint32_t()); @@ -180,6 +187,11 @@ class MockPolicyHandlerInterface : public policy::PolicyHandlerInterface { GetAppRequestTypes, const std::vector(const std::string& policy_app_id)); MOCK_CONST_METHOD0(GetVehicleInfo, const policy::VehicleInfo()); + +#ifdef EXTENDED_PROPRIETARY + MOCK_CONST_METHOD0(GetMetaInfo, const policy::MetaInfo()); +#endif // EXTENDED_PROPRIETARY + MOCK_METHOD1(Increment, void(usage_statistics::GlobalCounterId type)); MOCK_METHOD2(Increment, void(const std::string& app_id, @@ -192,10 +204,12 @@ class MockPolicyHandlerInterface : public policy::PolicyHandlerInterface { void(const std::string& app_id, usage_statistics::AppStopwatchId type, int32_t timespan_seconds)); +#ifdef ENABLE_SECURITY MOCK_CONST_METHOD0(RetrieveCertificate, std::string()); +#endif // ENABLE_SECURITY MOCK_CONST_METHOD0(get_settings, const policy::PolicySettings&()); MOCK_CONST_METHOD0(RemoteAppsUrl, const std::string()); - MOCK_METHOD2(GetServiceUrls, + MOCK_METHOD2(GetUpdateUrls, void(const std::string& service_type, policy::EndpointUrls& end_points)); diff --git a/src/components/media_manager/CMakeLists.txt b/src/components/media_manager/CMakeLists.txt index 3ca02357ab..46146855bb 100644 --- a/src/components/media_manager/CMakeLists.txt +++ b/src/components/media_manager/CMakeLists.txt @@ -98,7 +98,8 @@ include_directories ( ${COMPONENTS_DIR}/config_profile/include/ ${JSONCPP_INCLUDE_DIRECTORY} ${CMAKE_BINARY_DIR}/src/components/ - ${COMPONENTS_DIR}/policy/include/ + ${POLICY_PATH}/include/ + ${POLICY_GLOBAL_INCLUDE_PATH}/ ${default_includes} ${LOG4CXX_INCLUDE_DIRECTORY} ) diff --git a/src/components/rpc_base/include/rpc_base/rpc_base.h b/src/components/rpc_base/include/rpc_base/rpc_base.h index 883c2ec4bf..4b9b432d9a 100644 --- a/src/components/rpc_base/include/rpc_base/rpc_base.h +++ b/src/components/rpc_base/include/rpc_base/rpc_base.h @@ -300,7 +300,7 @@ class Array : public std::vector, public CompositeType { Json::Value ToJsonValue() const; void ToDbusWriter(dbus::MessageWriter* writer) const; - bool is_valid() const; + virtual bool is_valid() const; bool is_initialized() const; void ReportErrors(ValidationReport* report) const; virtual void SetPolicyTableType( diff --git a/src/components/telemetry_monitor/CMakeLists.txt b/src/components/telemetry_monitor/CMakeLists.txt index f3004dc61e..354badb41a 100644 --- a/src/components/telemetry_monitor/CMakeLists.txt +++ b/src/components/telemetry_monitor/CMakeLists.txt @@ -33,12 +33,14 @@ set(TELEMETRY_MONITOR_SRC_DIR ${COMPONENTS_DIR}/telemetry_monitor/src) include_directories ( include + ${COMPONENTS_DIR}/include/application_manager/ ${COMPONENTS_DIR}/utils/include/ ${COMPONENTS_DIR}/protocol_handler/include/ ${COMPONENTS_DIR}/connection_handler/include/ ${COMPONENTS_DIR}/transport_manager/include/ ${COMPONENTS_DIR}/application_manager/include/ - ${COMPONENTS_DIR}/policy/include/ + ${POLICY_PATH}/include/ + ${POLICY_GLOBAL_INCLUDE_PATH}/ ${COMPONENTS_DIR}/hmi_message_handler/include/ ${COMPONENTS_DIR}/formatters/include/ ${COMPONENTS_DIR}/media_manager/include/ diff --git a/src/components/transport_manager/CMakeLists.txt b/src/components/transport_manager/CMakeLists.txt index fbe6018d6a..49a3702896 100644 --- a/src/components/transport_manager/CMakeLists.txt +++ b/src/components/transport_manager/CMakeLists.txt @@ -38,6 +38,7 @@ include_directories ( ${COMPONENTS_DIR}/connection_handler/include ${COMPONENTS_DIR}/config_profile/include ${COMPONENTS_DIR}/resumption/include + ${POLICY_GLOBAL_INCLUDE_PATH}/ ${JSONCPP_INCLUDE_DIRECTORY} ${LIBUSB_INCLUDE_DIRECTORY} ${LOG4CXX_INCLUDE_DIRECTORY} diff --git a/src/components/utils/src/sqlite_wrapper/sql_database.cc b/src/components/utils/src/sqlite_wrapper/sql_database.cc index 8c9563ca71..ced9339b23 100644 --- a/src/components/utils/src/sqlite_wrapper/sql_database.cc +++ b/src/components/utils/src/sqlite_wrapper/sql_database.cc @@ -54,6 +54,9 @@ bool SQLDatabase::Open() { if (conn_) return true; error_ = sqlite3_open(get_path().c_str(), &conn_); + if (error_ != SQLITE_OK) { + conn_ = NULL; + } return error_ == SQLITE_OK; } diff --git a/src/components/utils/test/CMakeLists.txt b/src/components/utils/test/CMakeLists.txt index 6ec12a17e6..e457e5901e 100644 --- a/src/components/utils/test/CMakeLists.txt +++ b/src/components/utils/test/CMakeLists.txt @@ -36,7 +36,7 @@ include_directories ( ${COMPONENTS_DIR}/utils/include ${COMPONENTS_DIR}/rpc_base/include ${COMPONENTS_DIR}/utils/test/include - ${COMPONENTS_DIR}/policy/include + ${POLICY_PATH}/include ) set(testSources -- cgit v1.2.1