From 313ef52c229346ebc70a4fe41ff12d6639cb78c0 Mon Sep 17 00:00:00 2001 From: Justin Dickow Date: Tue, 15 Jul 2014 11:38:41 -0400 Subject: [PATCH] Components ApplicationManager changes Signed-off-by: Justin Dickow --- src/components/application_manager/CMakeLists.txt | 11 +- .../include/application_manager/application.h | 8 +- .../include/application_manager/application_impl.h | 66 +-- .../application_manager/application_manager_impl.h | 74 ++- .../application_manager/commands/command_impl.h | 11 +- .../commands/hmi/get_urls.h~HEAD | 70 +++ .../commands/hmi/get_urls.h~develop | 70 +++ .../hmi/on_device_state_changed_notification.h | 72 +++ .../hmi/on_resume_audio_source_notification.h | 74 +++ .../commands/hmi/on_update_device_list.h | 6 +- .../commands/hmi/request_from_hmi.h | 2 +- .../commands/hmi/update_app_list_request.h | 7 +- .../commands/hmi/update_app_list_response.h | 6 +- .../commands/mobile/alert_maneuver_request.h | 1 - .../commands/mobile/perform_interaction_request.h | 9 - .../commands/mobile/scrollable_message_request.h | 3 - .../commands/mobile/show_constant_tbt_request.h | 3 - .../commands/mobile/show_request.h | 3 - .../commands/mobile/update_turn_list_request.h | 3 - .../include/application_manager/hmi_capabilities.h | 29 +- .../application_manager/hmi_command_factory.h | 4 - .../include/application_manager/message_helper.h | 39 +- .../application_manager/mobile_message_handler.h | 5 - .../policies/policy_event_observer.h | 5 +- .../application_manager/policies/policy_handler.h | 28 +- .../policies/pt_exchange_handler_ext.h | 1 - .../policies/pt_exchange_handler_impl.h | 1 - .../include/application_manager/resume_ctrl.h | 121 +++-- .../application_manager/smart_object_keys.h | 10 +- .../application_manager/time_metric_observer.h | 59 +++ .../application_manager/src/application_impl.cc | 45 +- .../src/application_manager_impl.cc | 358 ++++++++------ .../src/commands/command_impl.cc | 7 +- .../src/commands/hmi/get_urls.cc | 2 +- .../src/commands/hmi/notification_from_hmi.cc | 3 + .../src/commands/hmi/notification_to_hmi.cc | 3 + .../hmi/on_app_permission_consent_notification.cc | 30 +- .../hmi/on_device_state_changed_notification.cc | 70 +++ .../hmi/on_exit_application_notification.cc | 1 + .../src/commands/hmi/on_received_policy_update.cc | 2 +- .../hmi/on_resume_audio_source_notification.cc | 56 +++ .../commands/hmi/on_system_context_notification.cc | 17 + .../src/commands/hmi/on_update_device_list.cc | 1 + .../src/commands/hmi/request_from_hmi.cc | 4 + .../src/commands/hmi/request_to_hmi.cc | 2 + .../src/commands/hmi/response_from_hmi.cc | 3 + .../src/commands/hmi/response_to_hmi.cc | 2 + .../hmi/sdl_policy_update_response.cc~HEAD | 51 ++ .../hmi/sdl_policy_update_response.cc~develop | 51 ++ .../src/commands/hmi/update_app_list_request.cc | 1 + .../src/commands/hmi/update_app_list_response.cc | 2 + .../hmi/vr_perform_interaction_response.cc~HEAD | 56 +++ .../hmi/vr_perform_interaction_response.cc~develop | 56 +++ .../src/commands/mobile/add_command_request.cc | 27 +- .../src/commands/mobile/alert_maneuver_request.cc | 44 +- .../src/commands/mobile/alert_request.cc | 29 +- .../create_interaction_choice_set_request.cc | 38 +- .../src/commands/mobile/delete_file_request.cc | 9 +- .../commands/mobile/encoded_sync_pdata_request.cc | 6 +- .../commands/mobile/encoded_sync_pdata_response.cc | 3 - .../on_app_interface_unregistered_notification.cc | 3 - .../mobile/on_audio_pass_thru_notification.cc | 3 - .../commands/mobile/on_hash_change_notification.cc | 1 + .../commands/mobile/on_hmi_status_notification.cc | 1 - .../mobile/perform_audio_pass_thru_request.cc | 10 + .../commands/mobile/perform_interaction_request.cc | 87 ++-- .../src/commands/mobile/put_file_request.cc | 4 +- .../mobile/register_app_interface_request.cc | 110 ++--- .../commands/mobile/scrollable_message_request.cc | 31 +- .../mobile/set_global_properties_request.cc | 38 +- .../src/commands/mobile/set_icon_request.cc | 4 +- .../commands/mobile/show_constant_tbt_request.cc | 64 +-- .../src/commands/mobile/show_request.cc | 49 +- .../src/commands/mobile/sync_pdata_request.cc | 10 +- .../src/commands/mobile/system_request.cc | 2 +- .../commands/mobile/update_turn_list_request.cc | 54 +-- .../application_manager/src/hmi_capabilities.cc | 523 ++++++++++++--------- .../application_manager/src/hmi_command_factory.cc | 20 +- .../application_manager/src/message_helper.cc | 501 ++++++++++---------- .../src/mobile_message_handler.cc | 7 +- .../src/policies/policy_event_observer.cc | 49 +- .../src/policies/policy_handler.cc | 338 ++++++++++--- .../src/policies/pt_exchange_handler_ext.cc | 14 +- .../src/policies/pt_exchange_handler_impl.cc | 4 +- .../application_manager/src/request_controller.cc | 3 +- .../application_manager/src/resume_ctrl.cpp | 133 ++++-- 86 files changed, 2557 insertions(+), 1286 deletions(-) create mode 100644 src/components/application_manager/include/application_manager/commands/hmi/get_urls.h~HEAD create mode 100644 src/components/application_manager/include/application_manager/commands/hmi/get_urls.h~develop create mode 100644 src/components/application_manager/include/application_manager/commands/hmi/on_device_state_changed_notification.h create mode 100644 src/components/application_manager/include/application_manager/commands/hmi/on_resume_audio_source_notification.h create mode 100644 src/components/application_manager/include/application_manager/time_metric_observer.h create mode 100644 src/components/application_manager/src/commands/hmi/on_device_state_changed_notification.cc create mode 100644 src/components/application_manager/src/commands/hmi/on_resume_audio_source_notification.cc create mode 100644 src/components/application_manager/src/commands/hmi/sdl_policy_update_response.cc~HEAD create mode 100644 src/components/application_manager/src/commands/hmi/sdl_policy_update_response.cc~develop create mode 100644 src/components/application_manager/src/commands/hmi/vr_perform_interaction_response.cc~HEAD create mode 100644 src/components/application_manager/src/commands/hmi/vr_perform_interaction_response.cc~develop diff --git a/src/components/application_manager/CMakeLists.txt b/src/components/application_manager/CMakeLists.txt index 09c1f4a..ea98188 100644 --- a/src/components/application_manager/CMakeLists.txt +++ b/src/components/application_manager/CMakeLists.txt @@ -305,7 +305,6 @@ set (HMI_COMMANDS_SOURCES ./src/commands/hmi/on_ready_notification.cc ./src/commands/hmi/on_system_context_notification.cc ./src/commands/hmi/on_device_chosen_notification.cc -./src/commands/hmi/on_update_device_list.cc ./src/commands/hmi/on_allow_sdl_functionality_notification.cc ./src/commands/hmi/on_app_permission_consent_notification.cc ./src/commands/hmi/on_app_registered_notification.cc @@ -329,7 +328,6 @@ set (HMI_COMMANDS_SOURCES ./src/commands/hmi/on_ui_language_change_notification.cc ./src/commands/hmi/on_button_event_notification.cc ./src/commands/hmi/on_button_press_notification.cc -./src/commands/hmi/on_show_notification.cc ./src/commands/hmi/on_find_applications.cc ./src/commands/hmi/on_ui_keyboard_input_notification.cc ./src/commands/hmi/on_ui_touch_event_notification.cc @@ -344,6 +342,7 @@ set (HMI_COMMANDS_SOURCES ./src/commands/hmi/audio_stop_stream_response.cc ./src/commands/hmi/on_system_request_notification.cc ./src/commands/hmi/on_put_file_notification.cc +./src/commands/hmi/on_resume_audio_source_notification.cc ./src/commands/hmi/on_sdl_close_notification.cc ./src/commands/hmi/ui_set_display_layout_request.cc ./src/commands/hmi/ui_set_display_layout_response.cc @@ -358,6 +357,7 @@ set (HMI_COMMANDS_SOURCES ./src/commands/hmi/on_policy_update.cc ./src/commands/hmi/get_urls.cc ./src/commands/hmi/get_urls_response.cc +./src/commands/hmi/on_device_state_changed_notification.cc ) set (HMI_COMMANDS_SOURCES_JSON @@ -403,7 +403,6 @@ endif (${HMI_DBUS_API}) SET (LIBRARIES UsageStatistics - log4cxx dl ) @@ -412,4 +411,8 @@ IF(${CMAKE_SYSTEM_NAME} MATCHES "QNX") endif() add_library("ApplicationManager" ${SOURCES} ${MOBILE_COMMANDS_SOURCES} ${HMI_COMMANDS_SOURCES} ${POLICIES_MANAGER} ${EVENT_ENGINE}) -target_link_libraries ("ApplicationManager" ${LIBRARIES}) +target_link_libraries("ApplicationManager" ${LIBRARIES}) + +if(ENABLE_LOG) + target_link_libraries("ApplicationManager" log4cxx) +endif() diff --git a/src/components/application_manager/include/application_manager/application.h b/src/components/application_manager/include/application_manager/application.h index 75ef228..99795ad 100644 --- a/src/components/application_manager/include/application_manager/application.h +++ b/src/components/application_manager/include/application_manager/application.h @@ -390,8 +390,11 @@ class Application : public virtual InitialApplicationData, virtual bool has_been_activated() const = 0; virtual const Version& version() const = 0; + virtual void set_hmi_application_id(uint32_t hmi_app_id) = 0; + virtual uint32_t hmi_app_id() const = 0; virtual uint32_t app_id() const = 0; virtual const std::string& name() const = 0; + virtual const std::string folder_name() const = 0; virtual bool is_media_application() const = 0; virtual const mobile_api::HMILevel::eType& hmi_level() const = 0; virtual const uint32_t put_file_in_none_count() const = 0; @@ -421,8 +424,9 @@ class Application : public virtual InitialApplicationData, virtual uint32_t get_grammar_id() const = 0 ; virtual void set_grammar_id(uint32_t value) = 0; - virtual void set_protocol_version(ProtocolVersion protocol_version) = 0; - virtual ProtocolVersion protocol_version() = 0; + virtual void set_protocol_version( + const ProtocolVersion& protocol_version) = 0; + virtual ProtocolVersion protocol_version() const = 0; virtual bool AddFile(AppFile& file) = 0; virtual const AppFilesMap& getAppFiles() const = 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 bfc4d3b..3212937 100644 --- a/src/components/application_manager/include/application_manager/application_impl.h +++ b/src/components/application_manager/include/application_manager/application_impl.h @@ -55,6 +55,7 @@ class ApplicationImpl : public virtual InitialApplicationDataImpl, ApplicationImpl(uint32_t application_id, const std::string& global_app_id, usage_statistics::StatisticsManager* statistics_manager); + ~ApplicationImpl(); /** @@ -76,8 +77,11 @@ class ApplicationImpl : public virtual InitialApplicationDataImpl, bool has_been_activated() const; const Version& version() const; + void set_hmi_application_id(uint32_t hmi_app_id); + inline uint32_t hmi_app_id() const; inline uint32_t app_id() const; const std::string& name() const; + const std::string folder_name() const; bool is_media_application() const; const mobile_api::HMILevel::eType& hmi_level() const; const uint32_t put_file_in_none_count() const; @@ -107,8 +111,8 @@ class ApplicationImpl : public virtual InitialApplicationDataImpl, virtual uint32_t get_grammar_id() const; virtual void set_grammar_id(uint32_t value); - virtual void set_protocol_version(ProtocolVersion protocol_version); - virtual ProtocolVersion protocol_version(); + virtual void set_protocol_version(const ProtocolVersion& protocol_version); + virtual ProtocolVersion protocol_version() const; bool AddFile(AppFile& file); bool UpdateFile(AppFile& file); @@ -146,40 +150,44 @@ class ApplicationImpl : public virtual InitialApplicationDataImpl, private: - uint32_t hash_val_; - uint32_t grammar_id_; - + uint32_t hash_val_; + uint32_t grammar_id_; - smart_objects::SmartObject* active_message_; + smart_objects::SmartObject* active_message_; Version version_; - uint32_t app_id_; - std::string app_name_; - bool is_media_; - bool allowed_support_navigation_; - bool is_app_allowed_; - bool has_been_activated_; - bool tts_speak_state_; - bool hmi_supports_navi_streaming_; - - mobile_api::HMILevel::eType hmi_level_; - uint32_t put_file_in_none_count_; - uint32_t delete_file_in_none_count_; - uint32_t list_files_in_none_count_; - mobile_api::SystemContext::eType system_context_; - mobile_api::AudioStreamingState::eType audio_streaming_state_; - std::string app_icon_path_; - connection_handler::DeviceHandle device_; - - ProtocolVersion protocol_version_; - - AppFilesMap app_files_; + uint32_t hmi_app_id_; + uint32_t app_id_; + std::string app_name_; + bool is_media_; + bool allowed_support_navigation_; + bool is_app_allowed_; + bool has_been_activated_; + bool tts_speak_state_; + bool hmi_supports_navi_streaming_; + + mobile_api::HMILevel::eType hmi_level_; + uint32_t put_file_in_none_count_; + uint32_t delete_file_in_none_count_; + uint32_t list_files_in_none_count_; + mobile_api::SystemContext::eType system_context_; + mobile_api::AudioStreamingState::eType audio_streaming_state_; + std::string app_icon_path_; + connection_handler::DeviceHandle device_; + + ProtocolVersion protocol_version_; + AppFilesMap app_files_; std::set subscribed_buttons_; - std::set subscribed_vehicle_info_; - UsageStatistics usage_report_; + std::set subscribed_vehicle_info_; + UsageStatistics usage_report_; + DISALLOW_COPY_AND_ASSIGN(ApplicationImpl); }; +uint32_t ApplicationImpl::hmi_app_id() const { + return hmi_app_id_; +} + uint32_t ApplicationImpl::app_id() const { return app_id_; } 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 780f7d9..d4765b4 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 @@ -33,7 +33,7 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_H_ -#include +#include #include #include #include @@ -60,11 +60,10 @@ #include "interfaces/v4_protocol_v1_2_no_extra.h" #include "interfaces/v4_protocol_v1_2_no_extra_schema.h" - +#include "time_metric_observer.h" #include "protocol_handler/service_type.h" #include "utils/macro.h" -#include "utils/logger.h" #include "utils/shared_ptr.h" #include "utils/message_queue.h" #include "utils/prioritized_queue.h" @@ -162,7 +161,7 @@ struct MessageToHmi: public utils::SharedPtr { } }; -// Short type names for proiritized message queues +// Short type names for prioritized message queues typedef threads::MessageLoopThread > FromMobileQueue; typedef threads::MessageLoopThread > ToMobileQueue; typedef threads::MessageLoopThread > FromHmiQueue; @@ -177,6 +176,7 @@ class ApplicationManagerImpl : public ApplicationManager, public impl::FromHmiQueue::Handler, public impl::ToHmiQueue::Handler, public utils::Singleton { friend class ResumeCtrl; + friend class CommandImpl; public: ~ApplicationManagerImpl(); @@ -190,20 +190,21 @@ class ApplicationManagerImpl : public ApplicationManager, ///////////////////////////////////////////////////// ApplicationSharedPtr application(int32_t app_id) const; + ApplicationSharedPtr application_by_policy_id( + const std::string& policy_app_id) const; inline const std::set& applications() const; ApplicationSharedPtr active_application() const; std::vector applications_by_button(uint32_t button); std::vector applications_by_ivi(uint32_t vehicle_info); std::vector applications_with_navi(); - ApplicationSharedPtr application_by_policy_id( - const std::string& policy_app_id) const; + /** - * @brief Notifies all components interested in Vehicle Data update - * i.e. new value of odometer etc and returns list of applications - * subscribed for event. - * @param vehicle_info Enum value of type of vehicle data - * @param new value (for integer values currently) of vehicle data - */ + * @brief Notifies all components interested in Vehicle Data update + * i.e. new value of odometer etc and returns list of applications + * subscribed for event. + * @param vehicle_info Enum value of type of vehicle data + * @param new value (for integer values currently) of vehicle data + */ std::vector> IviInfoUpdated( VehicleDataType vehicle_info, int value); @@ -211,6 +212,13 @@ class ApplicationManagerImpl : public ApplicationManager, HMICapabilities& hmi_capabilities(); + /** + * @brief Setup observer for time metric. + * + * @param observer - pointer to observer + */ + void SetTimeMetricObserver(AMMetricObserver* observer); + ApplicationSharedPtr RegisterApplication( const utils::SharedPtr& request_for_registration); /* @@ -492,6 +500,29 @@ class ApplicationManagerImpl : public ApplicationManager, */ uint32_t GenerateGrammarID(); + /** + * Generate new HMI application ID + * + * @return New HMI application ID + */ + uint32_t GenerateNewHMIAppID(); + + /** + * @brief Parse smartObject and replace mobile app Id by HMI app ID + * + * @param message Smartobject to be parsed + */ + void ReplaceMobileByHMIAppId( + smart_objects::SmartObject& message); + + /** + * @brief Parse smartObject and replace HMI app ID by mobile app Id + * + * @param message Smartobject to be parsed + */ + void ReplaceHMIByMobileAppId( + smart_objects::SmartObject& message); + /* * @brief Save binary data to specified directory * @@ -579,21 +610,24 @@ class ApplicationManagerImpl : public ApplicationManager, // CALLED ON messages_to_hmi_ thread! virtual void Handle(const impl::MessageToHmi& message) OVERRIDE; + /** + * Function used only by HMI request/response/notification base classes + * to change HMI app id to Mobile app id and vice versa. + * Dot use it inside Core + */ + ApplicationSharedPtr application_by_hmi_app(int32_t hmi_app_id) const; + private: // members - ResumeCtrl resume_ctrl_; - /** * @brief Resume controler is responcible for save and load information * about persistent application data on disk, and save session ID for resuming * application in case INGITION_OFF or MASTER_RESSET */ + ResumeCtrl resume_ctrl_; + - /** - * @brief Map of connection keys and associated applications - */ - std::map applications_; /** * @brief List of applications @@ -631,9 +665,7 @@ class ApplicationManagerImpl : public ApplicationManager, hmi_apis::HMI_API* hmi_so_factory_; mobile_apis::MOBILE_API* mobile_so_factory_; -# ifdef ENABLE_LOG - static log4cxx::LoggerPtr logger_; -# endif // ENABLE_LOG + AMMetricObserver* metric_observer_; static uint32_t corelation_id_; static const uint32_t max_corelation_id_; 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 d12a2e8..8fec72d 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 @@ -37,13 +37,8 @@ #include "utils/logger.h" namespace application_manager { - namespace commands { -#ifdef ENABLE_LOG -extern log4cxx::LoggerPtr logger_; -#endif // ENABLE_LOG - /** * @brief Class is intended to encapsulate RPC as an object **/ @@ -85,12 +80,14 @@ class CommandImpl : public Command { protected: MessageSharedPtr message_; +#ifdef ENABLE_LOG + static log4cxx::LoggerPtr logger_; +#endif // ENABLE_LOG + private: DISALLOW_COPY_AND_ASSIGN(CommandImpl); }; } // namespace commands - } // namespace application_manager - #endif // SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_COMMAND_IMPL_H_ diff --git a/src/components/application_manager/include/application_manager/commands/hmi/get_urls.h~HEAD b/src/components/application_manager/include/application_manager/commands/hmi/get_urls.h~HEAD new file mode 100644 index 0000000..9241446 --- /dev/null +++ b/src/components/application_manager/include/application_manager/commands/hmi/get_urls.h~HEAD @@ -0,0 +1,70 @@ +/** + * 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_COMMANDS_HMI_GET_URLS_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_HMI_GET_URLS_H_ + +#include "application_manager/commands/hmi/request_from_hmi.h" + +namespace application_manager { +namespace commands { + +/** + * @brief GetUrls command class + **/ +class GetUrls : public RequestFromHMI { + public: + /** + * @brief GetUrls class constructor + * + * @param message Incoming SmartObject message + **/ + explicit GetUrls(const MessageSharedPtr& message); + + /** + * @brief GetUrls class destructor + **/ + virtual ~GetUrls(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(GetUrls); +}; + +} // namespace commands +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_HMI_GET_URLS_H_ diff --git a/src/components/application_manager/include/application_manager/commands/hmi/get_urls.h~develop b/src/components/application_manager/include/application_manager/commands/hmi/get_urls.h~develop new file mode 100644 index 0000000..9241446 --- /dev/null +++ b/src/components/application_manager/include/application_manager/commands/hmi/get_urls.h~develop @@ -0,0 +1,70 @@ +/** + * 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_COMMANDS_HMI_GET_URLS_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_HMI_GET_URLS_H_ + +#include "application_manager/commands/hmi/request_from_hmi.h" + +namespace application_manager { +namespace commands { + +/** + * @brief GetUrls command class + **/ +class GetUrls : public RequestFromHMI { + public: + /** + * @brief GetUrls class constructor + * + * @param message Incoming SmartObject message + **/ + explicit GetUrls(const MessageSharedPtr& message); + + /** + * @brief GetUrls class destructor + **/ + virtual ~GetUrls(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(GetUrls); +}; + +} // namespace commands +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_HMI_GET_URLS_H_ diff --git a/src/components/application_manager/include/application_manager/commands/hmi/on_device_state_changed_notification.h b/src/components/application_manager/include/application_manager/commands/hmi/on_device_state_changed_notification.h new file mode 100644 index 0000000..5c12bdf --- /dev/null +++ b/src/components/application_manager/include/application_manager/commands/hmi/on_device_state_changed_notification.h @@ -0,0 +1,72 @@ +/** + * 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_COMMANDS_HMI_ON_DEVICE_STATE_CHANGED_NOTIFICATION_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_HMI_ON_DEVICE_STATE_CHANGED_NOTIFICATION_H_ + +#include "application_manager/commands/hmi/notification_from_hmi.h" + +namespace application_manager { + +namespace commands { + +/** + * @brief OnDeviceStateChangedNotification command class + **/ +class OnDeviceStateChangedNotification : public NotificationFromHMI { + public: + /** + * @brief OnDeviceStateChangedNotification class constructor + * + * @param message Incoming SmartObject message + **/ + explicit OnDeviceStateChangedNotification(const MessageSharedPtr& message); + + /** + * @brief OnDeviceStateChangedNotification class destructor + **/ + virtual ~OnDeviceStateChangedNotification(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(OnDeviceStateChangedNotification); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_HMI_ON_DEVICE_STATE_CHANGED_NOTIFICATION_H_ diff --git a/src/components/application_manager/include/application_manager/commands/hmi/on_resume_audio_source_notification.h b/src/components/application_manager/include/application_manager/commands/hmi/on_resume_audio_source_notification.h new file mode 100644 index 0000000..c27e2e5 --- /dev/null +++ b/src/components/application_manager/include/application_manager/commands/hmi/on_resume_audio_source_notification.h @@ -0,0 +1,74 @@ +/** + * 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_COMMANDS_HMI_ON_RESUME_AUDIO_SOURCE_NOTIFICATION_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_HMI_ON_RESUME_AUDIO_SOURCE_NOTIFICATION_H_ + +#include "application_manager/commands/hmi/notification_to_hmi.h" +#include "application_manager/application_impl.h" + +namespace application_manager { + +namespace commands { + +/** + * @brief OnResumeAudioSourceNotification command class + **/ +class OnResumeAudioSourceNotification : public NotificationToHMI { + public: + /** + * @brief OnResumeAudioSourceNotification class constructor + * + * @param message Incoming SmartObject message + **/ + explicit OnResumeAudioSourceNotification(const MessageSharedPtr& message); + + /** + * @brief OnResumeAudioSourceNotification class destructor + **/ + virtual ~OnResumeAudioSourceNotification(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + + DISALLOW_COPY_AND_ASSIGN(OnResumeAudioSourceNotification); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_HMI_ON_RESUME_AUDIO_SOURCE_NOTIFICATION_H_ diff --git a/src/components/application_manager/include/application_manager/commands/hmi/on_update_device_list.h b/src/components/application_manager/include/application_manager/commands/hmi/on_update_device_list.h index b6d7a55..c0d355c 100644 --- a/src/components/application_manager/include/application_manager/commands/hmi/on_update_device_list.h +++ b/src/components/application_manager/include/application_manager/commands/hmi/on_update_device_list.h @@ -30,8 +30,8 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_HMI_GET_DEVICE_LIST_RESPONSE_H_ -#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_HMI_GET_DEVICE_LIST_RESPONSE_H_ +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_HMI_ON_UPDATE_DEVICE_LIST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_HMI_ON_UPDATE_DEVICE_LIST_H_ #include "application_manager/commands/hmi/notification_from_hmi.h" @@ -69,4 +69,4 @@ class OnUpdateDeviceList : public NotificationFromHMI { } // namespace application_manager -#endif // SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_HMI_GET_DEVICE_LIST_RESPONSE_H_ +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_HMI_ON_UPDATE_DEVICE_LIST_H_ 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 3eea88e..4270b9e 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 @@ -1,5 +1,5 @@ /* - Copyright (c) 2013, Ford Motor Company + Copyright (c) 2014, Ford Motor Company All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/src/components/application_manager/include/application_manager/commands/hmi/update_app_list_request.h b/src/components/application_manager/include/application_manager/commands/hmi/update_app_list_request.h index 51dac16..d230723 100644 --- a/src/components/application_manager/include/application_manager/commands/hmi/update_app_list_request.h +++ b/src/components/application_manager/include/application_manager/commands/hmi/update_app_list_request.h @@ -30,8 +30,8 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_HMI_GET_APP_LIST_REQUEST_H_ -#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_HMI_GET_APP_LIST_REQUEST_H_ +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_HMI_UPDATE_APP_LIST_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_HMI_UPDATE_APP_LIST_REQUEST_H_ #include "application_manager/commands/hmi/request_to_hmi.h" @@ -69,4 +69,5 @@ class UpdateAppListRequest : public RequestToHMI { } // namespace application_manager -#endif // SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_HMI_GET_APP_LIST_REQUEST_H_ +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_HMI_UPDATE_APP_LIST_REQUEST_H_ + diff --git a/src/components/application_manager/include/application_manager/commands/hmi/update_app_list_response.h b/src/components/application_manager/include/application_manager/commands/hmi/update_app_list_response.h index 7e3f4d1..3e6a1d7 100644 --- a/src/components/application_manager/include/application_manager/commands/hmi/update_app_list_response.h +++ b/src/components/application_manager/include/application_manager/commands/hmi/update_app_list_response.h @@ -30,8 +30,8 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_HMI_GET_APP_LIST_RESPONSE_H_ -#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_HMI_GET_APP_LIST_RESPONSE_H_ +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_HMI_UPDATE_APP_LIST_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_HMI_UPDATE_APP_LIST_RESPONSE_H_ #include "application_manager/commands/hmi/response_from_hmi.h" @@ -69,4 +69,4 @@ class UpdateAppListResponse : public ResponseFromHMI { } // namespace application_manager -#endif // SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_HMI_GET_APP_LIST_RESPONSE_H_ +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_HMI_UPDATE_APP_LIST_RESPONSE_H_ diff --git a/src/components/application_manager/include/application_manager/commands/mobile/alert_maneuver_request.h b/src/components/application_manager/include/application_manager/commands/mobile/alert_maneuver_request.h index e932b72..9f1ce92 100644 --- a/src/components/application_manager/include/application_manager/commands/mobile/alert_maneuver_request.h +++ b/src/components/application_manager/include/application_manager/commands/mobile/alert_maneuver_request.h @@ -73,7 +73,6 @@ class AlertManeuverRequest : public CommandRequestImpl { virtual void on_event(const event_engine::Event& event); private: - mobile_apis::Result::eType result_; mobile_apis::Result::eType tts_speak_result_code_; mobile_apis::Result::eType navi_alert_maneuver_result_code_; Pending pending_requests_; diff --git a/src/components/application_manager/include/application_manager/commands/mobile/perform_interaction_request.h b/src/components/application_manager/include/application_manager/commands/mobile/perform_interaction_request.h index 364360e..dd6d14a 100644 --- a/src/components/application_manager/include/application_manager/commands/mobile/perform_interaction_request.h +++ b/src/components/application_manager/include/application_manager/commands/mobile/perform_interaction_request.h @@ -104,15 +104,6 @@ class PerformInteractionRequest : public CommandRequestImpl { void ProcessVRResponse(const smart_objects::SmartObject& message); /* - * @brief Function will be called when event AppUnregistered comes - * - * @param message which will be sent to mobile side - * - */ - void ProcessAppUnregisteredNotification - (const smart_objects::SmartObject& message); - - /* * @brief Sends PerformInteraction response to mobile side * * @param message which should send to mobile side diff --git a/src/components/application_manager/include/application_manager/commands/mobile/scrollable_message_request.h b/src/components/application_manager/include/application_manager/commands/mobile/scrollable_message_request.h index bf8bc3e..0c6305e 100644 --- a/src/components/application_manager/include/application_manager/commands/mobile/scrollable_message_request.h +++ b/src/components/application_manager/include/application_manager/commands/mobile/scrollable_message_request.h @@ -76,9 +76,6 @@ class ScrollabelMessageRequest : public CommandRequestImpl { private: - // members - mobile_apis::Result::eType result_; - DISALLOW_COPY_AND_ASSIGN(ScrollabelMessageRequest); }; diff --git a/src/components/application_manager/include/application_manager/commands/mobile/show_constant_tbt_request.h b/src/components/application_manager/include/application_manager/commands/mobile/show_constant_tbt_request.h index 968a30c..19ba37f 100644 --- a/src/components/application_manager/include/application_manager/commands/mobile/show_constant_tbt_request.h +++ b/src/components/application_manager/include/application_manager/commands/mobile/show_constant_tbt_request.h @@ -73,9 +73,6 @@ class ShowConstantTBTRequest : public CommandRequestImpl { private: - // members - mobile_apis::Result::eType result_; - DISALLOW_COPY_AND_ASSIGN(ShowConstantTBTRequest); }; diff --git a/src/components/application_manager/include/application_manager/commands/mobile/show_request.h b/src/components/application_manager/include/application_manager/commands/mobile/show_request.h index c187058..5dddaaa 100644 --- a/src/components/application_manager/include/application_manager/commands/mobile/show_request.h +++ b/src/components/application_manager/include/application_manager/commands/mobile/show_request.h @@ -78,9 +78,6 @@ class ShowRequest : public CommandRequestImpl { */ bool CheckMenuFieldsNames(); - // members - mobile_apis::Result::eType result_; - DISALLOW_COPY_AND_ASSIGN(ShowRequest); }; diff --git a/src/components/application_manager/include/application_manager/commands/mobile/update_turn_list_request.h b/src/components/application_manager/include/application_manager/commands/mobile/update_turn_list_request.h index 0ae79a5..71fb677 100644 --- a/src/components/application_manager/include/application_manager/commands/mobile/update_turn_list_request.h +++ b/src/components/application_manager/include/application_manager/commands/mobile/update_turn_list_request.h @@ -80,9 +80,6 @@ class UpdateTurnListRequest : public CommandRequestImpl { */ bool CheckTurnListArray(); - // members - mobile_apis::Result::eType result_; - DISALLOW_COPY_AND_ASSIGN(UpdateTurnListRequest); }; diff --git a/src/components/application_manager/include/application_manager/hmi_capabilities.h b/src/components/application_manager/include/application_manager/hmi_capabilities.h index 6fa0403..5aa4b9d 100644 --- a/src/components/application_manager/include/application_manager/hmi_capabilities.h +++ b/src/components/application_manager/include/application_manager/hmi_capabilities.h @@ -35,7 +35,7 @@ #include "interfaces/HMI_API.h" #include "interfaces/MOBILE_API.h" -#include "utils/logger.h" +#include "json/json.h" namespace NsSmartDeviceLink { namespace NsSmartObjects { @@ -361,7 +361,6 @@ class HMICapabilities { void set_prerecorded_speech( const smart_objects::SmartObject& prerecorded_speech); - protected: /* @@ -372,6 +371,29 @@ class HMICapabilities { */ bool load_capabilities_from_file(); + /* + * @brief function checks if json member exists + * + * @param json_member from file hmi_capabilities.json + * @param name_of_member name which we should check + * hmi_capabilities.json + * + * @returns TRUE if member exists and returns FALSE if + * member does not exist. + */ + bool check_existing_json_member( + const Json::Value& json_member, const char* name_of_member); + + /* + * @brief function converts json object "languages" to smart object + * + * @param json_languages from file hmi_capabilities.json + * @param languages - the converted object + * + */ + void convert_json_languages_to_obj(Json::Value& json_languages, + smart_objects::SmartObject& languages); + private: bool is_vr_cooperating_; bool is_tts_cooperating_; @@ -405,9 +427,6 @@ class HMICapabilities { smart_objects::SmartObject* prerecorded_speech_; ApplicationManagerImpl* app_mngr_; -#ifdef ENABLE_LOG - static log4cxx::LoggerPtr logger_; -#endif // ENABLE_LOG DISALLOW_COPY_AND_ASSIGN(HMICapabilities); }; diff --git a/src/components/application_manager/include/application_manager/hmi_command_factory.h b/src/components/application_manager/include/application_manager/hmi_command_factory.h index e12051a..d6f85a4 100644 --- a/src/components/application_manager/include/application_manager/hmi_command_factory.h +++ b/src/components/application_manager/include/application_manager/hmi_command_factory.h @@ -35,7 +35,6 @@ #include "application_manager/commands/command.h" #include "utils/macro.h" -#include "utils/logger.h" namespace application_manager { @@ -56,9 +55,6 @@ class HMICommandFactory { private: HMICommandFactory(); -#ifdef ENABLE_LOG - static log4cxx::LoggerPtr logger_; -#endif // ENABLE_LOG DISALLOW_COPY_AND_ASSIGN(HMICommandFactory); }; 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 dd1691e..4161cf2 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 { typedef std::vector SmartObjectList; /** + * @brief Creates request for different interfaces(JSON, DBUS) + * @param correlation_id unique ID + * @param params Vector of arguments that we need in GetVehicleData request (e.g. gps, odometer, fuel_level) + */ + static void CreateGetVehicleDataRequest(uint32_t correlation_id, const std::vector& params); + + /** * @brief Sends HMI status notification to mobile * *@param application_impl application with changed HMI status @@ -142,23 +149,30 @@ class MessageHelper { */ static const VehicleData& vehicle_data(); + /** + * @brief Convert string to HMI level, if possible + * @param hmi_level Stringified HMI level + * @return Appropriate enum from HMI level, or INVALID_ENUM, if conversiion + * is not possible + */ + static mobile_api::HMILevel::eType StringToHMILevel( + const std::string& hmi_level); + /* * @brief Used to obtain string representation of app's * HMI Level. * @param hmi_level Desired HMI Level */ - static const char* StringifiedHMILevel( + static std::string StringifiedHMILevel( mobile_apis::HMILevel::eType hmi_level); /* * @brief Used to obtain function name by its id * @param function_id Function ID */ - static const char* StringifiedFunctionID( + static std::string StringifiedFunctionID( mobile_apis::FunctionID::eType function_id); - static void CreateGetDeviceData(int32_t correlation_id); - static smart_objects::SmartObject* CreateBlockedByPoliciesResponse( mobile_apis::FunctionID::eType function_id, mobile_apis::Result::eType result, uint32_t correlation_id, @@ -219,6 +233,12 @@ class MessageHelper { static void ResetGlobalproperties(ApplicationSharedPtr app); static void SendActivateAppToHMI(uint32_t const app_id); + + static void SendOnResumeAudioSourceToHMI(const uint32_t app_id); + + static std::string GetDeviceMacAddressForHandle( + const uint32_t device_handle); + static void GetDeviceInfoForHandle(const uint32_t device_handle, policy::DeviceParams* device_info); static void GetDeviceInfoForApp(uint32_t connection_key, @@ -326,7 +346,7 @@ class MessageHelper { * @param correlation_id Correlation id from request */ static void SendUpdateSDLResponse(const std::string& result, - uint32_t correlation_id); + uint32_t correlation_id); /** * @brief Send OnStatusUpdate to HMI on policy update status change @@ -394,7 +414,10 @@ class MessageHelper { * */ static mobile_apis::Result::eType VerifyImageFiles( - smart_objects::SmartObject& message, ApplicationConstSharedPtr app); + smart_objects::SmartObject& message, ApplicationConstSharedPtr app); + + static mobile_apis::Result::eType VerifyImageVrHelpItems( + smart_objects::SmartObject& message, ApplicationConstSharedPtr app); static bool VerifySoftButtonText(smart_objects::SmartObject& soft_button); @@ -415,8 +438,8 @@ class MessageHelper { * @return Common language string representation */ static std::string CommonLanguageToString( - hmi_apis::Common_Language::eType language); -private: + hmi_apis::Common_Language::eType language); + private: static smart_objects::SmartObject* CreateChangeRegistration( int32_t function_id, int32_t language, uint32_t app_id); diff --git a/src/components/application_manager/include/application_manager/mobile_message_handler.h b/src/components/application_manager/include/application_manager/mobile_message_handler.h index 20d46a7..91a0157 100644 --- a/src/components/application_manager/include/application_manager/mobile_message_handler.h +++ b/src/components/application_manager/include/application_manager/mobile_message_handler.h @@ -34,7 +34,6 @@ #define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_MOBILE_MESSAGE_HANDLER_IMPL_H_ #include "utils/macro.h" -#include "utils/logger.h" #include "protocol_handler/raw_message.h" #include "application_manager/message.h" @@ -58,10 +57,6 @@ class MobileMessageHandler { //! ------------------------------------------------------------- private: -# ifdef ENABLE_LOG - static log4cxx::LoggerPtr logger_; -# endif // ENABLE_LOG - DISALLOW_COPY_AND_ASSIGN(MobileMessageHandler); }; } // namespace application_manager 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 61ef424..401f4d4 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 @@ -34,9 +34,11 @@ #define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_POLICY_EVENT_OBSERVER_H_ #include "application_manager/event_engine/event_observer.h" -#include "policy/policy_manager.h" namespace policy { +namespace smart_objects = NsSmartDeviceLink::NsSmartObjects; + +class PolicyManager; class PolicyEventObserver : public application_manager::event_engine::EventObserver { @@ -48,6 +50,7 @@ class PolicyEventObserver : int32_t hmi_correlation_id = 0); private: PolicyManager* policy_manager_; + void ProcessOdometerEvent(const smart_objects::SmartObject& message); }; } // namespace policy 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 bc875f9..8929ca2 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 @@ -59,22 +59,19 @@ class PolicyHandler : public utils::Singleton, public: virtual ~PolicyHandler(); PolicyManager* LoadPolicyLibrary(); - PolicyManager* LoadPolicyLibrary(const std::string& path); PolicyManager* policy_manager() const { return policy_manager_; } bool InitPolicyTable(); bool RevertPolicyTable(); bool SendMessageToSDK(const BinaryMessage& pt_string); - bool ReceiveMessageFromSDK(const BinaryMessage& pt_string); + bool ReceiveMessageFromSDK(const std::string& file, + const BinaryMessage& pt_string); bool UnloadPolicyLibrary(); void OnPTExchangeNeeded(); void OnPermissionsUpdated(const std::string& policy_app_id, - const Permissions& permissions); - /** - * @brief Checks, if policy update is necessary for application - */ - void CheckAppPolicyState(const std::string& application_id); + const Permissions& permissions, + const HMILevel& default_hmi); /** * Lets client to notify PolicyHandler that more kilometers expired @@ -176,7 +173,7 @@ class PolicyHandler : public utils::Singleton, * application * @param policy_app_id Application id */ - void OnCurrentDeviceIdUpdateRequired(const std::string& policy_app_id); + std::string OnCurrentDeviceIdUpdateRequired(const std::string& policy_app_id); /** * @brief Set parameters from OnSystemInfoChanged to policy table @@ -200,6 +197,12 @@ class PolicyHandler : public utils::Singleton, virtual void OnSystemInfoUpdateRequired(); /** + * Removes device + * @param device_id id of device + */ + void RemoveDevice(const std::string& device_id); + + /** * Adds statistics info * @param type type of info */ @@ -217,6 +220,8 @@ class PolicyHandler : public utils::Singleton, */ uint32_t GetAppIdForSending(); + std::string GetAppName(const std::string& policy_app_id); + protected: /** * Starts next retry exchange policy table @@ -257,11 +262,11 @@ class PolicyHandler : public utils::Singleton, PolicyManager* policy_manager_; void* dl_handle_; AppIds last_used_app_ids_; - static log4cxx::LoggerPtr logger_; threads::Thread retry_sequence_; sync_primitives::Lock retry_sequence_lock_; PTExchangeHandler* exchange_handler_; utils::SharedPtr event_observer_; + bool on_ignition_check_done_; /** * @brief Contains device handles, which were sent for user consent to HMI @@ -275,6 +280,11 @@ class PolicyHandler : public utils::Singleton, */ bool is_exchange_in_progress_; + /** + * @brief Holds device ids, which were unpaired + */ + DeviceIds unpaired_device_ids_; + inline PolicyManager* CreateManager(); DISALLOW_COPY_AND_ASSIGN(PolicyHandler);FRIEND_BASE_SINGLETON_CLASS(PolicyHandler); 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 d6605e4..4cad92a 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 @@ -43,7 +43,6 @@ class PTExchangeHandlerExt : public PTExchangeHandler { ~PTExchangeHandlerExt(); virtual bool StartExchange(); private: - static log4cxx::LoggerPtr logger_; PolicyHandler* policy_handler_; }; } // namespace policy 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 4283bff..9eab3f4 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 @@ -44,7 +44,6 @@ class PTExchangeHandlerImpl : public PTExchangeHandler { virtual bool StartExchange(); protected: PolicyHandler* policy_handler_; - static log4cxx::LoggerPtr logger_; }; } // namespace policy diff --git a/src/components/application_manager/include/application_manager/resume_ctrl.h b/src/components/application_manager/include/application_manager/resume_ctrl.h index 47d8882..e180a69 100644 --- a/src/components/application_manager/include/application_manager/resume_ctrl.h +++ b/src/components/application_manager/include/application_manager/resume_ctrl.h @@ -33,7 +33,7 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_RESUME_CTRL_H #define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_RESUME_CTRL_H -#include +#include #include #include #include @@ -48,10 +48,10 @@ #include "application_manager/event_engine/event_observer.h" #include "smart_objects/smart_object.h" #include "application_manager/application.h" +#include "utils/timer_thread.h" namespace application_manager { - namespace smart_objects = NsSmartDeviceLink::NsSmartObjects; class ApplicationManagerImpl; @@ -145,7 +145,31 @@ class ResumeCtrl: public event_engine::EventObserver { * @param application that is need to be restored * @return true if it was saved, otherwise return false */ - bool CheckApplicationHash(std::string mobile_app_id, uint32_t hash); + bool CheckApplicationHash(ApplicationSharedPtr application, uint32_t hash); + + /** + * @brief Check if Resume controller have saved application with hmi app id + * @param hmi_app_id - hmi application id + * @return true if exist, false otherwise + */ + bool IsHMIApplicationIdExist(uint32_t hmi_app_id); + + /** + * @brief Check if Resume controller have saved instance of application + * @param mobile_app_id - mobile application id + * @return true if exist, false otherwise + */ + bool IsApplicationSaved(const std::string& mobile_app_id); + + /** + * @brief Function is used for application resume. HMI app ID must be + * the same(PASA VCA module use it for stored app info). + * Retrieves HMI app ID for the given mobile app ID from stored information. + * + * @param mobile_app_id - mobile application id + * @return HMI app ID + */ + uint32_t GetHMIApplicationID(const std::string& mobile_app_id); /** * @brief Timer callback function @@ -155,9 +179,8 @@ class ResumeCtrl: public event_engine::EventObserver { private: - mutable sync_primitives::Lock queue_lock_; + typedef std::pair application_timestamp; - timer::TimerThread timer_; /** * @brief This struct need to map * timestamp and application from correlationID @@ -167,20 +190,6 @@ class ResumeCtrl: public event_engine::EventObserver { ApplicationSharedPtr app; }; -#ifdef ENABLE_LOG - static log4cxx::LoggerPtr logger_; -#endif // ENABLE_LOG - - /** - * @brief Time step to check resumption TIME_OUT - */ - static const uint32_t kTimeStep = 3; - - Json::Value& GetSavedApplications(); - - void SetSavedApplication(Json::Value& apps_json); - - typedef std::pair application_timestamp; struct TimeStampComparator { bool operator() (const application_timestamp& lhs, const application_timestamp& rhs) const{ @@ -189,37 +198,37 @@ class ResumeCtrl: public event_engine::EventObserver { }; /** - *@brief Mapping applications to time_stamps - * wait for timer to resume HMI Level - * - */ - std::multiset waiting_for_timer_; - - - ApplicationManagerImpl* app_mngr_; - - /** - * @brief times of IGN_OFF that zombie application have to be saved. + * @brief Check device MAC address + * + * @param application that is need to be restored + * @param saved_device_mac Saved device MAC address + * + * @return TRUE on success, otherwise FALSE */ - static const uint32_t kApplicationLifes = 3; + bool IsDeviceMacAddressEqual(ApplicationSharedPtr application, + const std::string& saved_device_mac); + Json::Value& GetSavedApplications(); - /** - * @brief Check if Resume controller have saved instance of application - * @param app_id - application id witch is the same as session_key or connection_key - * @return true if exist, false otherwise - */ - bool ApplicationIsSaved(const uint32_t app_id); - - Json::Value GetApplicationCommands(ApplicationConstSharedPtr application); - Json::Value GetApplicationSubMenus(ApplicationConstSharedPtr application); - Json::Value GetApplicationInteractionChoiseSets(ApplicationConstSharedPtr application); - Json::Value GetApplicationGlobalProperties(ApplicationConstSharedPtr application); - Json::Value GetApplicationSubscriptions(ApplicationConstSharedPtr application); - Json::Value GetApplicationFiles(ApplicationConstSharedPtr application); - Json::Value GetApplicationShow(ApplicationConstSharedPtr application); + void SetSavedApplication(Json::Value& apps_json); - Json::Value JsonFromSO(const NsSmartDeviceLink::NsSmartObjects::SmartObject *so); + Json::Value GetApplicationCommands( + ApplicationConstSharedPtr application); + Json::Value GetApplicationSubMenus( + ApplicationConstSharedPtr application); + Json::Value GetApplicationInteractionChoiseSets( + ApplicationConstSharedPtr application); + Json::Value GetApplicationGlobalProperties( + ApplicationConstSharedPtr application); + Json::Value GetApplicationSubscriptions( + ApplicationConstSharedPtr application); + Json::Value GetApplicationFiles( + ApplicationConstSharedPtr application); + Json::Value GetApplicationShow( + ApplicationConstSharedPtr application); + + Json::Value JsonFromSO( + const NsSmartDeviceLink::NsSmartObjects::SmartObject *so); void SendHMIRequest(const hmi_apis::FunctionID::eType& function_id, const smart_objects::SmartObject* msg_params = NULL, @@ -228,6 +237,26 @@ class ResumeCtrl: public event_engine::EventObserver { bool ProcessHMIRequest( NsSmartDeviceLink::NsSmartObjects::SmartObject* request = NULL, bool use_events = false); + + /** + * @brief Time step to check resumption TIME_OUT + */ + static const uint32_t kTimeStep = 3; + + /** + * @brief times of IGN_OFF that zombie application have to be saved. + */ + static const uint32_t kApplicationLifes = 3; + + /** + *@brief Mapping applications to time_stamps + * wait for timer to resume HMI Level + * + */ + std::multiset waiting_for_timer_; + mutable sync_primitives::Lock queue_lock_; + timer::TimerThread timer_; + ApplicationManagerImpl* app_mngr_; }; } // namespace application_manager 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 8809011..6584d3d 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 @@ -52,6 +52,8 @@ const char default_app_id[] = "default"; const char msg_params[] = "msg_params"; const char info[] = "info"; const char app_id[] = "appID"; +const char hmi_app_id[] = "hmiAppID"; +const char device_mac[] = "deviceMAC"; const char url[] = "url"; const char cmd_icon[] = "cmdIcon"; const char result_code[] = "resultCode"; @@ -123,6 +125,7 @@ const char max_duration[] = "maxDuration"; const char sampling_rate[] = "samplingRate"; const char bits_per_sample[] = "bitsPerSample"; const char audio_type[] = "audioType"; +const char mute_audio[] = "muteAudio"; const char button_name[] = "buttonName"; const char button_event_mode[] = "buttonEventMode"; const char button_press_mode[] = "buttonPressMode"; @@ -163,7 +166,7 @@ const char type[] = "type"; const char system_file[] = "systemFile"; const char offset[] = "offset"; const char length[] = "length"; - +const char secondary_image[] = "secondaryImage"; const char filenames[] = "filenames"; const char hmi_display_language_desired[] = "hmiDisplayLanguageDesired"; @@ -181,6 +184,7 @@ const char device_name[] = "deviceName"; const char reason[] = "reason"; const char available[] = "available"; const char text[] = "text"; +const char character_set[] = "characterSet"; // vehicle info const char gps[] = "gps"; @@ -217,6 +221,7 @@ const char slider_position[] = "sliderPosition"; const char system_action[] = "systemAction"; const char prerecorded_speech[] = "prerecordedSpeech"; const char supported_diag_modes[] = "supportedDiagModes"; +const char priority[] = "priority"; //resuming const char application_commands[] = "applicationCommands"; @@ -229,6 +234,8 @@ const char application_subscribtions[] = "subscribtions"; const char application_files[] = "applicationFiles"; const char application_show[] = "applicationShow"; const char resumption[] = "resumption"; +const char resume_vr_grammars[] = "resumeVrGrammars"; + const char ign_off_count[] = "ign_off_count"; const char connection_info[] = "connection_info"; const char is_download_complete[] = "is_download_complete"; @@ -236,6 +243,7 @@ const char is_download_complete[] = "is_download_complete"; const char hash_id[] = "hashID"; const char time_stamp[] = "timeStamp"; const char manual_text_entry[] = "manualTextEntry"; +const char image_type_supported[] = "imageTypeSupported"; } // namespace strings namespace mobile_notification { diff --git a/src/components/application_manager/include/application_manager/time_metric_observer.h b/src/components/application_manager/include/application_manager/time_metric_observer.h new file mode 100644 index 0000000..780401f --- /dev/null +++ b/src/components/application_manager/include/application_manager/time_metric_observer.h @@ -0,0 +1,59 @@ +/** + * 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_TIME_METRIC_OBSERVER_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_TIME_METRIC_OBSERVER_H_ + + +#include "smart_objects/smart_object.h" +#include "application_manager/smart_object_keys.h" +#include "json/json.h" +#include "utils/shared_ptr.h" +#include "utils/date_time.h" + +namespace smart_objects = NsSmartDeviceLink::NsSmartObjects; +namespace application_manager { + +class AMMetricObserver { + public: + struct MessageMetric { + TimevalStruct begin; + TimevalStruct end; + utils::SharedPtr message; + }; + typedef utils::SharedPtr MessageMetricSharedPtr; + + virtual void OnMessage(MessageMetricSharedPtr) = 0; + virtual ~AMMetricObserver(){} +}; +} // application_manager +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_USAGE_STATISTICS_H_ diff --git a/src/components/application_manager/src/application_impl.cc b/src/components/application_manager/src/application_impl.cc index bde3f71..d2a9d62 100644 --- a/src/components/application_manager/src/application_impl.cc +++ b/src/components/application_manager/src/application_impl.cc @@ -36,13 +36,13 @@ #include "application_manager/message_helper.h" #include "config_profile/profile.h" #include "utils/file_system.h" +#include "utils/logger.h" -namespace { -log4cxx::LoggerPtr g_logger = log4cxx::Logger::getLogger("ApplicationManager"); -} namespace application_manager { +CREATE_LOGGERPTR_GLOBAL(logger_, "ApplicationManager") + ApplicationImpl::ApplicationImpl( uint32_t application_id, const std::string& global_app_id, @@ -65,6 +65,9 @@ ApplicationImpl::ApplicationImpl( grammar_id_(0), usage_report_(global_app_id, statistics_manager), protocol_version_(ProtocolVersion::kV3) { + + // subscribe application to custom button by default + SubscribeToButton(mobile_apis::ButtonName::CUSTOM_BUTTON); } ApplicationImpl::~ApplicationImpl() { @@ -76,7 +79,11 @@ ApplicationImpl::~ApplicationImpl() { subscribed_buttons_.clear(); subscribed_vehicle_info_.clear(); - + if (is_perform_interaction_active()) { + set_perform_interaction_active(0); + set_perform_interaction_mode(-1); + DeletePerformInteractionChoiceSetMap(); + } CleanupFiles(); } @@ -127,10 +134,18 @@ const Version& ApplicationImpl::version() const { return version_; } +void ApplicationImpl::set_hmi_application_id(uint32_t hmi_app_id) { + hmi_app_id_ = hmi_app_id; +} + const std::string& ApplicationImpl::name() const { return app_name_; } +const std::string ApplicationImpl::folder_name() const { + return name() + mobile_app_id()->asString(); +} + bool ApplicationImpl::is_media_application() const { return is_media_; } @@ -230,7 +245,7 @@ void ApplicationImpl::set_audio_streaming_state( const mobile_api::AudioStreamingState::eType& state) { if (!is_media_application() && state != mobile_api::AudioStreamingState::NOT_AUDIBLE) { - LOG4CXX_WARN(g_logger, "Trying to set audio streaming state" + LOG4CXX_WARN(logger_, "Trying to set audio streaming state" " for non-media application to different from NOT_AUDIBLE"); return; } @@ -238,8 +253,7 @@ void ApplicationImpl::set_audio_streaming_state( } bool ApplicationImpl::set_app_icon_path(const std::string& path) { - std::string file_name = path.substr(path.find_last_of("/") + 1); - if (app_files_.find(file_name) != app_files_.end()) { + if (app_files_.find(path) != app_files_.end()) { app_icon_path_ = path; return true; } @@ -266,17 +280,17 @@ bool ApplicationImpl::has_been_activated() const { return has_been_activated_; } -void ApplicationImpl::set_protocol_version(ProtocolVersion protocol_version) { +void ApplicationImpl::set_protocol_version( + const ProtocolVersion& protocol_version) { protocol_version_ = protocol_version; } -ProtocolVersion ApplicationImpl::protocol_version() { +ProtocolVersion ApplicationImpl::protocol_version() const { return protocol_version_; } bool ApplicationImpl::AddFile(AppFile& file) { if (app_files_.count(file.file_name) == 0) { - app_files_[file.file_name] = file; return true; } @@ -375,7 +389,7 @@ uint32_t ApplicationImpl::UpdateHash() { void ApplicationImpl::CleanupFiles() { std::string directory_name = profile::Profile::instance()->app_storage_folder(); - directory_name += "/" + name(); + directory_name += "/" + folder_name(); if (file_system::DirectoryExists(directory_name)) { std::vector files = file_system::ListFiles( @@ -384,13 +398,12 @@ void ApplicationImpl::CleanupFiles() { for (std::vector::const_iterator it = files.begin(); it != files.end(); ++it) { - app_files_it = app_files_.find(*it); - + std::string file_name = directory_name; + file_name += "/"; + file_name += *it; + app_files_it = app_files_.find(file_name); if ((app_files_it == app_files_.end()) || (!app_files_it->second.is_persistent)) { - std::string file_name = directory_name; - file_name += "/"; - file_name += *it; file_system::DeleteFile(file_name); } } diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index c3c0332..c36f956 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -29,9 +29,6 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ - -#include "application_manager/application_manager_impl.h" - #include #include #include @@ -52,13 +49,11 @@ #include "utils/file_system.h" #include "application_manager/application_impl.h" #include "usage_statistics/counter.h" +#include namespace application_manager { -#ifdef ENABLE_LOG -log4cxx::LoggerPtr ApplicationManagerImpl::logger_ = log4cxx::LoggerPtr( - log4cxx::Logger::getLogger("ApplicationManager")); -#endif // ENABLE_LOG +CREATE_LOGGERPTR_GLOBAL(logger_, "ApplicationManager") uint32_t ApplicationManagerImpl::corelation_id_ = 0; const uint32_t ApplicationManagerImpl::max_corelation_id_ = UINT_MAX; @@ -143,13 +138,43 @@ bool ApplicationManagerImpl::Stop() { ApplicationSharedPtr ApplicationManagerImpl::application(int32_t app_id) const { sync_primitives::AutoLock lock(applications_list_lock_); - std::map::const_iterator it = - applications_.find(app_id); - if (applications_.end() != it) { - return it->second; - } else { - return ApplicationSharedPtr(); + std::set::const_iterator it = + application_list_.begin(); + for (; it != application_list_.end(); ++it) { + if ((*it)->app_id() == app_id) { + return (*it); + } } + return ApplicationSharedPtr(); +} + +ApplicationSharedPtr ApplicationManagerImpl::application_by_hmi_app( + int32_t hmi_app_id) const { + sync_primitives::AutoLock lock(applications_list_lock_); + + std::set::const_iterator it = + application_list_.begin(); + for (; it != application_list_.end(); ++it) { + if ((*it)->hmi_app_id() == hmi_app_id) { + return (*it); + } + } + return ApplicationSharedPtr(); +} + +ApplicationSharedPtr ApplicationManagerImpl::application_by_policy_id( + const std::string& policy_app_id) const { + sync_primitives::AutoLock lock(applications_list_lock_); + + std::vector result; + for (std::set::iterator it = application_list_.begin(); + application_list_.end() != it; + ++it) { + if (policy_app_id.compare((*it)->mobile_app_id()->asString()) == 0) { + return *it; + } + } + return ApplicationSharedPtr(); } ApplicationSharedPtr ApplicationManagerImpl::active_application() const { @@ -211,20 +236,6 @@ std::vector ApplicationManagerImpl::applications_with_navi return result; } -ApplicationSharedPtr ApplicationManagerImpl::application_by_policy_id( - const std::string& policy_app_id) const { - sync_primitives::AutoLock lock(applications_list_lock_); - - std::map::const_iterator it = applications_ - .begin(); - for (; applications_.end() != it; ++it) { - if (policy_app_id.compare(it->second->mobile_app_id()->asString()) == 0) { - return it->second; - } - } - return ApplicationSharedPtr(); -} - ApplicationSharedPtr ApplicationManagerImpl::RegisterApplication( const utils::SharedPtr& request_for_registration) { @@ -273,11 +284,11 @@ ApplicationSharedPtr ApplicationManagerImpl::RegisterApplication( const std::string mobile_app_id = params[strings::app_id].asString(); ApplicationSharedPtr application( - new ApplicationImpl(app_id, mobile_app_id, policy_manager_)); + new ApplicationImpl(app_id, mobile_app_id, policy_manager_)); if (!application) { usage_statistics::AppCounter count_of_rejections_sync_out_of_memory( - policy_manager_, mobile_app_id, - usage_statistics::REJECTIONS_SYNC_OUT_OF_MEMORY); + policy_manager_, mobile_app_id, + usage_statistics::REJECTIONS_SYNC_OUT_OF_MEMORY); ++count_of_rejections_sync_out_of_memory; utils::SharedPtr response( @@ -296,18 +307,18 @@ ApplicationSharedPtr ApplicationManagerImpl::RegisterApplication( application->set_device(device_id); application->set_grammar_id(GenerateGrammarID()); mobile_api::Language::eType launguage_desired = - static_cast(params[strings::language_desired] - .asInt()); + static_cast(params[strings::language_desired] + .asInt()); application->set_language(launguage_desired); application->usage_report().RecordAppRegistrationVuiLanguage( - launguage_desired); + launguage_desired); mobile_api::Language::eType hmi_display_language_desired = - static_cast(params[strings::hmi_display_language_desired] - .asInt()); + static_cast(params[strings::hmi_display_language_desired] + .asInt()); application->set_ui_language(hmi_display_language_desired); application->usage_report().RecordAppRegistrationGuiLanguage( - hmi_display_language_desired); + hmi_display_language_desired); Version version; int32_t min_version = @@ -347,17 +358,13 @@ ApplicationSharedPtr ApplicationManagerImpl::RegisterApplication( application->set_mobile_app_id(message[strings::msg_params][strings::app_id]); application->set_protocol_version( - static_cast( - message[strings::params][strings::protocol_version].asInt())); + static_cast( + message[strings::params][strings::protocol_version].asInt())); sync_primitives::AutoLock lock(applications_list_lock_); - applications_.insert(std::pair(app_id, application)); application_list_.insert(application); - // TODO(PV): add asking user to allow application - // BasicCommunication_AllowApp - // application->set_app_allowed(result); return application; } @@ -508,41 +515,33 @@ void ApplicationManagerImpl::OnHMIStartedCooperation() { hmi_cooperating_ = true; LOG4CXX_INFO(logger_, "ApplicationManagerImpl::OnHMIStartedCooperation()"); - if (true == profile::Profile::instance()->launch_hmi()) { - utils::SharedPtr is_vr_ready( + utils::SharedPtr is_vr_ready( MessageHelper::CreateModuleInfoSO( - static_cast(hmi_apis::FunctionID::VR_IsReady))); - ManageHMICommand(is_vr_ready); + static_cast(hmi_apis::FunctionID::VR_IsReady))); + ManageHMICommand(is_vr_ready); - utils::SharedPtr is_tts_ready( + utils::SharedPtr is_tts_ready( MessageHelper::CreateModuleInfoSO(hmi_apis::FunctionID::TTS_IsReady)); - ManageHMICommand(is_tts_ready); + ManageHMICommand(is_tts_ready); - utils::SharedPtr is_ui_ready( + utils::SharedPtr is_ui_ready( MessageHelper::CreateModuleInfoSO(hmi_apis::FunctionID::UI_IsReady)); - ManageHMICommand(is_ui_ready); + ManageHMICommand(is_ui_ready); - utils::SharedPtr is_navi_ready( + utils::SharedPtr is_navi_ready( MessageHelper::CreateModuleInfoSO( - hmi_apis::FunctionID::Navigation_IsReady)); - ManageHMICommand(is_navi_ready); + hmi_apis::FunctionID::Navigation_IsReady)); + ManageHMICommand(is_navi_ready); - utils::SharedPtr is_ivi_ready( + utils::SharedPtr is_ivi_ready( MessageHelper::CreateModuleInfoSO( - hmi_apis::FunctionID::VehicleInfo_IsReady)); - ManageHMICommand(is_ivi_ready); + hmi_apis::FunctionID::VehicleInfo_IsReady)); + ManageHMICommand(is_ivi_ready); - utils::SharedPtr button_capabilities( + utils::SharedPtr button_capabilities( MessageHelper::CreateModuleInfoSO( - hmi_apis::FunctionID::Buttons_GetCapabilities)); - ManageHMICommand(button_capabilities); - } - - if (!connection_handler_) { - LOG4CXX_WARN(logger_, "Connection handler is not set."); - } else { - connection_handler_->StartTransportManager(); - } + hmi_apis::FunctionID::Buttons_GetCapabilities)); + ManageHMICommand(button_capabilities); } uint32_t ApplicationManagerImpl::GetNextHMICorrelationID() { @@ -746,7 +745,6 @@ void ApplicationManagerImpl::RemoveDevice( const connection_handler::DeviceHandle& device_handle) { } - bool ApplicationManagerImpl::IsAudioStreamingAllowed(uint32_t connection_key) const { ApplicationSharedPtr app = application(connection_key); @@ -787,6 +785,57 @@ uint32_t ApplicationManagerImpl::GenerateGrammarID() { return rand(); } +uint32_t ApplicationManagerImpl::GenerateNewHMIAppID() { + uint32_t hmi_app_id = rand(); + while (resume_ctrl_.IsHMIApplicationIdExist(hmi_app_id)) { + hmi_app_id = rand(); + } + + return hmi_app_id; +} + +void ApplicationManagerImpl::ReplaceMobileByHMIAppId( + smart_objects::SmartObject& message) { + + if (message.keyExists(strings::app_id)) { + ApplicationSharedPtr application = + ApplicationManagerImpl::instance()->application( + message[strings::app_id].asUInt()); + if (application.valid()) { + LOG4CXX_INFO(logger_, "ReplaceMobileByHMIAppId from " << message[strings::app_id].asInt() + << " to " << application->hmi_app_id()); + message[strings::app_id] = application->hmi_app_id(); + } + } else { + std::set keys = message.enumerate(); + std::set::const_iterator key = keys.begin(); + for (; key != keys.end(); ++key) { + ReplaceMobileByHMIAppId(message[*key]); + } + } +} + +void ApplicationManagerImpl::ReplaceHMIByMobileAppId( + smart_objects::SmartObject& message) { + if (message.keyExists(strings::app_id)) { + ApplicationSharedPtr application = + ApplicationManagerImpl::instance()->application_by_hmi_app( + message[strings::app_id].asUInt()); + + if (application.valid()) { + LOG4CXX_INFO(logger_, "ReplaceHMIByMobileAppId from " << message[strings::app_id].asInt() + << " to " << application->app_id()); + message[strings::app_id] = application->app_id(); + } + } else { + std::set keys = message.enumerate(); + std::set::const_iterator key = keys.begin(); + for (; key != keys.end(); ++key) { + ReplaceHMIByMobileAppId(message[*key]); + } + } +} + bool ApplicationManagerImpl::OnServiceStartedCallback( const connection_handler::DeviceHandle& device_handle, const int32_t& session_key, @@ -845,6 +894,7 @@ void ApplicationManagerImpl::OnServiceEndedCallback(const int32_t& session_key, LOG4CXX_INFO_EXT( logger_, "OnServiceEndedCallback " << type << " in session " << session_key); + switch (type) { case protocol_handler::kRpc: { LOG4CXX_INFO(logger_, "Remove application."); @@ -909,24 +959,24 @@ void ApplicationManagerImpl::SendMessageToMobile( } ApplicationSharedPtr app = application( - (*message)[strings::params][strings::connection_key].asUInt()); + (*message)[strings::params][strings::connection_key].asUInt()); if (!app) { - LOG4CXX_ERROR_EXT(logger_, - "No application associated with connection key"); - if ((*message)[strings::msg_params].keyExists(strings::result_code) && - ((*message)[strings::msg_params][strings::result_code] == - NsSmartDeviceLinkRPC::V1::Result::UNSUPPORTED_VERSION)) { - (*message)[strings::params][strings::protocol_version] = - ProtocolVersion::kV1; - } else { - (*message)[strings::params][strings::protocol_version] = - ProtocolVersion::kV3; - } - } else { - (*message)[strings::params][strings::protocol_version] = - app->protocol_version(); - } + LOG4CXX_ERROR_EXT(logger_, + "No application associated with connection key"); + if ((*message)[strings::msg_params].keyExists(strings::result_code) && + ((*message)[strings::msg_params][strings::result_code] == + NsSmartDeviceLinkRPC::V1::Result::UNSUPPORTED_VERSION)) { + (*message)[strings::params][strings::protocol_version] = + ProtocolVersion::kV1; + } else { + (*message)[strings::params][strings::protocol_version] = + ProtocolVersion::kV3; + } + } else { + (*message)[strings::params][strings::protocol_version] = + app->protocol_version(); + } mobile_so_factory().attachSchema(*message); LOG4CXX_INFO( @@ -1012,29 +1062,52 @@ bool ApplicationManagerImpl::ManageMobileCommand( mobile_so_factory().attachSchema(*message); if (policy_manager_) { + const std::string stringified_functionID = + MessageHelper::StringifiedFunctionID(function_id); LOG4CXX_INFO( logger_, - "Checking permissions for " << app->mobile_app_id()->asString() << " in " << MessageHelper::StringifiedHMILevel(app->hmi_level()) << " rpc " << MessageHelper::StringifiedFunctionID(function_id)); + "Checking permissions for " << app->mobile_app_id()->asString() << + " in " << MessageHelper::StringifiedHMILevel(app->hmi_level()) << + " rpc " << stringified_functionID); policy::CheckPermissionResult result = policy_manager_->CheckPermissions( app->mobile_app_id()->asString(), MessageHelper::StringifiedHMILevel(app->hmi_level()), - MessageHelper::StringifiedFunctionID(function_id)); + stringified_functionID); if (app->hmi_level() == mobile_apis::HMILevel::HMI_NONE && function_id != mobile_apis::FunctionID::UnregisterAppInterfaceID) { app->usage_report().RecordRpcSentInHMINone(); } - if (!result.hmi_level_permitted) { - LOG4CXX_WARN( - logger_, - "Request blocked by policies. " << "FunctionID: " << static_cast(function_id) << " Application HMI status: " << static_cast(app->hmi_level())); + if (result.hmi_level_permitted != policy::kRpcAllowed) { + LOG4CXX_WARN(logger_, "Request blocked by policies. " + << "Function: " + << stringified_functionID + << ", FunctionID: " + << static_cast(function_id) + << " Application HMI status: " + << static_cast(app->hmi_level())); app->usage_report().RecordPolicyRejectedRpcCall(); + mobile_apis::Result::eType check_result = + mobile_apis::Result::DISALLOWED; + + switch (result.hmi_level_permitted) { + case policy::kRpcDisallowed: + check_result = mobile_apis::Result::DISALLOWED; + break; + case policy::kRpcUserDisallowed: + check_result = mobile_apis::Result::USER_DISALLOWED; + break; + default: + check_result = mobile_apis::Result::INVALID_ENUM; + break; + } + smart_objects::SmartObject* response = MessageHelper::CreateBlockedByPoliciesResponse(function_id, - mobile_apis::Result::REJECTED, correlation_id, connection_key); + check_result, correlation_id, connection_key); ApplicationManagerImpl::instance()->SendMessageToMobile(response); return true; @@ -1225,7 +1298,8 @@ bool ApplicationManagerImpl::ConvertMessageToSO( || ((output.validate() != smart_objects::Errors::OK) && (output.validate() != smart_objects::Errors::UNEXPECTED_PARAMETER))) { - LOG4CXX_WARN(logger_, "Failed to parse string to smart object"); + LOG4CXX_WARN(logger_, "Failed to parse string to smart object :" + << message.json_message()); utils::SharedPtr response( MessageHelper::CreateNegativeResponse( message.connection_key(), message.function_id(), @@ -1240,7 +1314,7 @@ bool ApplicationManagerImpl::ConvertMessageToSO( output[strings::params][strings::connection_key] = message.connection_key(); output[strings::params][strings::protocol_version] = - message.protocol_version(); + message.protocol_version(); if (message.binary_data()) { output[strings::params][strings::binary_data] = *(message.binary_data()); @@ -1341,26 +1415,25 @@ bool ApplicationManagerImpl::ConvertSOtoMessage( std::string output_string; switch (message.getElement(jhs::S_PARAMS).getElement(jhs::S_PROTOCOL_TYPE) .asInt()) { - case 0: - { - if (message.getElement(jhs::S_PARAMS).getElement(jhs::S_PROTOCOL_VERSION).asInt() == 1) { - if (!formatters::CFormatterJsonSDLRPCv1::toString(message, - output_string)) { - LOG4CXX_WARN(logger_, "Failed to serialize smart object"); - return false; - } - output.set_protocol_version(application_manager::kV1); - } else { - if (!formatters::CFormatterJsonSDLRPCv2::toString(message, - output_string)) { - LOG4CXX_WARN(logger_, "Failed to serialize smart object"); - return false; - } - output.set_protocol_version( - static_cast( - message.getElement(jhs::S_PARAMS).getElement( - jhs::S_PROTOCOL_VERSION).asUInt())); + case 0: { + if (message.getElement(jhs::S_PARAMS).getElement(jhs::S_PROTOCOL_VERSION).asInt() == 1) { + if (!formatters::CFormatterJsonSDLRPCv1::toString(message, + output_string)) { + LOG4CXX_WARN(logger_, "Failed to serialize smart object"); + return false; + } + output.set_protocol_version(application_manager::kV1); + } else { + if (!formatters::CFormatterJsonSDLRPCv2::toString(message, + output_string)) { + LOG4CXX_WARN(logger_, "Failed to serialize smart object"); + return false; } + output.set_protocol_version( + static_cast( + message.getElement(jhs::S_PARAMS).getElement( + jhs::S_PROTOCOL_VERSION).asUInt())); + } break; } @@ -1423,6 +1496,8 @@ utils::SharedPtr ApplicationManagerImpl::ConvertRawMsgToMessage( DCHECK(message); utils::SharedPtr outgoing_message; + LOG4CXX_INFO(logger_, "Service type." << message->service_type()); + if (message->service_type() != protocol_handler::kRpc && message->service_type() != protocol_handler::kBulk) { @@ -1455,7 +1530,8 @@ utils::SharedPtr ApplicationManagerImpl::ConvertRawMsgToMessage( void ApplicationManagerImpl::ProcessMessageFromMobile( const utils::SharedPtr& message) { LOG4CXX_INFO(logger_, "ApplicationManagerImpl::ProcessMessageFromMobile()"); - + AMMetricObserver::MessageMetricSharedPtr metric(new AMMetricObserver::MessageMetric()); + metric->begin = date_time::DateTime::getCurrentTime(); utils::SharedPtr so_from_mobile( new smart_objects::SmartObject); @@ -1468,10 +1544,15 @@ void ApplicationManagerImpl::ProcessMessageFromMobile( LOG4CXX_ERROR(logger_, "Cannot create smart object from message"); return; } + metric->message = so_from_mobile; if (!ManageMobileCommand(so_from_mobile)) { LOG4CXX_ERROR(logger_, "Received command didn't run successfully"); } + metric->end = date_time::DateTime::getCurrentTime(); + if (metric_observer_) { + metric_observer_->OnMessage(metric); + } } void ApplicationManagerImpl::ProcessMessageFromHMI( @@ -1528,6 +1609,10 @@ HMICapabilities& ApplicationManagerImpl::hmi_capabilities() { return hmi_capabilities_; } +void ApplicationManagerImpl::SetTimeMetricObserver(AMMetricObserver* observer) { + metric_observer_ = observer; +} + void ApplicationManagerImpl::addNotification(const CommandSharedPtr& ptr) { notification_list_.push_back(ptr); } @@ -1588,14 +1673,14 @@ void ApplicationManagerImpl::HeadUnitReset( void ApplicationManagerImpl::UnregisterAllApplications() { LOG4CXX_INFO(logger_, "ApplicationManagerImpl::UnregisterAllApplications " << - unregister_reason_); + unregister_reason_); hmi_cooperating_ = false; std::set::iterator it = application_list_.begin(); while (it != application_list_.end()) { MessageHelper::SendOnAppInterfaceUnregisteredNotificationToMobile( - (*it)->app_id(), unregister_reason_); + (*it)->app_id(), unregister_reason_); UnregisterApplication((*it)->app_id(), mobile_apis::Result::INVALID_ENUM, true); @@ -1605,10 +1690,10 @@ void ApplicationManagerImpl::UnregisterAllApplications() { } void ApplicationManagerImpl::UnregisterApplication( - const uint32_t& app_id, mobile_apis::Result::eType reason, - bool is_resuming) { + const uint32_t& app_id, mobile_apis::Result::eType reason, + bool is_resuming) { LOG4CXX_INFO(logger_, - "ApplicationManagerImpl::UnregisterApplication " << app_id); + "ApplicationManagerImpl::UnregisterApplication " << app_id); switch (reason) { case mobile_apis::Result::DISALLOWED: @@ -1620,30 +1705,42 @@ void ApplicationManagerImpl::UnregisterApplication( break; } } + ApplicationSharedPtr app_to_remove; + { + sync_primitives::AutoLock lock(applications_list_lock_); - sync_primitives::AutoLock lock(applications_list_lock_); + std::set::const_iterator it = application_list_.begin(); + for (; it != application_list_.end(); ++it) { + if ((*it)->app_id() == app_id) { + app_to_remove = *it; + } + } + application_list_.erase(app_to_remove); + } - std::map::iterator it = applications_.find(app_id); - if (applications_.end() == it) { + if (!app_to_remove) { LOG4CXX_INFO(logger_, "Application is already unregistered."); return; } - ApplicationSharedPtr app_to_remove = it->second; + if (is_resuming) { resume_ctrl_.SaveApplication(app_to_remove); } + if (audio_pass_thru_active_) { // May be better to put this code in MessageHelper? end_audio_pass_thru(); StopAudioPassThru(app_id); MessageHelper::SendStopAudioPathThru(); } - MessageHelper::ResetGlobalproperties(it->second); - MessageHelper::SendOnAppUnregNotificationToHMI(it->second); - applications_.erase(it); - application_list_.erase(app_to_remove); + MessageHelper::SendOnAppUnregNotificationToHMI(app_to_remove); + request_ctrl_.terminateAppRequests(app_id); + // { + // sync_primitives::AutoLock lock(applications_list_lock_); + + // } return; } @@ -1705,7 +1802,6 @@ void ApplicationManagerImpl::Handle(const impl::MessageToHmi& message) { LOG4CXX_INFO(logger_, "Message from hmi given away."); } - void ApplicationManagerImpl::Mute(VRTTSSessionChanging changing_state) { mobile_apis::AudioStreamingState::eType state = hmi_capabilities_.attenuated_supported() @@ -1747,8 +1843,8 @@ void ApplicationManagerImpl::Unmute(VRTTSSessionChanging changing_state) { } mobile_apis::Result::eType ApplicationManagerImpl::SaveBinary( - const std::vector& binary_data, const std::string& file_path, - const std::string& file_name, const uint32_t offset) { + const std::vector& binary_data, const std::string& file_path, + const std::string& file_name, const uint32_t offset) { LOG4CXX_INFO(logger_, "SaveBinaryWithOffset binary_size = " << binary_data.size() << " offset = " << offset); @@ -1789,10 +1885,10 @@ mobile_apis::Result::eType ApplicationManagerImpl::SaveBinary( } uint32_t ApplicationManagerImpl::GetAvailableSpaceForApp( - const std::string& app_name) { + const std::string& app_name) { const uint32_t app_quota = profile::Profile::instance()->app_dir_quota(); std::string app_storage_path = - profile::Profile::instance()->app_storage_folder(); + profile::Profile::instance()->app_storage_folder(); app_storage_path += "/"; app_storage_path += app_name; @@ -1805,7 +1901,7 @@ uint32_t ApplicationManagerImpl::GetAvailableSpaceForApp( uint32_t current_app_quota = app_quota - size_of_directory; uint32_t available_disk_space = - file_system::GetAvailableDiskSpace(app_storage_path); + file_system::GetAvailableDiskSpace(app_storage_path); if (current_app_quota > available_disk_space) { return available_disk_space; diff --git a/src/components/application_manager/src/commands/command_impl.cc b/src/components/application_manager/src/commands/command_impl.cc index d59e1e3..bc87cd0 100644 --- a/src/components/application_manager/src/commands/command_impl.cc +++ b/src/components/application_manager/src/commands/command_impl.cc @@ -33,13 +33,9 @@ #include "application_manager/commands/command_impl.h" namespace application_manager { - namespace commands { -#ifdef ENABLE_LOG -log4cxx::LoggerPtr logger_ = log4cxx::LoggerPtr( - log4cxx::Logger::getLogger("Commands")); -#endif +CREATE_LOGGERPTR_LOCAL(CommandImpl::logger_, "Commands") const int32_t CommandImpl::hmi_protocol_type_ = 1; const int32_t CommandImpl::mobile_protocol_type_ = 0; @@ -65,5 +61,4 @@ void CommandImpl::Run() { } } // namespace commands - } // namespace application_manager 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 c45c2db..8bddd9e 100644 --- a/src/components/application_manager/src/commands/hmi/get_urls.cc +++ b/src/components/application_manager/src/commands/hmi/get_urls.cc @@ -60,7 +60,7 @@ void GetUrls::Run() { smart_objects::SmartObject(smart_objects::SmartType_Array); for (size_t i = 0; i < endpoints.size(); ++i) { object[strings::msg_params][hmi_response::urls][i][strings::url] = endpoints[i].url; - if ("default" != endpoints[i].app_id) { + if (policy::kDefaultId != endpoints[i].app_id) { object[strings::msg_params][hmi_response::urls][i][hmi_response::policy_app_id] = endpoints[i].app_id; } diff --git a/src/components/application_manager/src/commands/hmi/notification_from_hmi.cc b/src/components/application_manager/src/commands/hmi/notification_from_hmi.cc index b324e19..2b7ec13 100644 --- a/src/components/application_manager/src/commands/hmi/notification_from_hmi.cc +++ b/src/components/application_manager/src/commands/hmi/notification_from_hmi.cc @@ -40,6 +40,9 @@ namespace commands { NotificationFromHMI::NotificationFromHMI(const MessageSharedPtr& message) : CommandImpl(message) { + + // Replace HMI app id with Mobile connection id + ApplicationManagerImpl::instance()->ReplaceHMIByMobileAppId(*(message.get())); } NotificationFromHMI::~NotificationFromHMI() { diff --git a/src/components/application_manager/src/commands/hmi/notification_to_hmi.cc b/src/components/application_manager/src/commands/hmi/notification_to_hmi.cc index 51ab188..e4f8920 100644 --- a/src/components/application_manager/src/commands/hmi/notification_to_hmi.cc +++ b/src/components/application_manager/src/commands/hmi/notification_to_hmi.cc @@ -39,6 +39,9 @@ namespace commands { NotificationToHMI::NotificationToHMI(const MessageSharedPtr& message) : CommandImpl(message) { + + // Replace Mobile connection id with HMI app id + ApplicationManagerImpl::instance()->ReplaceMobileByHMIAppId(*(message.get())); } NotificationToHMI::~NotificationToHMI() { diff --git a/src/components/application_manager/src/commands/hmi/on_app_permission_consent_notification.cc b/src/components/application_manager/src/commands/hmi/on_app_permission_consent_notification.cc index 708766d..62d27cf 100644 --- a/src/components/application_manager/src/commands/hmi/on_app_permission_consent_notification.cc +++ b/src/components/application_manager/src/commands/hmi/on_app_permission_consent_notification.cc @@ -41,7 +41,7 @@ namespace application_manager { namespace commands { OnAppPermissionConsentNotification::OnAppPermissionConsentNotification(const MessageSharedPtr& message) - : NotificationFromHMI(message) { + : NotificationFromHMI(message) { } OnAppPermissionConsentNotification::~OnAppPermissionConsentNotification() { @@ -57,8 +57,8 @@ void OnAppPermissionConsentNotification::Run() { if (msg_params.keyExists(strings::app_id)) { uint32_t connection_key = msg_params[strings::app_id].asUInt(); ApplicationSharedPtr app = - application_manager::ApplicationManagerImpl::instance() - ->application(connection_key); + application_manager::ApplicationManagerImpl::instance() + ->application(connection_key); if (app.valid()) { permission_consent.policy_app_id = app->mobile_app_id()->asString(); @@ -75,18 +75,18 @@ void OnAppPermissionConsentNotification::Run() { smart_objects::SmartArray* user_consent = msg_params["consentedFunctions"].asArray(); - smart_objects::SmartArray::const_iterator it = user_consent->begin(); - smart_objects::SmartArray::const_iterator it_end = user_consent->end(); - for (; it != it_end; ++it) { - policy::FunctionalGroupPermission permissions; - permissions.group_id = (*it)["id"].asInt(); - permissions.group_alias = (*it)["name"].asString(); - if ((*it).keyExists("allowed")) { - permissions.state = (*it)["allowed"].asBool() ? policy::kAllowed : - policy::kDisallowed; - } else { - permissions.state = policy::kUndefined; - } + smart_objects::SmartArray::const_iterator it = user_consent->begin(); + smart_objects::SmartArray::const_iterator it_end = user_consent->end(); + for (; it != it_end; ++it) { + policy::FunctionalGroupPermission permissions; + permissions.group_id = (*it)["id"].asInt(); + permissions.group_alias = (*it)["name"].asString(); + if ((*it).keyExists("allowed")) { + permissions.state = (*it)["allowed"].asBool() ? policy::kGroupAllowed : + policy::kGroupDisallowed; + } else { + permissions.state = policy::kGroupUndefined; + } permission_consent.group_permissions.push_back(permissions); } diff --git a/src/components/application_manager/src/commands/hmi/on_device_state_changed_notification.cc b/src/components/application_manager/src/commands/hmi/on_device_state_changed_notification.cc new file mode 100644 index 0000000..8af2571 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/on_device_state_changed_notification.cc @@ -0,0 +1,70 @@ +/** + * Copyright (c) 2013, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include "application_manager/commands/hmi/on_device_state_changed_notification.h" +#include "application_manager/policies/policy_handler.h" +#include "application_manager/message_helper.h" +#include "interfaces/HMI_API.h" + +namespace application_manager { + +namespace commands { + +OnDeviceStateChangedNotification::OnDeviceStateChangedNotification( + const MessageSharedPtr& message) + : NotificationFromHMI(message) { +} + +OnDeviceStateChangedNotification::~OnDeviceStateChangedNotification() { +} + +void OnDeviceStateChangedNotification::Run() { + LOG4CXX_INFO(logger_, "OnDeviceStateChangedNotification::Run"); + + if ((*message_)[strings::msg_params]["deviceState"] + == hmi_apis::Common_DeviceState::UNPAIRED) { + std::string device_id = (*message_)[strings::msg_params]["deviceInternalId"] + .asString(); + if (device_id.empty()) { + if ((*message_)[strings::msg_params].keyExists("deviceId")) { + device_id = MessageHelper::GetDeviceMacAddressForHandle( + (*message_)[strings::msg_params]["deviceId"]["id"].asInt()); + } + } + policy::PolicyHandler::instance()->RemoveDevice(device_id); + } +} + +} // namespace commands + +} // namespace application_manager + diff --git a/src/components/application_manager/src/commands/hmi/on_exit_application_notification.cc b/src/components/application_manager/src/commands/hmi/on_exit_application_notification.cc index de4e29d..3aff6a9 100644 --- a/src/components/application_manager/src/commands/hmi/on_exit_application_notification.cc +++ b/src/components/application_manager/src/commands/hmi/on_exit_application_notification.cc @@ -59,6 +59,7 @@ void OnExitApplicationNotification::Run() { } app_impl->set_hmi_level(mobile_apis::HMILevel::HMI_NONE); app_impl->set_audio_streaming_state(mobile_apis::AudioStreamingState::NOT_AUDIBLE); + app_impl->set_system_context(mobile_api::SystemContext::SYSCTXT_MAIN); MessageHelper::SendHMIStatusNotification(*app_impl); } 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 3fcea69..1e517f3 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 @@ -55,7 +55,7 @@ void OnReceivedPolicyUpdate::Run() { LOG4CXX_ERROR(logger_, "Failed to read Update file."); return; } - policy::PolicyHandler::instance()->ReceiveMessageFromSDK(file_content); + policy::PolicyHandler::instance()->ReceiveMessageFromSDK(file_path, file_content); } } // namespace commands diff --git a/src/components/application_manager/src/commands/hmi/on_resume_audio_source_notification.cc b/src/components/application_manager/src/commands/hmi/on_resume_audio_source_notification.cc new file mode 100644 index 0000000..70868b8 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/on_resume_audio_source_notification.cc @@ -0,0 +1,56 @@ +/** + * 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. + */ + +#include "application_manager/commands/hmi/on_resume_audio_source_notification.h" +#include "interfaces/MOBILE_API.h" + +namespace application_manager { + +namespace commands { + +OnResumeAudioSourceNotification::OnResumeAudioSourceNotification( + const MessageSharedPtr& message) + : NotificationToHMI(message) { +} + +OnResumeAudioSourceNotification::~OnResumeAudioSourceNotification() { +} + +void OnResumeAudioSourceNotification::Run() { + LOG4CXX_INFO(logger_, "OnResumeAudioSourceNotification::Run"); + SendNotification(); +} + +} // namespace commands + +} // namespace application_manager + diff --git a/src/components/application_manager/src/commands/hmi/on_system_context_notification.cc b/src/components/application_manager/src/commands/hmi/on_system_context_notification.cc index dbfe338..9c245e0 100644 --- a/src/components/application_manager/src/commands/hmi/on_system_context_notification.cc +++ b/src/components/application_manager/src/commands/hmi/on_system_context_notification.cc @@ -60,6 +60,23 @@ void OnSystemContextNotification::Run() { // SDLAQ-CRS-833 implementation for (; app_list.end() != it; ++it) { + + // send notification for background app + if (((*message_)[strings::msg_params].keyExists(strings::app_id)) && + ((*it)->app_id() == + (*message_)[strings::msg_params][strings::app_id].asUInt())) { + + if ((mobile_api::SystemContext::SYSCTXT_ALERT == system_context) && + (mobile_api::HMILevel::HMI_BACKGROUND == (*it)->hmi_level())) { + if (system_context != (*it)->system_context()) { + (*it)->set_system_context(system_context); + MessageHelper::SendHMIStatusNotification((*(*it))); + } + // change system context for full app + system_context = mobile_api::SystemContext::SYSCTXT_HMI_OBSCURED; + } + } + if (mobile_api::HMILevel::HMI_FULL == (*it)->hmi_level() || mobile_api::HMILevel::HMI_LIMITED == (*it)->hmi_level()) { diff --git a/src/components/application_manager/src/commands/hmi/on_update_device_list.cc b/src/components/application_manager/src/commands/hmi/on_update_device_list.cc index 737e62c..a5b8474 100644 --- a/src/components/application_manager/src/commands/hmi/on_update_device_list.cc +++ b/src/components/application_manager/src/commands/hmi/on_update_device_list.cc @@ -50,3 +50,4 @@ void OnUpdateDeviceList::Run() { } // namespace commands } // namespace application_manager + 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 c30819d..7b7f740 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 @@ -31,6 +31,7 @@ */ #include "application_manager/commands/hmi/request_from_hmi.h" +#include "application_manager/application_manager_impl.h" namespace application_manager { @@ -38,6 +39,9 @@ namespace commands { RequestFromHMI::RequestFromHMI(const MessageSharedPtr& message) : CommandImpl(message) { + + // Replace HMI app id with Mobile connection id + ApplicationManagerImpl::instance()->ReplaceHMIByMobileAppId(*(message.get())); } RequestFromHMI::~RequestFromHMI() { diff --git a/src/components/application_manager/src/commands/hmi/request_to_hmi.cc b/src/components/application_manager/src/commands/hmi/request_to_hmi.cc index aa8c974..c0d4f60 100644 --- a/src/components/application_manager/src/commands/hmi/request_to_hmi.cc +++ b/src/components/application_manager/src/commands/hmi/request_to_hmi.cc @@ -39,6 +39,8 @@ namespace commands { RequestToHMI::RequestToHMI(const MessageSharedPtr& message) : CommandImpl(message) { + // Replace Mobile connection id with HMI app id + ApplicationManagerImpl::instance()->ReplaceMobileByHMIAppId(*(message.get())); } RequestToHMI::~RequestToHMI() { diff --git a/src/components/application_manager/src/commands/hmi/response_from_hmi.cc b/src/components/application_manager/src/commands/hmi/response_from_hmi.cc index bba5d7d..42bebb8 100644 --- a/src/components/application_manager/src/commands/hmi/response_from_hmi.cc +++ b/src/components/application_manager/src/commands/hmi/response_from_hmi.cc @@ -45,6 +45,9 @@ ResponseFromHMI::ResponseFromHMI(const MessageSharedPtr& message) (*message)[strings::msg_params][strings::info] = (*message)[strings::params][hmi_response::message]; } + + // Replace HMI app id with Mobile connection id + ApplicationManagerImpl::instance()->ReplaceHMIByMobileAppId(*(message.get())); } ResponseFromHMI::~ResponseFromHMI() { diff --git a/src/components/application_manager/src/commands/hmi/response_to_hmi.cc b/src/components/application_manager/src/commands/hmi/response_to_hmi.cc index 9e9cbe2..d189874 100644 --- a/src/components/application_manager/src/commands/hmi/response_to_hmi.cc +++ b/src/components/application_manager/src/commands/hmi/response_to_hmi.cc @@ -39,6 +39,8 @@ namespace commands { ResponseToHMI::ResponseToHMI(const MessageSharedPtr& message) : CommandImpl(message) { + // Replace Mobile connection id with HMI app id + ApplicationManagerImpl::instance()->ReplaceMobileByHMIAppId(*(message.get())); } ResponseToHMI::~ResponseToHMI() { diff --git a/src/components/application_manager/src/commands/hmi/sdl_policy_update_response.cc~HEAD b/src/components/application_manager/src/commands/hmi/sdl_policy_update_response.cc~HEAD new file mode 100644 index 0000000..a3db3a9 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/sdl_policy_update_response.cc~HEAD @@ -0,0 +1,51 @@ +/** + * Copyright (c) 2013, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include "application_manager/commands/hmi/sdl_policy_update_response.h" + +namespace application_manager { + +namespace commands { +SDLPolicyUpdateResponse::SDLPolicyUpdateResponse( + const MessageSharedPtr& message): ResponseFromHMI(message) { +} + +SDLPolicyUpdateResponse::~SDLPolicyUpdateResponse() { +} + +void SDLPolicyUpdateResponse::Run() { + LOG4CXX_INFO(logger_, "SDLPolicyUpdateResponse::Run"); + // TODO(PV): add some logic here +} +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/hmi/sdl_policy_update_response.cc~develop b/src/components/application_manager/src/commands/hmi/sdl_policy_update_response.cc~develop new file mode 100644 index 0000000..a3db3a9 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/sdl_policy_update_response.cc~develop @@ -0,0 +1,51 @@ +/** + * Copyright (c) 2013, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include "application_manager/commands/hmi/sdl_policy_update_response.h" + +namespace application_manager { + +namespace commands { +SDLPolicyUpdateResponse::SDLPolicyUpdateResponse( + const MessageSharedPtr& message): ResponseFromHMI(message) { +} + +SDLPolicyUpdateResponse::~SDLPolicyUpdateResponse() { +} + +void SDLPolicyUpdateResponse::Run() { + LOG4CXX_INFO(logger_, "SDLPolicyUpdateResponse::Run"); + // TODO(PV): add some logic here +} +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/hmi/update_app_list_request.cc b/src/components/application_manager/src/commands/hmi/update_app_list_request.cc index eaa09b4..955f4b1 100644 --- a/src/components/application_manager/src/commands/hmi/update_app_list_request.cc +++ b/src/components/application_manager/src/commands/hmi/update_app_list_request.cc @@ -53,3 +53,4 @@ void UpdateAppListRequest::Run() { } // namespace application_manager + diff --git a/src/components/application_manager/src/commands/hmi/update_app_list_response.cc b/src/components/application_manager/src/commands/hmi/update_app_list_response.cc index 7c8537b..d5db0b4 100644 --- a/src/components/application_manager/src/commands/hmi/update_app_list_response.cc +++ b/src/components/application_manager/src/commands/hmi/update_app_list_response.cc @@ -52,3 +52,5 @@ void UpdateAppListResponse::Run() { } // namespace commands } // namespace application_manager + + diff --git a/src/components/application_manager/src/commands/hmi/vr_perform_interaction_response.cc~HEAD b/src/components/application_manager/src/commands/hmi/vr_perform_interaction_response.cc~HEAD new file mode 100644 index 0000000..fea09b9 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/vr_perform_interaction_response.cc~HEAD @@ -0,0 +1,56 @@ +/** + * Copyright (c) 2013, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ +#include "application_manager/commands/hmi/vr_perform_interaction_response.h" +#include "application_manager/event_engine/event.h" + +namespace application_manager { + +namespace commands { + +VRPerformInteractionResponse::VRPerformInteractionResponse( + const MessageSharedPtr& message) + : ResponseFromHMI(message) { +} + +VRPerformInteractionResponse::~VRPerformInteractionResponse() { +} + +void VRPerformInteractionResponse::Run() { + LOG4CXX_INFO(logger_, "VRPerformInteractionResponse::Run"); + event_engine::Event event(hmi_apis::FunctionID::VR_PerformInteraction); + event.set_smart_object(*message_); + event.raise(); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/hmi/vr_perform_interaction_response.cc~develop b/src/components/application_manager/src/commands/hmi/vr_perform_interaction_response.cc~develop new file mode 100644 index 0000000..fea09b9 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/vr_perform_interaction_response.cc~develop @@ -0,0 +1,56 @@ +/** + * Copyright (c) 2013, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ +#include "application_manager/commands/hmi/vr_perform_interaction_response.h" +#include "application_manager/event_engine/event.h" + +namespace application_manager { + +namespace commands { + +VRPerformInteractionResponse::VRPerformInteractionResponse( + const MessageSharedPtr& message) + : ResponseFromHMI(message) { +} + +VRPerformInteractionResponse::~VRPerformInteractionResponse() { +} + +void VRPerformInteractionResponse::Run() { + LOG4CXX_INFO(logger_, "VRPerformInteractionResponse::Run"); + event_engine::Event event(hmi_apis::FunctionID::VR_PerformInteraction); + event.set_smart_object(*message_); + event.raise(); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/mobile/add_command_request.cc b/src/components/application_manager/src/commands/mobile/add_command_request.cc index 3fd9c50..1a7a15b 100644 --- a/src/components/application_manager/src/commands/mobile/add_command_request.cc +++ b/src/components/application_manager/src/commands/mobile/add_command_request.cc @@ -67,15 +67,18 @@ void AddCommandRequest::Run() { return; } - mobile_apis::Result::eType verification_result = - MessageHelper::VerifyImageFiles((*message_)[strings::msg_params], app); - - if (mobile_apis::Result::SUCCESS != verification_result) { - LOG4CXX_ERROR_EXT( - logger_, - "MessageHelper::VerifyImageFiles return " << verification_result); - SendResponse(false, verification_result); - return; + if ((*message_)[strings::msg_params].keyExists(strings::cmd_icon)) { + mobile_apis::Result::eType verification_result = + MessageHelper::VerifyImage((*message_)[strings::msg_params] + [strings::cmd_icon], app); + + if (mobile_apis::Result::SUCCESS != verification_result) { + LOG4CXX_ERROR_EXT( + logger_, + "MessageHelper::VerifyImage return " << verification_result); + SendResponse(false, verification_result); + return; + } } if (!((*message_)[strings::msg_params].keyExists(strings::cmd_id))) { @@ -345,8 +348,10 @@ void AddCommandRequest::on_event(const event_engine::Event& event) { bool result = ((hmi_apis::Common_Result::SUCCESS == ui_result_) && (hmi_apis::Common_Result::SUCCESS == vr_result_)) || ((hmi_apis::Common_Result::SUCCESS == ui_result_) && - (hmi_apis::Common_Result::INVALID_ENUM == vr_result_)) || - ((hmi_apis::Common_Result::INVALID_ENUM == ui_result_) && + (hmi_apis::Common_Result::INVALID_ENUM == vr_result_ || + hmi_apis::Common_Result::UNSUPPORTED_RESOURCE == vr_result_)) || + ((hmi_apis::Common_Result::INVALID_ENUM == ui_result_ || + hmi_apis::Common_Result::UNSUPPORTED_RESOURCE == ui_result_ ) && (hmi_apis::Common_Result::SUCCESS == vr_result_)); if (!result && (hmi_apis::Common_Result::REJECTED == ui_result_)) { diff --git a/src/components/application_manager/src/commands/mobile/alert_maneuver_request.cc b/src/components/application_manager/src/commands/mobile/alert_maneuver_request.cc index 4707d46..77169d0 100644 --- a/src/components/application_manager/src/commands/mobile/alert_maneuver_request.cc +++ b/src/components/application_manager/src/commands/mobile/alert_maneuver_request.cc @@ -42,7 +42,6 @@ namespace commands { AlertManeuverRequest::AlertManeuverRequest(const MessageSharedPtr& message) : CommandRequestImpl(message), - result_(mobile_apis::Result::INVALID_ENUM), tts_speak_result_code_(mobile_apis::Result::INVALID_ENUM), navi_alert_maneuver_result_code_(mobile_apis::Result::INVALID_ENUM) { } @@ -73,15 +72,9 @@ void AlertManeuverRequest::Run() { MessageHelper::ProcessSoftButtons((*message_)[strings::msg_params], app); if (mobile_apis::Result::SUCCESS != processing_result) { - if (mobile_apis::Result::INVALID_DATA == processing_result) { - LOG4CXX_ERROR(logger_, "Wrong soft buttons parameters!"); - SendResponse(false, processing_result); - return; - } - if (mobile_apis::Result::UNSUPPORTED_RESOURCE == processing_result) { - LOG4CXX_ERROR(logger_, "UNSUPPORTED_RESOURCE!"); - result_ = processing_result; - } + LOG4CXX_ERROR(logger_, "Wrong soft buttons parameters!"); + SendResponse(false, processing_result); + return; } // Checking parameters and how many HMI requests should be sent @@ -159,13 +152,16 @@ void AlertManeuverRequest::on_event(const event_engine::Event& event) { if (pending_requests_.IsFinal(event_id)) { bool result = ((hmi_apis::Common_Result::SUCCESS == - static_cast(tts_speak_result_code_)) && - (hmi_apis::Common_Result::SUCCESS == - static_cast(navi_alert_maneuver_result_code_))) || - ((hmi_apis::Common_Result::INVALID_ENUM == - static_cast(tts_speak_result_code_)) && - (hmi_apis::Common_Result::SUCCESS == - static_cast(navi_alert_maneuver_result_code_))); + static_cast(tts_speak_result_code_) || + hmi_apis::Common_Result::UNSUPPORTED_RESOURCE == + static_cast(tts_speak_result_code_) || + (hmi_apis::Common_Result::INVALID_ENUM == + static_cast(tts_speak_result_code_))) && + (hmi_apis::Common_Result::SUCCESS == + static_cast(navi_alert_maneuver_result_code_))) || + (hmi_apis::Common_Result::SUCCESS == static_cast( + tts_speak_result_code_) && hmi_apis::Common_Result::UNSUPPORTED_RESOURCE == + static_cast(navi_alert_maneuver_result_code_)); mobile_apis::Result::eType result_code = static_cast(std::max(tts_speak_result_code_, @@ -173,15 +169,11 @@ void AlertManeuverRequest::on_event(const event_engine::Event& event) { const char* return_info = NULL; - if (result) { - if (mobile_apis::Result::INVALID_ENUM != result_) { - result_code = result_; - } else if (hmi_apis::Common_Result::UNSUPPORTED_RESOURCE == - static_cast(result_code)) { - result_code = mobile_apis::Result::WARNINGS; - return_info = - std::string("Unsupported phoneme type sent in a prompt").c_str(); - } + if (result && hmi_apis::Common_Result::UNSUPPORTED_RESOURCE == + static_cast(tts_speak_result_code_)) { + result_code = mobile_apis::Result::WARNINGS; + return_info = + std::string("Unsupported phoneme type sent in a prompt").c_str(); } SendResponse(result, result_code, return_info, diff --git a/src/components/application_manager/src/commands/mobile/alert_request.cc b/src/components/application_manager/src/commands/mobile/alert_request.cc index 3201669..0169162 100644 --- a/src/components/application_manager/src/commands/mobile/alert_request.cc +++ b/src/components/application_manager/src/commands/mobile/alert_request.cc @@ -51,7 +51,7 @@ AlertRequest::AlertRequest(const MessageSharedPtr& message) awaiting_tts_stop_speaking_response_(false), response_success_(false), flag_other_component_sent_(false), - response_result_(mobile_apis::Result::SUCCESS), + response_result_(mobile_apis::Result::INVALID_ENUM), tts_speak_response_(mobile_apis::Result::INVALID_ENUM) { subscribe_on_event(hmi_apis::FunctionID::UI_OnResetTimeout); } @@ -124,10 +124,9 @@ void AlertRequest::on_event(const event_engine::Event& event) { static_cast( message[strings::params][hmi_response::code].asInt()); // Mobile Alert request is successful when UI_Alert is successful - response_success_ = mobile_apis::Result::SUCCESS == result_code; - if (!response_success_) { - response_result_ = result_code; - } + response_success_ = (mobile_apis::Result::SUCCESS == result_code || + mobile_apis::Result::UNSUPPORTED_RESOURCE == result_code); + response_result_ = result_code; response_params_ = message[strings::msg_params]; break; } @@ -153,18 +152,20 @@ void AlertRequest::on_event(const event_engine::Event& event) { if (!HasHmiResponsesToWait()) { std::string response_info(""); if ((mobile_apis::Result::UNSUPPORTED_RESOURCE == tts_speak_response_) && - (!flag_other_component_sent_) && response_success_) { + (!flag_other_component_sent_) && (mobile_apis::Result::SUCCESS == + response_result_)) { response_success_ = false; response_result_ = mobile_apis::Result::WARNINGS; response_info = "Unsupported phoneme type sent in a prompt"; } else if ((mobile_apis::Result::UNSUPPORTED_RESOURCE == tts_speak_response_) && (mobile_apis::Result::UNSUPPORTED_RESOURCE == - response_result_) && response_success_) { + response_result_)) { response_result_ = mobile_apis::Result::WARNINGS; response_info = "Unsupported phoneme type sent in a prompt and " "unsupported image sent in soft buttons"; } else if ((mobile_apis::Result::UNSUPPORTED_RESOURCE == - tts_speak_response_) && response_success_) { + tts_speak_response_) && (mobile_apis::Result::SUCCESS == + response_result_)) { response_result_ = mobile_apis::Result::WARNINGS; response_info = "Unsupported phoneme type sent in a prompt"; } @@ -187,15 +188,9 @@ bool AlertRequest::Validate(uint32_t app_id) { MessageHelper::ProcessSoftButtons((*message_)[strings::msg_params], app); if (mobile_apis::Result::SUCCESS != processing_result) { - if (mobile_apis::Result::INVALID_DATA == processing_result) { - LOG4CXX_ERROR(logger_, "INVALID_DATA!"); - SendResponse(false, processing_result); - return false; - } - if (mobile_apis::Result::UNSUPPORTED_RESOURCE == processing_result) { - LOG4CXX_ERROR(logger_, "UNSUPPORTED_RESOURCE!"); - response_result_ = processing_result; - } + LOG4CXX_ERROR(logger_, "INVALID_DATA!"); + SendResponse(false, processing_result); + return false; } // check if mandatory params(alertText1 and TTSChunk) specified diff --git a/src/components/application_manager/src/commands/mobile/create_interaction_choice_set_request.cc b/src/components/application_manager/src/commands/mobile/create_interaction_choice_set_request.cc index d43834d..faaf578 100644 --- a/src/components/application_manager/src/commands/mobile/create_interaction_choice_set_request.cc +++ b/src/components/application_manager/src/commands/mobile/create_interaction_choice_set_request.cc @@ -63,20 +63,30 @@ void CreateInteractionChoiceSetRequest::Run() { SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); return; } - - mobile_apis::Result::eType verification_result = - MessageHelper::VerifyImageFiles((*message_)[strings::msg_params], app); - - mobile_apis::Result::eType result_ = mobile_apis::Result::SUCCESS; - if (mobile_apis::Result::SUCCESS != verification_result) { - if (mobile_apis::Result::INVALID_DATA == verification_result) { - LOG4CXX_ERROR(logger_, "VerifyImageFiles INVALID_DATA!"); - SendResponse(false, verification_result); - return; + for (uint32_t i = 0; + i < (*message_)[strings::msg_params][strings::choice_set].length(); + ++i) { + mobile_apis::Result::eType verification_result_image = + mobile_apis::Result::SUCCESS; + mobile_apis::Result::eType verification_result_secondary_image = + mobile_apis::Result::SUCCESS; + if ((*message_)[strings::msg_params] + [strings::choice_set][i].keyExists(strings::image)) { + verification_result_image = MessageHelper::VerifyImage( + (*message_)[strings::msg_params][strings::choice_set] + [i][strings::image], app); } - if (mobile_apis::Result::UNSUPPORTED_RESOURCE == verification_result) { - LOG4CXX_ERROR(logger_, "VerifyImageFiles UNSUPPORTED_RESOURCE!"); - result_ = verification_result; + if ((*message_)[strings::msg_params] + [strings::choice_set][i].keyExists(strings::secondary_image)) { + verification_result_secondary_image = MessageHelper::VerifyImage( + (*message_)[strings::msg_params][strings::choice_set] + [i][strings::secondary_image], app); + } + if (verification_result_image == mobile_apis::Result::INVALID_DATA || + verification_result_secondary_image == mobile_apis::Result::INVALID_DATA) { + LOG4CXX_ERROR(logger_, "VerifyImage INVALID_DATA!"); + SendResponse(false, mobile_apis::Result::INVALID_DATA); + return; } } @@ -98,7 +108,7 @@ void CreateInteractionChoiceSetRequest::Run() { (*message_)[strings::msg_params][strings::grammar_id] = grammar_id; app->AddChoiceSet(choice_set_id, (*message_)[strings::msg_params]); SendVRAddCommandRequest(app); - SendResponse(true, result_); + SendResponse(true, mobile_apis::Result::SUCCESS); app->UpdateHash(); } diff --git a/src/components/application_manager/src/commands/mobile/delete_file_request.cc b/src/components/application_manager/src/commands/mobile/delete_file_request.cc index 62034fb..ca5a439 100644 --- a/src/components/application_manager/src/commands/mobile/delete_file_request.cc +++ b/src/components/application_manager/src/commands/mobile/delete_file_request.cc @@ -75,18 +75,18 @@ void DeleteFileRequest::Run() { std::string full_file_path = profile::Profile::instance()->app_storage_folder() + "/"; - full_file_path += application->name(); + full_file_path += application->folder_name(); full_file_path += "/"; full_file_path += sync_file_name; if (file_system::FileExists(full_file_path)) { if (file_system::DeleteFile(full_file_path)) { - const AppFile* file = application->GetFile(sync_file_name); + const AppFile* file = application->GetFile(full_file_path); if (file) { SendFileRemovedNotification(file); } - application->DeleteFile(sync_file_name); + application->DeleteFile(full_file_path); application->increment_delete_file_in_none_count(); SendResponse(true, mobile_apis::Result::SUCCESS); } else { @@ -97,7 +97,8 @@ void DeleteFileRequest::Run() { } } -void DeleteFileRequest::SendFileRemovedNotification(const AppFile* file) const { +void DeleteFileRequest::SendFileRemovedNotification( + const AppFile* file) const { smart_objects::SmartObject msg_params = smart_objects::SmartObject( smart_objects::SmartType_Map); diff --git a/src/components/application_manager/src/commands/mobile/encoded_sync_pdata_request.cc b/src/components/application_manager/src/commands/mobile/encoded_sync_pdata_request.cc index b75b144..f523a46 100644 --- a/src/components/application_manager/src/commands/mobile/encoded_sync_pdata_request.cc +++ b/src/components/application_manager/src/commands/mobile/encoded_sync_pdata_request.cc @@ -46,7 +46,7 @@ namespace commands { const std::string EncodedSyncPDataRequest::TEMPORARY_HARDCODED_FILENAME = "policy_sync_data.dat"; const std::string EncodedSyncPDataRequest::TEMPORARY_HARDCODED_FOLDERNAME = - profile::Profile::instance()->app_storage_folder() + "/policies"; + "policies"; EncodedSyncPDataRequest::EncodedSyncPDataRequest( const MessageSharedPtr& message) @@ -88,6 +88,10 @@ void EncodedSyncPDataRequest::Run() { const std::vector file_data(string_pdata.begin(), string_pdata.end()); + std::string path = + profile::Profile::instance()->app_storage_folder() + "/"; + path += TEMPORARY_HARDCODED_FOLDERNAME; + std::string file_path = file_system::CreateDirectory(TEMPORARY_HARDCODED_FOLDERNAME); diff --git a/src/components/application_manager/src/commands/mobile/encoded_sync_pdata_response.cc b/src/components/application_manager/src/commands/mobile/encoded_sync_pdata_response.cc index 0c738bf..f537f20 100644 --- a/src/components/application_manager/src/commands/mobile/encoded_sync_pdata_response.cc +++ b/src/components/application_manager/src/commands/mobile/encoded_sync_pdata_response.cc @@ -34,7 +34,6 @@ #include "application_manager/commands/mobile/encoded_sync_pdata_response.h" namespace application_manager { - namespace commands { EncodedSyncPDataResponse::EncodedSyncPDataResponse( @@ -59,7 +58,5 @@ void EncodedSyncPDataResponse::Run() { SendResponse(true); } - } // namespace commands - } // namespace application_manager diff --git a/src/components/application_manager/src/commands/mobile/on_app_interface_unregistered_notification.cc b/src/components/application_manager/src/commands/mobile/on_app_interface_unregistered_notification.cc index 6063c8c..ebd0d6a 100644 --- a/src/components/application_manager/src/commands/mobile/on_app_interface_unregistered_notification.cc +++ b/src/components/application_manager/src/commands/mobile/on_app_interface_unregistered_notification.cc @@ -36,7 +36,6 @@ #include "interfaces/MOBILE_API.h" namespace application_manager { - namespace commands { OnAppInterfaceUnregisteredNotification::OnAppInterfaceUnregisteredNotification( @@ -52,7 +51,5 @@ void OnAppInterfaceUnregisteredNotification::Run() { SendNotification(); } - } // namespace commands - } // namespace application_manager diff --git a/src/components/application_manager/src/commands/mobile/on_audio_pass_thru_notification.cc b/src/components/application_manager/src/commands/mobile/on_audio_pass_thru_notification.cc index dd000ca..2515f59 100644 --- a/src/components/application_manager/src/commands/mobile/on_audio_pass_thru_notification.cc +++ b/src/components/application_manager/src/commands/mobile/on_audio_pass_thru_notification.cc @@ -34,7 +34,6 @@ #include "application_manager/commands/mobile/on_audio_pass_thru_notification.h" namespace application_manager { - namespace commands { OnAudioPassThruNotification::OnAudioPassThruNotification( @@ -50,7 +49,5 @@ void OnAudioPassThruNotification::Run() { SendNotification(); } - } // namespace commands - } // namespace application_manager diff --git a/src/components/application_manager/src/commands/mobile/on_hash_change_notification.cc b/src/components/application_manager/src/commands/mobile/on_hash_change_notification.cc index 1f30231..b9ee133 100644 --- a/src/components/application_manager/src/commands/mobile/on_hash_change_notification.cc +++ b/src/components/application_manager/src/commands/mobile/on_hash_change_notification.cc @@ -37,6 +37,7 @@ #include "application_manager/application_impl.h" #include "interfaces/MOBILE_API.h" #include +#include namespace application_manager { diff --git a/src/components/application_manager/src/commands/mobile/on_hmi_status_notification.cc b/src/components/application_manager/src/commands/mobile/on_hmi_status_notification.cc index 4208d6b..1678841 100644 --- a/src/components/application_manager/src/commands/mobile/on_hmi_status_notification.cc +++ b/src/components/application_manager/src/commands/mobile/on_hmi_status_notification.cc @@ -36,7 +36,6 @@ #include "interfaces/MOBILE_API.h" namespace application_manager { - namespace commands { OnHMIStatusNotification::OnHMIStatusNotification( diff --git a/src/components/application_manager/src/commands/mobile/perform_audio_pass_thru_request.cc b/src/components/application_manager/src/commands/mobile/perform_audio_pass_thru_request.cc index d17bb26..ccf4ab2 100644 --- a/src/components/application_manager/src/commands/mobile/perform_audio_pass_thru_request.cc +++ b/src/components/application_manager/src/commands/mobile/perform_audio_pass_thru_request.cc @@ -150,6 +150,8 @@ void PerformAudioPassThruRequest::SendSpeakRequest() { ++i) { msg_params[hmi_request::tts_chunks][i][str::text] = (*message_)[str::msg_params][str::initial_prompt][i][str::text]; + msg_params[hmi_request::tts_chunks][i][str::type] = + hmi_apis::Common_SpeechCapabilities::SC_TEXT; } // app_id msg_params[strings::app_id] = connection_key(); @@ -189,6 +191,14 @@ void PerformAudioPassThruRequest::SendPerformAudioPassThruRequest() { (*message_)[str::msg_params][str::audio_pass_display_text2]; } + if ((*message_)[str::msg_params].keyExists(str::mute_audio)) { + msg_params[str::mute_audio] = + (*message_)[str::msg_params][str::mute_audio].asBool(); + } else { + // If omitted, the value is set to true + msg_params[str::mute_audio] = true; + } + SendHMIRequest(hmi_apis::FunctionID::UI_PerformAudioPassThru, &msg_params, true); } diff --git a/src/components/application_manager/src/commands/mobile/perform_interaction_request.cc b/src/components/application_manager/src/commands/mobile/perform_interaction_request.cc index cc30f76..f9ddc0f 100644 --- a/src/components/application_manager/src/commands/mobile/perform_interaction_request.cc +++ b/src/components/application_manager/src/commands/mobile/perform_interaction_request.cc @@ -58,8 +58,6 @@ PerformInteractionRequest::PerformInteractionRequest( subscribe_on_event(hmi_apis::FunctionID::UI_OnResetTimeout); subscribe_on_event(hmi_apis::FunctionID::VR_OnCommand); subscribe_on_event(hmi_apis::FunctionID::Buttons_OnButtonPress); - subscribe_on_event( - hmi_apis::FunctionID::BasicCommunication_OnAppUnregistered); } PerformInteractionRequest::~PerformInteractionRequest() { @@ -108,16 +106,15 @@ void PerformInteractionRequest::Run() { return; } - mobile_apis::Result::eType verification_result = - MessageHelper::VerifyImageFiles((*message_)[strings::msg_params], app); - - if ((mobile_apis::Result::SUCCESS != verification_result) && - (mobile_apis::Result::UNSUPPORTED_RESOURCE != verification_result)) { - LOG4CXX_ERROR_EXT( - logger_, - "MessageHelper::VerifyImageFiles return " << verification_result); - SendResponse(false, verification_result); - return; + if ((*message_)[strings::msg_params].keyExists(strings::vr_help)) { + if (mobile_apis::Result::SUCCESS != MessageHelper::VerifyImageVrHelpItems( + (*message_)[strings::msg_params][strings::vr_help], app)) { + LOG4CXX_ERROR_EXT( + logger_, + "MessageHelper::VerifyImageVrHelpItems return INVALID_DATA!"); + SendResponse(false, mobile_apis::Result::INVALID_DATA); + return; + } } smart_objects::SmartObject& choice_list = @@ -164,11 +161,21 @@ void PerformInteractionRequest::Run() { } case mobile_apis::InteractionMode::MANUAL_ONLY: { LOG4CXX_INFO(logger_, "Interaction Mode: MANUAL_ONLY"); + + if (!CheckChoiceSetVRSynonyms(app)) { + return; + } + if (!CheckChoiceSetMenuNames(app)) { return; } + if (!CheckVrHelpItemPositions(app)) { + return; + } + app->set_perform_interaction_active(correlation_id); + SendVRPerformInteractionRequest(app); SendUIPerformInteractionRequest(app); break; } @@ -208,17 +215,11 @@ void PerformInteractionRequest::on_event(const event_engine::Event& event) { default_timeout()); break; } - case hmi_apis::FunctionID::UI_PerformInteraction: { LOG4CXX_INFO(logger_, "Received UI_PerformInteraction event"); ProcessPerformInteractionResponse(event.smart_object()); break; } - case hmi_apis::FunctionID::BasicCommunication_OnAppUnregistered: { - LOG4CXX_INFO(logger_, "Received OnAppUnregistered event"); - ProcessAppUnregisteredNotification(event.smart_object()); - break; - } case hmi_apis::FunctionID::VR_PerformInteraction: { LOG4CXX_INFO(logger_, "Received TTS_PerformInteraction"); ProcessVRResponse(event.smart_object()); @@ -277,7 +278,7 @@ void PerformInteractionRequest::ProcessVRResponse( vr_perform_interaction_code_ = static_cast( message[strings::params][hmi_response::code].asInt()); if (mobile_apis::Result::ABORTED == vr_perform_interaction_code_) { - LOG4CXX_INFO(logger_, "VR response abborted"); + LOG4CXX_INFO(logger_, "VR response aborted"); if (mobile_apis::InteractionMode::VR_ONLY == interaction_mode_) { LOG4CXX_INFO(logger_, "Abort send Close Popup"); smart_objects::SmartObject c_p_request_so = smart_objects::SmartObject( @@ -350,19 +351,6 @@ void PerformInteractionRequest::ProcessVRResponse( } } -void PerformInteractionRequest::ProcessAppUnregisteredNotification - (const smart_objects::SmartObject& message) { - LOG4CXX_INFO(logger_, - "PerformInteractionRequest::ProcessAppUnregisteredNotification"); - const uint32_t app_id = connection_key(); - if (app_id == message[strings::msg_params][strings::app_id].asUInt()) { - DisablePerformInteraction(); - } else { - LOG4CXX_INFO(logger_, "Notification was sent from another application"); - } -} - - void PerformInteractionRequest::ProcessPerformInteractionResponse( const smart_objects::SmartObject& message) { LOG4CXX_INFO(logger_, @@ -377,8 +365,10 @@ void PerformInteractionRequest::ProcessPerformInteractionResponse( bool result = false; int32_t hmi_response_code = message[strings::params][hmi_response::code].asInt(); - if (hmi_apis::Common_Result::SUCCESS == - hmi_apis::Common_Result::eType(hmi_response_code)) { + if ((hmi_apis::Common_Result::SUCCESS == + static_cast(hmi_response_code)) || + (hmi_apis::Common_Result::UNSUPPORTED_RESOURCE == + static_cast(hmi_response_code))) { if (message[strings::msg_params].keyExists(strings::manual_text_entry)) { msg_params[strings::trigger_source] = mobile_apis::TriggerSource::TS_KEYBOARD; } else { @@ -402,8 +392,6 @@ void PerformInteractionRequest::ProcessPerformInteractionResponse( SendResponse(result, result_code, return_info, &(msg_params)); } - - void PerformInteractionRequest::SendUIPerformInteractionRequest( application_manager::ApplicationSharedPtr const app) { smart_objects::SmartObject& choice_set_id_list = @@ -500,17 +488,19 @@ void PerformInteractionRequest::SendVRPerformInteractionRequest( smart_objects::SmartObject& choice_list = (*message_)[strings::msg_params][strings::interaction_choice_set_id_list]; - msg_params[strings::grammar_id] = smart_objects::SmartObject(smart_objects::SmartType_Array); - int32_t grammar_id_index = 0; - for (uint32_t i = 0; i < choice_list.length(); ++i) { - smart_objects::SmartObject* choice_set = - app->FindChoiceSet(choice_list[i].asInt()); - if (!choice_set) { - LOG4CXX_WARN(logger_, "Couldn't found choiset"); - continue; + if (mobile_apis::InteractionMode::MANUAL_ONLY != interaction_mode_) { + msg_params[strings::grammar_id] = smart_objects::SmartObject(smart_objects::SmartType_Array); + int32_t grammar_id_index = 0; + for (uint32_t i = 0; i < choice_list.length(); ++i) { + smart_objects::SmartObject* choice_set = + app->FindChoiceSet(choice_list[i].asInt()); + if (!choice_set) { + LOG4CXX_WARN(logger_, "Couldn't found choiset"); + continue; + } + msg_params[strings::grammar_id][grammar_id_index++]= + (*choice_set)[strings::grammar_id].asUInt(); } - uint32_t grammar_id = (*choice_set)[strings::grammar_id].asUInt(); - msg_params[strings::grammar_id][grammar_id_index++]= (*choice_set)[strings::grammar_id]; } if ((*message_)[strings::msg_params].keyExists(strings::help_prompt)) { @@ -537,7 +527,10 @@ void PerformInteractionRequest::SendVRPerformInteractionRequest( if (0 < vr_commands.length()) { // copy only first synonym smart_objects::SmartObject item(smart_objects::SmartType_Map); - item[strings::text] = vr_commands[0].asString(); + // Since there is no custom data from application side, SDL should + // construct prompt and append delimiter to each item + item[strings::text] = vr_commands[0].asString() + + profile::Profile::instance()->tts_delimiter(); msg_params[strings::help_prompt][index++] = item; } } diff --git a/src/components/application_manager/src/commands/mobile/put_file_request.cc b/src/components/application_manager/src/commands/mobile/put_file_request.cc index 19c1915..00a70b2 100644 --- a/src/components/application_manager/src/commands/mobile/put_file_request.cc +++ b/src/components/application_manager/src/commands/mobile/put_file_request.cc @@ -116,7 +116,7 @@ void PutFileRequest::Run() { // Policy table update in json format is currently to be received via PutFile // TODO(PV): after latest discussion has to be changed if (mobile_apis::FileType::JSON == file_type_) { - policy::PolicyHandler::instance()->ReceiveMessageFromSDK(binary_data); + policy::PolicyHandler::instance()->ReceiveMessageFromSDK(sync_file_name_, binary_data); } offset_ = 0; @@ -153,7 +153,7 @@ void PutFileRequest::Run() { ApplicationManagerImpl::instance()->GetAvailableSpaceForApp(application->name())); file_path = profile::Profile::instance()->app_storage_folder(); - file_path += "/" + application->name(); + file_path += "/" + application->folder_name(); if (binary_data.size() > ApplicationManagerImpl::instance()->GetAvailableSpaceForApp(application->name())) { diff --git a/src/components/application_manager/src/commands/mobile/register_app_interface_request.cc b/src/components/application_manager/src/commands/mobile/register_app_interface_request.cc index 27fcd13..fcdf630 100644 --- a/src/components/application_manager/src/commands/mobile/register_app_interface_request.cc +++ b/src/components/application_manager/src/commands/mobile/register_app_interface_request.cc @@ -137,15 +137,6 @@ bool RegisterAppInterfaceRequest::Init() { void RegisterAppInterfaceRequest::Run() { LOG4CXX_INFO(logger_, "RegisterAppInterfaceRequest::Run " << connection_key()); - // wait till HMI started - while (!ApplicationManagerImpl::instance()->IsHMICooperating()) { - sleep(1); - // TODO(DK): timer_->StartWait(1); - ApplicationManagerImpl::instance()->updateRequestTimeout(connection_key(), - correlation_id(), - default_timeout()); - } - ApplicationSharedPtr application = ApplicationManagerImpl::instance()->application(connection_key()); @@ -182,16 +173,30 @@ void RegisterAppInterfaceRequest::Run() { return; } - ApplicationSharedPtr app = ApplicationManagerImpl::instance()->RegisterApplication( - message_); - const smart_objects::SmartObject& msg_params = (*message_)[strings::msg_params]; + ApplicationSharedPtr app = + ApplicationManagerImpl::instance()->RegisterApplication(message_); + if (!app) { LOG4CXX_ERROR_EXT(logger_, "Application " << - msg_params[strings::app_name].asString() << " hasn't been registered!"); + msg_params[strings::app_name].asString() << + " hasn't been registered!"); } else { + + // For resuming application need to restore hmi_app_id from resumeCtrl + const std::string mobile_app_id = msg_params[strings::app_id].asString(); + ResumeCtrl& resumer = ApplicationManagerImpl::instance()->resume_controller(); + + // there is side affect with 2 mobile app with the same mobile app_id + if (resumer.IsApplicationSaved(mobile_app_id)) { + app->set_hmi_application_id(resumer.GetHMIApplicationID(mobile_app_id)); + } else { + app->set_hmi_application_id( + ApplicationManagerImpl::instance()->GenerateNewHMIAppID()); + } + app->set_is_media_application( msg_params[strings::is_media_application].asBool()); @@ -221,32 +226,31 @@ void RegisterAppInterfaceRequest::Run() { app->set_allowed_support_navigation(true); } } - } + } // Add device to policy table and set device info, if any - policy::DeviceParams device_params; - application_manager::MessageHelper::GetDeviceInfoForHandle(app->device(), - &device_params); + std::string device_mac_address = + application_manager::MessageHelper::GetDeviceMacAddressForHandle(app->device()); policy::DeviceInfo device_info; if (msg_params.keyExists(strings::device_info)) { FillDeviceInfo(&device_info); } - policy::PolicyHandler::instance()->SetDeviceInfo( - device_params.device_mac_address, device_info); + policy::PolicyHandler::instance()->SetDeviceInfo(device_mac_address, + device_info); - // TODO(AOleyni): Find other criteria of ignition on instead of number of - // registered applications - // Check policy update on first application registration after ignition on - if (1 - == application_manager::ApplicationManagerImpl::instance()->applications() - .size()) { - policy::PolicyHandler::instance()->PTExchangeAtIgnition(); - } + // Check policy update on ignition on, if it was not done before + policy::PolicyHandler::instance()->PTExchangeAtIgnition(); // Check necessity of policy update for current application - policy::PolicyHandler::instance()->CheckAppPolicyState( - msg_params[strings::app_id].asString()); + // TODO(KKolodiy): need remove policy_manager + policy::PolicyManager* policy_manager = + policy::PolicyHandler::instance()->policy_manager(); + if (!policy_manager) { + LOG4CXX_WARN(logger_, "The shared library of policy is not loaded"); + } else { + policy_manager->CheckAppPolicyState(msg_params[strings::app_id].asString()); + } SendRegisterAppInterfaceResponseToMobile(); } @@ -272,7 +276,6 @@ void RegisterAppInterfaceRequest::on_event(const event_engine::Event& event) { } } - void RegisterAppInterfaceRequest::SendRegisterAppInterfaceResponseToMobile( mobile_apis::Result::eType result) { smart_objects::SmartObject* params = new smart_objects::SmartObject( @@ -280,10 +283,10 @@ void RegisterAppInterfaceRequest::SendRegisterAppInterfaceResponseToMobile( if (!params) { std::string mobile_app_id = - (*message_)[strings::msg_params][strings::app_id].asString(); + (*message_)[strings::msg_params][strings::app_id].asString(); usage_statistics::AppCounter count_of_rejections_sync_out_of_memory( - policy::PolicyHandler::instance()->policy_manager(), mobile_app_id, - usage_statistics::REJECTIONS_SYNC_OUT_OF_MEMORY); + policy::PolicyHandler::instance()->policy_manager(), mobile_app_id, + usage_statistics::REJECTIONS_SYNC_OUT_OF_MEMORY); ++count_of_rejections_sync_out_of_memory; SendResponse(false, mobile_apis::Result::OUT_OF_MEMORY); return; @@ -332,7 +335,6 @@ void RegisterAppInterfaceRequest::SendRegisterAppInterfaceResponseToMobile( } if (hmi_capabilities.display_capabilities()) { - response_params[hmi_response::display_capabilities] = smart_objects::SmartObject(smart_objects::SmartType_Map); @@ -369,10 +371,8 @@ void RegisterAppInterfaceRequest::SendRegisterAppInterfaceResponseToMobile( if (hmi_capabilities.display_capabilities()->getElement( hmi_response::image_capabilities).length() > 0) { - display_caps[hmi_response::graphic_supported] = true; } else { - display_caps[hmi_response::graphic_supported] = false; } @@ -443,30 +443,29 @@ void RegisterAppInterfaceRequest::SendRegisterAppInterfaceResponseToMobile( const char* add_info = ""; bool resumption = (*message_)[strings::msg_params].keyExists(strings::hash_id); if (resumption) { - hash_id = (*message_)[strings::msg_params][strings::hash_id].asUInt(); - const std::string& mobile_app_id = (*application->mobile_app_id()).asString(); - if (!resumer.CheckApplicationHash(mobile_app_id, - hash_id)) { + if (!resumer.CheckApplicationHash(application, hash_id)) { result = mobile_apis::Result::RESUME_FAILED; - LOG4CXX_WARN(logger_, "Hash does not maches"); - add_info = "Hash does not maches"; + LOG4CXX_WARN(logger_, "Hash does not matches"); + add_info = "Hash does not matches"; } else if (!resumer.CheckPersistenceFilesForResumption(application)) { result = mobile_apis::Result::RESUME_FAILED; LOG4CXX_WARN(logger_, "Persistent data is missed"); add_info = "Persistent data is missed"; } else { - add_info = " Resume Succesed"; + add_info = " Resume Succeed"; } } - MessageHelper::SendOnAppRegisteredNotificationToHMI(*(application.get()), resumption); + + MessageHelper::SendOnAppRegisteredNotificationToHMI( + *(application.get()), resumption); + SendResponse(true, result, add_info, params); if (result != mobile_apis::Result::RESUME_FAILED) { resumer.StartResumption(application, hash_id); } else { resumer.StartResumptionOnlyHMILevel(application); } - } mobile_apis::Result::eType @@ -600,13 +599,19 @@ mobile_apis::Result::eType RegisterAppInterfaceRequest::CheckWithPolicyData() { policy::StringArray app_nicknames; policy::StringArray app_hmi_types; - bool init_result = policy::PolicyHandler::instance()->policy_manager() - ->GetInitialAppData( - message[strings::msg_params][strings::app_id].asString(), &app_nicknames, - &app_hmi_types); + // TODO(KKolodiy): need remove method policy_manager + policy::PolicyManager* policy_manager = + policy::PolicyHandler::instance()->policy_manager(); + if (!policy_manager) { + LOG4CXX_WARN(logger_, "The shared library of policy is not loaded"); + return mobile_apis::Result::WARNINGS; + } + const bool init_result = policy_manager->GetInitialAppData( + message[strings::msg_params][strings::app_id].asString(), &app_nicknames, + &app_hmi_types); if (!init_result) { - LOG4CXX_INFO(logger_, "Error during initial application data check."); + LOG4CXX_ERROR(logger_, "Error during initial application data check."); return mobile_apis::Result::INVALID_DATA; } @@ -615,7 +620,7 @@ mobile_apis::Result::eType RegisterAppInterfaceRequest::CheckWithPolicyData() { app_nicknames.begin(), app_nicknames.end(), message[strings::msg_params][strings::app_name].asString()); if (app_nicknames.end() == it) { - LOG4CXX_INFO(logger_, + LOG4CXX_WARN(logger_, "Application name was not found in nicknames list."); //App should be unregistered, if its name is not present in nicknames list return mobile_apis::Result::INVALID_DATA; @@ -765,7 +770,7 @@ bool RegisterAppInterfaceRequest::IsApplicationWithSameAppIdRegistered() { LOG4CXX_INFO(logger_, "RegisterAppInterfaceRequest::IsApplicationRegistered"); int32_t mobile_app_id = (*message_)[strings::msg_params][strings::app_id] - .asInt(); + .asInt(); const std::set& applications = ApplicationManagerImpl::instance()->applications(); @@ -782,7 +787,6 @@ bool RegisterAppInterfaceRequest::IsApplicationWithSameAppIdRegistered() { return false; } - } // namespace commands } // namespace application_manager diff --git a/src/components/application_manager/src/commands/mobile/scrollable_message_request.cc b/src/components/application_manager/src/commands/mobile/scrollable_message_request.cc index e949b98..2c403e0 100644 --- a/src/components/application_manager/src/commands/mobile/scrollable_message_request.cc +++ b/src/components/application_manager/src/commands/mobile/scrollable_message_request.cc @@ -44,9 +44,7 @@ namespace commands { ScrollabelMessageRequest::ScrollabelMessageRequest( const MessageSharedPtr& message) - : CommandRequestImpl(message), - result_(mobile_apis::Result::INVALID_ENUM) { - + : CommandRequestImpl(message) { subscribe_on_event(hmi_apis::FunctionID::UI_OnResetTimeout); } @@ -84,15 +82,9 @@ void ScrollabelMessageRequest::Run() { MessageHelper::ProcessSoftButtons((*message_)[strings::msg_params], app); if (mobile_apis::Result::SUCCESS != processing_result) { - if (mobile_apis::Result::INVALID_DATA == processing_result) { - LOG4CXX_ERROR(logger_, "Wrong soft buttons parameters!"); - SendResponse(false, processing_result); - return; - } - if (mobile_apis::Result::UNSUPPORTED_RESOURCE == processing_result) { - LOG4CXX_ERROR(logger_, "UNSUPPORTED_RESOURCE!"); - result_ = processing_result; - } + LOG4CXX_ERROR(logger_, "Wrong soft buttons parameters!"); + SendResponse(false, processing_result); + return; } smart_objects::SmartObject msg_params = smart_objects::SmartObject( @@ -131,19 +123,16 @@ void ScrollabelMessageRequest::on_event(const event_engine::Event& event) { mobile_apis::Result::eType result_code = static_cast (message[strings::params][hmi_response::code].asInt()); - + HMICapabilities& hmi_capabilities = + ApplicationManagerImpl::instance()->hmi_capabilities(); bool result = false; - if (mobile_apis::Result::SUCCESS == result_code) { + if (mobile_apis::Result::SUCCESS == result_code || + mobile_apis::Result::ABORTED == result_code) { result = true; - } - if (mobile_apis::Result::ABORTED == result_code) { + } else if ((mobile_apis::Result::UNSUPPORTED_RESOURCE == result_code) && + hmi_capabilities.is_ui_cooperating()) { result = true; - } else - - if (mobile_apis::Result::INVALID_ENUM != result_) { - result_code = result_; } - SendResponse(result, result_code, NULL, &(message[strings::msg_params])); break; } diff --git a/src/components/application_manager/src/commands/mobile/set_global_properties_request.cc b/src/components/application_manager/src/commands/mobile/set_global_properties_request.cc index 6c58d79..948c4b8 100644 --- a/src/components/application_manager/src/commands/mobile/set_global_properties_request.cc +++ b/src/components/application_manager/src/commands/mobile/set_global_properties_request.cc @@ -81,19 +81,31 @@ void SetGlobalPropertiesRequest::Run() { return; } + mobile_apis::Result::eType verification_result = mobile_apis::Result::SUCCESS; + + if ((*message_)[strings::msg_params].keyExists(strings::menu_icon)) { + verification_result = MessageHelper::VerifyImage( + (*message_)[strings::msg_params][strings::menu_icon], app); + if (mobile_apis::Result::SUCCESS != verification_result) { + LOG4CXX_ERROR_EXT( + logger_, + "MessageHelper::VerifyImage return " << verification_result); + SendResponse(false, verification_result); + return; + } + } // Check for image file(s) in vrHelpItem - mobile_apis::Result::eType verification_result = - MessageHelper::VerifyImageFiles((*message_)[strings::msg_params], app); - - if (mobile_apis::Result::SUCCESS != verification_result) { - LOG4CXX_ERROR_EXT( - logger_, - "MessageHelper::VerifyImageFiles return " << verification_result); - SendResponse(false, verification_result); - return; + if ((*message_)[strings::msg_params].keyExists(strings::vr_help)) { + if (mobile_apis::Result::SUCCESS != MessageHelper::VerifyImageVrHelpItems( + (*message_)[strings::msg_params][strings::vr_help], app)) { + LOG4CXX_ERROR_EXT( + logger_, + "MessageHelper::VerifyImage return INVALID_DATA!" ); + SendResponse(false, mobile_apis::Result::INVALID_DATA); + return; + } } - bool is_help_prompt_present = msg_params.keyExists(strings::help_prompt); bool is_timeout_prompt_present = msg_params.keyExists( strings::timeout_prompt); @@ -308,9 +320,11 @@ void SetGlobalPropertiesRequest::on_event(const event_engine::Event& event) { bool result = ((hmi_apis::Common_Result::SUCCESS == ui_result_) && (hmi_apis::Common_Result::SUCCESS == tts_result_ || hmi_apis::Common_Result::UNSUPPORTED_RESOURCE == tts_result_)) - || ((hmi_apis::Common_Result::SUCCESS == ui_result_) + || ((hmi_apis::Common_Result::SUCCESS == ui_result_ || + hmi_apis::Common_Result::UNSUPPORTED_RESOURCE == ui_result_) && (hmi_apis::Common_Result::INVALID_ENUM == tts_result_)) - || ((hmi_apis::Common_Result::INVALID_ENUM == ui_result_) + || ((hmi_apis::Common_Result::INVALID_ENUM == ui_result_ || + hmi_apis::Common_Result::UNSUPPORTED_RESOURCE == ui_result_) && (hmi_apis::Common_Result::SUCCESS == tts_result_)); mobile_apis::Result::eType result_code; diff --git a/src/components/application_manager/src/commands/mobile/set_icon_request.cc b/src/components/application_manager/src/commands/mobile/set_icon_request.cc index 3e1bf3d..876231d 100644 --- a/src/components/application_manager/src/commands/mobile/set_icon_request.cc +++ b/src/components/application_manager/src/commands/mobile/set_icon_request.cc @@ -67,12 +67,12 @@ void SetIconRequest::Run() { std::string full_file_path = profile::Profile::instance()->app_storage_folder() + "/"; - full_file_path += app->name(); + full_file_path += app->folder_name(); full_file_path += "/"; full_file_path += sync_file_name; if (!file_system::FileExists(full_file_path)) { - LOG4CXX_ERROR(logger_, "No such file"); + LOG4CXX_ERROR(logger_, "No such file " << full_file_path); SendResponse(false, mobile_apis::Result::INVALID_DATA); return; } diff --git a/src/components/application_manager/src/commands/mobile/show_constant_tbt_request.cc b/src/components/application_manager/src/commands/mobile/show_constant_tbt_request.cc index 89d4dc8..6f56dd2 100644 --- a/src/components/application_manager/src/commands/mobile/show_constant_tbt_request.cc +++ b/src/components/application_manager/src/commands/mobile/show_constant_tbt_request.cc @@ -43,8 +43,7 @@ namespace application_manager { namespace commands { ShowConstantTBTRequest::ShowConstantTBTRequest(const MessageSharedPtr& message) - : CommandRequestImpl(message), - result_(mobile_apis::Result::INVALID_ENUM) { + : CommandRequestImpl(message) { } ShowConstantTBTRequest::~ShowConstantTBTRequest() { @@ -72,35 +71,36 @@ void ShowConstantTBTRequest::Run() { smart_objects::SmartType_Map); msg_params = (*message_)[strings::msg_params]; - if (msg_params.keyExists(strings::soft_buttons)) { - mobile_apis::Result::eType processing_result = - MessageHelper::ProcessSoftButtons(msg_params, app); - if (mobile_apis::Result::SUCCESS != processing_result) { - if (mobile_apis::Result::INVALID_DATA == processing_result) { - LOG4CXX_ERROR(logger_, "INVALID_DATA!"); - SendResponse(false, processing_result); - return; - } - if (mobile_apis::Result::UNSUPPORTED_RESOURCE == processing_result) { - LOG4CXX_ERROR(logger_, "UNSUPPORTED_RESOURCE!"); - result_ = processing_result; - } - } + mobile_apis::Result::eType processing_result = + MessageHelper::ProcessSoftButtons(msg_params, app); + + if (mobile_apis::Result::SUCCESS != processing_result) { + LOG4CXX_ERROR(logger_, "INVALID_DATA!"); + SendResponse(false, processing_result); + return; } - mobile_apis::Result::eType verification_result = - MessageHelper::VerifyImageFiles(msg_params, app); - if (mobile_apis::Result::SUCCESS != verification_result) { - if (mobile_apis::Result::INVALID_DATA == verification_result) { - LOG4CXX_ERROR(logger_, "VerifyImageFiles INVALID_DATA!"); + mobile_apis::Result::eType verification_result = + mobile_apis::Result::SUCCESS; + if (msg_params.keyExists(strings::turn_icon)) { + verification_result = MessageHelper::VerifyImage( + msg_params[strings::turn_icon], app); + if (mobile_apis::Result::SUCCESS != verification_result) { + LOG4CXX_ERROR(logger_, "VerifyImage INVALID_DATA!"); SendResponse(false, verification_result); return; } - if (mobile_apis::Result::UNSUPPORTED_RESOURCE == verification_result) { - LOG4CXX_ERROR(logger_, "VerifyImageFiles UNSUPPORTED_RESOURCE!"); - result_ = verification_result; + } + + if (msg_params.keyExists(strings::next_turn_icon)) { + verification_result = MessageHelper::VerifyImage( + msg_params[strings::next_turn_icon], app); + if (mobile_apis::Result::SUCCESS != verification_result) { + LOG4CXX_ERROR(logger_, "VerifyImage INVALID_DATA!"); + SendResponse(false, verification_result); + return; } } @@ -170,12 +170,16 @@ void ShowConstantTBTRequest::on_event(const event_engine::Event& event) { LOG4CXX_INFO(logger_, "Received Navigation_ShowConstantTBT event"); mobile_apis::Result::eType result_code = - static_cast( - message[strings::params][hmi_response::code].asInt()); - - bool result = mobile_apis::Result::SUCCESS == result_code; - if (mobile_apis::Result::INVALID_ENUM != result_) { - result_code = result_; + GetMobileResultCode(static_cast( + message[strings::params][hmi_response::code].asInt())); + HMICapabilities& hmi_capabilities = + ApplicationManagerImpl::instance()->hmi_capabilities(); + bool result = false; + if (mobile_apis::Result::SUCCESS == result_code) { + result = true; + } else if ((mobile_apis::Result::UNSUPPORTED_RESOURCE == result_code) && + hmi_capabilities.is_ui_cooperating()) { + result = true; } SendResponse(result, result_code, NULL, &(message[strings::msg_params])); diff --git a/src/components/application_manager/src/commands/mobile/show_request.cc b/src/components/application_manager/src/commands/mobile/show_request.cc index 3c826f4..9422e31 100644 --- a/src/components/application_manager/src/commands/mobile/show_request.cc +++ b/src/components/application_manager/src/commands/mobile/show_request.cc @@ -41,8 +41,7 @@ namespace application_manager { namespace commands { ShowRequest::ShowRequest(const MessageSharedPtr& message) - : CommandRequestImpl(message), - result_(mobile_apis::Result::INVALID_ENUM) { + : CommandRequestImpl(message) { } ShowRequest::~ShowRequest() { @@ -72,29 +71,30 @@ void ShowRequest::Run() { MessageHelper::ProcessSoftButtons((*message_)[strings::msg_params], app); if (mobile_apis::Result::SUCCESS != processing_result) { - if (mobile_apis::Result::INVALID_DATA == processing_result) { - LOG4CXX_ERROR(logger_, "INVALID_DATA!"); - SendResponse(false, processing_result); - return; - } - if (mobile_apis::Result::UNSUPPORTED_RESOURCE == processing_result) { - LOG4CXX_ERROR(logger_, "UNSUPPORTED_RESOURCE!"); - result_ = processing_result; - } + LOG4CXX_ERROR(logger_, "INVALID_DATA!"); + SendResponse(false, processing_result); + return; } mobile_apis::Result::eType verification_result = - MessageHelper::VerifyImageFiles((*message_)[strings::msg_params], app); - - if (mobile_apis::Result::SUCCESS != verification_result) { - if (mobile_apis::Result::INVALID_DATA == verification_result) { - LOG4CXX_ERROR(logger_, "VerifyImageFiles INVALID_DATA!"); + mobile_apis::Result::SUCCESS; + if ((*message_)[strings::msg_params].keyExists(strings::graphic)) { + verification_result = MessageHelper::VerifyImage( + (*message_)[strings::msg_params][strings::graphic], app); + if (mobile_apis::Result::SUCCESS != verification_result) { + LOG4CXX_ERROR(logger_, "VerifyImage INVALID_DATA!"); SendResponse(false, verification_result); return; } - if (mobile_apis::Result::UNSUPPORTED_RESOURCE == verification_result) { - LOG4CXX_ERROR(logger_, "VerifyImageFiles UNSUPPORTED_RESOURCE!"); - result_ = verification_result; + } + + if ((*message_)[strings::msg_params].keyExists(strings::secondary_graphic)) { + verification_result = MessageHelper::VerifyImage( + (*message_)[strings::msg_params][strings::secondary_graphic], app); + if (mobile_apis::Result::SUCCESS != verification_result) { + LOG4CXX_ERROR(logger_, "VerifyImage INVALID_DATA!"); + SendResponse(false, verification_result); + return; } } @@ -210,9 +210,14 @@ void ShowRequest::on_event(const event_engine::Event& event) { static_cast( message[strings::params][hmi_response::code].asInt()); - bool result = mobile_apis::Result::SUCCESS == result_code; - if (mobile_apis::Result::INVALID_ENUM != result_) { - result_code = result_; + bool result = false; + HMICapabilities& hmi_capabilities = + ApplicationManagerImpl::instance()->hmi_capabilities(); + if (mobile_apis::Result::SUCCESS == result_code) { + result = true; + } else if ((mobile_apis::Result::UNSUPPORTED_RESOURCE == result_code) && + hmi_capabilities.is_ui_cooperating()) { + result = true; } SendResponse(result, result_code, NULL, &(message[strings::msg_params])); diff --git a/src/components/application_manager/src/commands/mobile/sync_pdata_request.cc b/src/components/application_manager/src/commands/mobile/sync_pdata_request.cc index 9740718..e33e5b9 100644 --- a/src/components/application_manager/src/commands/mobile/sync_pdata_request.cc +++ b/src/components/application_manager/src/commands/mobile/sync_pdata_request.cc @@ -45,8 +45,7 @@ namespace commands { const std::string SyncPDataRequest::TEMPORARY_HARDCODED_FILENAME = "policy_sync_data.dat"; -const std::string SyncPDataRequest::TEMPORARY_HARDCODED_FOLDERNAME = - profile::Profile::instance()->app_storage_folder() + "/policies"; +const std::string SyncPDataRequest::TEMPORARY_HARDCODED_FOLDERNAME = "policies"; SyncPDataRequest::SyncPDataRequest(const MessageSharedPtr& message) : CommandRequestImpl(message) { @@ -78,8 +77,11 @@ void SyncPDataRequest::Run() { const std::vector file_data = (*message_)[strings::params][strings::binary_data].asBinary(); - std::string file_path = file_system::CreateDirectory( - TEMPORARY_HARDCODED_FOLDERNAME); + std::string path = + profile::Profile::instance()->app_storage_folder() + "/"; + path += TEMPORARY_HARDCODED_FOLDERNAME; + + std::string file_path = file_system::CreateDirectory(path); mobile_apis::Result::eType save_result = ApplicationManagerImpl::instance()->SaveBinary( diff --git a/src/components/application_manager/src/commands/mobile/system_request.cc b/src/components/application_manager/src/commands/mobile/system_request.cc index a5603fa..4207b24 100644 --- a/src/components/application_manager/src/commands/mobile/system_request.cc +++ b/src/components/application_manager/src/commands/mobile/system_request.cc @@ -115,7 +115,7 @@ void SystemRequest::Run() { msg_params[strings::file_name] = full_file_path; } if (mobile_apis::RequestType::PROPRIETARY != request_type) { - msg_params[strings::app_id] = application->app_id(); + msg_params[strings::app_id] = (application->mobile_app_id())->asString(); } msg_params[strings::request_type] = (*message_)[strings::msg_params] [strings::request_type]; diff --git a/src/components/application_manager/src/commands/mobile/update_turn_list_request.cc b/src/components/application_manager/src/commands/mobile/update_turn_list_request.cc index 9fd188c..0b0d724 100644 --- a/src/components/application_manager/src/commands/mobile/update_turn_list_request.cc +++ b/src/components/application_manager/src/commands/mobile/update_turn_list_request.cc @@ -44,8 +44,7 @@ namespace application_manager { namespace commands { UpdateTurnListRequest::UpdateTurnListRequest(const MessageSharedPtr& message) - : CommandRequestImpl(message), - result_(mobile_apis::Result::INVALID_ENUM) { + : CommandRequestImpl(message) { } UpdateTurnListRequest::~UpdateTurnListRequest() { @@ -63,34 +62,31 @@ void UpdateTurnListRequest::Run() { return; } - if ((*message_)[strings::msg_params].keyExists(strings::soft_buttons)) { - mobile_apis::Result::eType processing_result = - MessageHelper::ProcessSoftButtons((*message_)[strings::msg_params], app); + mobile_apis::Result::eType processing_result = + MessageHelper::ProcessSoftButtons((*message_)[strings::msg_params], app); - if (mobile_apis::Result::SUCCESS != processing_result) { - if (mobile_apis::Result::INVALID_DATA == processing_result) { - LOG4CXX_ERROR(logger_, "INVALID_DATA!"); - SendResponse(false, processing_result); + if (mobile_apis::Result::SUCCESS != processing_result) { + LOG4CXX_ERROR(logger_, "INVALID_DATA!"); + SendResponse(false, processing_result); + return; + } + + if ((*message_)[strings::msg_params].keyExists(strings::turn_list)) { + smart_objects::SmartObject& turn_list_array = + ((*message_)[strings::msg_params][strings::turn_list]); + for (uint32_t i = 0; i < turn_list_array.length(); ++i) { + if((turn_list_array[i].keyExists(strings::turn_icon)) && + (mobile_apis::Result::SUCCESS != MessageHelper::VerifyImage( + turn_list_array[i][strings::turn_icon], app))) { + LOG4CXX_ERROR_EXT( + logger_, + "MessageHelper::VerifyImage return INVALID_DATA"); + SendResponse(false, mobile_apis::Result::INVALID_DATA); return; } - if (mobile_apis::Result::UNSUPPORTED_RESOURCE == processing_result) { - LOG4CXX_ERROR(logger_, "UNSUPPORTED_RESOURCE!"); - result_ = processing_result; - } } } - mobile_apis::Result::eType verification_result = - MessageHelper::VerifyImageFiles((*message_)[strings::msg_params], app); - - if (mobile_apis::Result::SUCCESS != verification_result) { - LOG4CXX_ERROR_EXT( - logger_, - "MessageHelper::VerifyImageFiles return " << verification_result); - SendResponse(false, verification_result); - return; - } - smart_objects::SmartObject msg_params = smart_objects::SmartObject( smart_objects::SmartType_Map); msg_params = (*message_)[strings::msg_params]; @@ -141,11 +137,13 @@ void UpdateTurnListRequest::on_event(const event_engine::Event& event) { mobile_apis::Result::eType result_code = static_cast( message[strings::params][hmi_response::code].asInt()); + HMICapabilities& hmi_capabilities = + ApplicationManagerImpl::instance()->hmi_capabilities(); + + bool result = (mobile_apis::Result::SUCCESS == result_code) || + ((mobile_apis::Result::UNSUPPORTED_RESOURCE == result_code) && + (hmi_capabilities.is_ui_cooperating())); - bool result = mobile_apis::Result::SUCCESS == result_code; - if (mobile_apis::Result::INVALID_ENUM != result_) { - result_code = result_; - } SendResponse(result, result_code, NULL, &(message[strings::msg_params])); break; diff --git a/src/components/application_manager/src/hmi_capabilities.cc b/src/components/application_manager/src/hmi_capabilities.cc index 1087a5e..71e0fbd 100644 --- a/src/components/application_manager/src/hmi_capabilities.cc +++ b/src/components/application_manager/src/hmi_capabilities.cc @@ -36,18 +36,19 @@ #include "interfaces/HMI_API.h" #include "config_profile/profile.h" #include "smart_objects/smart_object.h" +#include "application_manager/smart_object_keys.h" #include "application_manager/message_helper.h" #include "application_manager/hmi_capabilities.h" #include "application_manager/smart_object_keys.h" #include "application_manager/application_manager_impl.h" #include "application_manager/message_helper.h" +#include "formatters/CFormatterJsonBase.hpp" namespace application_manager { +namespace Formatters = NsSmartDeviceLink::NsJSONHandler::Formatters; + +CREATE_LOGGERPTR_GLOBAL(logger_, "HMICapabilities") -#ifdef ENABLE_LOG -log4cxx::LoggerPtr HMICapabilities::logger_ = log4cxx::LoggerPtr( - log4cxx::Logger::getLogger("HMICapabilities")); -#endif std::map languages_enum_values = { {"EN_US", hmi_apis::Common_Language::EN_US}, @@ -130,7 +131,8 @@ std::map text_fields_enum_na {"secondaryText" , hmi_apis::Common_TextFieldName::secondaryText}, {"tertiaryText" , hmi_apis::Common_TextFieldName::tertiaryText}, {"timeToDestination", hmi_apis::Common_TextFieldName::timeToDestination}, - {"turnText" , hmi_apis::Common_TextFieldName::turnText} + {"turnText" , hmi_apis::Common_TextFieldName::turnText}, + {"menuTitle" , hmi_apis::Common_TextFieldName::menuTitle}, }; std::map media_clock_enum_name = @@ -185,11 +187,11 @@ image_field_name_enum = {"turnIcon", hmi_apis::Common_ImageFieldName::turnIcon}, {"menuIcon", hmi_apis::Common_ImageFieldName::menuIcon}, {"cmdIcon", hmi_apis::Common_ImageFieldName::cmdIcon}, + {"appIcon", hmi_apis::Common_ImageFieldName::appIcon}, {"graphic", hmi_apis::Common_ImageFieldName::graphic}, {"showConstantTBTIcon", hmi_apis::Common_ImageFieldName::showConstantTBTIcon}, {"showConstantTBTNextTurnIcon", - hmi_apis::Common_ImageFieldName::showConstantTBTNextTurnIcon}, - {"nextTurnIcon", hmi_apis::Common_ImageFieldName::showConstantTBTNextTurnIcon} + hmi_apis::Common_ImageFieldName::showConstantTBTNextTurnIcon} }; const std::map file_type_enum = @@ -204,6 +206,28 @@ const std::map file_type_enum = {"JSON", hmi_apis::Common_FileType::JSON} }; +const std::map display_type_enum = +{ + {"CID", hmi_apis::Common_DisplayType::CID}, + {"TYPE2", hmi_apis::Common_DisplayType::TYPE2}, + {"TYPE5", hmi_apis::Common_DisplayType::TYPE5}, + {"NGN", hmi_apis::Common_DisplayType::NGN}, + {"GEN2_8_DMA", hmi_apis::Common_DisplayType::GEN2_8_DMA}, + {"GEN2_6_DMA", hmi_apis::Common_DisplayType::GEN2_6_DMA}, + {"MFD3", hmi_apis::Common_DisplayType::MFD3}, + {"MFD4", hmi_apis::Common_DisplayType::MFD4}, + {"MFD5", hmi_apis::Common_DisplayType::MFD5}, + {"GEN3_8_INCH", hmi_apis::Common_DisplayType::GEN3_8_INCH} +}; + +const std::map character_set_enum = +{ + {"TYPE2SET" , hmi_apis::Common_CharacterSet::TYPE2SET}, + {"TYPE5SET" , hmi_apis::Common_CharacterSet::TYPE5SET}, + {"CID1SET" , hmi_apis::Common_CharacterSet::CID1SET}, + {"CID2SET" , hmi_apis::Common_CharacterSet::CID2SET} +}; + HMICapabilities::HMICapabilities(ApplicationManagerImpl* const app_mngr) : is_vr_cooperating_(false), is_tts_cooperating_(false), @@ -541,6 +565,7 @@ bool HMICapabilities::load_capabilities_from_file() { } try { + Json::Reader reader_; Json::Value root_json; @@ -549,234 +574,278 @@ bool HMICapabilities::load_capabilities_from_file() { return false; } // UI - Json::Value ui = root_json.get("UI", ""); - set_active_ui_language( - languages_enum_values.find(ui.get("language", "").asString())->second); - - Json::Value languages = ui.get("languages", ""); - smart_objects::SmartObject ui_languages = - smart_objects::SmartObject(smart_objects::SmartType_Array); - for (int32_t i = 0, j = 0; i < languages.size(); i++) { - std::map::const_iterator it = - languages_enum_values.find(languages[i].asString()); - if (languages_enum_values.end() != it) { - ui_languages[j++] = it->second; + if (check_existing_json_member(root_json, "UI")) { + Json::Value ui = root_json.get("UI", ""); + + if (check_existing_json_member(ui, "language")) { + set_active_ui_language( + languages_enum_values.find(ui.get("language", "").asString())->second); } - } - set_ui_supported_languages(ui_languages); - Json::Value display_capabilities = ui.get("displayCapabilities", ""); - smart_objects::SmartObject display_capabilities_so = - smart_objects::SmartObject(smart_objects::SmartType_Map); - display_capabilities_so["displayType"] = - display_capabilities.get("displayType", "").asString(); + if (check_existing_json_member(ui, "languages")) { + smart_objects::SmartObject ui_languages_so( + smart_objects::SmartType_Array); + Json::Value languages_ui = ui.get("languages", ""); + convert_json_languages_to_obj(languages_ui, ui_languages_so); + set_ui_supported_languages(ui_languages_so); + } - display_capabilities_so["textFields"] = - smart_objects::SmartObject(smart_objects::SmartType_Array); + if (check_existing_json_member(ui, "displayCapabilities")) { + smart_objects::SmartObject display_capabilities_so; + Json::Value display_capabilities = ui.get("displayCapabilities", ""); + Formatters::CFormatterJsonBase::jsonValueToObj( + display_capabilities, display_capabilities_so); + + if (display_capabilities_so.keyExists(hmi_response::display_type)) { + std::map + ::const_iterator it = display_type_enum.find( + (display_capabilities_so[hmi_response::display_type]).asString()); + display_capabilities_so.erase(hmi_response::display_type); + if (display_type_enum.end() != it) { + display_capabilities_so[hmi_response::display_type] = it->second; + } + } + + if (display_capabilities_so.keyExists(hmi_response::text_fields)) { + int32_t len = + display_capabilities_so[hmi_response::text_fields].length(); + + for (int32_t i = 0; i < len; ++i) { + + if ((display_capabilities_so + [hmi_response::text_fields][i]).keyExists(strings::name)) { + std::map + ::const_iterator it_text_field_name = text_fields_enum_name.find( + display_capabilities_so[hmi_response::text_fields] + [i][strings::name].asString()); + display_capabilities_so[hmi_response::text_fields][i].erase(strings::name); + if (text_fields_enum_name.end() != it_text_field_name) { + display_capabilities_so[hmi_response::text_fields] + [i][strings::name] = it_text_field_name->second; + } + } + if ((display_capabilities_so + [hmi_response::text_fields][i]).keyExists(strings::character_set)) { + std::map + ::const_iterator it_characte_set = character_set_enum.find( + display_capabilities_so[hmi_response::text_fields] + [i][strings::character_set].asString()); + display_capabilities_so + [hmi_response::text_fields][i].erase(strings::character_set); + if (character_set_enum.end() != it_characte_set) { + display_capabilities_so + [hmi_response::text_fields][i][strings::character_set] = + it_characte_set->second; + } + } + } + } + + if (display_capabilities_so.keyExists(hmi_response::image_fields)) { + smart_objects::SmartObject& array_image_fields = + display_capabilities_so[hmi_response::image_fields]; + for (int32_t i = 0; i < array_image_fields.length(); ++i) { + if (array_image_fields[i].keyExists(strings::name)) { + std::map + ::const_iterator it = image_field_name_enum.find( + (array_image_fields[i][strings::name]).asString()); + array_image_fields[i].erase(strings::name); + if (image_field_name_enum.end() != it) { + array_image_fields[i][strings::name] = it->second; + } + } + if (array_image_fields[i].keyExists(strings::image_type_supported)) { + smart_objects::SmartObject& image_type_supported_array = + array_image_fields[i][strings::image_type_supported]; + smart_objects::SmartObject image_type_supported_enum( + smart_objects::SmartType_Array); + for (int32_t k = 0, j = 0; k < image_type_supported_array.length(); ++k) { + std::map + ::const_iterator it = file_type_enum.find( + (image_type_supported_array[k]).asString()); + if (file_type_enum.end() != it) { + image_type_supported_enum[j++] = it->second; + } + } + array_image_fields[i].erase(strings::image_type_supported); + array_image_fields[i][strings::image_type_supported] = + image_type_supported_enum; + } + } + } + if (display_capabilities_so.keyExists(hmi_response::media_clock_formats)) { + smart_objects::SmartObject& media_clock_formats_array = + display_capabilities_so[hmi_response::media_clock_formats]; + smart_objects::SmartObject media_clock_formats_enum( + smart_objects::SmartType_Array); + for (int32_t i = 0, j = 0; i < media_clock_formats_array.length(); ++i) { + std::map + ::const_iterator it = media_clock_enum_name.find( + (media_clock_formats_array[i]).asString()); + if (media_clock_enum_name.end() != it) { + media_clock_formats_enum[j++] = it->second; + } + } + display_capabilities_so.erase(hmi_response::media_clock_formats); + display_capabilities_so[hmi_response::media_clock_formats] = + media_clock_formats_enum; + } + + if (display_capabilities_so.keyExists(hmi_response::image_capabilities)) { + smart_objects::SmartObject& image_capabilities_array = + display_capabilities_so[hmi_response::image_capabilities]; + smart_objects::SmartObject image_capabilities_enum( + smart_objects::SmartType_Array); + for (int32_t i = 0, j = 0; i < image_capabilities_array.length(); ++i) { + std::map + ::const_iterator it = image_type_enum.find( + (image_capabilities_array[i]).asString()); + if (image_type_enum.end() != it) { + image_capabilities_enum[j++] = it->second; + } + } + display_capabilities_so.erase(hmi_response::image_capabilities); + display_capabilities_so[hmi_response::image_capabilities] = + image_capabilities_enum; + } + set_display_capabilities(display_capabilities_so); + } - Json::Value text_fields = display_capabilities.get("textFields", ""); - for (int32_t i = 0; i < text_fields.size(); i++) { + if (check_existing_json_member(ui, "audioPassThruCapabilities")) { + Json::Value audio_capabilities = ui.get("audioPassThruCapabilities", ""); + smart_objects::SmartObject audio_capabilities_so = + smart_objects::SmartObject(smart_objects::SmartType_Array); + int32_t i = 0; + audio_capabilities_so[i] = + smart_objects::SmartObject(smart_objects::SmartType_Map); + if (check_existing_json_member(audio_capabilities, "samplingRate")) { + audio_capabilities_so[i]["samplingRate"] = + sampling_rate_enum.find( + audio_capabilities.get("samplingRate", "").asString())->second; + } + if (check_existing_json_member(audio_capabilities, "bitsPerSample")) { + audio_capabilities_so[i]["bitsPerSample"] = + bit_per_sample_enum.find( + audio_capabilities.get("bitsPerSample", "").asString())->second; + } + if (check_existing_json_member(audio_capabilities, "audioType")) { + audio_capabilities_so[i]["audioType"] = + audio_type_enum.find( + audio_capabilities.get("audioType", "").asString())->second; + } + set_audio_pass_thru_capabilities(audio_capabilities_so); + } - // there is an issue with enum to string, therefore used string - display_capabilities_so["textFields"][i]["name"] = - text_fields_enum_name.find(text_fields[i].asString())->first; - } + if (check_existing_json_member(ui, "hmiZoneCapabilities")) { + smart_objects::SmartObject hmi_zone_capabilities_so = + smart_objects::SmartObject(smart_objects::SmartType_Array); + int32_t index = 0; + hmi_zone_capabilities_so[index] = + hmi_zone_enum.find(ui.get("hmiZoneCapabilities", "").asString())->second; + set_hmi_zone_capabilities(hmi_zone_capabilities_so); + } - display_capabilities_so["imageFields"] = - smart_objects::SmartObject(smart_objects::SmartType_Array); - Json::Value image_fields = display_capabilities.get("imageFields", ""); - for (int32_t i = 0; i < image_fields.size(); ++i) { - smart_objects::SmartObject image_field = - smart_objects::SmartObject(smart_objects::SmartType_Map); - image_field["name"] = image_field_name_enum.find( - image_fields[i].get("name","").asString())->second; - image_field["imageTypeSupported"] = - smart_objects::SmartObject(smart_objects::SmartType_Array); - Json::Value image_type_suported = - image_fields[i].get("imageTypeSupported", ""); - for (int32_t j = 0; j < image_type_suported.size(); ++j) { - image_field["imageTypeSupported"][j] = (file_type_enum.find( - image_type_suported[j].asString()))->second; + if (check_existing_json_member(ui, "softButtonCapabilities")) { + Json::Value soft_button_capabilities = ui.get( + "softButtonCapabilities", ""); + smart_objects::SmartObject soft_button_capabilities_so; + Formatters::CFormatterJsonBase::jsonValueToObj( + soft_button_capabilities, soft_button_capabilities_so); + set_soft_button_capabilities(soft_button_capabilities_so); } - image_field["imageResolution"]["resolutionWidth"] = - ((image_fields[i].get("imageResolution", "")). - get("resolutionWidth", "")).asInt(); - image_field["imageResolution"]["resolutionHeight"] = - ((image_fields[i].get("imageResolution", "")). - get("resolutionHeight", "")).asInt(); - display_capabilities_so["imageFields"][i] = image_field; - } + } //UI end - display_capabilities_so["mediaClockFormats"] = - smart_objects::SmartObject(smart_objects::SmartType_Array); - Json::Value media_clock_format = - display_capabilities.get("mediaClockFormats", ""); - for (int32_t i = 0; i < media_clock_format.size(); i++) { - display_capabilities_so["mediaClockFormats"][i] = - media_clock_enum_name.find(media_clock_format[i].asString())->second; - } - display_capabilities_so["graphicSupported"] = - display_capabilities.get("graphicSupported", "").asBool(); + // VR + if (check_existing_json_member(root_json, "VR")) { + Json::Value vr = root_json.get("VR", ""); + if (check_existing_json_member(vr, "language")) { + set_active_vr_language( + languages_enum_values.find(vr.get("language", "").asString())->second); + } - display_capabilities_so["templatesAvailable"] = + if (check_existing_json_member(vr, "languages")) { + Json::Value languages_vr = vr.get("languages", ""); + smart_objects::SmartObject vr_languages_so = smart_objects::SmartObject(smart_objects::SmartType_Array); - Json::Value teplates_available = - display_capabilities.get("templatesAvailable", ""); - for(int32_t i = 0; i < teplates_available.size(); ++i) { - display_capabilities_so["templatesAvailable"][i] = - teplates_available[i].asString(); - } - Json::Value screen_params_resolution = - (display_capabilities.get("screenParams", "")).get("resolution", ""); - Json::Value screen_params_touch_event_available = - (display_capabilities.get("screenParams", "")) - .get("touchEventAvailable", ""); - display_capabilities_so["screenParams"]["resolution"]["resolutionWidth"] = - screen_params_resolution.get("resolutionWidth", "").asInt(); - display_capabilities_so["screenParams"]["resolution"]["resolutionHeight"] = - screen_params_resolution.get("resolutionHeight", "").asInt(); - display_capabilities_so["screenParams"] - ["touchEventAvailable"]["pressAvailable"] = - screen_params_touch_event_available.get("pressAvailable", "").asBool(); - display_capabilities_so["screenParams"] - ["touchEventAvailable"]["multiTouchAvailable"] = - screen_params_touch_event_available.get("multiTouchAvailable", "").asBool(); - display_capabilities_so["screenParams"] - ["touchEventAvailable"]["doublePressAvailable"] = - screen_params_touch_event_available.get("doublePressAvailable", "").asBool(); - display_capabilities_so["numCustomPresetsAvailable"] = - display_capabilities.get("numCustomPresetsAvailable", "").asInt(); - - Json::Value image_capabilities = - display_capabilities.get("imageCapabilities", ""); - display_capabilities_so["imageCapabilities"] = - smart_objects::SmartObject(smart_objects::SmartType_Array); - for (int32_t i = 0; i < image_capabilities.size(); i++) { - display_capabilities_so["imageCapabilities"][i] = - image_type_enum.find(image_capabilities[i].asString())->second; - } - set_display_capabilities(display_capabilities_so); - - Json::Value audio_capabilities = ui.get("audioPassThruCapabilities", ""); - smart_objects::SmartObject audio_capabilities_so = - smart_objects::SmartObject(smart_objects::SmartType_Array); - int32_t i = 0; - audio_capabilities_so[i] = - smart_objects::SmartObject(smart_objects::SmartType_Map); - audio_capabilities_so[i]["samplingRate"] = - sampling_rate_enum.find( - audio_capabilities.get("samplingRate", "").asString())->second; - audio_capabilities_so[i]["bitsPerSample"] = - bit_per_sample_enum.find( - audio_capabilities.get("bitsPerSample", "").asString())->second; - audio_capabilities_so[i]["audioType"] = - audio_type_enum.find( - audio_capabilities.get("audioType", "").asString())->second; - set_audio_pass_thru_capabilities(audio_capabilities_so); - - smart_objects::SmartObject hmi_zone_capabilities_so = - smart_objects::SmartObject(smart_objects::SmartType_Array); - int32_t index = 0; - hmi_zone_capabilities_so[index] = - hmi_zone_enum.find(ui.get("hmiZoneCapabilities", "").asString())->second; - set_hmi_zone_capabilities(hmi_zone_capabilities_so); - - Json::Value soft_button_capabilities = ui.get("softButtonCapabilities", ""); - smart_objects::SmartObject soft_button_capabilities_so = - smart_objects::SmartObject(smart_objects::SmartType_Map); - soft_button_capabilities_so["shortPressAvailable"] = - soft_button_capabilities.get("shortPressAvailable", "").asBool(); - soft_button_capabilities_so["longPressAvailable"] = - soft_button_capabilities.get("longPressAvailable", "").asBool(); - soft_button_capabilities_so["upDownAvailable"] = - soft_button_capabilities.get("upDownAvailable", "").asBool(); - soft_button_capabilities_so["imageSupported"] = - soft_button_capabilities.get("imageSupported", "").asBool(); - set_soft_button_capabilities(soft_button_capabilities_so); + convert_json_languages_to_obj(languages_vr, vr_languages_so); + set_vr_supported_languages(vr_languages_so); + } - // VR - Json::Value vr = root_json.get("VR", ""); - set_active_vr_language( - languages_enum_values.find(vr.get("language", "").asString())->second); - - languages = vr.get("languages", ""); - smart_objects::SmartObject vr_languages = - smart_objects::SmartObject(smart_objects::SmartType_Array); - for (int32_t i = 0, j = 0; i < languages.size(); i++) { - std::map::const_iterator it = - languages_enum_values.find(languages[i].asString()); - if (languages_enum_values.end() != it) { - vr_languages[j++] = it->second; + if (check_existing_json_member(vr, "capabilities")) { + Json::Value capabilities = vr.get("capabilities", ""); + smart_objects::SmartObject vr_capabilities_so = + smart_objects::SmartObject(smart_objects::SmartType_Array); + for (int32_t i = 0; i < capabilities.size(); ++i) { + vr_capabilities_so[i] = + vr_enum_capabilities.find(capabilities[i].asString())->second; + } + set_vr_capabilities(vr_capabilities_so); } - } - set_vr_supported_languages(vr_languages); - - Json::Value capabilities = vr.get("capabilities", ""); - smart_objects::SmartObject vr_capabilities = - smart_objects::SmartObject(smart_objects::SmartType_Array); - for (int32_t i = 0; i < capabilities.size(); i++) { - vr_capabilities[i] = - vr_enum_capabilities.find(capabilities[i].asString())->second; - } - set_vr_capabilities(vr_capabilities); - - // TTS - Json::Value tts = root_json.get("TTS", ""); - set_active_tts_language( - languages_enum_values.find(tts.get("language", "").asString())->second); - - languages = tts.get("languages", ""); - smart_objects::SmartObject tts_languages = - smart_objects::SmartObject(smart_objects::SmartType_Array); - for (int32_t i = 0, j = 0; i < languages.size(); i++) { - std::map::const_iterator it = - languages_enum_values.find(languages[i].asString()); - if (languages_enum_values.end() != it) { - tts_languages[j++] = it->second; + }//VR end + + //TTS + if (check_existing_json_member(root_json, "TTS")) { + Json::Value tts = root_json.get("TTS", ""); + + if (check_existing_json_member(tts, "language")) { + set_active_tts_language( + languages_enum_values.find(tts.get("language", "").asString())->second); + } + + if (check_existing_json_member(tts, "languages")) { + Json::Value languages_tts = tts.get("languages", ""); + smart_objects::SmartObject tts_languages_so = + smart_objects::SmartObject(smart_objects::SmartType_Array); + convert_json_languages_to_obj(languages_tts, tts_languages_so); + set_tts_supported_languages(tts_languages_so); } - } - set_tts_supported_languages(tts_languages); - set_speech_capabilities( - smart_objects::SmartObject(tts.get("capabilities", "").asString())); + if (check_existing_json_member(tts, "capabilities")) { + set_speech_capabilities( + smart_objects::SmartObject(tts.get("capabilities", "").asString())); + } + } //TTS end // Buttons - Json::Value buttons = root_json.get("Buttons", ""); - Json::Value bt_capabilities = buttons.get("capabilities", ""); - smart_objects::SmartObject buttons_capabilities = - smart_objects::SmartObject(smart_objects::SmartType_Array); - for (int32_t i = 0; i < bt_capabilities.size(); i++) { - smart_objects::SmartObject button = - smart_objects::SmartObject(smart_objects::SmartType_Map); - button["name"] = - button_enum_name.find(bt_capabilities[i].get("name", "").asString())->second; - button["shortPressAvailable"] = - bt_capabilities[i].get("shortPressAvailable", "").asBool(); - button["longPressAvailable"] = - bt_capabilities[i].get("longPressAvailable", "").asBool(); - button["upDownAvailable"] = - bt_capabilities[i].get("upDownAvailable", "").asBool(); - - buttons_capabilities[i] = button; - } - set_button_capabilities(buttons_capabilities); - - Json::Value presetBank = buttons.get("presetBankCapabilities", ""); - smart_objects::SmartObject preset_bank = - smart_objects::SmartObject(smart_objects::SmartType_Map); - preset_bank["onScreenPresetsAvailable"] = - presetBank.get("onScreenPresetsAvailable", "").asBool(); - set_preset_bank_capabilities(preset_bank); - - // VehicleType - Json::Value vehicle_info = root_json.get("VehicleInfo", ""); - smart_objects::SmartObject vehicle_type = - smart_objects::SmartObject(smart_objects::SmartType_Map); - vehicle_type["make"] = vehicle_info.get("make", "").asString(); - vehicle_type["model"] = vehicle_info.get("model", "").asString(); - vehicle_type["modelYear"] = vehicle_info.get("modelYear", "").asString(); - vehicle_type["trim"] = vehicle_info.get("trim", "").asString(); - set_vehicle_type(vehicle_type); + if (check_existing_json_member(root_json, "Buttons")) { + Json::Value buttons = root_json.get("Buttons", ""); + if (check_existing_json_member(buttons, "capabilities")) { + Json::Value bt_capabilities = buttons.get("capabilities", ""); + smart_objects::SmartObject buttons_capabilities_so; + Formatters::CFormatterJsonBase::jsonValueToObj( + bt_capabilities, buttons_capabilities_so); + + for (int32_t i = 0; i < buttons_capabilities_so.length(); ++i) { + if ((buttons_capabilities_so[i]).keyExists(strings::name)) { + std::map + ::const_iterator it = button_enum_name.find( + (buttons_capabilities_so[i][strings::name]).asString()); + buttons_capabilities_so[i].erase(strings::name); + if (button_enum_name.end() != it) { + buttons_capabilities_so[i][strings::name] = it->second; + } + } + } + set_button_capabilities(buttons_capabilities_so); + } + if (check_existing_json_member(buttons, "presetBankCapabilities")) { + Json::Value presetBank = buttons.get("presetBankCapabilities", ""); + smart_objects::SmartObject preset_bank_so; + Formatters::CFormatterJsonBase::jsonValueToObj( + presetBank, preset_bank_so); + set_preset_bank_capabilities(preset_bank_so); + } + } //Buttons end + + //VehicleType + if (check_existing_json_member(root_json, "VehicleInfo")) { + Json::Value vehicle_info = root_json.get("VehicleInfo", ""); + smart_objects::SmartObject vehicle_type_so; + Formatters::CFormatterJsonBase::jsonValueToObj( + vehicle_info, vehicle_type_so); + set_vehicle_type(vehicle_type_so); + }// VehicleType end + } catch (...) { return false; @@ -784,4 +853,20 @@ bool HMICapabilities::load_capabilities_from_file() { return true; } +bool HMICapabilities::check_existing_json_member( + const Json::Value& json_member, const char* name_of_member) { + return json_member.isMember(name_of_member); +} + +void HMICapabilities::convert_json_languages_to_obj(Json::Value& json_languages, + smart_objects::SmartObject& languages) { + for (int32_t i = 0, j = 0; i < json_languages.size(); ++i) { + std::map::const_iterator it = + languages_enum_values.find(json_languages[i].asString()); + if (languages_enum_values.end() != it) { + languages[j++] = it->second; + } + } +} + } // namespace application_manager diff --git a/src/components/application_manager/src/hmi_command_factory.cc b/src/components/application_manager/src/hmi_command_factory.cc index 2cbb6d8..3ed6fff 100644 --- a/src/components/application_manager/src/hmi_command_factory.cc +++ b/src/components/application_manager/src/hmi_command_factory.cc @@ -67,6 +67,7 @@ #include "application_manager/commands/hmi/on_exit_all_applications_notification.h" #include "application_manager/commands/hmi/on_exit_application_notification.h" #include "application_manager/commands/hmi/on_put_file_notification.h" +#include "application_manager/commands/hmi/on_resume_audio_source_notification.h" #include "application_manager/commands/hmi/on_ignition_cycle_over_notification.h" #include "application_manager/commands/hmi/on_system_info_changed_notification.h" #include "application_manager/commands/hmi/get_system_info_request.h" @@ -228,7 +229,6 @@ #include "application_manager/commands/hmi/on_navi_tbt_client_state_notification.h" #include "application_manager/commands/hmi/on_button_event_notification.h" #include "application_manager/commands/hmi/on_button_press_notification.h" -#include "application_manager/commands/hmi/on_show_notification.h" #include "application_manager/commands/hmi/on_vi_vehicle_data_notification.h" #include "application_manager/commands/hmi/on_ui_keyboard_input_notification.h" #include "application_manager/commands/hmi/on_ui_touch_event_notification.h" @@ -256,13 +256,11 @@ #include "application_manager/commands/hmi/on_policy_update.h" #include "application_manager/commands/hmi/get_urls.h" #include "application_manager/commands/hmi/get_urls_response.h" +#include "application_manager/commands/hmi/on_device_state_changed_notification.h" namespace application_manager { -#ifdef ENABLE_LOG -log4cxx::LoggerPtr HMICommandFactory::logger_ = log4cxx::LoggerPtr( - log4cxx::Logger::getLogger("ApplicationManager")); -#endif // ENABLE_LOG +CREATE_LOGGERPTR_GLOBAL(logger_, "ApplicationManager") CommandSharedPtr HMICommandFactory::CreateCommand( const MessageSharedPtr& message) { @@ -1907,10 +1905,6 @@ CommandSharedPtr HMICommandFactory::CreateCommand( break; } #endif // #ifdef HMI_DBUS_API - case hmi_apis::FunctionID::UI_ShowNotification: { - command.reset(new commands::OnShowNotification(message)); - break; - } case hmi_apis::FunctionID::Navigation_OnTBTClientState: { command.reset(new commands::OnNaviTBTClientStateNotification(message)); break; @@ -1975,6 +1969,10 @@ CommandSharedPtr HMICommandFactory::CreateCommand( command.reset(new commands::OnPutFileNotification(message)); break; } + case hmi_apis::FunctionID::BasicCommunication_OnResumeAudioSource: { + command.reset(new commands::OnResumeAudioSourceNotification(message)); + break; + } case hmi_apis::FunctionID::UI_SetDisplayLayout: { if (is_response) { command.reset(new commands::UiSetDisplayLayoutResponse(message)); @@ -2019,6 +2017,10 @@ CommandSharedPtr HMICommandFactory::CreateCommand( command.reset(new commands::OnPolicyUpdate(message)); break; } + case hmi_apis::FunctionID::SDL_OnDeviceStateChanged: { + command.reset(new commands::OnDeviceStateChangedNotification(message)); + break; + } } return command; diff --git a/src/components/application_manager/src/message_helper.cc b/src/components/application_manager/src/message_helper.cc index 12982ef..4044212 100644 --- a/src/components/application_manager/src/message_helper.cc +++ b/src/components/application_manager/src/message_helper.cc @@ -33,22 +33,27 @@ #include #include #include +#include +#include -#include "utils/macro.h" +#include "application_manager/application.h" #include "application_manager/application_manager_impl.h" +#include "application_manager/commands/command_impl.h" #include "application_manager/message_helper.h" #include "application_manager/policies/policy_handler.h" -#include "application_manager/commands/command_impl.h" -#include "connection_handler/connection_handler_impl.h" -#include "application_manager/application.h" #include "config_profile/profile.h" -#include "utils/file_system.h" +#include "connection_handler/connection_handler_impl.h" #include "interfaces/MOBILE_API.h" +#include "smart_objects/enum_schema_item.h" +#include "utils/file_system.h" +#include "utils/macro.h" +#include "utils/logger.h" -namespace { +namespace application_manager { -log4cxx::LoggerPtr g_logger = log4cxx::LoggerPtr( - log4cxx::Logger::getLogger("ApplicationManager")); +CREATE_LOGGERPTR_GLOBAL(logger_, "ApplicationManager") + +namespace { hmi_apis::Common_Language::eType ToCommonLanguage( mobile_apis::Language::eType mobile_language) { @@ -59,11 +64,11 @@ hmi_apis::Common_Language::eType ToCommonLanguage( long max_common_lang_val = long(hmi_apis::Common_Language::NO_NO); long max_mobile_lang = long(mobile_apis::Language::NO_NO); if (max_common_lang_val != max_mobile_lang) { - LOG4CXX_ERROR(g_logger, "Mapping between Common_Language and Language" + LOG4CXX_ERROR(logger_, "Mapping between Common_Language and Language" " has changed! Please update converter function"); } if (lang_val > max_common_lang_val) { - LOG4CXX_ERROR(g_logger, "Non-convertable language ID"); + LOG4CXX_ERROR(logger_, "Non-convertable language ID"); } return hmi_apis::Common_Language::eType(lang_val); } @@ -87,12 +92,6 @@ const uint32_t GetPriorityCode(const std::string& priority) { return static_cast(hmi_apis::Common_AppPriority::INVALID_ENUM); } -} // namespase - -namespace application_manager { - -namespace { - bool ValidateSoftButtons(smart_objects::SmartObject& soft_buttons) { using namespace smart_objects; for (size_t i = 0; i < soft_buttons.length(); ++i) { @@ -112,7 +111,7 @@ bool ValidateSoftButtons(smart_objects::SmartObject& soft_buttons) { } } return true; -} +} // namespace } std::pair kVehicleDataInitializer[] = { @@ -297,7 +296,7 @@ void MessageHelper::SendOnAppRegisteredNotificationToHMI( .ngn_media_screen_name(); if (resumption) { - message[strings::msg_params][strings::resumption] = true; + message[strings::msg_params][strings::resume_vr_grammars] = true; } if (ngn_media_screen_name) { @@ -337,10 +336,16 @@ void MessageHelper::SendOnAppRegisteredNotificationToHMI( .tts_name()); } std::string priority; - policy::PolicyHandler::instance()->policy_manager()->GetPriority( - application_impl.mobile_app_id()->asString(), &priority); - if (!priority.empty()) { - message[strings::msg_params]["priority"] = GetPriorityCode(priority); + // TODO(KKolodiy): need remove method policy_manager + policy::PolicyManager* policy_manager = + policy::PolicyHandler::instance()->policy_manager(); + if (!policy_manager) { + LOG4CXX_WARN(logger_, "The shared library of policy is not loaded"); + } else { + policy_manager->GetPriority(application_impl.mobile_app_id()->asString(), &priority); + if (!priority.empty()) { + message[strings::msg_params][strings::priority] = GetPriorityCode(priority); + } } DCHECK(ApplicationManagerImpl::instance()->ManageHMICommand(notification)); } @@ -348,7 +353,7 @@ void MessageHelper::SendOnAppRegisteredNotificationToHMI( smart_objects::SmartObject* MessageHelper::GetHashUpdateNotification( const uint32_t app_id) { - LOG4CXX_INFO(g_logger, "GetHashUpdateNotification" << app_id); + LOG4CXX_INFO(logger_, "GetHashUpdateNotification" << app_id); ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application( app_id); DCHECK(app.get()); @@ -363,7 +368,7 @@ smart_objects::SmartObject* MessageHelper::GetHashUpdateNotification( } void MessageHelper::SendHashUpdateNotification(const uint32_t app_id) { - LOG4CXX_INFO(g_logger, "SendHashUpdateNotification"); + LOG4CXX_INFO(logger_, "SendHashUpdateNotification"); smart_objects::SmartObject* so = GetHashUpdateNotification(app_id); PrintSmartObject(*so); @@ -397,152 +402,121 @@ const VehicleData& MessageHelper::vehicle_data() { return vehicle_data_; } -const char* MessageHelper::StringifiedHMILevel( +mobile_apis::HMILevel::eType MessageHelper::StringToHMILevel( + const std::string& hmi_level) { + using namespace NsSmartDeviceLink::NsSmartObjects; + mobile_apis::HMILevel::eType value; + if (TEnumSchemaItem::stringToEnum( + hmi_level, value)) { + return value; + } + return mobile_apis::HMILevel::INVALID_ENUM; +} + +std::string MessageHelper::StringifiedHMILevel( mobile_apis::HMILevel::eType hmi_level) { - switch (hmi_level) { - case mobile_apis::HMILevel::HMI_FULL: - return hmi_levels::kFull; - case mobile_apis::HMILevel::HMI_LIMITED: - return hmi_levels::kLimited; - case mobile_apis::HMILevel::HMI_BACKGROUND: - return hmi_levels::kBackground; - case mobile_apis::HMILevel::HMI_NONE: - return hmi_levels::kNone; - default: - return ""; + using namespace NsSmartDeviceLink::NsSmartObjects; + typedef std::map EnumMap; + const EnumMap& enum_map = + TEnumSchemaItem::getEnumElementsStringRepresentation(); + EnumMap::const_iterator found = enum_map.find(hmi_level); + if (found != enum_map.end()) { + const std::string& enum_name = found->second; + return enum_name; + } else { + return ""; } } -const char* MessageHelper::StringifiedFunctionID( +std::string MessageHelper::StringifiedFunctionID( mobile_apis::FunctionID::eType function_id) { - switch (function_id) { - case mobile_apis::FunctionID::RegisterAppInterfaceID: - return "RegisterAppInterface"; - case mobile_apis::FunctionID::UnregisterAppInterfaceID: - return "UnregisterAppInterface"; - case mobile_apis::FunctionID::SetGlobalPropertiesID: - return "SetGlobalProperties"; - case mobile_apis::FunctionID::ResetGlobalPropertiesID: - return "ResetGlobalProperties"; - case mobile_apis::FunctionID::AddCommandID: - return "AddCommand"; - case mobile_apis::FunctionID::DeleteCommandID: - return "DeleteCommand"; - case mobile_apis::FunctionID::AddSubMenuID: - return "AddSubMenu"; - case mobile_apis::FunctionID::DeleteSubMenuID: - return "DeleteSubMenu"; - case mobile_apis::FunctionID::CreateInteractionChoiceSetID: - return "CreateInteractionChoiceSet"; - case mobile_apis::FunctionID::PerformInteractionID: - return "PerformInteraction"; - case mobile_apis::FunctionID::DeleteInteractionChoiceSetID: - return "DeleteInteractionChoiceSet"; - case mobile_apis::FunctionID::AlertID: - return "Alert"; - case mobile_apis::FunctionID::ShowID: - return "Show"; - case mobile_apis::FunctionID::SpeakID: - return "Speak"; - case mobile_apis::FunctionID::SetMediaClockTimerID: - return "SetMediaClockTimer"; - case mobile_apis::FunctionID::EncodedSyncPDataID: - return "EncodedSyncPData"; - case mobile_apis::FunctionID::SyncPDataID: - return "SyncPData"; - case mobile_apis::FunctionID::PerformAudioPassThruID: - return "PerformAudioPassThru"; - case mobile_apis::FunctionID::EndAudioPassThruID: - return "EndAudioPassThru"; - case mobile_apis::FunctionID::SubscribeButtonID: - return "SubscribeButton"; - case mobile_apis::FunctionID::UnsubscribeButtonID: - return "UnsubscribeButton"; - case mobile_apis::FunctionID::SubscribeVehicleDataID: - return "SubscribeVehicleData"; - case mobile_apis::FunctionID::UnsubscribeVehicleDataID: - return "UnsubscribeVehicleData"; - case mobile_apis::FunctionID::GetVehicleDataID: - return "GetVehicleData"; - case mobile_apis::FunctionID::ReadDIDID: - return "ReadDID"; - case mobile_apis::FunctionID::GetDTCsID: - return "GetDTCs"; - case mobile_apis::FunctionID::ScrollableMessageID: - return "ScrollableMessage"; - case mobile_apis::FunctionID::SliderID: - return "Slider"; - case mobile_apis::FunctionID::ShowConstantTBTID: - return "ShowConstantTBT"; - case mobile_apis::FunctionID::AlertManeuverID: - return "AlertManeuver"; - case mobile_apis::FunctionID::UpdateTurnListID: - return "UpdateTurnList"; - case mobile_apis::FunctionID::ChangeRegistrationID: - return "ChangeRegistration"; - case mobile_apis::FunctionID::GenericResponseID: - return "GenericResponse"; - case mobile_apis::FunctionID::PutFileID: - return "PutFile"; - case mobile_apis::FunctionID::DeleteFileID: - return "DeleteFile"; - case mobile_apis::FunctionID::ListFilesID: - return "ListFiles"; - case mobile_apis::FunctionID::SetAppIconID: - return "SetAppIcon"; - case mobile_apis::FunctionID::SetDisplayLayoutID: - return "SetDisplayLayout"; - case mobile_apis::FunctionID::OnHMIStatusID: - return "OnHMIStatus"; - case mobile_apis::FunctionID::OnAppInterfaceUnregisteredID: - return "OnAppInterfaceUnregistered"; - case mobile_apis::FunctionID::OnButtonEventID: - return "OnButtonEvent"; - case mobile_apis::FunctionID::OnButtonPressID: - return "OnButtonPress"; - case mobile_apis::FunctionID::OnVehicleDataID: - return "OnVehicleData"; - case mobile_apis::FunctionID::OnCommandID: - return "OnCommand"; - case mobile_apis::FunctionID::OnEncodedSyncPDataID: - return "OnEncodedSyncPData"; - case mobile_apis::FunctionID::OnTBTClientStateID: - return "OnTBTClientState"; - case mobile_apis::FunctionID::OnPermissionsChangeID: - return "OnPermissionsChange"; - case mobile_apis::FunctionID::OnAudioPassThruID: - return "OnAudioPassThru"; - case mobile_apis::FunctionID::OnLanguageChangeID: - return "OnLanguageChange"; - case mobile_apis::FunctionID::OnDriverDistractionID: - return "OnDriverDistraction"; - case mobile_apis::FunctionID::OnSyncPDataID: - return "OnSyncPData"; - case mobile_apis::FunctionID::OnSystemRequestID: - return "OnSystemRequest"; - default: - return ""; + using namespace NsSmartDeviceLink::NsSmartObjects; + typedef std::map EnumMap; + const EnumMap& enum_map = + TEnumSchemaItem::getEnumElementsStringRepresentation(); + EnumMap::const_iterator found = enum_map.find(function_id); + if (found != enum_map.end()) { + const std::string& enum_name = found->second; + // Strip 'ID' suffix from value name + DCHECK(enum_name.length() > 2 + && enum_name.substr(enum_name.length() - 2) == "ID"); + return enum_name.substr(0, enum_name.length() - 2); + } else { + return ""; } } -void MessageHelper::CreateGetDeviceData(int32_t correlation_id) { +#ifdef HMI_DBUS_API +namespace { +const std::map create_get_vehicle_data_args() { + std::map rc; + rc.insert(std::make_pair(strings::gps, hmi_apis::FunctionID::VehicleInfo_GetGpsData)); + rc.insert(std::make_pair(strings::speed, hmi_apis::FunctionID::VehicleInfo_GetSpeed)); + rc.insert(std::make_pair(strings::rpm, hmi_apis::FunctionID::VehicleInfo_GetRpm)); + rc.insert(std::make_pair(strings::fuel_level, hmi_apis::FunctionID::VehicleInfo_GetFuelLevel)); + rc.insert(std::make_pair(strings::fuel_level_state, hmi_apis::FunctionID::VehicleInfo_GetFuelLevelState)); + rc.insert(std::make_pair(strings::instant_fuel_consumption, hmi_apis::FunctionID::VehicleInfo_GetInstantFuelConsumption)); + rc.insert(std::make_pair(strings::external_temp, hmi_apis::FunctionID::VehicleInfo_GetExternalTemperature)); + rc.insert(std::make_pair(strings::vin, hmi_apis::FunctionID::VehicleInfo_GetVin)); + rc.insert(std::make_pair(strings::prndl, hmi_apis::FunctionID::VehicleInfo_GetPrndl)); + rc.insert(std::make_pair(strings::tire_pressure, hmi_apis::FunctionID::VehicleInfo_GetTirePressure)); + rc.insert(std::make_pair(strings::odometer, hmi_apis::FunctionID::VehicleInfo_GetOdometer)); + rc.insert(std::make_pair(strings::belt_status, hmi_apis::FunctionID::VehicleInfo_GetBeltStatus)); + rc.insert(std::make_pair(strings::body_information, hmi_apis::FunctionID::VehicleInfo_GetBodyInformation)); + rc.insert(std::make_pair(strings::device_status, hmi_apis::FunctionID::VehicleInfo_GetDeviceStatus)); + rc.insert(std::make_pair(strings::driver_braking, hmi_apis::FunctionID::VehicleInfo_GetDriverBraking)); + rc.insert(std::make_pair(strings::wiper_status, hmi_apis::FunctionID::VehicleInfo_GetWiperStatus)); + rc.insert(std::make_pair(strings::head_lamp_status, hmi_apis::FunctionID::VehicleInfo_GetHeadLampStatus)); + rc.insert(std::make_pair(strings::engine_torque, hmi_apis::FunctionID::VehicleInfo_GetEngineTorque)); + rc.insert(std::make_pair(strings::acc_pedal_pos, hmi_apis::FunctionID::VehicleInfo_GetAccPedalPosition)); + rc.insert(std::make_pair(strings::steering_wheel_angle, hmi_apis::FunctionID::VehicleInfo_GetSteeringWheelAngle)); + rc.insert(std::make_pair(strings::e_call_info, hmi_apis::FunctionID::VehicleInfo_GetECallInfo)); + rc.insert(std::make_pair(strings::airbag_status, hmi_apis::FunctionID::VehicleInfo_GetAirbagStatus)); + rc.insert(std::make_pair(strings::emergency_event, hmi_apis::FunctionID::VehicleInfo_GetEmergencyEvent)); + rc.insert(std::make_pair(strings::cluster_mode_status, hmi_apis::FunctionID::VehicleInfo_GetClusterModeStatus)); + rc.insert(std::make_pair(strings::my_key, hmi_apis::FunctionID::VehicleInfo_GetMyKey)); + return rc; +} +static std::map vehicle_data_args = create_get_vehicle_data_args(); +} +#endif + +void MessageHelper::CreateGetVehicleDataRequest(uint32_t correlation_id, const std::vector& params) { +#ifdef HMI_JSON_API smart_objects::SmartObject* request = new smart_objects::SmartObject; - if (!request) { - return; - } - smart_objects::SmartObject& object = *request; - object[strings::params][strings::message_type] = static_cast(kRequest); - object[strings::params][strings::function_id] = + + (*request)[strings::params][strings::message_type] = static_cast(kRequest); + (*request)[strings::params][strings::function_id] = static_cast(hmi_apis::FunctionID::VehicleInfo_GetVehicleData); - object[strings::params][strings::correlation_id] = correlation_id; - object[strings::params][strings::protocol_version] = + (*request)[strings::params][strings::correlation_id] = correlation_id; + (*request)[strings::params][strings::protocol_version] = commands::CommandImpl::protocol_version_; - object[strings::params][strings::protocol_type] = + (*request)[strings::params][strings::protocol_type] = commands::CommandImpl::hmi_protocol_type_; - object[strings::msg_params] = smart_objects::SmartObject( - smart_objects::SmartType_Map); - object[strings::msg_params][strings::odometer] = true; + (*request)[strings::msg_params] = smart_objects::SmartObject(smart_objects::SmartType_Map); + for (std::vector::const_iterator it = params.begin(); + it != params.end(); it++) { + (*request)[strings::msg_params][*it] = true; + } ApplicationManagerImpl::instance()->ManageHMICommand(request); +#endif + +#ifdef HMI_DBUS_API + for (std::vector::const_iterator it = params.begin(); + it != params.end(); it++) { + smart_objects::SmartObject* request = new smart_objects::SmartObject; + + (*request)[strings::params][strings::message_type] = static_cast(kRequest); + (*request)[strings::params][strings::correlation_id] = correlation_id; + (*request)[strings::params][strings::protocol_version] = + commands::CommandImpl::protocol_version_; + (*request)[strings::params][strings::protocol_type] = + commands::CommandImpl::hmi_protocol_type_; + (*request)[strings::params][strings::function_id] = + static_cast(vehicle_data_args[*it]); + ApplicationManagerImpl::instance()->ManageHMICommand(request); + } +#endif } smart_objects::SmartObject* MessageHelper::CreateBlockedByPoliciesResponse( @@ -631,7 +605,7 @@ smart_objects::SmartObject* MessageHelper::CreateSetAppIcon( } bool MessageHelper::SendIVISubscribtions(const uint32_t app_id) { - LOG4CXX_INFO(g_logger, " MessageHelper::SendIVISubscribtions "); + LOG4CXX_INFO(logger_, " MessageHelper::SendIVISubscribtions "); bool succes = true; ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application( @@ -650,7 +624,7 @@ bool MessageHelper::SendIVISubscribtions(const uint32_t app_id) { MessageHelper::SmartObjectList MessageHelper::GetIVISubscribtionRequests( const uint32_t app_id) { - LOG4CXX_INFO(g_logger, " MessageHelper::GetIVISubscribtionRequests "); + LOG4CXX_INFO(logger_, " MessageHelper::GetIVISubscribtionRequests "); ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application( app_id); @@ -1197,15 +1171,21 @@ void MessageHelper::SendOnAppUnregNotificationToHMI( hmi_apis::FunctionID::BasicCommunication_OnAppUnregistered; message[strings::params][strings::message_type] = MessageType::kNotification; - message[strings::msg_params][strings::app_id] = app->app_id(); - + // we put hmi_app_id because applicaton list does not contain application on this momment + // and ReplaceHMIByMobileAppId function will be unable to replace app_id to hmi_app_id + message[strings::msg_params][strings::app_id] = app->hmi_app_id(); ApplicationManagerImpl::instance()->ManageHMICommand(&message); } void MessageHelper::SendActivateAppToHMI(uint32_t const app_id) { smart_objects::SmartObject* message = new smart_objects::SmartObject( smart_objects::SmartType_Map); - if (!message) { + + application_manager::ApplicationConstSharedPtr app = + application_manager::ApplicationManagerImpl::instance() + ->application(app_id); + if (!app.valid()) { + LOG4CXX_WARN(logger_, "Invalid app_id: " << app_id); return; } @@ -1216,14 +1196,15 @@ void MessageHelper::SendActivateAppToHMI(uint32_t const app_id) { ApplicationManagerImpl::instance()->GetNextHMICorrelationID(); (*message)[strings::msg_params][strings::app_id] = app_id; - application_manager::ApplicationConstSharedPtr app = - application_manager::ApplicationManagerImpl::instance() - ->application(app_id); - std::string priority; - policy::PolicyHandler::instance()->policy_manager()->GetPriority( - app->mobile_app_id()->asString(), &priority); - + // TODO(KKolodiy): need remove method policy_manager + policy::PolicyManager* policy_manager = + policy::PolicyHandler::instance()->policy_manager(); + if (!policy_manager) { + LOG4CXX_WARN(logger_, "The shared library of policy is not loaded"); + } else { + policy_manager->GetPriority(app->mobile_app_id()->asString(), &priority); + } if (!priority.empty()) { (*message)[strings::msg_params]["priority"] = GetPriorityCode(priority); } @@ -1231,6 +1212,39 @@ void MessageHelper::SendActivateAppToHMI(uint32_t const app_id) { ApplicationManagerImpl::instance()->ManageHMICommand(message); } +void MessageHelper::SendOnResumeAudioSourceToHMI(const uint32_t app_id) { + LOG4CXX_WARN(logger_, "SendOnResumeAudioSourceToHMI app_id: " << app_id); + + smart_objects::SmartObject* message = new smart_objects::SmartObject( + smart_objects::SmartType_Map); + application_manager::ApplicationConstSharedPtr app = + application_manager::ApplicationManagerImpl::instance() + ->application(app_id); + if (!app.valid()) { + LOG4CXX_WARN(logger_, "Invalid app_id: " << app_id); + return; + } + + (*message)[strings::params][strings::function_id] = + hmi_apis::FunctionID::BasicCommunication_OnResumeAudioSource; + (*message)[strings::params][strings::message_type] = MessageType::kNotification; + (*message)[strings::params][strings::correlation_id] = + ApplicationManagerImpl::instance()->GetNextHMICorrelationID(); + (*message)[strings::msg_params][strings::app_id] = app_id; + + ApplicationManagerImpl::instance()->ManageHMICommand(message); +} + +std::string MessageHelper::GetDeviceMacAddressForHandle( + const uint32_t device_handle) { + + std::string device_mac_address = ""; + connection_handler::ConnectionHandlerImpl::instance()->GetDataOnDeviceID( + device_handle, NULL, NULL, &device_mac_address); + + return device_mac_address; +} + void MessageHelper::GetDeviceInfoForHandle(const uint32_t device_handle, policy::DeviceParams* device_info) { if (!device_info) { @@ -1277,24 +1291,19 @@ void MessageHelper::SendActivateAppResponse(policy::AppPermissions& permissions, commands::CommandImpl::protocol_version_; (*message)[strings::params][hmi_response::code] = 0; - bool isSDLAllowed = permissions.isSDLAllowed; - if (!isSDLAllowed) { + (*message)[strings::msg_params]["isSDLAllowed"] = permissions.isSDLAllowed; + if (!permissions.isSDLAllowed) { (*message)[strings::msg_params]["device"]["name"] = permissions.deviceInfo .device_name; - // TODO(AOleynik): Change id assignment (*message)[strings::msg_params]["device"]["id"] = permissions.deviceInfo .device_handle; } - (*message)[strings::msg_params]["isSDLAllowed"] = isSDLAllowed; + (*message)[strings::msg_params]["isAppRevoked"] = permissions.appRevoked; + (*message)[strings::msg_params]["isAppPermissionsRevoked"] = permissions + .isAppPermissionsRevoked; - // TODO(AOleynik): Add processing of other parameters - if (permissions.appRevoked) { - (*message)[strings::msg_params]["isAppRevoked"] = permissions.appRevoked; - } if (permissions.isAppPermissionsRevoked) { - (*message)[strings::msg_params]["isAppPermissionsRevoked"] = permissions - .isAppPermissionsRevoked; (*message)[strings::msg_params]["appRevokedPermissions"] = smart_objects::SmartObject(smart_objects::SmartType_Array); for (size_t i = 0; i < permissions.appRevokedPermissions.size(); ++i) { @@ -1302,10 +1311,10 @@ void MessageHelper::SendActivateAppResponse(policy::AppPermissions& permissions, .appRevokedPermissions[i]; } } - if (permissions.appPermissionsConsentNeeded) { - (*message)[strings::msg_params]["isPermissionsConsentNeeded"] = permissions - .appPermissionsConsentNeeded; - } + + (*message)[strings::msg_params]["isPermissionsConsentNeeded"] = permissions + .appPermissionsConsentNeeded; + if (!permissions.priority.empty()) { (*message)[strings::msg_params]["priority"] = GetPriorityCode( permissions.priority); @@ -1372,26 +1381,6 @@ void MessageHelper::SendPolicyUpdate( ApplicationManagerImpl::instance()->ManageHMICommand(message); } -void MessageHelper::SendUpdateSDLResponse(const std::string& result, - uint32_t correlation_id) { - smart_objects::SmartObject* message = new smart_objects::SmartObject( - smart_objects::SmartType_Map); - if (!message) { - return; - } - - (*message)[strings::params][strings::function_id] = - hmi_apis::FunctionID::SDL_UpdateSDL; - (*message)[strings::params][strings::message_type] = - MessageType::kResponse; - (*message)[strings::params][strings::correlation_id] = correlation_id; - (*message)[strings::params][hmi_response::code] = 0; - - (*message)[strings::msg_params]["result"] = result; - - ApplicationManagerImpl::instance()->ManageHMICommand(message); -} - void MessageHelper::SendGetUserFriendlyMessageResponse( const std::vector& msg, uint32_t correlation_id) { @@ -1426,6 +1415,7 @@ void MessageHelper::SendGetUserFriendlyMessageResponse( const std::string line1 = "line1"; const std::string line2 = "line2"; const std::string textBody = "textBody"; + const std::string message_code = "messageCode"; std::vector::const_iterator it = msg.begin(); std::vector::const_iterator it_end = msg.end(); @@ -1433,22 +1423,23 @@ void MessageHelper::SendGetUserFriendlyMessageResponse( user_friendly_messages[index] = smart_objects::SmartObject( smart_objects::SmartType_Map); - smart_objects::SmartObject& msg = user_friendly_messages[index]; + smart_objects::SmartObject& obj = user_friendly_messages[index]; + obj[message_code] = it->message_code; if (!it->tts.empty()) { - msg[tts] = it->tts; + obj[tts] = it->tts; } if (!it->label.empty()) { - msg[label] = it->label; + obj[label] = it->label; } if (!it->line1.empty()) { - msg[line1] = it->line1; + obj[line1] = it->line1; } if (!it->line2.empty()) { - msg[line2] = it->line2; + obj[line2] = it->line2; } if (!it->text_body.empty()) { - msg[textBody] = it->text_body; + obj[textBody] = it->text_body; } } @@ -1489,10 +1480,10 @@ void MessageHelper::SendGetListOfPermissionsResponse( smart_objects::SmartObject& item = allowed_functions_array[index]; item[strings::name] = (*it).group_name; item[strings::id] = (*it).group_id; - policy::PermissionState permission_state = (*it).state; + policy::GroupConsent permission_state = (*it).state; // If state undefined, 'allowed' parameter should be absent - if (policy::kUndefined != permission_state) { - item["allowed"] = policy::kAllowed == permission_state; + if (policy::kGroupUndefined != permission_state) { + item["allowed"] = policy::kGroupAllowed == permission_state; } } @@ -1581,7 +1572,7 @@ void MessageHelper::ResetGlobalproperties(ApplicationSharedPtr app) { void MessageHelper::SendNaviStartStream(const std::string& url, int32_t connection_key) { - LOG4CXX_INFO(g_logger, "MessageHelper::SendNaviStartStream"); + LOG4CXX_INFO(logger_, "MessageHelper::SendNaviStartStream"); smart_objects::SmartObject* start_stream = new smart_objects::SmartObject( smart_objects::SmartType_Map); @@ -1718,7 +1709,7 @@ void MessageHelper::SendAudioStopStream(int32_t connection_key) { } bool MessageHelper::SendStopAudioPathThru() { - LOG4CXX_INFO(g_logger, "MessageHelper::SendAudioStopAudioPathThru"); + LOG4CXX_INFO(logger_, "MessageHelper::SendAudioStopAudioPathThru"); NsSmartDeviceLink::NsSmartObjects::SmartObject* result = new NsSmartDeviceLink::NsSmartObjects::SmartObject; @@ -1739,7 +1730,6 @@ bool MessageHelper::SendStopAudioPathThru() { void MessageHelper::SendPolicySnapshotNotification( unsigned int connection_key, const std::vector& policy_data, const std::string& url, int timeout) { - printf("\n\t\t\t\tSendPolicySnapshotNotification\n"); smart_objects::SmartObject* pt_notification = new smart_objects::SmartObject( smart_objects::SmartType_Map); smart_objects::SmartObject& content = *pt_notification; @@ -1950,6 +1940,27 @@ void MessageHelper::SendGetStatusUpdateResponse(const std::string& status, ApplicationManagerImpl::instance()->ManageHMICommand(message); } +void MessageHelper::SendUpdateSDLResponse(const std::string& result, uint32_t correlation_id) { + smart_objects::SmartObject* message = new smart_objects::SmartObject( + smart_objects::SmartType_Map); + if (!message) { + return; + } + + (*message)[strings::params][strings::function_id] = + hmi_apis::FunctionID::SDL_UpdateSDL; + (*message)[strings::params][strings::message_type] = + MessageType::kResponse; + (*message)[strings::params][strings::correlation_id] = correlation_id; + (*message)[strings::params][hmi_response::code] = 0; + + (*message)[strings::msg_params]["result"] = result; + + ApplicationManagerImpl::instance()->ManageHMICommand(message); +} + + + void MessageHelper::SendOnStatusUpdate(const std::string& status) { smart_objects::SmartObject* message = new smart_objects::SmartObject( smart_objects::SmartType_Map); @@ -2041,7 +2052,7 @@ mobile_apis::Result::eType MessageHelper::VerifyImage( full_file_path += file_name; } else { - full_file_path += app->name(); + full_file_path += app->folder_name(); full_file_path += "/"; full_file_path += file_name; } @@ -2050,20 +2061,26 @@ mobile_apis::Result::eType MessageHelper::VerifyImage( return mobile_apis::Result::INVALID_DATA; } - const HMICapabilities& hmi_capabilities = ApplicationManagerImpl::instance() - ->hmi_capabilities(); - mobile_apis::ImageType::eType image_type = - static_cast(image[strings::image_type] - .asInt()); - if (!hmi_capabilities.VerifyImageType(image_type)) { - return mobile_apis::Result::UNSUPPORTED_RESOURCE; - } - image[strings::value] = full_file_path; return mobile_apis::Result::SUCCESS; } +mobile_apis::Result::eType MessageHelper::VerifyImageVrHelpItems( + smart_objects::SmartObject& message, ApplicationConstSharedPtr app) { + mobile_apis::Result::eType verification_result_image = + mobile_apis::Result::SUCCESS; + for (uint32_t i = 0; i < message.length(); ++i) { + if (message[i].keyExists(strings::image)) { + verification_result_image = VerifyImage(message[i][strings::image], app); + if (mobile_apis::Result::SUCCESS != verification_result_image) { + return verification_result_image; + } + } + } + return mobile_apis::Result::SUCCESS; +} + bool MessageHelper::VerifySoftButtonText( smart_objects::SmartObject& soft_button) { std::string text = soft_button[strings::text].asString(); @@ -2104,7 +2121,6 @@ mobile_apis::Result::eType MessageHelper::ProcessSoftButtons( smart_objects::SmartObject soft_buttons = smart_objects::SmartObject( smart_objects::SmartType_Array); - bool flag_unsuported_resource = false; int32_t j = 0; for (int32_t i = 0; i < request_soft_buttons.length(); ++i) { @@ -2117,15 +2133,8 @@ mobile_apis::Result::eType MessageHelper::ProcessSoftButtons( if (request_soft_buttons[i].keyExists(strings::image)) { mobile_apis::Result::eType verification_result = VerifyImage( request_soft_buttons[i][strings::image], app); - if (mobile_apis::Result::SUCCESS != verification_result) { - if (mobile_apis::Result::UNSUPPORTED_RESOURCE - == verification_result) { - request_soft_buttons[i].erase(strings::image); - flag_unsuported_resource = true; - } else { - return mobile_apis::Result::INVALID_DATA; - } + return mobile_apis::Result::INVALID_DATA; } } else { return mobile_apis::Result::INVALID_DATA; @@ -2162,13 +2171,8 @@ mobile_apis::Result::eType MessageHelper::ProcessSoftButtons( request_soft_buttons[i][strings::image], app); if (mobile_apis::Result::SUCCESS != verification_result) { - if (mobile_apis::Result::UNSUPPORTED_RESOURCE - == verification_result) { - request_soft_buttons[i].erase(strings::image); - flag_unsuported_resource = true; - } else { - return mobile_apis::Result::INVALID_DATA; - } + return mobile_apis::Result::INVALID_DATA; + } } break; @@ -2180,12 +2184,6 @@ mobile_apis::Result::eType MessageHelper::ProcessSoftButtons( } soft_buttons[j] = request_soft_buttons[i]; - - if (!soft_buttons[j].keyExists(strings::system_action)) { - soft_buttons[j][strings::system_action] = - mobile_apis::SystemAction::DEFAULT_ACTION; - } - ++j; } @@ -2194,15 +2192,12 @@ mobile_apis::Result::eType MessageHelper::ProcessSoftButtons( if (0 == request_soft_buttons.length()) { message_params.erase(strings::soft_buttons); } - if (flag_unsuported_resource) { - return mobile_apis::Result::UNSUPPORTED_RESOURCE; - } else { - return mobile_apis::Result::SUCCESS; - } + return mobile_apis::Result::SUCCESS; } // TODO(AK): change printf to logger bool MessageHelper::PrintSmartObject(const smart_objects::SmartObject& object) { +#ifdef ENABLE_LOG static uint32_t tab = 0; std::string tab_buffer; @@ -2268,7 +2263,7 @@ bool MessageHelper::PrintSmartObject(const smart_objects::SmartObject& object) { } else { printf("\n-------------------------------------------------------------\n"); } - +#endif return true; } diff --git a/src/components/application_manager/src/mobile_message_handler.cc b/src/components/application_manager/src/mobile_message_handler.cc index d0693fa..52637c1 100644 --- a/src/components/application_manager/src/mobile_message_handler.cc +++ b/src/components/application_manager/src/mobile_message_handler.cc @@ -37,6 +37,7 @@ #include "protocol_handler/service_type.h" #include "protocol_handler/protocol_payload.h" #include "utils/bitstream.h" +#include "utils/logger.h" #include #include @@ -50,10 +51,8 @@ const uint8_t kUnknown = 0xF; namespace application_manager { -#ifdef ENABLE_LOG -log4cxx::LoggerPtr MobileMessageHandler::logger_ = log4cxx::LoggerPtr( - log4cxx::Logger::getLogger("MobileMessageHandler")); -#endif // ENABLE_LOG +CREATE_LOGGERPTR_GLOBAL(logger_, "MobileMessageHandler") + application_manager::Message* MobileMessageHandler::HandleIncomingMessageProtocolV1( diff --git a/src/components/application_manager/src/policies/policy_event_observer.cc b/src/components/application_manager/src/policies/policy_event_observer.cc index 6cfbbd6..6fbc3df 100644 --- a/src/components/application_manager/src/policies/policy_event_observer.cc +++ b/src/components/application_manager/src/policies/policy_event_observer.cc @@ -32,8 +32,9 @@ #include "application_manager/policies/policy_event_observer.h" #include "application_manager/smart_object_keys.h" -#include "smart_objects/smart_object.h" #include "utils/date_time.h" +#include "policy/policy_manager.h" +#include "smart_objects/smart_object.h" namespace policy { namespace smart_objects = NsSmartDeviceLink::NsSmartObjects; @@ -50,28 +51,44 @@ void PolicyEventObserver::on_event(const event_engine::Event& event) { const smart_objects::SmartObject& message = event.smart_object(); switch (event.id()) { +#ifdef HMI_JSON_API case hmi_apis::FunctionID::VehicleInfo_GetVehicleData: { - if (hmi_apis::Common_Result::SUCCESS - == static_cast(message[strings::params][hmi_response::code] - .asInt())) { - if (message[strings::msg_params].keyExists(strings::odometer)) { - - TimevalStruct current_time = date_time::DateTime::getCurrentTime(); - const int kSecondsInDay = 60 * 60 * 24; - int days_after_epoch = current_time.tv_sec / kSecondsInDay; - - policy_manager_->PTUpdatedAt( - message[strings::msg_params][strings::odometer].asInt(), - days_after_epoch); - } - } + ProcessOdometerEvent(message); break; } default: { break; } - } unsubscribe_from_event(hmi_apis::FunctionID::VehicleInfo_GetVehicleData); +#endif +#ifdef HMI_DBUS_API + case hmi_apis::FunctionID::VehicleInfo_GetOdometer: { + ProcessOdometerEvent(message); + break; + } + default: { + break; + } + unsubscribe_from_event(hmi_apis::FunctionID::VehicleInfo_GetOdometer); +#endif + } +} + +void PolicyEventObserver::ProcessOdometerEvent(const smart_objects::SmartObject& message) { + if (hmi_apis::Common_Result::SUCCESS + == static_cast(message[strings::params][hmi_response::code] + .asInt())) { + + if (message[strings::msg_params].keyExists(strings::odometer)) { + TimevalStruct current_time = date_time::DateTime::getCurrentTime(); + const int kSecondsInDay = 60 * 60 * 24; + int days_after_epoch = current_time.tv_sec / kSecondsInDay; + + policy_manager_->PTUpdatedAt( + message[strings::msg_params][strings::odometer].asInt(), + days_after_epoch); + } + } } void PolicyEventObserver::subscribe_on_event( diff --git a/src/components/application_manager/src/policies/policy_handler.cc b/src/components/application_manager/src/policies/policy_handler.cc index 68e6414..f602e80 100644 --- a/src/components/application_manager/src/policies/policy_handler.cc +++ b/src/components/application_manager/src/policies/policy_handler.cc @@ -33,6 +33,8 @@ #include #include #include +#include +#include "application_manager/smart_object_keys.h" #include "application_manager/policies/policy_handler.h" #include "application_manager/policies/policy_retry_sequence.h" #include "application_manager/policies/pt_exchange_handler_impl.h" @@ -45,6 +47,7 @@ #include "json/value.h" #include "config_profile/profile.h" #include "application_manager/usage_statistics.h" +#include "policy/policy_types.h" namespace policy { typedef std::set> ApplicationList; @@ -52,14 +55,14 @@ typedef std::set> Application PolicyHandler* PolicyHandler::instance_ = NULL; const std::string PolicyHandler::kLibrary = "libPolicy.so"; -log4cxx::LoggerPtr PolicyHandler::logger_ = log4cxx::LoggerPtr( - log4cxx::Logger::getLogger("PolicyHandler")); +CREATE_LOGGERPTR_GLOBAL(logger_, "PolicyHandler") PolicyHandler::PolicyHandler() : policy_manager_(0), dl_handle_(0), exchange_handler_(NULL), is_exchange_in_progress_(false), + on_ignition_check_done_(false), retry_sequence_("RetrySequence", new RetrySequence(this)) { } @@ -68,19 +71,18 @@ PolicyHandler::~PolicyHandler() { } PolicyManager* PolicyHandler::LoadPolicyLibrary() { - return LoadPolicyLibrary("./"); -} - -PolicyManager* PolicyHandler::LoadPolicyLibrary(const std::string& path) { - std::string filename = path + kLibrary; - dl_handle_ = dlopen(filename.c_str(), RTLD_LAZY); + if (profile::Profile::instance()->policy_turn_off()) { + LOG4CXX_WARN(logger_, "System is configured to work without policy functionality."); + policy_manager_ = NULL; + return NULL; + } + dl_handle_ = dlopen(kLibrary.c_str(), RTLD_LAZY); char* error_string = dlerror(); if (error_string == NULL) { policy_manager_ = CreateManager(); policy_manager_->set_listener(this); #if defined (EXTENDED_POLICY) - //exchange_handler_ = new PTExchangeHandlerImpl(this); exchange_handler_ = new PTExchangeHandlerExt(this); #else exchange_handler_ = new PTExchangeHandlerImpl(this); @@ -108,13 +110,19 @@ PolicyManager* PolicyHandler::CreateManager() { bool PolicyHandler::InitPolicyTable() { std::string preloaded_file = profile::Profile::instance()->preloaded_pt_file(); - DCHECK(policy_manager_); + if (!policy_manager_) { + LOG4CXX_WARN(logger_, "The shared library of policy is not loaded"); + return false; + } return policy_manager_->LoadPTFromFile(preloaded_file); } bool PolicyHandler::RevertPolicyTable() { LOG4CXX_INFO(logger_, "Removing user consent records in policy table."); - DCHECK(policy_manager_); + if (!policy_manager_) { + LOG4CXX_WARN(logger_, "The shared library of policy is not loaded"); + return false; + } return policy_manager()->ResetUserConsent(); } @@ -184,6 +192,10 @@ uint32_t PolicyHandler::GetAppIdForSending() { } DeviceConsent PolicyHandler::GetDeviceForSending(DeviceParams& device_params) { + if (!policy_manager_) { + LOG4CXX_WARN(logger_, "The shared library of policy is not loaded"); + return kDeviceDisallowed; + } uint32_t app_id = 0; uint32_t app_id_previous = 0; while (true) { @@ -235,24 +247,33 @@ const std::string PolicyHandler::ConvertUpdateStatus(PolicyTableStatus status) { void PolicyHandler::SetDeviceInfo(std::string& device_id, const DeviceInfo& device_info) { LOG4CXX_INFO(logger_, "SetDeviceInfo"); + if (!policy_manager_) { + LOG4CXX_WARN(logger_, "The shared library of policy is not loaded"); + return; + } policy_manager_->SetDeviceInfo(device_id, device_info); } void PolicyHandler::OnAppPermissionConsent( const PermissionConsent& permissions) { LOG4CXX_INFO(logger_, "OnAppPermissionConsent"); - DCHECK(policy_manager_); + if (!policy_manager_) { + LOG4CXX_WARN(logger_, "The shared library of policy is not loaded"); + return; + } if (!permissions.policy_app_id.empty()) { policy_manager_->SetUserConsentForApp(permissions); } - - //TODO(AOleynik): Handle situation for all apps (policy_app_id is empty) } void PolicyHandler::OnGetUserFriendlyMessage( const std::vector& message_codes, const std::string& language, uint32_t correlation_id) { LOG4CXX_INFO(logger_, "OnGetUserFriendlyMessage"); + if (!policy_manager_) { + LOG4CXX_WARN(logger_, "The shared library of policy is not loaded"); + return; + } std::vector result = policy_manager_ ->GetUserFriendlyMessages(message_codes, language); // Send response to HMI with gathered data @@ -263,6 +284,10 @@ void PolicyHandler::OnGetUserFriendlyMessage( void PolicyHandler::OnGetListOfPermissions(const uint32_t connection_key, const uint32_t correlation_id) { LOG4CXX_INFO(logger_, "OnGetListOfPermissions"); + if (!policy_manager_) { + LOG4CXX_WARN(logger_, "The shared library of policy is not loaded"); + return; + } application_manager::ApplicationSharedPtr app = application_manager::ApplicationManagerImpl::instance()->application( connection_key); @@ -287,6 +312,10 @@ void PolicyHandler::OnGetListOfPermissions(const uint32_t connection_key, void PolicyHandler::OnGetStatusUpdate(const uint32_t correlation_id) { LOG4CXX_INFO(logger_, "OnGetStatusUpdate"); + if (!policy_manager_) { + LOG4CXX_WARN(logger_, "The shared library of policy is not loaded"); + return; + } policy::PolicyTableStatus status = policy_manager_->GetPolicyTableStatus(); application_manager::MessageHelper::SendGetStatusUpdateResponse( ConvertUpdateStatus(status), correlation_id); @@ -298,10 +327,9 @@ void PolicyHandler::OnUpdateStatusChanged(PolicyTableStatus status) { ConvertUpdateStatus(status)); } -void PolicyHandler::OnCurrentDeviceIdUpdateRequired( +std::string PolicyHandler::OnCurrentDeviceIdUpdateRequired( const std::string& policy_app_id) { LOG4CXX_INFO(logger_, "OnCurrentDeviceIdUpdateRequired"); - // TODO(AOleynik): Get registered device info from SDL application_manager::ApplicationSharedPtr app = application_manager::ApplicationManagerImpl::instance() ->application_by_policy_id(policy_app_id); @@ -309,17 +337,20 @@ void PolicyHandler::OnCurrentDeviceIdUpdateRequired( if (!app.valid()) { LOG4CXX_WARN(logger_, "Application with id '" << policy_app_id << "' " "not found within registered applications."); - policy_manager_->UpdateCurrentDeviceId(std::string()); - return; + return ""; } DeviceParams device_param; application_manager::MessageHelper::GetDeviceInfoForApp(app->app_id(), &device_param); - policy_manager_->UpdateCurrentDeviceId(device_param.device_mac_address); + return device_param.device_mac_address; } void PolicyHandler::OnSystemInfoChanged(const std::string& language) { LOG4CXX_INFO(logger_, "OnSystemInfoChanged"); + if (!policy_manager_) { + LOG4CXX_WARN(logger_, "The shared library of policy is not loaded"); + return; + } policy_manager_->SetSystemLanguage(language); } @@ -327,11 +358,19 @@ void PolicyHandler::OnGetSystemInfo(const std::string& ccpu_version, const std::string& wers_country_code, const std::string& language) { LOG4CXX_INFO(logger_, "OnGetSystemInfo"); + if (!policy_manager_) { + LOG4CXX_WARN(logger_, "The shared library of policy is not loaded"); + return; + } policy_manager_->SetSystemInfo(ccpu_version, wers_country_code, language); } void PolicyHandler::OnSystemInfoUpdateRequired() { LOG4CXX_INFO(logger_, "OnSystemInfoUpdateRequired"); + if (!policy_manager_) { + LOG4CXX_WARN(logger_, "The shared library of policy is not loaded"); + return; + } application_manager::MessageHelper::SendGetSystemInfoRequest(); } @@ -380,7 +419,8 @@ void PolicyHandler::OnPendingPermissionChange( case mobile_apis::HMILevel::HMI_FULL: case mobile_apis::HMILevel::HMI_LIMITED: case mobile_apis::HMILevel::HMI_BACKGROUND: { - if (permissions.isAppPermissionsRevoked) { + if (permissions.isAppPermissionsRevoked + || permissions.appUnauthorized) { application_manager::MessageHelper::SendOnAppPermissionsChangedNotification( app->app_id(), permissions); policy_manager_->RemovePendingPermissionChanges(policy_app_id); @@ -395,24 +435,33 @@ void PolicyHandler::OnPendingPermissionChange( bool PolicyHandler::SendMessageToSDK(const BinaryMessage& pt_string) { LOG4CXX_INFO(logger_, "PolicyHandler::SendMessageToSDK"); - + if (!policy_manager_) { + LOG4CXX_WARN(logger_, "The shared library of policy is not loaded"); + return false; + } is_exchange_in_progress_ = true; std::string url; uint32_t app_id = last_used_app_ids_.back(); - if (policy_manager_) { - application_manager::ApplicationSharedPtr app = - application_manager::ApplicationManagerImpl::instance() - ->application(app_id); - if (!app.valid()) { - LOG4CXX_WARN(logger_, "There is no registered application with " - "connection key '" << app_id << "'"); - return false; - } + application_manager::ApplicationSharedPtr app = + application_manager::ApplicationManagerImpl::instance() + ->application(app_id); - url = policy_manager_->GetUpdateUrl(PolicyServiceTypes::POLICY); + if (!app.valid()) { + LOG4CXX_WARN(logger_, "There is no registered application with " + "connection key '" << app_id << "'"); + return false; + } + + const std::string& mobile_app_id = app->mobile_app_id()->asString(); + if (mobile_app_id.empty()) { + LOG4CXX_WARN(logger_, "Application with connection key '" << app_id << "'" + " has no application id."); + return false; } + url = policy_manager_->GetUpdateUrl(PolicyServiceTypes::POLICY); + LOG4CXX_INFO( logger_, "Update url is " << url << " for application " << application_manager::ApplicationManagerImpl::instance()-> application(app_id)->name()); @@ -423,7 +472,8 @@ bool PolicyHandler::SendMessageToSDK(const BinaryMessage& pt_string) { return true; } -bool PolicyHandler::ReceiveMessageFromSDK(const BinaryMessage& pt_string) { +bool PolicyHandler::ReceiveMessageFromSDK(const std::string& file, + const BinaryMessage& pt_string) { if (!policy_manager_) { LOG4CXX_WARN(logger_, "The shared library of policy is not loaded"); return false; @@ -431,7 +481,7 @@ bool PolicyHandler::ReceiveMessageFromSDK(const BinaryMessage& pt_string) { is_exchange_in_progress_ = false; - bool ret = policy_manager_->LoadPT(pt_string); + bool ret = policy_manager_->LoadPT(file, pt_string); LOG4CXX_INFO(logger_, "Policy table is saved: " << std::boolalpha << ret); if (ret) { LOG4CXX_INFO(logger_, "PTU was successful."); @@ -442,9 +492,24 @@ bool PolicyHandler::ReceiveMessageFromSDK(const BinaryMessage& pt_string) { application_manager::ApplicationManagerImpl::instance() ->GetNextHMICorrelationID(); event_observer_ = new PolicyEventObserver(policy_manager_); + event_observer_.get()->subscribe_on_event( +#ifdef HMI_JSON_API hmi_apis::FunctionID::VehicleInfo_GetVehicleData, correlation_id); - application_manager::MessageHelper::CreateGetDeviceData(correlation_id); +#endif +#ifdef HMI_DBUS_API + hmi_apis::FunctionID::VehicleInfo_GetOdometer, correlation_id); +#endif + std::vector vehicle_data_args; + vehicle_data_args.push_back(application_manager::strings::odometer); + application_manager::MessageHelper::CreateGetVehicleDataRequest(correlation_id, vehicle_data_args); + if (policy_manager_->CleanupUnpairedDevices(unpaired_device_ids_)) { + unpaired_device_ids_.clear(); + } + } else { + // TODO(PV): should be exchange restarted at this point? + LOG4CXX_WARN(logger_, "Exchange wasn't successful, trying another one."); + //OnPTExchangeNeeded(); } return ret; } @@ -499,19 +564,51 @@ void PolicyHandler::StartPTExchange(bool skip_device_selection) { void PolicyHandler::StartNextRetry() { DCHECK(exchange_handler_); + if (!policy_manager_) { + LOG4CXX_WARN(logger_, "The shared library of policy is not loaded"); + return; + } exchange_handler_->StartExchange(); } void PolicyHandler::OnAllowSDLFunctionalityNotification(bool is_allowed, uint32_t device_id) { LOG4CXX_INFO(logger_, "OnAllowSDLFunctionalityNotification"); + if (!policy_manager_) { + LOG4CXX_WARN(logger_, "The shared library of policy is not loaded"); + return; + } if (device_id) { DeviceParams device_params; application_manager::MessageHelper::GetDeviceInfoForHandle(device_id, &device_params); + if (kDefaultDeviceMacAddress == device_params.device_mac_address) { + LOG4CXX_WARN(logger_, "Device with handle " << device_id + << " wasn't found."); + return; + } policy_manager_->SetUserConsentForDevice(device_params.device_mac_address, is_allowed); + // In case of changed consent for device, related applications will be + // limited to pre_DataConsent permissions, if device disallowed, or switch + // back to their own permissions, if device allowed again, and must be + // notified about these changes + typedef std::set ApplicationList; + ApplicationList app_list = + application_manager::ApplicationManagerImpl::instance()->applications(); + ApplicationList::const_iterator it_app_list = app_list.begin(); + ApplicationList::const_iterator it_app_list_end = app_list.end(); + for (; it_app_list != it_app_list_end; ++it_app_list) { + if (device_id == (*it_app_list).get()->device()) { + policy_manager_->ReactOnUserDevConsentForApp( + it_app_list->get()->mobile_app_id()->asString(), + is_allowed); + policy_manager_->SendNotificationOnPermissionsUpdated( + (*it_app_list).get()->mobile_app_id()->asString()); + } + } + DeviceHandles::iterator it = std::find(pending_device_handles_.begin(), pending_device_handles_.end(), device_id); @@ -528,27 +625,30 @@ void PolicyHandler::OnAllowSDLFunctionalityNotification(bool is_allowed, return; } - - // TODO(AOleynik): Handle situation, if general functionality is concerned } void PolicyHandler::OnIgnitionCycleOver() { LOG4CXX_INFO(logger_, "OnIgnitionCycleOver"); + if (!policy_manager_) { + LOG4CXX_WARN(logger_, "The shared library of policy is not loaded"); + return; + } policy_manager_->IncrementIgnitionCycles(); } void PolicyHandler::KmsChanged(int kms) { LOG4CXX_INFO(logger_, "PolicyHandler::KmsChanged " << kms << " kilometers"); + if (!policy_manager_) { + LOG4CXX_WARN(logger_, "The shared library of policy is not loaded"); + return; + } PTExchangeAtOdometer(kms); } void PolicyHandler::OnActivateApp(uint32_t connection_key, uint32_t correlation_id) { LOG4CXX_INFO(logger_, "OnActivateApp"); - if (!policy_manager_) { - LOG4CXX_WARN(logger_, "The shared library of policy is not loaded"); - return; - } + application_manager::ApplicationSharedPtr app = application_manager::ApplicationManagerImpl::instance()->application( connection_key); @@ -558,37 +658,42 @@ void PolicyHandler::OnActivateApp(uint32_t connection_key, } std::string policy_app_id = app->mobile_app_id()->asString(); - AppPermissions permissions = policy_manager_->GetAppPermissionsChanges( - policy_app_id); + AppPermissions permissions(policy_app_id); + + if (!policy_manager_) { + LOG4CXX_WARN(logger_, "The shared library of policy is not loaded"); + } else { + permissions = policy_manager_->GetAppPermissionsChanges( + policy_app_id); #if defined(EXTENDED_POLICY) - application_manager::UsageStatistics& usage = app->usage_report(); + application_manager::UsageStatistics& usage = app->usage_report(); - usage.RecordAppUserSelection(); + usage.RecordAppUserSelection(); - DeviceConsent consent = GetDeviceForSending(permissions.deviceInfo); - permissions.isSDLAllowed = kDeviceAllowed == consent ? true : false; + DeviceConsent consent = GetDeviceForSending(permissions.deviceInfo); + permissions.isSDLAllowed = kDeviceAllowed == consent ? true : false; - if (permissions.appRevoked) { - usage.RecordRunAttemptsWhileRevoked(); - } + 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 isSDLAllowed is false, we should provide device params for user consent + if (!permissions.isSDLAllowed) { + pending_device_handles_.push_back(permissions.deviceInfo.device_handle); + } #else - permissions.isSDLAllowed = true; + permissions.isSDLAllowed = true; #endif - if (permissions.isSDLAllowed && - PolicyTableStatus::StatusUpdateRequired == policy_manager_->GetPolicyTableStatus()) { - printf("\n\t\t\t\t\tUpdate is requried\n"); - StartPTExchange(); + if (permissions.isSDLAllowed && + PolicyTableStatus::StatusUpdateRequired == policy_manager_->GetPolicyTableStatus()) { + StartPTExchange(); + } + policy_manager_->RemovePendingPermissionChanges(policy_app_id); } application_manager::MessageHelper::SendActivateAppResponse(permissions, correlation_id); - policy_manager_->RemovePendingPermissionChanges(policy_app_id); } void PolicyHandler::PTExchangeAtIgnition() { @@ -598,15 +703,24 @@ void PolicyHandler::PTExchangeAtIgnition() { return; } + if (on_ignition_check_done_) { + return; + } + + on_ignition_check_done_ = true; + TimevalStruct current_time = date_time::DateTime::getCurrentTime(); const int kSecondsInDay = 60 * 60 * 24; int days = current_time.tv_sec / kSecondsInDay; - // Start update on limits exhaustion, if update wasn't started already by any - // other event LOG4CXX_INFO( logger_, - "\nIgnition cycles exceeded: " << std::boolalpha << policy_manager_->ExceededIgnitionCycles() << "\nDays exceeded: " << std::boolalpha << policy_manager_->ExceededDays(days) << "\nStatusUpdateRequired: " << std::boolalpha << (policy_manager_->GetPolicyTableStatus() == StatusUpdateRequired)); + "\nIgnition cycles exceeded: " << std::boolalpha << + policy_manager_->ExceededIgnitionCycles() + << "\nDays exceeded: " << std::boolalpha + << policy_manager_->ExceededDays(days) + << "\nStatusUpdateRequired: " << std::boolalpha + << (policy_manager_->GetPolicyTableStatus() == StatusUpdateRequired)); if (policy_manager_->ExceededIgnitionCycles() || policy_manager_->ExceededDays(days) || policy_manager_->GetPolicyTableStatus() == StatusUpdateRequired) { @@ -627,6 +741,10 @@ void PolicyHandler::PTExchangeAtOdometer(int kilometers) { void PolicyHandler::PTExchangeAtUserRequest(uint32_t correlation_id) { LOG4CXX_TRACE(logger_, "PT exchange at user request"); + if (!policy_manager_) { + LOG4CXX_WARN(logger_, "The shared library of policy is not loaded"); + return; + } policy::PolicyTableStatus status = policy_manager_->GetPolicyTableStatus(); if (status == policy::StatusUpdateRequired) { OnPTExchangeNeeded(); @@ -641,31 +759,71 @@ void PolicyHandler::OnPTExchangeNeeded() { } void PolicyHandler::OnPermissionsUpdated(const std::string& policy_app_id, - const Permissions& permissions) { + const Permissions& permissions, const HMILevel& default_hmi) { application_manager::ApplicationSharedPtr app = application_manager::ApplicationManagerImpl::instance() ->application_by_policy_id(policy_app_id); - if (app) { - application_manager::MessageHelper::SendOnPermissionsChangeNotification( - app->app_id(), permissions); - - LOG4CXX_INFO( - logger_, - "Notification sent for application_id:" << policy_app_id << " and connection_key " << app->app_id()); - } else { + if (!app) { LOG4CXX_WARN( logger_, "Connection_key not found for application_id:" << policy_app_id); + return; } -} -void PolicyHandler::CheckAppPolicyState(const std::string& application_id) { - LOG4CXX_INFO(logger_, "CheckAppPolicyState"); - policy_manager()->CheckAppPolicyState(application_id); + application_manager::MessageHelper::SendOnPermissionsChangeNotification( + app->app_id(), permissions); + + LOG4CXX_INFO( + logger_, + "Notification sent for application_id:" << policy_app_id + << " and connection_key " << app->app_id()); + + // The application currently not running (i.e. in NONE) should change HMI + // level to default + mobile_apis::HMILevel::eType current_hmi_level = app->hmi_level(); + mobile_apis::HMILevel::eType hmi_level = + application_manager::MessageHelper::StringToHMILevel(default_hmi); + + if (mobile_apis::HMILevel::INVALID_ENUM == hmi_level) { + LOG4CXX_WARN(logger_, "Couldn't convert default hmi level " + << default_hmi << " to enum."); + return; + } + if (current_hmi_level == hmi_level) { + LOG4CXX_INFO(logger_, "Application already in default hmi state."); + return; + } + switch (current_hmi_level) { + case mobile_apis::HMILevel::HMI_NONE: { + LOG4CXX_INFO(logger_, "Changing hmi level of application " << policy_app_id + << " to default hmi level " << default_hmi); + // If default is FULL, send request to HMI. Notification to mobile will be + // sent on response receiving. + if (mobile_apis::HMILevel::HMI_FULL == hmi_level) { + application_manager::MessageHelper::SendActivateAppToHMI(app->app_id()); + break; + } + + // Set application hmi level + app->set_hmi_level(hmi_level); + + // Send notification to mobile + application_manager::MessageHelper::SendHMIStatusNotification(*app.get()); + } + break; + default: + LOG4CXX_WARN(logger_, "Application " << policy_app_id << " is running." + "HMI level won't be changed."); + break; + } } void PolicyHandler::AddStatisticsInfo(int type) { + if (!policy_manager_) { + LOG4CXX_WARN(logger_, "The shared library of policy is not loaded"); + return; + } switch (static_cast(type)) { case hmi_apis::Common_StatisticsType::iAPP_BUFFER_FULL: { usage_statistics::GlobalCounter count_of_iap_buffer_full( @@ -680,6 +838,10 @@ void PolicyHandler::AddStatisticsInfo(int type) { } void PolicyHandler::OnSystemError(int code) { + if (!policy_manager_) { + LOG4CXX_WARN(logger_, "The shared library of policy is not loaded"); + return; + } switch (static_cast(code)) { case hmi_apis::Common_SystemError::SYNC_REBOOTED: { usage_statistics::GlobalCounter count_of_sync_reboots( @@ -699,5 +861,31 @@ void PolicyHandler::OnSystemError(int code) { } } +std::string PolicyHandler::GetAppName(const std::string& policy_app_id) { + application_manager::ApplicationSharedPtr app = + application_manager::ApplicationManagerImpl::instance() + ->application_by_policy_id(policy_app_id); + + if (!app) { + LOG4CXX_WARN( + logger_, + "Connection_key not found for application_id:" << policy_app_id); + return ""; + } + return app->name(); +} + +void PolicyHandler::RemoveDevice(const std::string& device_id) { + LOG4CXX_INFO(logger_, "PolicyHandler::RemoveDevice"); + if (!policy_manager_) { + LOG4CXX_WARN(logger_, "The shared library of policy is not loaded"); + return; + } + + policy::DeviceIds devices; + devices.insert(device_id); + policy_manager_->CleanupUnpairedDevices(devices); +} + } // namespace policy diff --git a/src/components/application_manager/src/policies/pt_exchange_handler_ext.cc b/src/components/application_manager/src/policies/pt_exchange_handler_ext.cc index 7369493..603674e 100644 --- a/src/components/application_manager/src/policies/pt_exchange_handler_ext.cc +++ b/src/components/application_manager/src/policies/pt_exchange_handler_ext.cc @@ -46,13 +46,11 @@ using std::string; namespace policy { -log4cxx::LoggerPtr PTExchangeHandlerExt::logger_ = log4cxx::LoggerPtr( - log4cxx::Logger::getLogger("PTExchangeHandlerExt")); - +CREATE_LOGGERPTR_GLOBAL(logger_, "PTExchangeHandlerExt") PTExchangeHandlerExt::PTExchangeHandlerExt(PolicyHandler* policy_handler) - : PTExchangeHandler(), - policy_handler_(policy_handler) { + : PTExchangeHandler(), + policy_handler_(policy_handler) { DCHECK(policy_handler_); } @@ -60,14 +58,14 @@ PTExchangeHandlerExt::~PTExchangeHandlerExt() { } bool PTExchangeHandlerExt::StartExchange() { - LOG4CXX_INFO(logger_, "PolicyHandler::StartExchange"); + LOG4CXX_INFO(logger_, "PolicyHandler::StartExchangeExtended"); PolicyManager* policy_manager = policy_handler_->policy_manager(); if (!policy_manager) { LOG4CXX_WARN(logger_, "The shared library of policy is not loaded"); return false; } string policy_snapshot_file_name = - Profile::instance()->policies_snapshot_file_name(); + Profile::instance()->policies_snapshot_file_name(); BinaryMessageSptr pt_snapshot = policy_manager->RequestPTUpdate(); if (pt_snapshot.valid()) { if (file_system::WriteBinaryFile(policy_snapshot_file_name, *pt_snapshot)) { @@ -76,7 +74,7 @@ bool PTExchangeHandlerExt::StartExchange() { policy_manager->RetrySequenceDelaysSeconds()); return true; } else { - LOG4CXX_ERROR(logger_, "Failed to write snapshot file"); + LOG4CXX_ERROR(logger_, "Failed to write snapshot file to " << policy_snapshot_file_name); } } else { LOG4CXX_ERROR(logger_, "Failed to obtain policy table snapshot"); diff --git a/src/components/application_manager/src/policies/pt_exchange_handler_impl.cc b/src/components/application_manager/src/policies/pt_exchange_handler_impl.cc index 110c878..0b5b627 100644 --- a/src/components/application_manager/src/policies/pt_exchange_handler_impl.cc +++ b/src/components/application_manager/src/policies/pt_exchange_handler_impl.cc @@ -31,12 +31,12 @@ */ #include "application_manager/policies/pt_exchange_handler_impl.h" +#include "utils/logger.h" #include namespace policy { -log4cxx::LoggerPtr PTExchangeHandlerImpl::logger_ = log4cxx::LoggerPtr( - log4cxx::Logger::getLogger("PTExchangeHandlerImpl")); +CREATE_LOGGERPTR_GLOBAL(logger_, "PTExchangeHandlerImpl") PTExchangeHandlerImpl::PTExchangeHandlerImpl(PolicyHandler* handler) : policy_handler_(handler) { diff --git a/src/components/application_manager/src/request_controller.cc b/src/components/application_manager/src/request_controller.cc index 57e8b77..433c0cd 100644 --- a/src/components/application_manager/src/request_controller.cc +++ b/src/components/application_manager/src/request_controller.cc @@ -40,8 +40,7 @@ namespace application_manager { namespace request_controller { using namespace sync_primitives; -log4cxx::LoggerPtr logger_ = - log4cxx::LoggerPtr(log4cxx::Logger::getLogger("RequestController")); +CREATE_LOGGERPTR_GLOBAL(logger_, "RequestController") RequestController::RequestController() : watchdog_(NULL) { diff --git a/src/components/application_manager/src/resume_ctrl.cpp b/src/components/application_manager/src/resume_ctrl.cpp index 3dd4bbb..0d42ce4 100644 --- a/src/components/application_manager/src/resume_ctrl.cpp +++ b/src/components/application_manager/src/resume_ctrl.cpp @@ -14,10 +14,9 @@ #include "resumption/last_state.h" namespace application_manager { -#ifdef ENABLE_LOG - log4cxx::LoggerPtr ResumeCtrl::logger_ = log4cxx::LoggerPtr( - log4cxx::Logger::getLogger("ResumeCtrl")); -#endif // ENABLE_LOG + +CREATE_LOGGERPTR_GLOBAL(logger_, "ResumeCtrl") + namespace Formatters = NsSmartDeviceLink::NsJSONHandler::Formatters; ResumeCtrl::ResumeCtrl(ApplicationManagerImpl* app_mngr) @@ -46,13 +45,13 @@ void ResumeCtrl::SaveApplication(ApplicationConstSharedPtr application) { Json::Value* json_app = NULL; const std::string& m_app_id = application->mobile_app_id()->asString(); - for (Json::Value::iterator it = GetSavedApplications().begin(); - it != GetSavedApplications().end(); ++it) { - if ((*it)[strings::app_id].asString() == m_app_id) { + Json::Value::iterator it = GetSavedApplications().begin(); + for (; it != GetSavedApplications().end(); ++it) { + if (m_app_id == (*it)[strings::app_id].asString()) { json_app = &(*it); LOG4CXX_INFO(logger_, "ResumeCtrl Application with this id " - "already exist ( update info ). mobile app_id = " - << m_app_id); + "already exist ( update info )." + "mobile app_id = " << m_app_id); break; } } @@ -67,10 +66,12 @@ void ResumeCtrl::SaveApplication(ApplicationConstSharedPtr application) { uint32_t grammar_id = application->get_grammar_id(); LOG4CXX_INFO(logger_, "Hash = " << hash); - uint32_t connection_key = application->app_id(); + (*json_app)[strings::device_mac] = + MessageHelper::GetDeviceMacAddressForHandle(application->device()); (*json_app)[strings::app_id] = m_app_id; (*json_app)[strings::grammar_id] = grammar_id; - (*json_app)[strings::connection_key] = connection_key; + (*json_app)[strings::connection_key] = application->app_id(); + (*json_app)[strings::hmi_app_id] = application->hmi_app_id(); (*json_app)[strings::hmi_level] = static_cast (application->hmi_level()); (*json_app)[strings::ign_off_count] = 0; @@ -101,8 +102,8 @@ bool ResumeCtrl::RestoreApplicationHMILevel(ApplicationSharedPtr application) { for (Json::Value::iterator it = GetSavedApplications().begin(); it != GetSavedApplications().end(); ++it) { const std::string& saved_m_app_id = (*it)[strings::app_id].asString(); - if (saved_m_app_id == - application->mobile_app_id()->asString()) { + + if (saved_m_app_id == application->mobile_app_id()->asString()) { mobile_apis::HMILevel::eType saved_hmi_level; mobile_apis::HMILevel::eType restored_hmi_level; @@ -114,7 +115,8 @@ bool ResumeCtrl::RestoreApplicationHMILevel(ApplicationSharedPtr application) { saved_hmi_level = static_cast( (*it)[strings::hmi_level].asInt()); - if (saved_hmi_level == application->hmi_level()) { + if ((saved_hmi_level == application->hmi_level()) && + (saved_hmi_level != mobile_apis::HMILevel::HMI_NONE)){ return false; } @@ -122,6 +124,9 @@ bool ResumeCtrl::RestoreApplicationHMILevel(ApplicationSharedPtr application) { restored_hmi_level = app_mngr_->PutApplicationInFull(application); } else if (saved_hmi_level == mobile_apis::HMILevel::HMI_LIMITED) { restored_hmi_level = app_mngr_->PutApplicationInLimited(application); + if (audio_streaming_state == mobile_apis::AudioStreamingState::AUDIBLE) { + MessageHelper::SendOnResumeAudioSourceToHMI(application->app_id()); + } } else { restored_hmi_level = saved_hmi_level; } @@ -144,11 +149,11 @@ bool ResumeCtrl::RestoreApplicationData(ApplicationSharedPtr application) { Json::Value::iterator it = GetSavedApplications().begin(); for (; it != GetSavedApplications().end(); ++it) { const std::string& saved_m_app_id = (*it)[strings::app_id].asString(); - if (saved_m_app_id == - application->mobile_app_id()->asString()) { + if (saved_m_app_id == application->mobile_app_id()->asString()) { break; } } + if (it == GetSavedApplications().end()) { LOG4CXX_WARN(logger_, "Application not saved"); return false; @@ -334,18 +339,44 @@ bool ResumeCtrl::RestoreApplicationData(ApplicationSharedPtr application) { return true; } -bool ResumeCtrl::ApplicationIsSaved(const uint32_t app_id) { - LOG4CXX_INFO(logger_, "ResumeCtrl::ApplicationIsSaved " << app_id); +bool ResumeCtrl::IsHMIApplicationIdExist(uint32_t hmi_app_id) { + LOG4CXX_INFO(logger_, "ResumeCtrl::IsHMIApplicationIdExist " << hmi_app_id); for (Json::Value::iterator it = GetSavedApplications().begin(); it != GetSavedApplications().end(); ++it) { - if ((*it)[strings::connection_key].asInt() == app_id) { + if ((*it)[strings::hmi_app_id].asUInt() == hmi_app_id) { return true; } } + return false; } +bool ResumeCtrl::IsApplicationSaved(const std::string& mobile_app_id) { + LOG4CXX_INFO(logger_, "ResumeCtrl::IsApplicationSaved " << mobile_app_id); + + for (Json::Value::iterator it = GetSavedApplications().begin(); + it != GetSavedApplications().end(); ++it) { + if ((*it)[strings::app_id].asString() == mobile_app_id) { + return true; + } + } + + return false; +} + +uint32_t ResumeCtrl::GetHMIApplicationID(const std::string& mobile_app_id) { + uint32_t hmi_app_id = 0; + for (Json::Value::iterator it = GetSavedApplications().begin(); + it != GetSavedApplications().end(); ++it) { + if ((*it)[strings::app_id].asString() == mobile_app_id) { + hmi_app_id = (*it)[strings::hmi_app_id].asUInt(); + } + } + + return hmi_app_id; +} + bool ResumeCtrl::RemoveApplicationFromSaved(ApplicationConstSharedPtr application) { LOG4CXX_INFO(logger_, "ResumeCtrl::RemoveApplicationFromSaved "); DCHECK(application.get()); @@ -355,6 +386,7 @@ bool ResumeCtrl::RemoveApplicationFromSaved(ApplicationConstSharedPtr applicatio for (Json::Value::iterator it = GetSavedApplications().begin(); it != GetSavedApplications().end(); ++it) { const std::string& saved_m_app_id = (*it)[strings::app_id].asString(); + if (saved_m_app_id != application->mobile_app_id()->asString()) { temp.push_back((*it)); } else { @@ -365,6 +397,7 @@ bool ResumeCtrl::RemoveApplicationFromSaved(ApplicationConstSharedPtr applicatio if (false == result) { return result; } + GetSavedApplications().clear(); for (std::vector::iterator it = temp.begin(); it != temp.end(); ++it) { @@ -394,13 +427,14 @@ bool ResumeCtrl::StartResumption(ApplicationSharedPtr application, LOG4CXX_INFO(logger_, "ResumeCtrl::StartResumption"); DCHECK(application.get()); LOG4CXX_INFO(logger_, "app_id = " << application->app_id()); + LOG4CXX_INFO(logger_, "hmi_app_id = " << application->hmi_app_id()); LOG4CXX_INFO(logger_, "mobile_id = " << application->mobile_app_id()->asString()); Json::Value::iterator it = GetSavedApplications().begin(); for (; it != GetSavedApplications().end(); ++it) { const std::string& saved_m_app_id = (*it)[strings::app_id].asString(); - if (saved_m_app_id == - application->mobile_app_id()->asString()) { + + if (saved_m_app_id == application->mobile_app_id()->asString()) { uint32_t saved_hash = (*it)[strings::hash_id].asUInt(); uint32_t time_stamp= (*it)[strings::time_stamp].asUInt(); @@ -422,7 +456,8 @@ bool ResumeCtrl::StartResumption(ApplicationSharedPtr application, return true; } } - LOG4CXX_INFO(logger_, "ResumeCtrl::Applicaton didn't saved"); + + LOG4CXX_INFO(logger_, "ResumeCtrl::Application wasn't saved"); MessageHelper::SendHMIStatusNotification(*application); return false; } @@ -437,10 +472,9 @@ bool ResumeCtrl::StartResumptionOnlyHMILevel(ApplicationSharedPtr application) { Json::Value::iterator it = GetSavedApplications().begin(); for (; it != GetSavedApplications().end(); ++it) { const std::string& saved_m_app_id = (*it)[strings::app_id].asString(); - if (saved_m_app_id == - application->mobile_app_id()->asString()) { + if (saved_m_app_id == application->mobile_app_id()->asString()) { uint32_t time_stamp= (*it)[strings::time_stamp].asUInt(); - if ( !timer_.isRunning() && app_mngr_->applications().size() > 1 ) { + if (!timer_.isRunning() && app_mngr_->applications().size() > 1) { RestoreApplicationHMILevel(application); RemoveApplicationFromSaved(application); } else { @@ -453,7 +487,8 @@ bool ResumeCtrl::StartResumptionOnlyHMILevel(ApplicationSharedPtr application) { return true; } } - LOG4CXX_INFO(logger_, "ResumeCtrl::Applicaton didn't saved"); + + LOG4CXX_INFO(logger_, "ResumeCtrl::Application wasn't saved"); MessageHelper::SendHMIStatusNotification(*application); return false; } @@ -465,11 +500,12 @@ bool ResumeCtrl::CheckPersistenceFilesForResumption(ApplicationSharedPtr applica Json::Value::iterator it = GetSavedApplications().begin(); for (; it != GetSavedApplications().end(); ++it) { const std::string& saved_m_app_id = (*it)[strings::app_id].asString(); - if (saved_m_app_id == - application->mobile_app_id()->asString()) { + + if (saved_m_app_id == application->mobile_app_id()->asString()) { break; } } + if (it == GetSavedApplications().end()) { LOG4CXX_WARN(logger_, "Application not saved"); return false; @@ -486,8 +522,8 @@ bool ResumeCtrl::CheckPersistenceFilesForResumption(ApplicationSharedPtr applica for (Json::Value::iterator json_it = app_commands.begin(); json_it != app_commands.end(); ++json_it) { Json::Value& json_command = *json_it; - smart_objects::SmartObject message = smart_objects::SmartObject( - smart_objects::SmartType::SmartType_Map); + smart_objects::SmartObject message = + smart_objects::SmartObject(smart_objects::SmartType::SmartType_Map); Formatters::CFormatterJsonBase::jsonValueToObj(json_command, message); mobile_apis::Result::eType verification_result = MessageHelper::VerifyImageFiles(message, application); @@ -497,12 +533,12 @@ bool ResumeCtrl::CheckPersistenceFilesForResumption(ApplicationSharedPtr applica } } - //add choisets + //add choice sets for (Json::Value::iterator json_it = app_choise_sets.begin(); json_it != app_choise_sets.end(); ++json_it) { Json::Value& json_choiset = *json_it; - smart_objects::SmartObject msg_param = smart_objects::SmartObject( - smart_objects::SmartType::SmartType_Map); + smart_objects::SmartObject msg_param = + smart_objects::SmartObject(smart_objects::SmartType::SmartType_Map); Formatters::CFormatterJsonBase::jsonValueToObj(json_choiset , msg_param); mobile_apis::Result::eType verification_result = MessageHelper::VerifyImageFiles(msg_param, application); @@ -515,16 +551,15 @@ bool ResumeCtrl::CheckPersistenceFilesForResumption(ApplicationSharedPtr applica return true; } -bool ResumeCtrl::CheckApplicationHash(std::string mobile_app_id, uint32_t hash) { +bool ResumeCtrl::CheckApplicationHash(ApplicationSharedPtr application, + uint32_t hash) { Json::Value::iterator it = GetSavedApplications().begin(); - for (; it != GetSavedApplications() - - .end(); ++it) { + for (; it != GetSavedApplications().end(); ++it) { std::string saved_m_app_id = (*it)[strings::app_id].asString(); - if (saved_m_app_id == mobile_app_id) { - uint32_t saved_hash = (*it)[strings::hash_id].asUInt(); - LOG4CXX_INFO(logger_, "recived hash = " << hash); + if (saved_m_app_id == application->mobile_app_id()->asString()) { + uint32_t saved_hash = (*it)[strings::hash_id].asUInt(); + LOG4CXX_INFO(logger_, "received hash = " << hash); LOG4CXX_INFO(logger_, "saved hash = " << saved_hash); if (hash == saved_hash) { return true; @@ -547,7 +582,7 @@ void ResumeCtrl::onTimer() { ApplicationManagerImpl::instance()->application((*it).first); if (!app.get()) { LOG4CXX_ERROR(logger_, "Invalid app_id = " << (*it).first); - break; + continue; } RestoreApplicationHMILevel(app); @@ -557,12 +592,20 @@ void ResumeCtrl::onTimer() { waiting_for_timer_.clear(); } -Json::Value &ResumeCtrl::GetSavedApplications() { +bool ResumeCtrl::IsDeviceMacAddressEqual(ApplicationSharedPtr application, + const std::string& saved_device_mac) { + const std::string device_mac = + MessageHelper::GetDeviceMacAddressForHandle(application->device()); + + return device_mac == saved_device_mac; +} + +Json::Value& ResumeCtrl::GetSavedApplications() { return resumption::LastState::instance()->dictionary[strings::resumption]; } void ResumeCtrl::SetSavedApplication(Json::Value& apps_json) { - resumption::LastState::instance()->dictionary[strings::resumption] = apps_json ; + resumption::LastState::instance()->dictionary[strings::resumption] = apps_json ; } Json::Value ResumeCtrl::GetApplicationCommands( @@ -757,8 +800,4 @@ void ResumeCtrl::SendHMIRequest( } } - } // namespace application_manager - - - -- 2.7.4