diff --git a/.github/workflows/sdl_core_github_ci_coverity.yml b/.github/workflows/sdl_core_github_ci_coverity.yml new file mode 100644 index 00000000000..c60482d30f9 --- /dev/null +++ b/.github/workflows/sdl_core_github_ci_coverity.yml @@ -0,0 +1,63 @@ +name: SDL Core Build With Coverity +on: + push: + branches: + - master + pull_request: + branches: + - master +jobs: + build: + environment: Coverity + runs-on: ubuntu-20.04 + steps: + - shell: bash + env: + COVERITY_SECRET: ${{ secrets.COVERITY_TOKEN }} + run: | + echo "$COVERITY_SECRET" && echo ${{ secrets.COVERITY_TOKEN }} && echo "end" + - uses: actions/checkout@v2 + - name: Init Submodules + run: git -C ${{ github.workspace }} submodule update --init --recursive + # Install Dependencies + - name: Apt Get Dependencies + run: sudo apt-get update && sudo apt-get install libssl-dev libbluetooth3 libbluetooth-dev libudev-dev cmake html2text lcov git cmake automake1.11 build-essential libavahi-client-dev sqlite3 libsqlite3-dev libgtest-dev bluez-tools libpulse-dev libusb-1.0.0-dev cppcheck python3-pip python3-setuptools && sudo apt-get install -f clang-format-6.0 + - name: Setup CMAKE + uses: jwlawson/actions-setup-cmake@v1.8 + with: + cmake-version: '3.16.3' + # Build Project + - name: Cache 3rd Party + id: core-3rd-party + uses: actions/cache@v2 + with: + path: ${{ github.workspace }}/core_3rd_party + key: ${{ runner.os }}-core-3rd-party-v3 + - name: Make 3rd Party Directory + if: steps.core-3rd-party.outputs.cache-hit != 'true' + run: mkdir ${{ github.workspace }}/core_3rd_party + - name: Make Directories + run: cd ${{ github.workspace }} && cd ../ && mkdir build && cd build + - name: Set 3rd Party Path + run: echo "THIRD_PARTY_INSTALL_PREFIX=${{ github.workspace }}/core_3rd_party" >> $GITHUB_ENV + - name: Set 3rd Party ARCH Path + run: echo "THIRD_PARTY_INSTALL_PREFIX_ARCH=${{ github.workspace }}/core_3rd_party" >> $GITHUB_ENV + - name: Configure + run: cmake ../sdl_core -DLOGGER_NAME=BOOST + - name: Download Coverity + env: + COVERITY_SECRET: ${{ secrets.COVERITY_TOKEN }} + run: wget https://scan.coverity.com/download/linux64 --post-data "token=${COVERITY_SECRET}&project=smartdevicelink%2Fsdl_core" -O coverity_tool.tgz + - name: unzip + run: tar zxvf coverity_tool.tgz + - name: Build + run: make install-3rd_party && ./cov-analysis-linux64-2020.09/bin/cov-build --dir cov-int make -j `nproc` install + - name: Set Library Path + run: echo "LD_LIBRARY_PATH=$THIRD_PARTY_INSTALL_PREFIX/lib:." >> $GITHUB_ENV + - name: Compress Coverity + run: tar czvf myproject.tgz cov-int + - name: Upload Coverity + env: + COVERITY_SECRET: ${{ secrets.COVERITY_TOKEN }} + run: curl --form token=${COVERITY_SECRET} --form email=jack@livio.io --form file=@myproject.tgz --form version="Version" --form description="Description" https://scan.coverity.com/builds?project=smartdevicelink%2Fsdl_core + diff --git a/CMakeLists.txt b/CMakeLists.txt index e638310f889..3b53b87e39b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,6 +29,7 @@ # POSSIBILITY OF SUCH DAMAGE. cmake_minimum_required(VERSION 2.8.11) +cmake_policy(SET CMP0054 NEW) set (PROJECT smartDeviceLinkCore) project (${PROJECT}) diff --git a/src/appMain/sdl_preloaded_pt.json b/src/appMain/sdl_preloaded_pt.json index 50bbce6a97b..e018a597f7d 100644 --- a/src/appMain/sdl_preloaded_pt.json +++ b/src/appMain/sdl_preloaded_pt.json @@ -3616,7 +3616,16 @@ "name": "pressureTelltale", "key": "OEM_REF_PRES_TEL", "type": "WarningLightStatus", - "mandatory": true + "mandatory": true, + "since": "2.0", + "until": "8.0" + }, + { + "name": "pressureTelltale", + "key": "OEM_REF_PRES_TEL", + "type": "WarningLightStatus", + "mandatory": false, + "since": "8.0" }, { "name": "leftFront", @@ -3646,7 +3655,40 @@ ], "key": "OEM_REF_LEFT_FR", "type": "Struct", - "mandatory": true + "mandatory": true, + "since": "2.0", + "until": "8.0" + }, + { + "name": "leftFront", + "params": [ + { + "name": "status", + "key": "OEM_REF_LEFT_FR_ST", + "type": "ComponentVolumeStatus", + "mandatory": true + }, + { + "name": "tpms", + "key": "OEM_REF_LEFT_FR_TMPS", + "type": "TPMS", + "mandatory": false, + "since": "5.0" + }, + { + "name": "pressure", + "key": "OEM_REF_LEFT_FR_PRES", + "type": "Float", + "mandatory": false, + "minvalue": 0, + "maxvalue": 2000, + "since": "5.0" + } + ], + "key": "OEM_REF_LEFT_FR", + "type": "Struct", + "mandatory": false, + "since": "8.0" }, { "name": "rightFront", @@ -3676,7 +3718,40 @@ ], "key": "OEM_REF_RIGHT_FR", "type": "Struct", - "mandatory": true + "mandatory": true, + "since": "2.0", + "until": "8.0" + }, + { + "name": "rightFront", + "params": [ + { + "name": "status", + "key": "OEM_REF_RIGHT_FR_ST", + "type": "ComponentVolumeStatus", + "mandatory": true + }, + { + "name": "tpms", + "key": "OEM_REF_RIGHT_FR_TMPS", + "type": "TPMS", + "mandatory": false, + "since": "5.0" + }, + { + "name": "pressure", + "key": "OEM_REF_RIGHT_FR_PRES", + "type": "Float", + "mandatory": false, + "minvalue": 0, + "maxvalue": 2000, + "since": "5.0" + } + ], + "key": "OEM_REF_RIGHT_FR", + "type": "Struct", + "mandatory": false, + "since": "8.0" }, { "name": "leftRear", @@ -3706,7 +3781,40 @@ ], "key": "OEM_REF_LEFT_REAR", "type": "Struct", - "mandatory": true + "mandatory": true, + "since": "2.0", + "until": "8.0" + }, + { + "name": "leftRear", + "params": [ + { + "name": "status", + "key": "OEM_REF_LEFT_REAR_ST", + "type": "ComponentVolumeStatus", + "mandatory": true + }, + { + "name": "tpms", + "key": "OEM_REF_LEFT_REAR_TMPS", + "type": "TPMS", + "mandatory": false, + "since": "5.0" + }, + { + "name": "pressure", + "key": "OEM_REF_LEFT_REAR_PRES", + "type": "Float", + "mandatory": false, + "minvalue": 0, + "maxvalue": 2000, + "since": "5.0" + } + ], + "key": "OEM_REF_LEFT_REAR", + "type": "Struct", + "mandatory": false, + "since": "8.0" }, { "name": "rightRear", @@ -3736,7 +3844,40 @@ ], "key": "OEM_REF_RIGHT_REAR", "type": "Struct", - "mandatory": true + "mandatory": true, + "since": "2.0", + "until": "8.0" + }, + { + "name": "rightRear", + "params": [ + { + "name": "status", + "key": "OEM_REF_RIGHT_REAR_ST", + "type": "ComponentVolumeStatus", + "mandatory": true + }, + { + "name": "tpms", + "key": "OEM_REF_RIGHT_REAR_TMPS", + "type": "TPMS", + "mandatory": false, + "since": "5.0" + }, + { + "name": "pressure", + "key": "OEM_REF_RIGHT_REAR_PRES", + "type": "Float", + "mandatory": false, + "minvalue": 0, + "maxvalue": 2000, + "since": "5.0" + } + ], + "key": "OEM_REF_RIGHT_REAR", + "type": "Struct", + "mandatory": false, + "since": "8.0" }, { "name": "innerLeftRear", @@ -3766,7 +3907,40 @@ ], "key": "OEM_REF_IN_LEFT_REAR", "type": "Struct", - "mandatory": true + "mandatory": true, + "since": "2.0", + "until": "8.0" + }, + { + "name": "innerLeftRear", + "params": [ + { + "name": "status", + "key": "OEM_REF_IN_LEFT_REAR_ST", + "type": "ComponentVolumeStatus", + "mandatory": true + }, + { + "name": "tpms", + "key": "OEM_REF_IN_LEFT_REAR_TMPS", + "type": "TPMS", + "mandatory": false, + "since": "5.0" + }, + { + "name": "pressure", + "key": "OEM_REF_IN_LEFT_REAR_PRES", + "type": "Float", + "mandatory": false, + "minvalue": 0, + "maxvalue": 2000, + "since": "5.0" + } + ], + "key": "OEM_REF_IN_LEFT_REAR", + "type": "Struct", + "mandatory": false, + "since": "8.0" }, { "name": "innerRightRear", @@ -3796,7 +3970,40 @@ ], "key": "OEM_REF_IN_RIGHT_REAR", "type": "Struct", - "mandatory": true + "mandatory": true, + "since": "2.0", + "until": "8.0" + }, + { + "name": "innerRightRear", + "params": [ + { + "name": "status", + "key": "OEM_REF_IN_RIGHT_REAR_ST", + "type": "ComponentVolumeStatus", + "mandatory": true + }, + { + "name": "tpms", + "key": "OEM_REF_IN_RIGHT_REAR_TMPS", + "type": "TPMS", + "mandatory": false, + "since": "5.0" + }, + { + "name": "pressure", + "key": "OEM_REF_IN_RIGHT_REAR_PRES", + "type": "Float", + "mandatory": false, + "minvalue": 0, + "maxvalue": 2000, + "since": "5.0" + } + ], + "key": "OEM_REF_IN_RIGHT_REAR", + "type": "Struct", + "mandatory": false, + "since": "8.0" } ], "key": "OEM_REF_TIRE_PRES", diff --git a/src/appMain/smartDeviceLink.ini b/src/appMain/smartDeviceLink.ini index d19f7ef7a1b..56822db0ef2 100644 --- a/src/appMain/smartDeviceLink.ini +++ b/src/appMain/smartDeviceLink.ini @@ -58,6 +58,8 @@ HMICapabilitiesCacheFile = hmi_capabilities_cache.json MaxCmdID = 2000000000 ; SDL respond timeout (in milliseconds) in case of HMI has not respond on a mobile request DefaultTimeout = 10000 +; Extra time to compensate default timeout due to external delays +DefaultTimeoutCompensation = 1000 ; Available disk space in bytes for each application file handling ; Default value is 100 MiB AppDirectoryQuota = 104857600 diff --git a/src/components/application_manager/include/application_manager/app_launch/app_launch_data_json.h b/src/components/application_manager/include/application_manager/app_launch/app_launch_data_json.h index 9e60183960c..dba2579f8f2 100644 --- a/src/components/application_manager/include/application_manager/app_launch/app_launch_data_json.h +++ b/src/components/application_manager/include/application_manager/app_launch/app_launch_data_json.h @@ -54,10 +54,6 @@ class AppLaunchDataJson : public AppLaunchDataImpl { AppLaunchDataJson(const AppLaunchSettings& settings, resumption::LastStateWrapperPtr last_state_wrapper); - DEPRECATED - AppLaunchDataJson(const AppLaunchSettings& settings, - resumption::LastState& last_state); - /** * @brief allows to destroy AppLaunchDataJson object */ @@ -99,10 +95,6 @@ class AppLaunchDataJson : public AppLaunchDataImpl { int32_t& found_index, Json::Value& dictionary) const; - DEPRECATED - Json::Value& GetApplicationListAndIndex(const ApplicationData& app_data, - int32_t& founded_index) const; - private: /** * @brief update time stamp diff --git a/src/components/application_manager/include/application_manager/app_service_manager.h b/src/components/application_manager/include/application_manager/app_service_manager.h index 94606909c60..e3a5f646028 100644 --- a/src/components/application_manager/include/application_manager/app_service_manager.h +++ b/src/components/application_manager/include/application_manager/app_service_manager.h @@ -65,9 +65,6 @@ class AppServiceManager { AppServiceManager(ApplicationManager& app_manager, resumption::LastStateWrapperPtr last_state); - DEPRECATED AppServiceManager(ApplicationManager& app_manager, - resumption::LastState& last_state); - /** * @brief Class destructor */ diff --git a/src/components/application_manager/include/application_manager/application.h b/src/components/application_manager/include/application_manager/application.h index 715faa4ccaf..86b26f24efe 100644 --- a/src/components/application_manager/include/application_manager/application.h +++ b/src/components/application_manager/include/application_manager/application.h @@ -206,6 +206,7 @@ class DynamicApplicationData { virtual const smart_objects::SmartObject* keyboard_props() const = 0; virtual const smart_objects::SmartObject* menu_title() const = 0; virtual const smart_objects::SmartObject* menu_icon() const = 0; + virtual const smart_objects::SmartObject* menu_layout() const = 0; virtual smart_objects::SmartObject day_color_scheme() const = 0; virtual smart_objects::SmartObject night_color_scheme() const = 0; virtual std::string display_layout() const = 0; @@ -245,6 +246,8 @@ class DynamicApplicationData { const smart_objects::SmartObject& keyboard_props) = 0; virtual void set_menu_title(const smart_objects::SmartObject& menu_title) = 0; virtual void set_menu_icon(const smart_objects::SmartObject& menu_icon) = 0; + virtual void set_menu_layout( + const smart_objects::SmartObject& menu_layout) = 0; virtual uint32_t audio_stream_retry_number() const = 0; @@ -374,12 +377,6 @@ class DynamicApplicationData { */ virtual smart_objects::SmartObject FindSubMenu(uint32_t menu_id) const = 0; - /* - * @brief Returns true if sub menu with such name already exist - */ - DEPRECATED virtual bool IsSubMenuNameAlreadyExist( - const std::string& name, const uint32_t parent_id) = 0; - /* * @brief Adds a interaction choice set to the application * diff --git a/src/components/application_manager/include/application_manager/application_data_impl.h b/src/components/application_manager/include/application_manager/application_data_impl.h index a64e0c8f339..086e71b48ba 100644 --- a/src/components/application_manager/include/application_manager/application_data_impl.h +++ b/src/components/application_manager/include/application_manager/application_data_impl.h @@ -102,6 +102,7 @@ class DynamicApplicationDataImpl : public virtual Application { const smart_objects::SmartObject* keyboard_props() const; const smart_objects::SmartObject* menu_title() const; const smart_objects::SmartObject* menu_icon() const; + const smart_objects::SmartObject* menu_layout() const; smart_objects::SmartObject day_color_scheme() const OVERRIDE; smart_objects::SmartObject night_color_scheme() const OVERRIDE; @@ -141,6 +142,7 @@ class DynamicApplicationDataImpl : public virtual Application { void set_keyboard_props(const smart_objects::SmartObject& keyboard_props); void set_menu_title(const smart_objects::SmartObject& menu_title); void set_menu_icon(const smart_objects::SmartObject& menu_icon); + void set_menu_layout(const smart_objects::SmartObject& menu_layout); void set_day_color_scheme(const smart_objects::SmartObject& color_scheme); void set_night_color_scheme(const smart_objects::SmartObject& color_scheme); void set_display_layout(const std::string& layout); @@ -323,6 +325,7 @@ class DynamicApplicationDataImpl : public virtual Application { smart_objects::SmartObject* keyboard_props_; smart_objects::SmartObject* menu_title_; smart_objects::SmartObject* menu_icon_; + smart_objects::SmartObject* menu_layout_; smart_objects::SmartObject* tbt_show_command_; smart_objects::SmartObjectSPtr display_capabilities_; AppWindowsTemplates window_templates_; 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 d9704ec6c44..c64ae2bbd2f 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 @@ -53,7 +53,6 @@ #include "application_manager/hmi_interfaces_impl.h" #include "application_manager/message.h" #include "application_manager/message_helper.h" -#include "application_manager/request_controller.h" #include "application_manager/resumption/resume_ctrl.h" #include "application_manager/rpc_handler.h" #include "application_manager/rpc_service.h" @@ -162,10 +161,6 @@ class ApplicationManagerImpl const policy::PolicySettings& policy_settings); ~ApplicationManagerImpl(); - DEPRECATED - bool Init(resumption::LastState&, - media_manager::MediaManager* media_manager) OVERRIDE; - /** * Inits application manager */ @@ -192,8 +187,6 @@ class ApplicationManagerImpl uint32_t hmi_app_id) const OVERRIDE; ApplicationSharedPtr application_by_policy_id( const std::string& policy_app_id) const OVERRIDE; - DEPRECATED ApplicationSharedPtr - application_by_name(const std::string& app_name) const OVERRIDE; ApplicationSharedPtr pending_application_by_policy_id( const std::string& policy_app_id) const OVERRIDE; ApplicationSharedPtr reregister_application_by_policy_id( @@ -790,14 +783,14 @@ class ApplicationManagerImpl * * @param ptr Reference to shared pointer that point on hmi notification */ - void addNotification(const CommandSharedPtr ptr); + void AddNotification(const CommandSharedPtr ptr); /** * @ Add notification to collection * - * @param ptr Reference to shared pointer that point on hmi notification + * @param notification Pointer that points to hmi notification */ - void removeNotification(const commands::Command* notification); + void RemoveNotification(const commands::Command* notification); /** * @ Updates request timeout @@ -806,7 +799,7 @@ class ApplicationManagerImpl * @param mobile_correlation_id Correlation ID of the mobile request * @param new_timeout_value New timeout in milliseconds to be set */ - void updateRequestTimeout(uint32_t connection_key, + void UpdateRequestTimeout(uint32_t connection_key, uint32_t mobile_correlation_id, uint32_t new_timeout_value) OVERRIDE; @@ -861,9 +854,6 @@ class ApplicationManagerImpl */ void EndNaviServices(uint32_t app_id) OVERRIDE; - DEPRECATED - void ForbidStreaming(uint32_t app_id) OVERRIDE; - void ForbidStreaming(uint32_t app_id, protocol_handler::ServiceType service_type) OVERRIDE; @@ -878,10 +868,6 @@ class ApplicationManagerImpl protocol_handler::ServiceType service_type, bool state) OVERRIDE; - void OnAppStreaming(uint32_t app_id, - protocol_handler::ServiceType service_type, - const Application::StreamingState new_state) OVERRIDE; - mobile_api::HMILevel::eType GetDefaultHmiLevel( ApplicationConstSharedPtr application) const; @@ -1002,6 +988,18 @@ class ApplicationManagerImpl return *rpc_handler_; } + request_controller::RequestTimeoutHandler& get_request_timeout_handler() + const OVERRIDE { + DCHECK(request_timeout_handler_); + return *request_timeout_handler_; + } + + request_controller::RequestController& get_request_controller() + const OVERRIDE { + DCHECK(request_ctrl_); + return *request_ctrl_; + } + void SetRPCService(std::unique_ptr& rpc_service) { rpc_service_ = std::move(rpc_service); } @@ -1615,8 +1613,10 @@ class ApplicationManagerImpl connection_handler::ConnectionHandler* connection_handler_; std::unique_ptr policy_handler_; protocol_handler::ProtocolHandler* protocol_handler_; + std::unique_ptr + request_timeout_handler_; + std::unique_ptr request_ctrl_; std::unique_ptr plugin_manager_; - request_controller::RequestController request_ctrl_; std::unique_ptr app_service_manager_; /** diff --git a/src/components/application_manager/include/application_manager/commands/command_request_impl.h b/src/components/application_manager/include/application_manager/commands/command_request_impl.h index df313b2bcf2..e2c95a085ba 100644 --- a/src/components/application_manager/include/application_manager/commands/command_request_impl.h +++ b/src/components/application_manager/include/application_manager/commands/command_request_impl.h @@ -255,6 +255,22 @@ class CommandRequestImpl : public CommandImpl, bool PrepareResultForMobileResponse(ResponseInfo& out_first, ResponseInfo& out_second) const; + /** + * @brief Checks result code from HMI for splitted RPC + * and returns parameter for sending to mobile app. + * @param out_first Contains result_code from HMI response and + * interface that returns response + * @param out_second Contains result_code from HMI response and + * interface that returns response + * @param out_third Contains result_code from HMI response and + * interface that returns response + * @return true if result code complies successful result code + * otherwise returns false + */ + bool PrepareResultForMobileResponse(ResponseInfo& out_first, + ResponseInfo& out_second, + ResponseInfo& out_third) const; + /** * @brief If message from HMI contains returns this info * or process result code from HMI and checks state of interface @@ -278,6 +294,19 @@ class CommandRequestImpl : public CommandImpl, mobile_apis::Result::eType PrepareResultCodeForResponse( const ResponseInfo& first, const ResponseInfo& second); + /** + * @brief Prepare result code for sending to mobile application + * @param first contains result_code from HMI response and + * interface that returns response + * @param second contains result_code from HMI response and + * interface that returns response. + * @return resulting code for sending to mobile application. + */ + mobile_apis::Result::eType PrepareResultCodeForResponse( + const ResponseInfo& first, + const ResponseInfo& second, + const ResponseInfo& third); + /** * @brief Resolves if the return code must be * UNSUPPORTED_RESOURCE @@ -372,6 +401,13 @@ class CommandRequestImpl : public CommandImpl, */ void AddTimeOutComponentInfoToMessage( smart_objects::SmartObject& response) const; + /** + * @brief AddRequestToTimeoutHandler checks the request and adds it to + * request_timeout_handler map for tracking + * @param request_to_hmi request to HMI + */ + void AddRequestToTimeoutHandler( + const smart_objects::SmartObject& request_to_hmi) const; }; } // namespace commands diff --git a/src/components/application_manager/include/application_manager/hmi_capabilities_impl.h b/src/components/application_manager/include/application_manager/hmi_capabilities_impl.h index f646c66ca15..9a22b2a4aaa 100644 --- a/src/components/application_manager/include/application_manager/hmi_capabilities_impl.h +++ b/src/components/application_manager/include/application_manager/hmi_capabilities_impl.h @@ -257,9 +257,6 @@ class HMICapabilitiesImpl : public HMICapabilities { void Init(resumption::LastStateWrapperPtr last_state_wrapper) OVERRIDE; - DEPRECATED - void Init(resumption::LastState* last_state) OVERRIDE; - HMILanguageHandler& get_hmi_language_handler() OVERRIDE; void set_handle_response_for( diff --git a/src/components/application_manager/include/application_manager/hmi_language_handler.h b/src/components/application_manager/include/application_manager/hmi_language_handler.h index 2ef034450df..5db5a844da7 100644 --- a/src/components/application_manager/include/application_manager/hmi_language_handler.h +++ b/src/components/application_manager/include/application_manager/hmi_language_handler.h @@ -96,9 +96,6 @@ class HMILanguageHandler : public event_engine::EventObserver { hmi_apis::Common_Language::eType vr, hmi_apis::Common_Language::eType tts); - DEPRECATED - void Init(resumption::LastState*); - void Init(resumption::LastStateWrapperPtr value); /** 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 12e74203332..88200d65930 100644 --- a/src/components/application_manager/include/application_manager/message_helper.h +++ b/src/components/application_manager/include/application_manager/message_helper.h @@ -1095,6 +1095,17 @@ class MessageHelper { ApplicationManager& app_mngr, const WindowID window_id); + /** + * @brief AddDefaultParamsToTireStatus adds missing default sub-params to + * tirePressure param, if version of related application requires presence of + * all sub-params in response + * @param application shared pointer to related application + * @param response_from_hmi reference to response from HMI + */ + static void AddDefaultParamsToTireStatus( + ApplicationSharedPtr application, + smart_objects::SmartObject& response_from_hmi); + private: /** * @brief Allows to fill SO according to the current permissions. diff --git a/src/components/application_manager/include/application_manager/plugin_manager/rpc_plugin.h b/src/components/application_manager/include/application_manager/plugin_manager/rpc_plugin.h index 88f91d14fc0..0c7538e8093 100644 --- a/src/components/application_manager/include/application_manager/plugin_manager/rpc_plugin.h +++ b/src/components/application_manager/include/application_manager/plugin_manager/rpc_plugin.h @@ -86,13 +86,6 @@ class RPCPlugin { policy::PolicyHandlerInterface& policy_handler, resumption::LastStateWrapperPtr last_state) = 0; - DEPRECATED - virtual bool Init(ApplicationManager& app_manager, - rpc_service::RPCService& rpc_service, - HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler, - resumption::LastState& last_state) = 0; - /** * @brief IsAbleToProcess check if plugin is able to process function * @param function_id RPC identifier diff --git a/src/components/application_manager/include/application_manager/plugin_manager/rpc_plugin_manager_impl.h b/src/components/application_manager/include/application_manager/plugin_manager/rpc_plugin_manager_impl.h index 004d6418f5e..a447034d866 100644 --- a/src/components/application_manager/include/application_manager/plugin_manager/rpc_plugin_manager_impl.h +++ b/src/components/application_manager/include/application_manager/plugin_manager/rpc_plugin_manager_impl.h @@ -59,13 +59,6 @@ class RPCPluginManagerImpl : public RPCPluginManager { policy::PolicyHandlerInterface& policy_handler, resumption::LastStateWrapperPtr last_state); - DEPRECATED - RPCPluginManagerImpl(ApplicationManager& app_manager, - rpc_service::RPCService& rpc_service, - HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler, - resumption::LastState& last_state); - uint32_t LoadPlugins(const std::string& plugins_path) OVERRIDE; utils::Optional FindPluginToProcess( 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 acf4ca7819a..662e2558718 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 @@ -86,8 +86,6 @@ class PolicyHandler : public PolicyHandlerInterface, bool InitPolicyTable() OVERRIDE; bool ResetPolicyTable() OVERRIDE; bool ClearUserConsent() OVERRIDE; - DEPRECATED bool SendMessageToSDK(const BinaryMessage& pt_string, - const std::string& url) OVERRIDE; bool ReceiveMessageFromSDK(const std::string& file, const BinaryMessage& pt_string) OVERRIDE; bool UnloadPolicyLibrary() OVERRIDE; diff --git a/src/components/application_manager/include/application_manager/request_controller.h b/src/components/application_manager/include/application_manager/request_controller_impl.h similarity index 56% rename from src/components/application_manager/include/application_manager/request_controller.h rename to src/components/application_manager/include/application_manager/request_controller_impl.h index 8a3c90061ee..7277cdc3fa8 100644 --- a/src/components/application_manager/include/application_manager/request_controller.h +++ b/src/components/application_manager/include/application_manager/request_controller_impl.h @@ -30,8 +30,8 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_REQUEST_CONTROLLER_H_ -#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_REQUEST_CONTROLLER_H_ +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_REQUEST_CONTROLLER_IMPL_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_REQUEST_CONTROLLER_IMPL_H_ #include #include @@ -47,6 +47,7 @@ #include "interfaces/HMI_API.h" #include "interfaces/MOBILE_API.h" +#include "application_manager/request_controller.h" #include "application_manager/request_controller_settings.h" #include "application_manager/request_info.h" #include "application_manager/request_tracker.h" @@ -55,165 +56,60 @@ namespace application_manager { namespace request_controller { -/** - * @brief RequestController class is used to control currently active mobile - * requests. - */ -class RequestController { +class RequestControllerImpl : public RequestController { public: - /** - * @brief Result code for addRequest - */ - enum TResult { - SUCCESS = 0, - TOO_MANY_REQUESTS, - TOO_MANY_PENDING_REQUESTS, - NONE_HMI_LEVEL_MANY_REQUESTS, - INVALID_DATA - }; - - /** - * @brief Thread pool state - */ - enum TPoolState { - UNDEFINED = 0, - STARTED, - STOPPED, - }; - - // Methods - /** * @brief Class constructor * */ - RequestController(const RequestControlerSettings& settings); + RequestControllerImpl(const RequestControlerSettings& settings, + RequestTimeoutHandler& request_timeout_handler); - /** - * @brief Class destructor - * - */ - virtual ~RequestController(); + ~RequestControllerImpl(); - /** - * @brief Initialize thread pool - * - */ - void InitializeThreadpool(); + void Stop() OVERRIDE; - /** - * @brief Destroy thread pool - * - */ - void DestroyThreadpool(); + void InitializeThreadpool() OVERRIDE; - /** - * @brief Check if max request amount wasn't exceed and adds request to queue. - * - * @param request Active mobile request - * @param hmi_level Current application hmi_level - * - * @return Result code - * - */ - TResult addMobileRequest(const RequestPtr request, - const mobile_apis::HMILevel::eType& hmi_level); + void DestroyThreadpool() OVERRIDE; - /** - * @brief Store HMI request until response or timeout won't remove it - * - * @param request Active hmi request - * @return Result code - * - */ - TResult addHMIRequest(const RequestPtr request); + TResult AddMobileRequest( + const RequestPtr request, + const mobile_apis::HMILevel::eType& hmi_level) OVERRIDE; - /** - * @ Add notification to collection - * - * @param ptr Reference to shared pointer that point on hmi notification - */ - void addNotification(const RequestPtr ptr); + TResult AddHMIRequest(const RequestPtr request) OVERRIDE; + + void AddNotification(const RequestPtr ptr) OVERRIDE; - /** - * @brief Removes request from queue - * - * @param correlation_id Active request correlation ID, - * @param connection_key Active request connection key (0 for HMI requersts) - * @param function_id Active request function id - * @param force_terminate if true, request controller will terminate - * even if not allowed by request - */ void TerminateRequest(const uint32_t correlation_id, const uint32_t connection_key, const int32_t function_id, - bool force_terminate = false); + const bool force_terminate = false) OVERRIDE; - /** - * @brief Removes request from queue - * - * @param mobile_correlation_id Active mobile request correlation ID - * - */ void OnMobileResponse(const uint32_t mobile_correlation_id, const uint32_t connection_key, - const int32_t function_id); + const int32_t function_id) OVERRIDE; - /** - * @brief Removes request from queue - * - * @param mobile_correlation_id Active mobile request correlation ID - * - */ - void OnHMIResponse(const uint32_t correlation_id, const int32_t function_id); + void OnHMIResponse(const uint32_t correlation_id, + const int32_t function_id) OVERRIDE; - /** - * @ Add notification to collection - * - * @param ptr Reference to shared pointer that point on hmi notification - */ - void removeNotification(const commands::Command* notification); + void RemoveNotification(const commands::Command* notification) OVERRIDE; - /** - * @brief Removes all requests from queue for specified application - * - * @param app_id Mobile application ID (app_id) - * - */ - void terminateAppRequests(const uint32_t& app_id); + void TerminateAppRequests(const uint32_t app_id) OVERRIDE; - /** - * @brief Terminates all requests from HMI - */ - void terminateAllHMIRequests(); + void TerminateAllHMIRequests() OVERRIDE; - /** - * @brief Terminates all requests from Mobile - */ - void terminateAllMobileRequests(); + void TerminateAllMobileRequests() OVERRIDE; - /** - * @brief Updates request timeout - * - * @param app_id Connection key of application - * @param mobile_correlation_id Correlation ID of the mobile request - * @param new_timeout_value New timeout to be set in milliseconds - */ - void updateRequestTimeout(const uint32_t& app_id, - const uint32_t& mobile_correlation_id, - const uint32_t& new_timeout); + void UpdateRequestTimeout(const uint32_t app_id, + const uint32_t mobile_correlation_id, + const uint32_t new_timeout) OVERRIDE; - /* - * @brief Function Should be called when Low Voltage is occured - */ - void OnLowVoltage(); + void OnLowVoltage() OVERRIDE; - /* - * @brief Function Should be called when Low Voltage is occured - */ - void OnWakeUp(); + void OnWakeUp() OVERRIDE; - bool IsLowVoltage(); + bool IsLowVoltage() OVERRIDE; protected: /** @@ -226,8 +122,8 @@ class RequestController { */ void NotifyTimer(); - void terminateWaitingForExecutionAppRequests(const uint32_t& app_id); - void terminateWaitingForResponseAppRequests(const uint32_t& app_id); + void TerminateWaitingForExecutionAppRequests(const uint32_t app_id); + void TerminateWaitingForResponseAppRequests(const uint32_t app_id); /** * @brief Checks whether all constraints are met before adding of request into @@ -246,19 +142,19 @@ class RequestController { * allowed for all applications * @return True if new request could be added, false otherwise */ - bool CheckPendingRequestsAmount(const uint32_t& pending_requests_amount); + bool CheckPendingRequestsAmount(const uint32_t pending_requests_amount); private: class Worker : public threads::ThreadDelegate { public: - explicit Worker(RequestController* requestController); + explicit Worker(RequestControllerImpl* request_controller); virtual ~Worker(); virtual void threadMain(); virtual void exitThreadMain(); protected: private: - RequestController* request_controller_; + RequestControllerImpl* request_controller_; sync_primitives::Lock thread_lock_; volatile bool stop_flag_; }; @@ -310,11 +206,12 @@ class RequestController { bool is_low_voltage_; const RequestControlerSettings& settings_; - DISALLOW_COPY_AND_ASSIGN(RequestController); + RequestTimeoutHandler& request_timeout_handler_; + DISALLOW_COPY_AND_ASSIGN(RequestControllerImpl); }; } // namespace request_controller } // namespace application_manager -#endif // SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_REQUEST_CONTROLLER_H_ +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_REQUEST_CONTROLLER_IMPL_H_ diff --git a/src/components/application_manager/include/application_manager/request_info.h b/src/components/application_manager/include/application_manager/request_info.h index c6cf00caeaa..e3d5dfd4911 100644 --- a/src/components/application_manager/include/application_manager/request_info.h +++ b/src/components/application_manager/include/application_manager/request_info.h @@ -127,7 +127,7 @@ struct RequestInfo { } uint64_t hash(); static uint64_t GenerateHash(uint32_t var1, uint32_t var2); - static uint32_t HmiConnectionKey; + static constexpr uint32_t kHmiConnectionKey = 0; protected: RequestPtr request_; @@ -199,7 +199,7 @@ class RequestInfoSet { * @return founded request or shared_ptr with NULL */ RequestInfoPtr Find(const uint32_t connection_key, - const uint32_t correlation_id); + const uint32_t correlation_id) const; /* * @brief Get request with smalest end_time_ @@ -269,7 +269,7 @@ class RequestInfoSet { TimeSortedRequestInfoSet time_sorted_pending_requests_; HashSortedRequestInfoSet hash_sorted_pending_requests_; - sync_primitives::Lock pending_requests_lock_; + mutable sync_primitives::Lock pending_requests_lock_; }; /** diff --git a/src/components/application_manager/include/application_manager/request_timeout_handler_impl.h b/src/components/application_manager/include/application_manager/request_timeout_handler_impl.h new file mode 100644 index 00000000000..c58d09598f9 --- /dev/null +++ b/src/components/application_manager/include/application_manager/request_timeout_handler_impl.h @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2018, 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_REQUEST_TIMEOUT_HANDLER_IMPL_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_REQUEST_TIMEOUT_HANDLER_IMPL_H_ + +#include +#include "application_manager/application_manager.h" +#include "application_manager/event_engine/event_observer.h" +#include "application_manager/request_timeout_handler.h" + +namespace application_manager { + +namespace request_controller { + +class RequestTimeoutHandlerImpl : public event_engine::EventObserver, + public RequestTimeoutHandler { + public: + RequestTimeoutHandlerImpl(ApplicationManager& application_manager); + void AddRequest(const uint32_t hmi_correlation_id, + const Request& request) OVERRIDE; + void RemoveRequest(const uint32_t hmi_correlation_id) OVERRIDE; + void on_event(const event_engine::Event& event) OVERRIDE; + + private: + /** + * @brief Checks whether specified request timeout should be updated or not + * @param request reference to request structure to check + * @param timeout new timeout to apply + * @param method_name name of method to check + * @return true if timeout update is required for this request, otherwise + * returns false + */ + bool IsTimeoutUpdateRequired(const Request& request, + const uint32_t timeout, + const hmi_apis::FunctionID::eType method_name); + + std::map requests_; + ApplicationManager& application_manager_; + mutable sync_primitives::Lock requests_lock_; +}; + +} // namespace request_controller +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_REQUEST_TIMEOUT_HANDLER_IMPL_H_ diff --git a/src/components/application_manager/include/application_manager/resumption/resume_ctrl.h b/src/components/application_manager/include/application_manager/resumption/resume_ctrl.h index 456eccd29c9..4cc42699bc6 100644 --- a/src/components/application_manager/include/application_manager/resumption/resume_ctrl.h +++ b/src/components/application_manager/include/application_manager/resumption/resume_ctrl.h @@ -276,9 +276,6 @@ class ResumeCtrl { */ virtual void RemoveFromResumption(uint32_t app_id) = 0; - DEPRECATED - virtual bool Init(resumption::LastState& last_state) = 0; - /** * @brief Initialization data for Resume controller * @return true if initialization is success otherwise diff --git a/src/components/application_manager/include/application_manager/resumption/resume_ctrl_impl.h b/src/components/application_manager/include/application_manager/resumption/resume_ctrl_impl.h index 9c529b5f9a9..b93b914a489 100644 --- a/src/components/application_manager/include/application_manager/resumption/resume_ctrl_impl.h +++ b/src/components/application_manager/include/application_manager/resumption/resume_ctrl_impl.h @@ -256,8 +256,6 @@ class ResumeCtrlImpl : public ResumeCtrl { */ void RemoveFromResumption(uint32_t app_id) OVERRIDE; - DEPRECATED bool Init(resumption::LastState& last_state) FINAL; - /** * @brief Initialization data for Resume controller * @return true if initialization is success otherwise diff --git a/src/components/application_manager/include/application_manager/resumption/resumption_data_json.h b/src/components/application_manager/include/application_manager/resumption/resumption_data_json.h index 2394fe00dcb..f33ef83a9b5 100644 --- a/src/components/application_manager/include/application_manager/resumption/resumption_data_json.h +++ b/src/components/application_manager/include/application_manager/resumption/resumption_data_json.h @@ -52,11 +52,6 @@ class ResumptionDataJson : public ResumptionData { resumption::LastStateWrapperPtr last_state_wrapper, const application_manager::ApplicationManager& application_manager); - DEPRECATED - ResumptionDataJson( - LastState&, - const application_manager::ApplicationManager& application_manager); - /** * @brief allows to destroy ResumptionDataJson object */ @@ -180,9 +175,6 @@ class ResumptionDataJson : public ResumptionData { */ void Persist() OVERRIDE; - DEPRECATED - resumption::LastState& last_state() const; - private: /** * @brief GetFromSavedOrAppend allows to get existed record about application 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 5572dfd55d5..b1b3c5f0002 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 @@ -308,6 +308,13 @@ extern const char* vin; extern const char* gearStatus; extern const char* prndl; extern const char* tire_pressure; +extern const char* pressure_telltale; +extern const char* left_front; +extern const char* right_front; +extern const char* left_rear; +extern const char* right_rear; +extern const char* inner_left_rear; +extern const char* inner_right_rear; extern const char* odometer; extern const char* belt_status; extern const char* electronic_park_brake_status; @@ -494,6 +501,10 @@ extern const char* const rect; extern const char* const x; extern const char* const y; extern const char* const preferred_fps; + +// OnResetTimeout +extern const char* const request_id; +extern const char* const reset_period; } // namespace strings namespace hmi_interface { diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/app_service_rpc_plugin.h b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/app_service_rpc_plugin.h index 444636ed75c..bae47385248 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/app_service_rpc_plugin.h +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/app_service_rpc_plugin.h @@ -50,13 +50,6 @@ class AppServiceRpcPlugin : public plugins::RPCPlugin { policy::PolicyHandlerInterface& policy_handler, resumption::LastStateWrapperPtr last_state) OVERRIDE; - DEPRECATED - bool Init(app_mngr::ApplicationManager& application_manager, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler, - resumption::LastState& last_state); - bool IsAbleToProcess( const int32_t function_id, const app_mngr::commands::Command::CommandSource source) OVERRIDE; diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_rpc_plugin.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_rpc_plugin.cc index e03973614d8..0e805da46ca 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_rpc_plugin.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_rpc_plugin.cc @@ -58,18 +58,6 @@ bool AppServiceRpcPlugin::Init( return true; } -bool AppServiceRpcPlugin::Init(app_mngr::ApplicationManager& app_manager, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler, - resumption::LastState& last_state) { - UNUSED(last_state); - application_manager_ = &app_manager; - command_factory_.reset(new app_service_rpc_plugin::AppServiceCommandFactory( - app_manager, rpc_service, hmi_capabilities, policy_handler)); - return true; -} - bool AppServiceRpcPlugin::IsAbleToProcess( const int32_t function_id, const commands::Command::CommandSource source) { return command_factory_->IsAbleToProcess(function_id, source); diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/test/commands/hmi/dummy_hmi_commands_test.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/test/commands/hmi/dummy_hmi_commands_test.cc index 4236ac23f93..4e79bad8999 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/test/commands/hmi/dummy_hmi_commands_test.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/test/commands/hmi/dummy_hmi_commands_test.cc @@ -92,14 +92,10 @@ class HMICommandsTest : public components::commands_test::CommandRequestTest< typedef Command CommandType; void InitCommand(const uint32_t& timeout) OVERRIDE { + CommandRequestTest::InitCommand(timeout); + stream_retry_.first = 0; stream_retry_.second = 0; - EXPECT_CALL(app_mngr_settings_, default_timeout()) - .WillOnce(ReturnRef(timeout)); - ON_CALL(app_mngr_, event_dispatcher()) - .WillByDefault(ReturnRef(event_dispatcher_)); - ON_CALL(app_mngr_, get_settings()) - .WillByDefault(ReturnRef(app_mngr_settings_)); ON_CALL(app_mngr_settings_, start_stream_retry_amount()) .WillByDefault(ReturnRef(stream_retry_)); } diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/test/commands/mobile/dummy_mobile_commands_test.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/test/commands/mobile/dummy_mobile_commands_test.cc index 69bff3ad762..3c70028574a 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/test/commands/mobile/dummy_mobile_commands_test.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/test/commands/mobile/dummy_mobile_commands_test.cc @@ -88,12 +88,8 @@ class MobileCommandsTest : public components::commands_test::CommandRequestTest< typedef Command CommandType; void InitCommand(const uint32_t& timeout) OVERRIDE { - EXPECT_CALL(app_mngr_settings_, default_timeout()) - .WillOnce(ReturnRef(timeout)); - ON_CALL(app_mngr_, event_dispatcher()) - .WillByDefault(ReturnRef(event_dispatcher_)); - ON_CALL(app_mngr_, get_settings()) - .WillByDefault(ReturnRef(app_mngr_settings_)); + CommandRequestTest::InitCommand(timeout); + ON_CALL(app_mngr_settings_, app_icons_folder()) .WillByDefault(ReturnRef(kEmptyString_)); } diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_consent_manager_impl.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_consent_manager_impl.h index 5cbc4b977e8..fd8c40405e9 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_consent_manager_impl.h +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_consent_manager_impl.h @@ -50,12 +50,6 @@ class RCConsentManagerImpl : public RCConsentManager { application_manager::ApplicationManager& application_manager, const uint32_t period_of_consent_expired); - DEPRECATED - RCConsentManagerImpl( - resumption::LastState& last_state, - application_manager::ApplicationManager& application_manager, - const uint32_t period_of_consent_expired); - void SaveModuleConsents( const std::string& policy_app_id, const std::string& mac_address, diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_rpc_plugin.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_rpc_plugin.h index 528e116403f..c1f7339aa31 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_rpc_plugin.h +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_rpc_plugin.h @@ -65,12 +65,6 @@ class RCRPCPlugin : public plugins::RPCPlugin { policy::PolicyHandlerInterface& policy_handler, resumption::LastStateWrapperPtr last_state) OVERRIDE; - DEPRECATED - bool Init(app_mngr::ApplicationManager& app_manager, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler, - resumption::LastState& last_state) OVERRIDE; /** * @param int32_t command id * @param CommandSource source diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/resource_allocation_manager.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/resource_allocation_manager.h index ee0bd118858..623498dac77 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/resource_allocation_manager.h +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/resource_allocation_manager.h @@ -129,6 +129,19 @@ class ResourceAllocationManager { virtual bool IsResourceFree(const std::string& module_type, const std::string& module_id) const = 0; + /** + * @brief IsResourceAllocated check if module is allocated by certain + * application + * @param module_type module to be checked + * @param module_id uuid of a resource to be checked + * @param app_id app to be checked + * @return true if module_type is allocated by application with provided + * app_id + */ + virtual bool IsResourceAllocated(const std::string& module_type, + const std::string& module_id, + const uint32_t app_id) = 0; + /** * @brief AcquireResource forces acquiring resource by application * @param module_type resource to acquire diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/resource_allocation_manager_impl.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/resource_allocation_manager_impl.h index 0fd54499125..4361312ddef 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/resource_allocation_manager_impl.h +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/resource_allocation_manager_impl.h @@ -94,6 +94,10 @@ class ResourceAllocationManagerImpl : public ResourceAllocationManager { bool IsResourceFree(const std::string& module_type, const std::string& module_id) const FINAL; + bool IsResourceAllocated(const std::string& module_type, + const std::string& module_id, + const uint32_t app_id) FINAL; + void SetAccessMode( const hmi_apis::Common_RCAccessMode::eType access_mode) FINAL; diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_on_remote_control_settings_notification.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_on_remote_control_settings_notification.cc index 217258b0869..860e18a1052 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_on_remote_control_settings_notification.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_on_remote_control_settings_notification.cc @@ -87,35 +87,34 @@ void RCOnRemoteControlSettingsNotification::DisallowRCFunctionality() { void RCOnRemoteControlSettingsNotification::Run() { SDL_LOG_AUTO_TRACE(); - if (!(*message_)[app_mngr::strings::msg_params].keyExists( - message_params::kAllowed)) { - SDL_LOG_DEBUG("Notification is ignored due to \"allow\" parameter absense"); + if ((*message_)[app_mngr::strings::msg_params].empty()) { + SDL_LOG_DEBUG("Notification is ignored due to absence of any parameters"); SDL_LOG_DEBUG("RC Functionality remains unchanged"); return; } + hmi_apis::Common_RCAccessMode::eType access_mode = + hmi_apis::Common_RCAccessMode::INVALID_ENUM; + if ((*message_)[app_mngr::strings::msg_params].keyExists( + message_params::kAccessMode)) { + access_mode = static_cast( + (*message_)[app_mngr::strings::msg_params][message_params::kAccessMode] + .asUInt()); + SDL_LOG_DEBUG( + "Setting up access mode : " << AccessModeToString(access_mode)); + } else { + access_mode = resource_allocation_manager_.GetAccessMode(); + SDL_LOG_DEBUG("No access mode received. Using last known: " + << AccessModeToString(access_mode)); + } + resource_allocation_manager_.SetAccessMode(access_mode); + const bool is_allowed = (*message_)[app_mngr::strings::msg_params][message_params::kAllowed] .asBool(); if (is_allowed) { - hmi_apis::Common_RCAccessMode::eType access_mode = - hmi_apis::Common_RCAccessMode::INVALID_ENUM; SDL_LOG_DEBUG("Allowing RC Functionality"); resource_allocation_manager_.set_rc_enabled(true); - if ((*message_)[app_mngr::strings::msg_params].keyExists( - message_params::kAccessMode)) { - access_mode = static_cast( - (*message_)[app_mngr::strings::msg_params] - [message_params::kAccessMode] - .asUInt()); - SDL_LOG_DEBUG( - "Setting up access mode : " << AccessModeToString(access_mode)); - } else { - access_mode = resource_allocation_manager_.GetAccessMode(); - SDL_LOG_DEBUG("No access mode received. Using last known: " - << AccessModeToString(access_mode)); - } - resource_allocation_manager_.SetAccessMode(access_mode); } else { SDL_LOG_DEBUG("Disallowing RC Functionality"); DisallowRCFunctionality(); diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/rc_command_request.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/rc_command_request.cc index 12608d64c1a..e179c0c0d70 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/rc_command_request.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/rc_command_request.cc @@ -278,6 +278,11 @@ void RCCommandRequest::ProcessConsentResult(const bool is_allowed, SDL_LOG_AUTO_TRACE(); if (is_allowed) { SetResourceState(module_type, ResourceState::BUSY); + const auto default_timeout = + application_manager_.get_settings().default_timeout() + + application_manager_.get_settings().default_timeout_compensation(); + application_manager_.UpdateRequestTimeout( + connection_key(), correlation_id(), default_timeout); Execute(); // run child's logic } else { resource_allocation_manager_.OnDriverDisallowed( diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_rpc_plugin.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_rpc_plugin.cc index 87090405e73..8250437e788 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_rpc_plugin.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_rpc_plugin.cc @@ -86,14 +86,6 @@ bool RCRPCPlugin::Init( return true; } -bool RCRPCPlugin::Init(application_manager::ApplicationManager&, - application_manager::rpc_service::RPCService&, - application_manager::HMICapabilities&, - policy::PolicyHandlerInterface&, - resumption::LastState&) { - return false; -} - bool RCRPCPlugin::IsAbleToProcess( const int32_t function_id, const application_manager::commands::Command::CommandSource diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/resource_allocation_manager_impl.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/resource_allocation_manager_impl.cc index a26cf714480..0c513cb01ec 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/resource_allocation_manager_impl.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/resource_allocation_manager_impl.cc @@ -488,6 +488,28 @@ bool ResourceAllocationManagerImpl::IsResourceFree( return ResourceState::FREE == resource->second; } +bool ResourceAllocationManagerImpl::IsResourceAllocated( + const std::string& module_type, + const std::string& module_id, + const uint32_t app_id) { + ModuleUid module(module_type, module_id); + sync_primitives::AutoLock lock(allocated_resources_lock_); + const auto allocation = allocated_resources_.find(module); + if (allocated_resources_.end() == allocation) { + SDL_LOG_DEBUG("Resource " << module_type << " is not allocated."); + return false; + } + + if (app_id != allocation->second) { + SDL_LOG_DEBUG("Resource " << module_type + << " is allocated by different application " + << allocation->second); + return true; + } + + return false; +} + void ResourceAllocationManagerImpl::SetAccessMode( const hmi_apis::Common_RCAccessMode::eType access_mode) { if (hmi_apis::Common_RCAccessMode::ASK_DRIVER != access_mode) { diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/button_press_request_test.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/button_press_request_test.cc index 6c0962a557f..3772a25f476 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/button_press_request_test.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/button_press_request_test.cc @@ -105,6 +105,8 @@ class ButtonPressRequestTest .WillByDefault(Return(true)); ON_CALL(mock_allocation_manager_, is_rc_enabled()) .WillByDefault(Return(true)); + ON_CALL(mock_allocation_manager_, GetAccessMode()) + .WillByDefault(Return(hmi_apis::Common_RCAccessMode::AUTO_ALLOW)); ON_CALL(mock_rc_capabilities_manager_, CheckButtonName(_, _)) .WillByDefault(Return(true)); ON_CALL(mock_rc_capabilities_manager_, CheckIfModuleExistsInCapabilities(_)) diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/on_remote_control_settings_test.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/on_remote_control_settings_test.cc index 62b726ac601..7907013fa37 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/on_remote_control_settings_test.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/on_remote_control_settings_test.cc @@ -145,9 +145,10 @@ TEST_F(RCOnRemoteControlSettingsNotificationTest, MessageSharedPtr mobile_message = CreateBasicMessage(); (*mobile_message)[application_manager::strings::msg_params] [message_params::kAllowed] = false; - - EXPECT_CALL(mock_allocation_manager_, ResetAllAllocations()); + ON_CALL(mock_allocation_manager_, GetAccessMode()) + .WillByDefault(Return(hmi_apis::Common_RCAccessMode::ASK_DRIVER)); EXPECT_CALL(mock_interior_data_manager_, OnDisablingRC()); + EXPECT_CALL(mock_allocation_manager_, ResetAllAllocations()); EXPECT_CALL(mock_rc_consent_manger_, RemoveAllConsents()); // Act diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/rc_get_interior_vehicle_data_consent_test.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/rc_get_interior_vehicle_data_consent_test.cc index 8fbaeda2f21..15b21481875 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/rc_get_interior_vehicle_data_consent_test.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/rc_get_interior_vehicle_data_consent_test.cc @@ -39,10 +39,11 @@ #include "application_manager/mock_event_dispatcher.h" #include "application_manager/mock_hmi_capabilities.h" #include "application_manager/mock_request_controller_settings.h" +#include "application_manager/mock_request_timeout_handler.h" #include "application_manager/mock_rpc_plugin.h" #include "application_manager/mock_rpc_plugin_manager.h" #include "application_manager/mock_rpc_protection_manager.h" -#include "application_manager/request_controller.h" +#include "application_manager/request_controller_impl.h" #include "application_manager/rpc_service_impl.h" #include "hmi_message_handler/mock_hmi_message_handler.h" #include "include/test/protocol_handler/mock_protocol_handler.h" @@ -81,6 +82,7 @@ using test::components::application_manager_test::MockApplication; using test::components::application_manager_test::MockCommandFactory; using test::components::application_manager_test::MockHMICapabilities; using test::components::application_manager_test::MockRequestControlerSettings; +using test::components::application_manager_test::MockRequestTimeoutHandler; using test::components::commands_test::CommandRequestTest; using test::components::commands_test::CommandsTestMocks; using test::components::hmi_message_handler_test::MockHMIMessageHandler; @@ -108,9 +110,10 @@ class RCGetInteriorVehicleDataConsentTest , command_holder(app_mngr_) , rc_capabilities_(std::make_shared( smart_objects::SmartType::SmartType_Array)) - , request_controller(mock_request_controler) , rpc_protection_manager_( std::make_shared()) + , request_controller(mock_request_controler, + mock_request_timeout_handler_) , rpc_service_(app_mngr_, request_controller, &mock_protocol_handler, @@ -214,9 +217,10 @@ class RCGetInteriorVehicleDataConsentTest smart_objects::SmartObjectSPtr rc_capabilities_; MockRPCPlugin mock_rpc_plugin; MockCommandFactory mock_command_factory; - am::request_controller::RequestController request_controller; std::shared_ptr rpc_protection_manager_; + MockRequestTimeoutHandler mock_request_timeout_handler_; + am::request_controller::RequestControllerImpl request_controller; am::rpc_service::RPCServiceImpl rpc_service_; RCRPCPlugin rc_plugin_; std::shared_ptr rc_app_extension_; @@ -235,6 +239,8 @@ TEST_F(RCGetInteriorVehicleDataConsentTest, Run_MobileSendButtonPressMessage_HMISendASKDRIVERModeToMobile) { // Arrange auto mobile_message = CreateBasicMessage(); + ON_CALL(mock_allocation_manager_, GetAccessMode()) + .WillByDefault(Return(hmi_apis::Common_RCAccessMode::ASK_DRIVER)); // Expectations EXPECT_CALL(mock_allocation_manager_, AcquireResource(_, _, _)) @@ -279,6 +285,9 @@ TEST_F(RCGetInteriorVehicleDataConsentTest, .WillOnce(ReturnRef(mock_command_factory)); auto mobile_message = CreateBasicMessage(); + ON_CALL(mock_allocation_manager_, GetAccessMode()) + .WillByDefault(Return(hmi_apis::Common_RCAccessMode::AUTO_DENY)); + auto rc_consent_response = CreateRCCommand( mobile_message); diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/set_interior_vehicle_data_request_test.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/set_interior_vehicle_data_request_test.cc index 9b06ddb1378..9ba959de299 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/set_interior_vehicle_data_request_test.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/set_interior_vehicle_data_request_test.cc @@ -112,6 +112,8 @@ class SetInteriorVehicleDataRequestTest ON_CALL(mock_rc_capabilities_manager_, GetModuleDataCapabilities(_, _)) .WillByDefault( Return(std::make_pair("", capabilitiesStatus::kSuccess))); + ON_CALL(mock_allocation_manager_, GetAccessMode()) + .WillByDefault(Return(hmi_apis::Common_RCAccessMode::AUTO_ALLOW)); } MessageSharedPtr CreateBasicMessage() { diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/include/rc_rpc_plugin/mock/mock_resource_allocation_manager.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/include/rc_rpc_plugin/mock/mock_resource_allocation_manager.h index fca6c9c77e3..2f128d64a8f 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/include/rc_rpc_plugin/mock/mock_resource_allocation_manager.h +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/include/rc_rpc_plugin/mock/mock_resource_allocation_manager.h @@ -70,6 +70,10 @@ class MockResourceAllocationManager MOCK_CONST_METHOD2(IsResourceFree, bool(const std::string& module_type, const std::string& module_id)); + MOCK_METHOD3(IsResourceAllocated, + bool(const std::string& module_type, + const std::string& module_id, + const uint32_t app_id)); MOCK_METHOD0(ResetAllAllocations, void()); MOCK_METHOD2(SendOnRCStatusNotifications, void(rc_rpc_plugin::NotificationTrigger::eType, diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_ui_reset_timeout_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_reset_timeout_notification.h similarity index 81% rename from src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_ui_reset_timeout_notification.h rename to src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_reset_timeout_notification.h index 1c87f82349c..57c6f55e03a 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_ui_reset_timeout_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_reset_timeout_notification.h @@ -30,8 +30,8 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_UI_RESET_TIMEOUT_NOTIFICATION_H_ -#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_UI_RESET_TIMEOUT_NOTIFICATION_H_ +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_RESET_TIMEOUT_NOTIFICATION_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_RESET_TIMEOUT_NOTIFICATION_H_ #include "application_manager/commands/notification_from_hmi.h" @@ -43,17 +43,17 @@ namespace commands { namespace hmi { /** - * @brief OnUIResetTimeoutNotification command class + * @brief OnResetTimeoutNotification command class **/ -class OnUIResetTimeoutNotification +class OnResetTimeoutNotification : public app_mngr::commands::NotificationFromHMI { public: /** - * @brief OnUIResetTimeoutNotification class constructor + * @brief OnResetTimeoutNotification class constructor * * @param message Incoming SmartObject message **/ - OnUIResetTimeoutNotification( + OnResetTimeoutNotification( const app_mngr::commands::MessageSharedPtr& message, app_mngr::ApplicationManager& application_manager, app_mngr::rpc_service::RPCService& rpc_service, @@ -61,9 +61,9 @@ class OnUIResetTimeoutNotification policy::PolicyHandlerInterface& policy_handle); /** - * @brief OnUIResetTimeoutNotification class destructor + * @brief OnResetTimeoutNotification class destructor **/ - virtual ~OnUIResetTimeoutNotification(); + virtual ~OnResetTimeoutNotification(); /** * @brief Execute command @@ -71,7 +71,7 @@ class OnUIResetTimeoutNotification virtual void Run(); private: - DISALLOW_COPY_AND_ASSIGN(OnUIResetTimeoutNotification); + DISALLOW_COPY_AND_ASSIGN(OnResetTimeoutNotification); }; } // namespace hmi @@ -80,4 +80,4 @@ class OnUIResetTimeoutNotification } // namespace sdl_rpc_plugin -#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_UI_RESET_TIMEOUT_NOTIFICATION_H_ +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_RESET_TIMEOUT_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_tts_reset_timeout_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_tts_reset_timeout_notification.h deleted file mode 100644 index c8bd1590641..00000000000 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_tts_reset_timeout_notification.h +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (c) 2018, 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_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_TTS_RESET_TIMEOUT_NOTIFICATION_H_ -#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_TTS_RESET_TIMEOUT_NOTIFICATION_H_ - -#include "application_manager/commands/notification_from_hmi.h" - -namespace sdl_rpc_plugin { -namespace app_mngr = application_manager; - -namespace commands { - -namespace hmi { - -/** - * @brief OnTTSResetTimeoutNotification command class - **/ -class OnTTSResetTimeoutNotification - : public app_mngr::commands::NotificationFromHMI { - public: - /** - * @brief OnTTSResetTimeoutNotification class constructor - * - * @param message Incoming SmartObject message - **/ - OnTTSResetTimeoutNotification( - const app_mngr::commands::MessageSharedPtr& message, - app_mngr::ApplicationManager& application_manager, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handle); - - /** - * @brief OnTTSResetTimeoutNotification class destructor - **/ - virtual ~OnTTSResetTimeoutNotification(); - - /** - * @brief Execute command - **/ - virtual void Run(); - - private: - DISALLOW_COPY_AND_ASSIGN(OnTTSResetTimeoutNotification); -}; - -} // namespace hmi - -} // namespace commands - -} // namespace sdl_rpc_plugin - -#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_TTS_RESET_TIMEOUT_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/delete_sub_menu_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/delete_sub_menu_request.h index af2ba4a1ea4..20fff456d53 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/delete_sub_menu_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/delete_sub_menu_request.h @@ -82,34 +82,45 @@ class DeleteSubMenuRequest : public app_mngr::commands::CommandRequestImpl { bool Init() FINAL; private: - /* - * @brief Deletes submenus that have a parentID that matches the parentID - * parameter + /** + * @brief Creates and queues up delete requests for a submenus that have a + * parent ID which matches the parentID parameter * * @param app_id Application ID * @param parentID Parent ID of a nested submenu */ void DeleteNestedSubMenus(app_mngr::ApplicationSharedPtr const app, - uint32_t parentID, + const uint32_t parentID, const app_mngr::SubMenuMap& subMenus); - /* - * @brief Deletes VR commands from SDL for corresponding submenu ID + /** + * @brief Creates and queues up delete requests for each VR command tied to + * the given submenu ID * * @param app_id Application ID * @param parentID Parent ID of a nested submenu */ void DeleteSubMenuVRCommands(app_mngr::ApplicationConstSharedPtr app, - uint32_t parentID); + const uint32_t parentID); - /* - * @brief Deletes UI commands from SDL for corresponding submenu ID + /** + * @brief Creates and queues up delete requests for each UI command tied to + * the given submenu ID * * @param app_id Application ID * @param parentID Parent ID of a nested submenu */ void DeleteSubMenuUICommands(app_mngr::ApplicationSharedPtr const app, - uint32_t parentID); + const uint32_t parentID); + + /** + * @brief Takes the next request in the queue and sends it to HMI + */ + void SendNextRequest(); + + typedef std::list RequestsList; + RequestsList requests_list_; + uint32_t pending_request_corr_id_; DISALLOW_COPY_AND_ASSIGN(DeleteSubMenuRequest); }; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/reset_global_properties_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/reset_global_properties_request.h index 7475520889b..760eb09c2d6 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/reset_global_properties_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/reset_global_properties_request.h @@ -105,7 +105,9 @@ class ResetGlobalPropertiesRequest hmi_apis::Common_Result::eType ui_result_; hmi_apis::Common_Result::eType tts_result_; + hmi_apis::Common_Result::eType rc_result_; std::string ui_response_info_; + std::string rc_response_info_; std::string tts_response_info_; }; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/sdl_rpc_plugin.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/sdl_rpc_plugin.h index b4ef7e6aedf..ab74ed08fb2 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/sdl_rpc_plugin.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/sdl_rpc_plugin.h @@ -54,13 +54,6 @@ class SDLRPCPlugin : public plugins::RPCPlugin { policy::PolicyHandlerInterface& policy_handler, resumption::LastStateWrapperPtr last_state) OVERRIDE; - DEPRECATED - bool Init(app_mngr::ApplicationManager& app_manager, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler, - resumption::LastState& last_state) OVERRIDE; - /** * @brief ProcessResumptionSubscription send appropriate subscribe requests * to HMI diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_audio_start_stream_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_audio_start_stream_request.cc index 21d62824362..05d0a4e8f2c 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_audio_start_stream_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_audio_start_stream_request.cc @@ -58,9 +58,11 @@ AudioStartStreamRequest::AudioStartStreamRequest( SDL_LOG_AUTO_TRACE(); std::pair stream_retry = application_manager_.get_settings().start_stream_retry_amount(); - default_timeout_ = stream_retry.second; + default_timeout_ = + stream_retry.second + + application_manager_.get_settings().default_timeout_compensation(); retry_number_ = stream_retry.first; - SDL_LOG_DEBUG("default_timeout_ = " << default_timeout_ + SDL_LOG_DEBUG("default_timeout_ = " << stream_retry.second << "; retry_number_ = " << retry_number_); } diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_start_stream_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_start_stream_request.cc index 973c323ebee..c671b11282b 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_start_stream_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_start_stream_request.cc @@ -58,9 +58,11 @@ NaviStartStreamRequest::NaviStartStreamRequest( SDL_LOG_AUTO_TRACE(); std::pair stream_retry = application_manager_.get_settings().start_stream_retry_amount(); - default_timeout_ = stream_retry.second; + default_timeout_ = + stream_retry.second + + application_manager_.get_settings().default_timeout_compensation(); retry_number_ = stream_retry.first; - SDL_LOG_DEBUG("default_timeout_ = " << default_timeout_ + SDL_LOG_DEBUG("default_timeout_ = " << stream_retry.second << "; retry_number_ = " << retry_number_); } diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_ui_reset_timeout_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_reset_timeout_notification.cc similarity index 88% rename from src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_ui_reset_timeout_notification.cc rename to src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_reset_timeout_notification.cc index d8de31cfbc5..ff5b2709c0d 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_ui_reset_timeout_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_reset_timeout_notification.cc @@ -29,8 +29,7 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ - -#include "sdl_rpc_plugin/commands/hmi/on_ui_reset_timeout_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_reset_timeout_notification.h" #include "application_manager/event_engine/event.h" #include "interfaces/HMI_API.h" @@ -43,7 +42,7 @@ namespace hmi { SDL_CREATE_LOG_VARIABLE("Commands") -OnUIResetTimeoutNotification::OnUIResetTimeoutNotification( +OnResetTimeoutNotification::OnResetTimeoutNotification( const application_manager::commands::MessageSharedPtr& message, ApplicationManager& application_manager, rpc_service::RPCService& rpc_service, @@ -55,12 +54,13 @@ OnUIResetTimeoutNotification::OnUIResetTimeoutNotification( hmi_capabilities, policy_handle) {} -OnUIResetTimeoutNotification::~OnUIResetTimeoutNotification() {} +OnResetTimeoutNotification::~OnResetTimeoutNotification() {} -void OnUIResetTimeoutNotification::Run() { +void OnResetTimeoutNotification::Run() { SDL_LOG_AUTO_TRACE(); - event_engine::Event event(hmi_apis::FunctionID::UI_OnResetTimeout); + event_engine::Event event( + hmi_apis::FunctionID::BasicCommunication_OnResetTimeout); event.set_smart_object(*message_); event.raise(application_manager_.event_dispatcher()); } diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_activate_app_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_activate_app_request.cc index 66ac9c458b1..4de8b17b8dc 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_activate_app_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_activate_app_request.cc @@ -142,7 +142,7 @@ void SDLActivateAppRequest::Run() { application_manager_.get_settings(); uint32_t total_retry_timeout = (settings.cloud_app_retry_timeout() * settings.cloud_app_max_retry_attempts()); - application_manager_.updateRequestTimeout( + application_manager_.UpdateRequestTimeout( 0, correlation_id(), default_timeout_ + total_retry_timeout); subscribe_on_event(BasicCommunication_OnAppRegistered); application_manager_.connection_handler().ConnectToDevice(app->device()); @@ -227,7 +227,7 @@ void SDLActivateAppRequest::Run() { application_manager_.get_settings(); uint32_t total_retry_timeout = (settings.cloud_app_retry_timeout() * settings.cloud_app_max_retry_attempts()); - application_manager_.updateRequestTimeout( + application_manager_.UpdateRequestTimeout( 0, correlation_id(), default_timeout_ + total_retry_timeout); subscribe_on_event(BasicCommunication_OnAppRegistered); application_manager_.connection_handler().ConnectToDevice( diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_get_capabilities_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_get_capabilities_response.cc index 45c5f59326b..128f41e01f4 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_get_capabilities_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_get_capabilities_response.cc @@ -151,11 +151,6 @@ void UIGetCapabilitiesResponse::Run() { hmi_capabilities_.set_driver_distraction_supported(true); } } - if (system_capabilities_so.keyExists(strings::display_capabilities)) { - sections_to_update.push_back(strings::display_capabilities); - hmi_capabilities_.set_system_display_capabilities( - system_capabilities_so[strings::display_capabilities]); - } } if (msg_params.keyExists(strings::pcm_stream_capabilities)) { diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/alert_maneuver_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/alert_maneuver_request.cc index 8728bb44036..0e0d91f05db 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/alert_maneuver_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/alert_maneuver_request.cc @@ -51,9 +51,7 @@ AlertManeuverRequest::AlertManeuverRequest( hmi_capabilities, policy_handler) , tts_speak_result_code_(hmi_apis::Common_Result::INVALID_ENUM) - , navi_alert_maneuver_result_code_(hmi_apis::Common_Result::INVALID_ENUM) { - subscribe_on_event(hmi_apis::FunctionID::TTS_OnResetTimeout); -} + , navi_alert_maneuver_result_code_(hmi_apis::Common_Result::INVALID_ENUM) {} AlertManeuverRequest::~AlertManeuverRequest() {} @@ -179,13 +177,7 @@ void AlertManeuverRequest::on_event(const event_engine::Event& event) { GetInfo(message, info_tts_); break; } - case hmi_apis::FunctionID::TTS_OnResetTimeout: { - SDL_LOG_INFO("Received TTS_OnResetTimeout event"); - application_manager_.updateRequestTimeout( - connection_key(), correlation_id(), default_timeout()); - break; - } default: { SDL_LOG_ERROR("Received unknown event " << event.id()); SendResponse( diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/alert_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/alert_request.cc index 5d1a058f164..26c209bf2a8 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/alert_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/alert_request.cc @@ -65,10 +65,7 @@ AlertRequest::AlertRequest( , awaiting_tts_stop_speaking_response_(false) , is_ui_alert_sent_(false) , alert_result_(hmi_apis::Common_Result::INVALID_ENUM) - , tts_speak_result_(hmi_apis::Common_Result::INVALID_ENUM) { - subscribe_on_event(hmi_apis::FunctionID::UI_OnResetTimeout); - subscribe_on_event(hmi_apis::FunctionID::TTS_OnResetTimeout); -} + , tts_speak_result_(hmi_apis::Common_Result::INVALID_ENUM) {} AlertRequest::~AlertRequest() {} @@ -129,18 +126,6 @@ void AlertRequest::on_event(const event_engine::Event& event) { const smart_objects::SmartObject& message = event.smart_object(); switch (event.id()) { - case hmi_apis::FunctionID::TTS_OnResetTimeout: - case hmi_apis::FunctionID::UI_OnResetTimeout: { - SDL_LOG_INFO( - "Received UI_OnResetTimeout event " - " or TTS_OnResetTimeout event " - << awaiting_tts_speak_response_ << " " - << awaiting_tts_stop_speaking_response_ << " " - << awaiting_ui_alert_response_); - application_manager_.updateRequestTimeout( - connection_key(), correlation_id(), default_timeout()); - break; - } case hmi_apis::FunctionID::UI_Alert: { SDL_LOG_INFO("Received UI_Alert event"); // Unsubscribe from event to avoid unwanted messages diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/create_interaction_choice_set_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/create_interaction_choice_set_request.cc index f3e0b679218..2f624efe765 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/create_interaction_choice_set_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/create_interaction_choice_set_request.cc @@ -369,7 +369,7 @@ void CreateInteractionChoiceSetRequest::CountReceivedVRResponses() { << expected_chs_count_ - received_chs_count_ << " more to wait."); if (received_chs_count_ < expected_chs_count_) { - application_manager_.updateRequestTimeout( + application_manager_.UpdateRequestTimeout( connection_key(), correlation_id(), default_timeout()); SDL_LOG_DEBUG("Timeout for request was updated"); } else { diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_sub_menu_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_sub_menu_request.cc index 19ec2dfb274..09346dc20a0 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_sub_menu_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_sub_menu_request.cc @@ -56,7 +56,9 @@ DeleteSubMenuRequest::DeleteSubMenuRequest( application_manager, rpc_service, hmi_capabilities, - policy_handler) {} + policy_handler) + , requests_list_() + , pending_request_corr_id_(0) {} DeleteSubMenuRequest::~DeleteSubMenuRequest() {} @@ -82,19 +84,42 @@ void DeleteSubMenuRequest::Run() { return; } + { + const DataAccessor accessor = app->sub_menu_map(); + const SubMenuMap& sub_menus = accessor.GetData(); + DeleteNestedSubMenus(app, menu_id, sub_menus); + } + smart_objects::SmartObject msg_params = smart_objects::SmartObject(smart_objects::SmartType_Map); - msg_params[strings::menu_id] = (*message_)[strings::msg_params][strings::menu_id]; msg_params[strings::app_id] = app->app_id(); + requests_list_.push_back(msg_params); + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); + SendNextRequest(); +} - SendHMIRequest(hmi_apis::FunctionID::UI_DeleteSubMenu, &msg_params, true); +void DeleteSubMenuRequest::SendNextRequest() { + SDL_LOG_AUTO_TRACE(); + + const auto request_params = requests_list_.front(); + auto function_id = hmi_apis::FunctionID::UI_DeleteSubMenu; + + if (request_params.keyExists(strings::cmd_id)) { + function_id = request_params.keyExists(strings::grammar_id) + ? hmi_apis::FunctionID::VR_DeleteCommand + : hmi_apis::FunctionID::UI_DeleteCommand; + } + + pending_request_corr_id_ = SendHMIRequest(function_id, &request_params, true); + SDL_LOG_DEBUG( + "Waiting for response for corr_id = " << pending_request_corr_id_); } void DeleteSubMenuRequest::DeleteNestedSubMenus(ApplicationSharedPtr const app, - uint32_t parentID, + const uint32_t parentID, const SubMenuMap& subMenus) { SDL_LOG_AUTO_TRACE(); @@ -108,26 +133,26 @@ void DeleteSubMenuRequest::DeleteNestedSubMenus(ApplicationSharedPtr const app, } if (parentID == (*it->second)[strings::parent_id].asUInt()) { - uint32_t menuID = (*it->second)[strings::menu_id].asUInt(); + const uint32_t menuID = (*it->second)[strings::menu_id].asUInt(); DeleteNestedSubMenus(app, menuID, subMenus); - DeleteSubMenuVRCommands(app, menuID); - DeleteSubMenuUICommands(app, menuID); + smart_objects::SmartObject msg_params = smart_objects::SmartObject(smart_objects::SmartType_Map); msg_params[strings::menu_id] = menuID; msg_params[strings::app_id] = app->app_id(); - SendHMIRequest(hmi_apis::FunctionID::UI_DeleteSubMenu, &msg_params); - ++it; - SDL_LOG_DEBUG("Removing submenuID: " << menuID); - app->RemoveSubMenu(menuID); - } else { - ++it; + requests_list_.push_back(msg_params); } + + ++it; } + + SDL_LOG_DEBUG("Delete commands with Parent ID: " << parentID); + DeleteSubMenuVRCommands(app, parentID); + DeleteSubMenuUICommands(app, parentID); } void DeleteSubMenuRequest::DeleteSubMenuVRCommands( - ApplicationConstSharedPtr app, uint32_t parentID) { + ApplicationConstSharedPtr app, const uint32_t parentID) { SDL_LOG_AUTO_TRACE(); const DataAccessor accessor = app->commands_map(); @@ -148,7 +173,7 @@ void DeleteSubMenuRequest::DeleteSubMenuVRCommands( msg_params[strings::grammar_id] = app->get_grammar_id(); msg_params[strings::type] = hmi_apis::Common_VRCommandType::Command; - SendHMIRequest(hmi_apis::FunctionID::VR_DeleteCommand, &msg_params); + requests_list_.push_back(msg_params); } } } @@ -175,16 +200,11 @@ void DeleteSubMenuRequest::DeleteSubMenuUICommands( const uint32_t cmd_id = (*it->second)[strings::cmd_id].asUInt(); msg_params[strings::app_id] = app->app_id(); msg_params[strings::cmd_id] = cmd_id; - SDL_LOG_DEBUG("Removing UI Command: " << cmd_id); - app->RemoveCommand(cmd_id); - app->help_prompt_manager().OnVrCommandDeleted(cmd_id, false); - it = commands.begin(); // Can not relay on - // iterators after erase was called - - SendHMIRequest(hmi_apis::FunctionID::UI_DeleteCommand, &msg_params); - } else { - ++it; + + requests_list_.push_back(msg_params); } + + ++it; } } @@ -193,48 +213,110 @@ void DeleteSubMenuRequest::on_event(const event_engine::Event& event) { const smart_objects::SmartObject& message = event.smart_object(); switch (event.id()) { - case hmi_apis::FunctionID::UI_DeleteSubMenu: { - EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); - hmi_apis::Common_Result::eType result_code = - static_cast( - message[strings::params][hmi_response::code].asInt()); - std::string response_info; - GetInfo(message, response_info); - const bool result = PrepareResultForMobileResponse( - result_code, HmiInterfaces::HMI_INTERFACE_UI); - - ApplicationSharedPtr application = - application_manager_.application(connection_key()); - - if (!application) { - SDL_LOG_ERROR("NULL pointer"); - return; + case hmi_apis::FunctionID::UI_DeleteCommand: { + SDL_LOG_DEBUG("Received UI_DeleteCommand response"); + + const auto corr_id = + message[strings::params][strings::correlation_id].asUInt(); + if (pending_request_corr_id_ == corr_id) { + auto msg_params = requests_list_.front(); + + const auto result_code = static_cast( + message[strings::params][hmi_response::code].asInt()); + + auto app = application_manager_.application(connection_key()); + if (!app) { + SDL_LOG_ERROR("Application not found"); + return; + } + + if (application_manager::commands::IsHMIResultSuccess(result_code)) { + const auto cmd_id = msg_params[strings::cmd_id].asUInt(); + SDL_LOG_DEBUG("Removing UI Command: " << cmd_id); + app->RemoveCommand(cmd_id); + app->help_prompt_manager().OnVrCommandDeleted(cmd_id, false); + } + + requests_list_.pop_front(); } - if (result) { - // delete sub menu items from SDL and HMI - uint32_t parentID = - (*message_)[strings::msg_params][strings::menu_id].asUInt(); - const DataAccessor accessor = application->sub_menu_map(); - const SubMenuMap& subMenus = accessor.GetData(); - DeleteNestedSubMenus(application, parentID, subMenus); - DeleteSubMenuVRCommands(application, parentID); - DeleteSubMenuUICommands(application, parentID); - application->RemoveSubMenu( - (*message_)[strings::msg_params][strings::menu_id].asInt()); + break; + } + + case hmi_apis::FunctionID::VR_DeleteCommand: { + SDL_LOG_DEBUG("Received VR_DeleteCommand response"); + + const auto corr_id = + message[strings::params][strings::correlation_id].asUInt(); + + if (corr_id == pending_request_corr_id_) { + auto app = application_manager_.application(connection_key()); + if (!app) { + SDL_LOG_ERROR("Application not found"); + return; + } + + requests_list_.pop_front(); } - SendResponse(result, - MessageHelper::HMIToMobileResult(result_code), - response_info.empty() ? NULL : response_info.c_str(), - &(message[strings::msg_params])); break; } + + case hmi_apis::FunctionID::UI_DeleteSubMenu: { + SDL_LOG_DEBUG("Received UI_DeleteSubMenu response"); + + const auto corr_id = + message[strings::params][strings::correlation_id].asUInt(); + if (corr_id == pending_request_corr_id_) { + auto msg_params = requests_list_.front(); + + const auto result_code = static_cast( + message[strings::params][hmi_response::code].asInt()); + + auto app = application_manager_.application(connection_key()); + if (!app) { + SDL_LOG_ERROR("Application not found"); + return; + } + + if (application_manager::commands::IsHMIResultSuccess(result_code)) { + const auto menu_id = msg_params[strings::menu_id].asUInt(); + SDL_LOG_DEBUG("Removing submenuID: " << menu_id); + app->RemoveSubMenu(menu_id); + } + + requests_list_.pop_front(); + } + + break; + } + default: { SDL_LOG_ERROR("Received unknown event" << event.id()); return; } } + + if (!requests_list_.empty()) { + SDL_LOG_DEBUG("Still waiting for another requests"); + SendNextRequest(); + return; + } + + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); + + hmi_apis::Common_Result::eType result_code = + static_cast( + message[strings::params][hmi_response::code].asInt()); + std::string response_info; + GetInfo(message, response_info); + const bool result = PrepareResultForMobileResponse( + result_code, HmiInterfaces::HMI_INTERFACE_UI); + + SendResponse(result, + MessageHelper::HMIToMobileResult(result_code), + response_info.empty() ? NULL : response_info.c_str(), + &(message[strings::msg_params])); } bool DeleteSubMenuRequest::Init() { diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_way_points_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_way_points_request.cc index 54b542d245f..9e156bf7558 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_way_points_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_way_points_request.cc @@ -51,9 +51,7 @@ GetWayPointsRequest::GetWayPointsRequest( application_manager, rpc_service, hmi_capabilities, - policy_handler) { - subscribe_on_event(hmi_apis::FunctionID::UI_OnResetTimeout); -} + policy_handler) {} GetWayPointsRequest::~GetWayPointsRequest() {} @@ -81,12 +79,6 @@ void GetWayPointsRequest::on_event(const event_engine::Event& event) { SDL_LOG_AUTO_TRACE(); const smart_objects::SmartObject& message = event.smart_object(); switch (event.id()) { - case hmi_apis::FunctionID::UI_OnResetTimeout: { - SDL_LOG_INFO("Received UI_OnResetTimeout event"); - application_manager_.updateRequestTimeout( - connection_key(), correlation_id(), default_timeout()); - break; - } case hmi_apis::FunctionID::Navigation_GetWayPoints: { SDL_LOG_INFO("Received Navigation_GetWayPoints event"); EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_Navigation); diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/perform_audio_pass_thru_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/perform_audio_pass_thru_request.cc index 0accdd1e76c..74b474f76b3 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/perform_audio_pass_thru_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/perform_audio_pass_thru_request.cc @@ -59,9 +59,7 @@ PerformAudioPassThruRequest::PerformAudioPassThruRequest( hmi_capabilities, policy_handler) , result_tts_speak_(hmi_apis::Common_Result::INVALID_ENUM) - , result_ui_(hmi_apis::Common_Result::INVALID_ENUM) { - subscribe_on_event(hmi_apis::FunctionID::TTS_OnResetTimeout); -} + , result_ui_(hmi_apis::Common_Result::INVALID_ENUM) {} PerformAudioPassThruRequest::~PerformAudioPassThruRequest() {} @@ -183,18 +181,12 @@ void PerformAudioPassThruRequest::on_event(const event_engine::Event& event) { StartMicrophoneRecording(); // update request timeout to get time for perform audio recording - application_manager_.updateRequestTimeout( + application_manager_.UpdateRequestTimeout( connection_key(), correlation_id(), default_timeout()); } break; } - case hmi_apis::FunctionID::TTS_OnResetTimeout: { - SDL_LOG_INFO("Received TTS_OnResetTimeout event"); - application_manager_.updateRequestTimeout( - connection_key(), correlation_id(), default_timeout()); - break; - } default: { SDL_LOG_ERROR("Received unknown event " << event.id()); return; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/perform_interaction_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/perform_interaction_request.cc index bb990574bd6..da1f744689c 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/perform_interaction_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/perform_interaction_request.cc @@ -83,7 +83,6 @@ PerformInteractionRequest::PerformInteractionRequest( , ui_result_code_(hmi_apis::Common_Result::INVALID_ENUM) { response_msg_params = smart_objects::SmartObject(smart_objects::SmartType_Map); - subscribe_on_event(hmi_apis::FunctionID::UI_OnResetTimeout); subscribe_on_event(hmi_apis::FunctionID::VR_OnCommand); subscribe_on_event(hmi_apis::FunctionID::Buttons_OnButtonPress); } @@ -236,12 +235,6 @@ void PerformInteractionRequest::on_event(const event_engine::Event& event) { const smart_objects::SmartObject& message = event.smart_object(); switch (event.id()) { - case hmi_apis::FunctionID::UI_OnResetTimeout: { - SDL_LOG_DEBUG("Received UI_OnResetTimeout event"); - application_manager_.updateRequestTimeout( - connection_key(), correlation_id(), default_timeout()); - break; - } case hmi_apis::FunctionID::UI_PerformInteraction: { SDL_LOG_DEBUG("Received UI_PerformInteraction event"); EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); @@ -299,7 +292,7 @@ void PerformInteractionRequest::onTimeOut() { DisablePerformInteraction(); CommandRequestImpl::onTimeOut(); } else { - application_manager_.updateRequestTimeout( + application_manager_.UpdateRequestTimeout( connection_key(), correlation_id(), default_timeout_); } break; @@ -351,8 +344,10 @@ bool PerformInteractionRequest::ProcessVRResponse( SendResponse(false, MessageHelper::HMIToMobileResult(vr_result_code_)); return true; } + SDL_LOG_DEBUG("Update timeout for UI"); - application_manager_.updateRequestTimeout( + application_manager_.UpdateRequestTimeout( + connection_key(), correlation_id(), default_timeout_); return false; } @@ -378,7 +373,7 @@ bool PerformInteractionRequest::ProcessVRResponse( if (mobile_apis::InteractionMode::BOTH == interaction_mode_ || mobile_apis::InteractionMode::MANUAL_ONLY == interaction_mode_) { SDL_LOG_DEBUG("Update timeout for UI"); - application_manager_.updateRequestTimeout( + application_manager_.UpdateRequestTimeout( connection_key(), correlation_id(), default_timeout_); } diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/reset_global_properties_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/reset_global_properties_request.cc index f4e07d4b78f..dd5e3d3e88d 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/reset_global_properties_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/reset_global_properties_request.cc @@ -58,7 +58,8 @@ ResetGlobalPropertiesRequest::ResetGlobalPropertiesRequest( hmi_capabilities, policy_handler) , ui_result_(hmi_apis::Common_Result::INVALID_ENUM) - , tts_result_(hmi_apis::Common_Result::INVALID_ENUM) {} + , tts_result_(hmi_apis::Common_Result::INVALID_ENUM) + , rc_result_(hmi_apis::Common_Result::INVALID_ENUM) {} ResetGlobalPropertiesRequest::~ResetGlobalPropertiesRequest() {} @@ -146,6 +147,14 @@ void ResetGlobalPropertiesRequest::on_event(const event_engine::Event& event) { GetInfo(message, tts_response_info_); break; } + case hmi_apis::FunctionID::RC_SetGlobalProperties: { + SDL_LOG_INFO("Received RC_SetGlobalProperties event"); + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_RC); + rc_result_ = static_cast( + message[strings::params][hmi_response::code].asInt()); + GetInfo(message, rc_response_info_); + break; + } default: { SDL_LOG_ERROR("Received unknown event " << event.id()); return; @@ -183,6 +192,8 @@ bool ResetGlobalPropertiesRequest::PrepareResponseParameters( ui_result_, HmiInterfaces::HMI_INTERFACE_UI, application_manager_); app_mngr::commands::ResponseInfo tts_properties_info( tts_result_, HmiInterfaces::HMI_INTERFACE_TTS, application_manager_); + app_mngr::commands::ResponseInfo rc_properties_info( + rc_result_, HmiInterfaces::HMI_INTERFACE_RC, application_manager_); HmiInterfaces::InterfaceState tts_interface_state = application_manager_.hmi_interfaces().GetInterfaceState( @@ -195,14 +206,13 @@ bool ResetGlobalPropertiesRequest::PrepareResponseParameters( out_result_code = mobile_apis::Result::WARNINGS; out_response_info = "Unsupported phoneme type sent in a prompt"; } else { - result = - PrepareResultForMobileResponse(ui_properties_info, tts_properties_info); - out_result_code = - PrepareResultCodeForResponse(ui_properties_info, tts_properties_info); - out_response_info = app_mngr::commands::MergeInfos(tts_properties_info, - tts_response_info_, - ui_properties_info, - ui_response_info_); + result = PrepareResultForMobileResponse( + ui_properties_info, tts_properties_info, rc_properties_info); + out_result_code = PrepareResultCodeForResponse( + ui_properties_info, tts_properties_info, rc_properties_info); + + out_response_info = app_mngr::commands::MergeInfos( + tts_response_info_, ui_response_info_, rc_response_info_); } return result; @@ -210,7 +220,8 @@ bool ResetGlobalPropertiesRequest::PrepareResponseParameters( bool ResetGlobalPropertiesRequest::IsPendingResponseExist() { return IsInterfaceAwaited(HmiInterfaces::HMI_INTERFACE_TTS) || - IsInterfaceAwaited(HmiInterfaces::HMI_INTERFACE_UI); + IsInterfaceAwaited(HmiInterfaces::HMI_INTERFACE_UI) || + IsInterfaceAwaited(HmiInterfaces::HMI_INTERFACE_RC); } } // namespace commands diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/scrollable_message_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/scrollable_message_request.cc index 89e77d9d197..7cfe5f54144 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/scrollable_message_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/scrollable_message_request.cc @@ -58,9 +58,7 @@ ScrollableMessageRequest::ScrollableMessageRequest( application_manager, rpc_service, hmi_capabilities, - policy_handler) { - subscribe_on_event(hmi_apis::FunctionID::UI_OnResetTimeout); -} + policy_handler) {} ScrollableMessageRequest::~ScrollableMessageRequest() {} @@ -131,12 +129,6 @@ void ScrollableMessageRequest::on_event(const event_engine::Event& event) { const smart_objects::SmartObject& message = event.smart_object(); switch (event.id()) { - case hmi_apis::FunctionID::UI_OnResetTimeout: { - SDL_LOG_INFO("Received UI_OnResetTimeout event"); - application_manager_.updateRequestTimeout( - connection_key(), correlation_id(), default_timeout()); - break; - } case hmi_apis::FunctionID::UI_ScrollableMessage: { SDL_LOG_INFO("Received UI_ScrollableMessage event"); EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_global_properties_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_global_properties_request.cc index bbce4d2bb35..0aab0003769 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_global_properties_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_global_properties_request.cc @@ -186,6 +186,7 @@ void SetGlobalPropertiesRequest::Run() { msg_params[strings::menu_layout].asUInt()); if (app->menu_layout_supported(menu_layout)) { params[strings::menu_layout] = msg_params[strings::menu_layout]; + app->set_menu_layout(msg_params[strings::menu_layout]); } else { is_menu_layout_available_ = false; } diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/slider_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/slider_request.cc index 22935e21369..0fdc412572e 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/slider_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/slider_request.cc @@ -55,9 +55,7 @@ SliderRequest::SliderRequest( application_manager, rpc_service, hmi_capabilities, - policy_handler) { - subscribe_on_event(hmi_apis::FunctionID::UI_OnResetTimeout); -} + policy_handler) {} SliderRequest::~SliderRequest() {} @@ -65,8 +63,7 @@ bool SliderRequest::Init() { /* Timeout in milliseconds. If omitted a standard value of 10000 milliseconds is used.*/ if ((*message_)[strings::msg_params].keyExists(strings::timeout)) { - default_timeout_ = - application_manager_.get_settings().default_timeout() + + default_timeout_ += (*message_)[strings::msg_params][strings::timeout].asUInt(); } @@ -134,12 +131,6 @@ void SliderRequest::on_event(const event_engine::Event& event) { const SmartObject& message = event.smart_object(); const event_engine::Event::EventID event_id = event.id(); - if (event_id == FunctionID::UI_OnResetTimeout) { - SDL_LOG_INFO("Received UI_OnResetTimeout event"); - application_manager_.updateRequestTimeout( - connection_key(), correlation_id(), default_timeout()); - return; - } if (event_id != FunctionID::UI_Slider) { SDL_LOG_ERROR("Received unknown event " << event.id()); diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/speak_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/speak_request.cc index b8de0538530..f8307f83556 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/speak_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/speak_request.cc @@ -55,9 +55,7 @@ SpeakRequest::SpeakRequest( application_manager, rpc_service, hmi_capabilities, - policy_handler) { - subscribe_on_event(hmi_apis::FunctionID::TTS_OnResetTimeout); -} + policy_handler) {} SpeakRequest::~SpeakRequest() {} @@ -112,13 +110,7 @@ void SpeakRequest::on_event(const event_engine::Event& event) { ProcessTTSSpeakResponse(event.smart_object()); break; } - case hmi_apis::FunctionID::TTS_OnResetTimeout: { - SDL_LOG_INFO("Received TTS_OnResetTimeout event"); - application_manager_.updateRequestTimeout( - connection_key(), correlation_id(), default_timeout()); - break; - } default: { SDL_LOG_ERROR("Received unknown event " << event.id()); break; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/subtle_alert_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/subtle_alert_request.cc index 2a8e2674364..8491a859e64 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/subtle_alert_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/subtle_alert_request.cc @@ -59,10 +59,7 @@ SubtleAlertRequest::SubtleAlertRequest( , is_ui_subtle_alert_sent_(false) , is_tts_stop_speaking_sent_(false) , subtle_alert_result_(hmi_apis::Common_Result::INVALID_ENUM) - , tts_speak_result_(hmi_apis::Common_Result::INVALID_ENUM) { - subscribe_on_event(hmi_apis::FunctionID::UI_OnResetTimeout); - subscribe_on_event(hmi_apis::FunctionID::TTS_OnResetTimeout); -} + , tts_speak_result_(hmi_apis::Common_Result::INVALID_ENUM) {} SubtleAlertRequest::~SubtleAlertRequest() {} @@ -118,18 +115,6 @@ void SubtleAlertRequest::on_event(const event_engine::Event& event) { const smart_objects::SmartObject& message = event.smart_object(); switch (event.id()) { - case hmi_apis::FunctionID::TTS_OnResetTimeout: - case hmi_apis::FunctionID::UI_OnResetTimeout: { - SDL_LOG_INFO( - "Received UI_OnResetTimeout event " - " or TTS_OnResetTimeout event" - << awaiting_tts_speak_response_ << " " - << awaiting_tts_stop_speaking_response_ << " " - << awaiting_ui_subtle_alert_response_); - application_manager_.updateRequestTimeout( - connection_key(), correlation_id(), default_timeout()); - break; - } case hmi_apis::FunctionID::UI_SubtleAlert: { SDL_LOG_INFO("Received UI_SubtleAlert event"); // Unsubscribe from event to avoid unwanted messages diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/hmi_command_factory.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/hmi_command_factory.cc index 0b6165c6aa7..c66e0b6950b 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/hmi_command_factory.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/hmi_command_factory.cc @@ -221,6 +221,7 @@ #include "sdl_rpc_plugin/commands/hmi/on_ready_notification.h" #include "sdl_rpc_plugin/commands/hmi/on_received_policy_update.h" #include "sdl_rpc_plugin/commands/hmi/on_record_start_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_reset_timeout_notification.h" #include "sdl_rpc_plugin/commands/hmi/on_sdl_close_notification.h" #include "sdl_rpc_plugin/commands/hmi/on_sdl_persistence_complete_notification.h" #include "sdl_rpc_plugin/commands/hmi/on_system_context_notification.h" @@ -228,13 +229,11 @@ #include "sdl_rpc_plugin/commands/hmi/on_system_request_notification.h" #include "sdl_rpc_plugin/commands/hmi/on_system_time_ready_notification.h" #include "sdl_rpc_plugin/commands/hmi/on_tts_language_change_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_tts_reset_timeout_notification.h" #include "sdl_rpc_plugin/commands/hmi/on_tts_started_notification.h" #include "sdl_rpc_plugin/commands/hmi/on_tts_stopped_notification.h" #include "sdl_rpc_plugin/commands/hmi/on_ui_command_notification.h" #include "sdl_rpc_plugin/commands/hmi/on_ui_keyboard_input_notification.h" #include "sdl_rpc_plugin/commands/hmi/on_ui_language_change_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_ui_reset_timeout_notification.h" #include "sdl_rpc_plugin/commands/hmi/on_ui_subtle_alert_pressed_notification.h" #include "sdl_rpc_plugin/commands/hmi/on_ui_touch_event_notification.h" #include "sdl_rpc_plugin/commands/hmi/on_ui_update_file_notification.h" @@ -787,8 +786,8 @@ CommandCreator& HMICommandFactory::get_creator_factory( case hmi_apis::FunctionID::UI_OnTouchEvent: { return factory.GetCreator(); } - case hmi_apis::FunctionID::UI_OnResetTimeout: { - return factory.GetCreator(); + case hmi_apis::FunctionID::BasicCommunication_OnResetTimeout: { + return factory.GetCreator(); } case hmi_apis::FunctionID::Navigation_SetVideoConfig: { return hmi_apis::messageType::request == message_type @@ -887,9 +886,6 @@ CommandCreator& HMICommandFactory::get_creator_factory( case hmi_apis::FunctionID::SDL_OnDeviceStateChanged: { return factory.GetCreator(); } - case hmi_apis::FunctionID::TTS_OnResetTimeout: { - return factory.GetCreator(); - } case hmi_apis::FunctionID::BasicCommunication_OnEventChanged: { return factory.GetCreator(); } diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/sdl_rpc_plugin.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/sdl_rpc_plugin.cc index c5bc79f09da..7cdfc73ed07 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/sdl_rpc_plugin.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/sdl_rpc_plugin.cc @@ -61,18 +61,6 @@ bool SDLRPCPlugin::Init(app_mngr::ApplicationManager& app_manager, return true; } -bool SDLRPCPlugin::Init( - application_manager::ApplicationManager& app_manager, - application_manager::rpc_service::RPCService& rpc_service, - application_manager::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler, - resumption::LastState& last_state) { - UNUSED(last_state); - command_factory_.reset(new sdl_rpc_plugin::SDLCommandFactory( - app_manager, rpc_service, hmi_capabilities, policy_handler)); - return true; -} - bool SDLRPCPlugin::IsAbleToProcess( const int32_t function_id, const app_mngr::commands::Command::CommandSource message_source) { diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/dummy_hmi_commands_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/dummy_hmi_commands_test.cc index ba7938d678e..2a0eda2b10a 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/dummy_hmi_commands_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/dummy_hmi_commands_test.cc @@ -113,6 +113,7 @@ #include "hmi/on_ready_notification.h" #include "hmi/on_received_policy_update.h" #include "hmi/on_record_start_notification.h" +#include "hmi/on_reset_timeout_notification.h" #include "hmi/on_resume_audio_source_notification.h" #include "hmi/on_sdl_close_notification.h" #include "hmi/on_sdl_consent_needed_notification.h" @@ -124,13 +125,11 @@ #include "hmi/on_system_info_changed_notification.h" #include "hmi/on_system_request_notification.h" #include "hmi/on_tts_language_change_notification.h" -#include "hmi/on_tts_reset_timeout_notification.h" #include "hmi/on_tts_started_notification.h" #include "hmi/on_tts_stopped_notification.h" #include "hmi/on_ui_command_notification.h" #include "hmi/on_ui_keyboard_input_notification.h" #include "hmi/on_ui_language_change_notification.h" -#include "hmi/on_ui_reset_timeout_notification.h" #include "hmi/on_ui_touch_event_notification.h" #include "hmi/on_update_device_list.h" #include "hmi/on_video_data_streaming_notification.h" @@ -261,14 +260,10 @@ class HMICommandsTest : public components::commands_test::CommandRequestTest< typedef Command CommandType; void InitCommand(const uint32_t& timeout) OVERRIDE { + CommandRequestTest::InitCommand(timeout); + stream_retry_.first = 0; stream_retry_.second = 0; - EXPECT_CALL(app_mngr_settings_, default_timeout()) - .WillOnce(ReturnRef(timeout)); - ON_CALL(app_mngr_, event_dispatcher()) - .WillByDefault(ReturnRef(event_dispatcher_)); - ON_CALL(app_mngr_, get_settings()) - .WillByDefault(ReturnRef(app_mngr_settings_)); ON_CALL(app_mngr_settings_, start_stream_retry_amount()) .WillByDefault(ReturnRef(stream_retry_)); } @@ -456,7 +451,6 @@ typedef Types::InitCommand(default_timeout); + app_ = ConfigureApp(&app_ptr_, kAppId_, NOT_MEDIA, NOT_NAVI, NOT_VC); - EXPECT_CALL(app_mngr_, get_settings()) - .WillOnce(ReturnRef(app_mngr_settings_)); - EXPECT_CALL(app_mngr_settings_, default_timeout()) - .WillOnce(ReturnRef(default_timeout)); - ON_CALL(app_mngr_, event_dispatcher()) - .WillByDefault(ReturnRef(mock_event_dispatcher_)); ON_CALL(app_mngr_, application_by_hmi_app(_)).WillByDefault(Return(app_)); ON_CALL(*app_ptr_, app_id()).WillByDefault(Return(kAppId_)); ON_CALL(app_mngr_, application(kConnectionKey)).WillByDefault(Return(app_)); @@ -360,12 +355,10 @@ typedef Types< hmi_apis::FunctionID::BasicCommunication_OnAppDeactivated>, CommandPair, - CommandPair, + CommandPair, CommandPair, CommandPair, - CommandPair, CommandPair, CommandPair > HMIOnNotificationsEventDispatcherTypes; @@ -515,7 +508,8 @@ TEST_F(HMICommandsNotificationsTest, std::shared_ptr command = CreateCommand(message); EXPECT_CALL(mock_rpc_service_, SendMessageToHMI(_)); - EXPECT_CALL(app_mngr_, event_dispatcher()); + EXPECT_CALL(app_mngr_, event_dispatcher()) + .WillOnce(ReturnRef(mock_event_dispatcher_)); EXPECT_CALL(mock_event_dispatcher_, raise_event(_)) .WillOnce(GetEventId(&event_id)); command->Run(); @@ -537,7 +531,8 @@ TEST_F(HMICommandsNotificationsTest, std::shared_ptr command = CreateCommand(message); EXPECT_CALL(mock_rpc_service_, SendMessageToHMI(_)); - EXPECT_CALL(app_mngr_, event_dispatcher()); + EXPECT_CALL(app_mngr_, event_dispatcher()) + .WillOnce(ReturnRef(mock_event_dispatcher_)); EXPECT_CALL(mock_event_dispatcher_, raise_event(_)) .WillOnce(GetEventId(&event_id)); command->Run(); @@ -559,7 +554,8 @@ TEST_F(HMICommandsNotificationsTest, OnButtonPressNotificationEventDispatcher) { CreateCommand(message); EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, Command::CommandSource::SOURCE_SDL)); - EXPECT_CALL(app_mngr_, event_dispatcher()); + EXPECT_CALL(app_mngr_, event_dispatcher()) + .WillOnce(ReturnRef(mock_event_dispatcher_)); EXPECT_CALL(mock_event_dispatcher_, raise_event(_)) .WillOnce(GetEventId(&event_id)); command->Run(); @@ -576,7 +572,8 @@ TEST_F(HMICommandsNotificationsTest, OnReadyNotificationEventDispatcher) { CreateCommand(message); EXPECT_CALL(app_mngr_, OnHMIReady()); - EXPECT_CALL(app_mngr_, event_dispatcher()); + EXPECT_CALL(app_mngr_, event_dispatcher()) + .WillOnce(ReturnRef(mock_event_dispatcher_)); EXPECT_CALL(mock_event_dispatcher_, raise_event(_)) .WillOnce(GetEventId(&event_id)); command->Run(); @@ -1296,11 +1293,10 @@ TEST_F(HMICommandsNotificationsTest, EXPECT_CALL(app_mngr_, application(_)).WillOnce(Return(app_)); EXPECT_CALL(app_mngr_settings_, max_cmd_id()).WillOnce(ReturnRef(kMaxCmdId)); - EXPECT_CALL(app_mngr_, get_settings()) - .WillOnce(ReturnRef(app_mngr_settings_)); EXPECT_CALL(*app_ptr_, is_perform_interaction_active()) .WillOnce(Return(kIsPerformInteractionActive)); - EXPECT_CALL(app_mngr_, event_dispatcher()); + EXPECT_CALL(app_mngr_, event_dispatcher()) + .WillOnce(ReturnRef(mock_event_dispatcher_)); EXPECT_CALL(mock_event_dispatcher_, raise_event(_)) .WillOnce(GetEventId(&event_id)); EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)).Times(0); diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/sdl_activate_app_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/sdl_activate_app_request_test.cc index 31285f5b177..a2dc705f60c 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/sdl_activate_app_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/sdl_activate_app_request_test.cc @@ -113,8 +113,9 @@ class SDLActivateAppRequestTest } void InitCommand(const uint32_t& timeout) OVERRIDE { - MockAppPtr mock_app = CreateMockApp(); CommandRequestTest::InitCommand(timeout); + + MockAppPtr mock_app = CreateMockApp(); ON_CALL((*mock_app), app_id()).WillByDefault(Return(kAppID)); ON_CALL(app_mngr_, application_by_hmi_app(kAppID)) .WillByDefault(Return(mock_app)); @@ -486,7 +487,7 @@ TEST_F(SDLActivateAppRequestTest, WaitingCloudApplication_ConnectDevice) { EXPECT_CALL(app_mngr_, get_settings()).WillOnce(ReturnRef(settings)); EXPECT_CALL(app_mngr_, - updateRequestTimeout(0, kCorrelationID, Gt(kMinimumTimeout))); + UpdateRequestTimeout(0, kCorrelationID, Gt(kMinimumTimeout))); MockConnectionHandler connection_handler; EXPECT_CALL(connection_handler, ConnectToDevice(kHandle)); diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/ui_get_capabilities_response_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/ui_get_capabilities_response_test.cc index a1661dc247c..37531b469ab 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/ui_get_capabilities_response_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/ui_get_capabilities_response_test.cc @@ -356,25 +356,6 @@ TEST_F(UIGetCapabilitiesResponseTest, SetVideoStreamingCapability_SUCCESS) { command->Run(); } -TEST_F(UIGetCapabilitiesResponseTest, SetSystemDisplayCapabilities_SUCCESS) { - MessageSharedPtr command_msg = CreateCommandMsg(); - (*command_msg)[strings::msg_params][strings::system_capabilities] = - smart_objects::SmartObject(smart_objects::SmartType_Map); - - ResponseFromHMIPtr command( - CreateCommand(command_msg)); - - const auto& display_capability_so = - (*command_msg)[strings::msg_params][strings::system_capabilities] - [strings::display_capabilities]; - - EXPECT_CALL(mock_hmi_capabilities_, - set_system_display_capabilities(display_capability_so)); - - ASSERT_TRUE(command->Init()); - command->Run(); -} - TEST_F(UIGetCapabilitiesResponseTest, SaveCachedCapabilitiesToFileCall_SUCCESS) { MessageSharedPtr command_msg = CreateCommandMsg(); diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/alert_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/alert_request_test.cc index 5e1f3e47821..9130fa52a0c 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/alert_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/alert_request_test.cc @@ -403,27 +403,6 @@ TEST_F(AlertRequestTest, OnEvent_InvalidEventId_UNSUCCESS) { command->on_event(event); } -TEST_F(AlertRequestTest, DISABLED_OnEvent_UI_OnResetTimeout_SUCCESS) { - PreConditions(); - Expectations(); - AddAlertTextsToMsg(); - - (*msg_)[am::strings::msg_params][am::strings::duration] = kDefaultTimeout; - - CommandPtr command(CreateCommand(msg_)); - EXPECT_TRUE(command->Init()); - - EXPECT_CALL( - app_mngr_, - updateRequestTimeout(kConnectionKey, kCorrelationId, kDefaultTimeout)); - - ExpectManageMobileCommandWithResultCode(mobile_apis::Result::INVALID_ENUM); - - Event event(hmi_apis::FunctionID::UI_OnResetTimeout); - event.set_smart_object(*msg_); - command->on_event(event); -} - TEST_F(AlertRequestTest, OnEvent_UIAlertHasHmiResponsesToWait_UNSUCCESS) { Expectations(); AddAlertTextsToMsg(); diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/create_interaction_choice_set_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/create_interaction_choice_set_test.cc index 80abfec61d8..d77e0588f8e 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/create_interaction_choice_set_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/create_interaction_choice_set_test.cc @@ -619,7 +619,7 @@ TEST_F(CreateInteractionChoiceSetRequestTest, OnEvent_ValidVrNoError_SUCCESS) { command_->Run(); - EXPECT_CALL(app_mngr_, updateRequestTimeout(_, _, _)); + EXPECT_CALL(app_mngr_, UpdateRequestTimeout(_, _, _)); EXPECT_CALL(app_mngr_, TerminateRequest(_, _, _)).Times(0); event.set_smart_object(*message_); @@ -655,7 +655,7 @@ TEST_F(CreateInteractionChoiceSetRequestTest, .WillByDefault(Return(kCorrelationId)); command_->Run(); - EXPECT_CALL(app_mngr_, updateRequestTimeout(_, _, _)); + EXPECT_CALL(app_mngr_, UpdateRequestTimeout(_, _, _)); EXPECT_CALL(app_mngr_, TerminateRequest(_, _, _)).Times(0); event.set_smart_object(*message_); @@ -696,7 +696,7 @@ TEST_F(CreateInteractionChoiceSetRequestTest, FillMessageFieldsItem2(message_); - EXPECT_CALL(app_mngr_, updateRequestTimeout(_, _, _)).Times(0); + EXPECT_CALL(app_mngr_, UpdateRequestTimeout(_, _, _)).Times(0); EXPECT_CALL(app_mngr_, TerminateRequest(_, _, _)); event.set_smart_object(*message_); command_->on_event(event); @@ -751,7 +751,7 @@ TEST_F(CreateInteractionChoiceSetRequestTest, command_->Run(); FillMessageFieldsItem2(message_); - EXPECT_CALL(app_mngr_, updateRequestTimeout(_, _, _)).Times(0); + EXPECT_CALL(app_mngr_, UpdateRequestTimeout(_, _, _)).Times(0); EXPECT_CALL(app_mngr_, TerminateRequest(_, _, _)); Event event(hmi_apis::FunctionID::VR_AddCommand); event.set_smart_object(*message_); @@ -801,7 +801,7 @@ TEST_F(CreateInteractionChoiceSetRequestTest, OnTimeOut_InvalidApp_UNSUCCESS) { command_->Run(); FillMessageFieldsItem2(message_); - EXPECT_CALL(app_mngr_, updateRequestTimeout(_, _, _)).Times(0); + EXPECT_CALL(app_mngr_, UpdateRequestTimeout(_, _, _)).Times(0); EXPECT_CALL(app_mngr_, TerminateRequest(_, _, _)).Times(2); Event event(hmi_apis::FunctionID::VR_AddCommand); event.set_smart_object(*message_); @@ -854,7 +854,7 @@ TEST_F(CreateInteractionChoiceSetRequestTest, FillMessageFieldsItem2(message_); - EXPECT_CALL(app_mngr_, updateRequestTimeout(_, _, _)).Times(0); + EXPECT_CALL(app_mngr_, UpdateRequestTimeout(_, _, _)).Times(0); resumption_test::MockResumeCtrl mock_resume_ctrl; EXPECT_CALL(app_mngr_, resume_controller()) .WillOnce(ReturnRef(mock_resume_ctrl)); @@ -935,7 +935,7 @@ TEST_F(CreateInteractionChoiceSetRequestTest, Run_ErrorFromHmiFalse_UNSUCCESS) { ManageMobileCommand( MobileResultCodeIs(mobile_apis::Result::GENERIC_ERROR), am::commands::Command::SOURCE_SDL)); - EXPECT_CALL(app_mngr_, updateRequestTimeout(_, _, _)).Times(0); + EXPECT_CALL(app_mngr_, UpdateRequestTimeout(_, _, _)).Times(0); EXPECT_CALL(app_mngr_, TerminateRequest(_, _, _)); event.set_smart_object(*message_); command_->on_event(event); diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/delete_sub_menu_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/delete_sub_menu_test.cc index f5856a8eda4..975cba89a1e 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/delete_sub_menu_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/delete_sub_menu_test.cc @@ -67,6 +67,7 @@ using sdl_rpc_plugin::commands::DeleteSubMenuResponse; typedef std::shared_ptr DeleteSubMenuRequestPtr; typedef std::shared_ptr DeleteSubMenuResponsePtr; +typedef std::shared_ptr EventPtr; MATCHER_P(CheckMessageResultCode, result_code, "") { return (*arg)[am::strings::msg_params][am::strings::result_code].asInt() == @@ -89,8 +90,9 @@ namespace { const uint32_t kConnectionKey = 2u; const uint32_t kCorrelationId = 10u; const uint32_t kMenuId = 100u; +const uint32_t kMenuIdChild = 101u; const uint32_t kGrammarId = 101u; -const int32_t kCmdId = 102; +const int32_t kCmdId = 102u; } // namespace class DeleteSubMenuRequestTest @@ -107,6 +109,224 @@ class DeleteSubMenuRequestTest std::make_shared()) , app_(CreateMockApp()) {} + /** + * @brief Generates submenu smart object with specified params + * @param menu_id id of the menu + * @param parent_id id of parent menu + * @return generated smart object + */ + smart_objects::SmartObjectSPtr GenerateSubMenuMap(const uint32_t menu_id, + const uint32_t parent_id) { + smart_objects::SmartObjectSPtr smartObjectPtr = + std::make_shared(); + + smart_objects::SmartObject& object = *smartObjectPtr; + + object[am::strings::position] = 1; + object[am::strings::menu_name] = "SubMenu " + std::to_string(menu_id); + object[am::strings::menu_id] = menu_id; + object[am::strings::parent_id] = parent_id; + + return smartObjectPtr; + } + + /** + * @brief Generates UI & VR commands smart object with specified params + * @param cmd_id id of the command + * @param parent_id id of parent command + * @return generated smart object + */ + smart_objects::SmartObjectSPtr GenerateUiVrCommandMapChild( + const uint32_t cmd_id, const uint32_t parent_id) { + smart_objects::SmartObjectSPtr smartObjectPtr = + std::make_shared(); + + smart_objects::SmartObject& object = *smartObjectPtr; + + object[am::strings::cmd_id] = cmd_id; + object[am::strings::grammar_id] = kGrammarId; + object[am::strings::vr_commands] = "VR commands"; + object[am::strings::type] = hmi_apis::Common_VRCommandType::Command; + object[am::strings::menu_params][am::hmi_request::parent_id] = parent_id; + + return smartObjectPtr; + } + + /** + * @brief Sets up expectations for a successful execution of submenu request + * @param next_function_id function id of the next request + */ + void SetUpSubMenuRequestExpectations( + const hmi_apis::FunctionID::eType next_function_id) { + (*message_)[am::strings::msg_params][am::strings::menu_id] = kMenuId; + (*message_)[am::strings::params][am::strings::connection_key] = + kConnectionKey; + (*message_)[am::strings::params][am::strings::function_id] = + next_function_id; + + smart_objects::SmartObject sub_menu = + (*message_)[am::strings::msg_params][am::strings::menu_id]; + EXPECT_CALL(app_mngr_, application(kConnectionKey)).WillOnce(Return(app_)); + EXPECT_CALL(*app_, FindSubMenu(kMenuId)).WillOnce(Return(sub_menu)); + + ON_CALL(*app_, sub_menu_map()).WillByDefault(Return(sub_menu_accessor_)); + ON_CALL(*app_, commands_map()).WillByDefault(Return(accessor_)); + + EXPECT_CALL(*app_, app_id()).WillRepeatedly(Return(kConnectionKey)); + EXPECT_CALL(app_mngr_, GetNextHMICorrelationID()) + .WillOnce(Return(kCorrelationId)); + + EXPECT_CALL(mock_rpc_service_, + ManageHMICommand(HMIResultCodeIs(next_function_id), _)) + .WillOnce(Return(true)); + } + + /** + * @brief Prepares submenu response event with the specified params + * @param correlation_id correlation id + * @param menu_id id of the menu + * @return pointer to prepared event + */ + EventPtr PrepareSubMenuResponseEvent(const uint32_t correlation_id, + const uint32_t menu_id) { + EventPtr menu_event = + std::make_shared(hmi_apis::FunctionID::UI_DeleteSubMenu); + (*message_)[am::strings::params][am::hmi_response::code] = + hmi_apis::Common_Result::SUCCESS; + (*message_)[am::strings::msg_params][am::strings::app_id] = kConnectionKey; + (*message_)[am::strings::params][am::strings::correlation_id] = + correlation_id; + (*message_)[am::strings::msg_params][am::strings::menu_id] = menu_id; + menu_event->set_smart_object(*message_); + + return menu_event; + } + + /** + * @brief Sets up expectations for a successful execution of submenu + * subsequent response + * @param event pointer to event representing the response message + * @param next_function_id function id of the next request + */ + void SetUpSubMenuSubsequentResponseExpectations( + EventPtr event, hmi_apis::FunctionID::eType next_function_id) { + const auto& event_so_ref = event->smart_object(); + const auto correlation_id = event->smart_object_correlation_id(); + const auto menu_id = + event_so_ref[am::strings::msg_params][am::strings::menu_id].asUInt(); + + EXPECT_CALL(app_mngr_, application(kConnectionKey)).WillOnce(Return(app_)); + EXPECT_CALL(*app_, RemoveSubMenu(menu_id)); + + EXPECT_CALL(app_mngr_, GetNextHMICorrelationID()) + .WillOnce(Return(correlation_id + 1)); + EXPECT_CALL(mock_rpc_service_, + ManageHMICommand(HMIResultCodeIs(next_function_id), _)) + .WillOnce(Return(true)); + } + + /** + * @brief Prepares VR command response event with the specified params + * @param correlation_id correlation id + * @return pointer to prepared event + */ + EventPtr PrepareVrCommandResponseEvent(const uint32_t correlation_id) { + EventPtr vr_event = + std::make_shared(hmi_apis::FunctionID::VR_DeleteCommand); + (*message_)[am::strings::msg_params][am::strings::app_id] = kConnectionKey; + (*message_)[am::strings::params][am::hmi_response::code] = + hmi_apis::Common_Result::SUCCESS; + (*message_)[am::strings::params][am::strings::correlation_id] = + correlation_id; + vr_event->set_smart_object(*message_); + + return vr_event; + } + + /** + * @brief Sets up expectations for a successful execution of VR command + * subsequent response + * @param event pointer to event representing the response message + * @param next_function_id function id of the next request + */ + void SetUpVrCommandSubsequentResponseExpectations( + EventPtr event, hmi_apis::FunctionID::eType next_function_id) { + const auto correlation_id = event->smart_object_correlation_id(); + + EXPECT_CALL(app_mngr_, application(kConnectionKey)).WillOnce(Return(app_)); + EXPECT_CALL(app_mngr_, GetNextHMICorrelationID()) + .WillOnce(Return(correlation_id + 1)); + EXPECT_CALL(mock_rpc_service_, + ManageHMICommand(HMIResultCodeIs(next_function_id), _)) + .WillOnce(Return(true)); + } + + /** + * @brief Prepares UI command response event with the specified params + * @param correlation_id correlation id + * @param cmd_id id of the command + * @return pointer to prepared event + */ + EventPtr PrepareUiCommandResponseEvent(const uint32_t correlation_id, + const uint32_t cmd_id) { + EventPtr ui_event = + std::make_shared(hmi_apis::FunctionID::UI_DeleteCommand); + (*message_)[am::strings::params][am::strings::correlation_id] = + correlation_id; + (*message_)[am::strings::params][am::hmi_response::code] = + hmi_apis::Common_Result::SUCCESS; + (*message_)[am::strings::msg_params][am::strings::app_id] = kConnectionKey; + (*message_)[am::strings::msg_params][am::strings::cmd_id] = cmd_id; + ui_event->set_smart_object(*message_); + + return ui_event; + } + + /** + * @brief Sets up expectations for a successful execution of UI command + * subsequent response + * @param event pointer to event representing the response message + * @param next_function_id function id of the next request + */ + void SetUpUiCommandSubsequentResponseExpectations( + EventPtr event, hmi_apis::FunctionID::eType next_function_id) { + const auto correlation_id = event->smart_object_correlation_id(); + const auto& event_so_ref = event->smart_object(); + const auto cmd_id = + event_so_ref[am::strings::msg_params][am::strings::cmd_id].asUInt(); + + EXPECT_CALL(app_mngr_, application(kConnectionKey)).WillOnce(Return(app_)); + EXPECT_CALL(*app_, RemoveCommand(cmd_id)) + .WillOnce(DeleteCommand(&commands_map_)); + EXPECT_CALL(*app_, help_prompt_manager()) + .WillOnce(ReturnRef(*mock_help_prompt_manager_)); + EXPECT_CALL(*mock_help_prompt_manager_, OnVrCommandDeleted(cmd_id, false)); + + EXPECT_CALL(app_mngr_, GetNextHMICorrelationID()) + .WillOnce(Return(correlation_id + 1)); + EXPECT_CALL(mock_rpc_service_, + ManageHMICommand(HMIResultCodeIs(next_function_id), _)) + .WillOnce(Return(true)); + } + + /** + * @brief Sets up expectations for a successful execution of submenu final + * response + * @param event pointer to event representing the response message + */ + void SetUpSubMenuFinalResponseExpectations(EventPtr event) { + const auto& event_so_ref = event->smart_object(); + const auto menu_id = + event_so_ref[am::strings::msg_params][am::strings::menu_id].asUInt(); + + EXPECT_CALL(app_mngr_, application(kConnectionKey)).WillOnce(Return(app_)); + EXPECT_CALL(*app_, RemoveSubMenu(menu_id)); + EXPECT_CALL( + mock_rpc_service_, + ManageMobileCommand(MobileResultCodeIs(mobile_apis::Result::SUCCESS), + am::commands::Command::SOURCE_SDL)); + } + am::CommandsMap commands_map_; am::SubMenuMap sub_menu_map_; mutable std::shared_ptr commands_lock_; @@ -215,175 +435,187 @@ TEST_F(DeleteSubMenuRequestTest, Run_FindSubMenuFalse_UNSUCCESS) { command_->Run(); } -TEST_F(DeleteSubMenuRequestTest, Run_SendHMIRequest_SUCCESS) { - (*message_)[am::strings::msg_params][am::strings::menu_id] = kMenuId; - (*message_)[am::strings::params][am::strings::connection_key] = - kConnectionKey; - - smart_objects::SmartObject sub_menu = - (*message_)[am::strings::msg_params][am::strings::menu_id]; - EXPECT_CALL(app_mngr_, application(kConnectionKey)).WillOnce(Return(app_)); - EXPECT_CALL(*app_, FindSubMenu(kMenuId)).WillOnce(Return(sub_menu)); - - EXPECT_CALL(*app_, app_id()).WillOnce(Return(kConnectionKey)); - EXPECT_CALL(app_mngr_, GetNextHMICorrelationID()) - .WillOnce(Return(kCorrelationId)); - - EXPECT_CALL(mock_rpc_service_, - ManageHMICommand( - HMIResultCodeIs(hmi_apis::FunctionID::UI_DeleteSubMenu), _)) - .WillOnce(Return(true)); - command_->Run(); -} - TEST_F(DeleteSubMenuRequestTest, OnEvent_UnknownEventId_UNSUCCESS) { Event event(hmi_apis::FunctionID::INVALID_ENUM); - EXPECT_CALL(app_mngr_, application(_)).Times(0); + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand(_, am::commands::Command::SOURCE_SDL)) + .Times(0); command_->on_event(event); } TEST_F(DeleteSubMenuRequestTest, OnEvent_InvalidApp_UNSUCCESS) { - Event event(hmi_apis::FunctionID::UI_DeleteSubMenu); - (*message_)[am::strings::params][am::hmi_response::code] = - hmi_apis::Common_Result::eType::SUCCESS; - event.set_smart_object(*message_); + auto sub_menu_ptr = GenerateSubMenuMap(kMenuId, 0); + sub_menu_map_.insert(std::pair( + kMenuId, sub_menu_ptr.get())); + + SetUpSubMenuRequestExpectations(hmi_apis::FunctionID::UI_DeleteSubMenu); + command_->Run(); + MockAppPtr invalid_app; + EventPtr event = PrepareSubMenuResponseEvent(kCorrelationId, kMenuId); + EXPECT_CALL(app_mngr_, application(_)).WillOnce(Return(invalid_app)); EXPECT_CALL(*app_, RemoveSubMenu(_)).Times(0); - command_->on_event(event); + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand(_, am::commands::Command::SOURCE_SDL)) + .Times(0); + + command_->on_event(*event); } -TEST_F(DeleteSubMenuRequestTest, OnEvent_DeleteSubmenu_SUCCESS) { - Event event(hmi_apis::FunctionID::UI_DeleteSubMenu); - (*message_)[am::strings::msg_params][am::strings::menu_id] = kMenuId; - (*message_)[am::strings::params][am::strings::connection_key] = - kConnectionKey; - (*message_)[am::strings::msg_params][am::strings::vr_commands] = - "vr_commands"; - (*message_)[am::strings::msg_params][am::strings::cmd_id] = kCmdId; - (*message_)[am::strings::msg_params][am::strings::menu_params] - [am::hmi_request::parent_id] = kMenuId; - const hmi_apis::Common_Result::eType result_code = - hmi_apis::Common_Result::SUCCESS; - (*message_)[am::strings::params][am::hmi_response::code] = result_code; - event.set_smart_object(*message_); +TEST_F(DeleteSubMenuRequestTest, OnEvent_DeleteSubmenuOnly_SUCCESS) { + auto sub_menu_ptr = GenerateSubMenuMap(kMenuId, 0); + sub_menu_map_.insert(std::pair( + kMenuId, sub_menu_ptr.get())); - commands_map_.insert( - std::make_pair(0, &((*message_)[am::strings::msg_params]))); + SetUpSubMenuRequestExpectations(hmi_apis::FunctionID::UI_DeleteSubMenu); + command_->Run(); - smart_objects::SmartObjectSPtr smartObjectPtr = - std::make_shared(); + EventPtr event = PrepareSubMenuResponseEvent(kCorrelationId, kMenuId); + SetUpSubMenuFinalResponseExpectations(event); + command_->on_event(*event); +} - smart_objects::SmartObject& object = *smartObjectPtr; +TEST_F(DeleteSubMenuRequestTest, OnEvent_DeleteSubmenuWithChildMenu_SUCCESS) { + auto sub_menu_ptr = GenerateSubMenuMap(kMenuId, 0); + sub_menu_map_.insert(std::pair( + kMenuId, sub_menu_ptr.get())); - object[am::strings::position] = 1; - object[am::strings::menu_name] = "SubMenu"; + auto sub_menu_child_ptr = GenerateSubMenuMap(kMenuIdChild, kMenuId); + sub_menu_map_.insert(std::pair( + kMenuIdChild, sub_menu_child_ptr.get())); - sub_menu_map_.insert( - std::pair(5, &object)); - EXPECT_CALL(*app_, sub_menu_map()).WillRepeatedly(Return(sub_menu_accessor_)); - EXPECT_CALL(app_mngr_, application(_)).WillRepeatedly(Return(app_)); + SetUpSubMenuRequestExpectations(hmi_apis::FunctionID::UI_DeleteSubMenu); + command_->Run(); - InSequence seq; - EXPECT_CALL(*app_, commands_map()).WillOnce(Return(accessor_)); - EXPECT_CALL(*app_, app_id()).WillOnce(Return(kConnectionKey)); - EXPECT_CALL(*app_, get_grammar_id()).WillOnce(Return(kGrammarId)); + EventPtr event = PrepareSubMenuResponseEvent(kCorrelationId, kMenuIdChild); + SetUpSubMenuSubsequentResponseExpectations( + event, hmi_apis::FunctionID::UI_DeleteSubMenu); + command_->on_event(*event); - EXPECT_CALL(mock_rpc_service_, - ManageHMICommand( - HMIResultCodeIs(hmi_apis::FunctionID::VR_DeleteCommand), _)) - .WillOnce(Return(true)); - - EXPECT_CALL(*app_, commands_map()).WillOnce(Return(accessor_)); - EXPECT_CALL(*app_, app_id()).WillOnce(Return(kConnectionKey)); - EXPECT_CALL(*app_, RemoveCommand(_)).WillOnce(DeleteCommand(&commands_map_)); - EXPECT_CALL(*app_, help_prompt_manager()) - .WillOnce(ReturnRef(*mock_help_prompt_manager_)); - EXPECT_CALL(*mock_help_prompt_manager_, OnVrCommandDeleted(kCmdId, false)); - EXPECT_CALL(mock_rpc_service_, - ManageHMICommand( - HMIResultCodeIs(hmi_apis::FunctionID::UI_DeleteCommand), _)) - .WillOnce(Return(true)); + EventPtr event_final = + PrepareSubMenuResponseEvent(kCorrelationId + 1, kMenuId); + SetUpSubMenuFinalResponseExpectations(event_final); + command_->on_event(*event_final); +} - EXPECT_CALL(*app_, RemoveSubMenu(_)); - EXPECT_CALL( - mock_rpc_service_, - ManageMobileCommand(MobileResultCodeIs(mobile_apis::Result::SUCCESS), - am::commands::Command::SOURCE_SDL)); - EXPECT_CALL(*app_, UpdateHash()); +TEST_F(DeleteSubMenuRequestTest, OnEvent_DeleteSubmenuWithVrAndUi_SUCCESS) { + auto sub_menu_ptr = GenerateSubMenuMap(kMenuId, 0); + sub_menu_map_.insert(std::pair( + kMenuId, sub_menu_ptr.get())); - DeleteSubMenuRequestPtr command = - CreateCommand(message_); + auto command_ptr = GenerateUiVrCommandMapChild(kCmdId, kMenuId); + commands_map_.insert(std::pair( + kCmdId, command_ptr.get())); - command->Init(); - command->on_event(event); -} + SetUpSubMenuRequestExpectations(hmi_apis::FunctionID::VR_DeleteCommand); + command_->Run(); -TEST_F(DeleteSubMenuResponseTest, Run_SUCCESS) { - MessageSharedPtr message(CreateMessage()); - (*message)[am::strings::msg_params][am::strings::connection_key] = - kConnectionKey; - DeleteSubMenuResponsePtr command( - CreateCommand(message)); + EventPtr event_vr = PrepareVrCommandResponseEvent(kCorrelationId); + SetUpVrCommandSubsequentResponseExpectations( + event_vr, hmi_apis::FunctionID::UI_DeleteCommand); + command_->on_event(*event_vr); - EXPECT_CALL( - mock_rpc_service_, - SendMessageToMobile(CheckMessageConnectionKey(kConnectionKey), _)); - command->Run(); + EventPtr event_ui = PrepareUiCommandResponseEvent(kCorrelationId + 1, kCmdId); + SetUpUiCommandSubsequentResponseExpectations( + event_ui, hmi_apis::FunctionID::UI_DeleteSubMenu); + command_->on_event(*event_ui); + + EventPtr event_final = + PrepareSubMenuResponseEvent(kCorrelationId + 2, kMenuId); + SetUpSubMenuFinalResponseExpectations(event_final); + command_->on_event(*event_final); } TEST_F(DeleteSubMenuRequestTest, - DeleteSubmenu_CommandhaventVrCommadsAndMenuParams_DontSendHMIRequest) { - Event event(hmi_apis::FunctionID::UI_DeleteSubMenu); - (*message_)[am::strings::msg_params][am::strings::menu_id] = kMenuId; - (*message_)[am::strings::params][am::strings::connection_key] = - kConnectionKey; - (*message_)[am::strings::params][am::hmi_response::code] = - am::mobile_api::Result::SUCCESS; - event.set_smart_object(*message_); + OnEvent_DeleteSubmenuWithChildVrAndUi_SUCCESS) { + auto sub_menu_ptr = GenerateSubMenuMap(kMenuId, 0); + sub_menu_map_.insert(std::pair( + kMenuId, sub_menu_ptr.get())); - commands_map_.insert( - std::make_pair(0, &((*message_)[am::strings::msg_params]))); + auto sub_menu_child_ptr = GenerateSubMenuMap(kMenuIdChild, kMenuId); + sub_menu_map_.insert(std::pair( + kMenuIdChild, sub_menu_child_ptr.get())); - EXPECT_CALL(app_mngr_, application(_)).WillRepeatedly(Return(app_)); - EXPECT_CALL(*app_, sub_menu_map()).WillRepeatedly(Return(sub_menu_accessor_)); - EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_, _)).Times(0); - EXPECT_CALL(*app_, commands_map()).Times(2).WillRepeatedly(Return(accessor_)); - EXPECT_CALL(*app_, RemoveCommand(_)).Times(0); + auto command_ptr = GenerateUiVrCommandMapChild(kCmdId, kMenuIdChild); + commands_map_.insert(std::pair( + kCmdId, command_ptr.get())); - EXPECT_CALL( - mock_rpc_service_, - ManageMobileCommand(MobileResultCodeIs(mobile_apis::Result::SUCCESS), - am::commands::Command::SOURCE_SDL)); - command_->on_event(event); + SetUpSubMenuRequestExpectations(hmi_apis::FunctionID::VR_DeleteCommand); + command_->Run(); + + EventPtr event_vr = PrepareVrCommandResponseEvent(kCorrelationId); + SetUpVrCommandSubsequentResponseExpectations( + event_vr, hmi_apis::FunctionID::UI_DeleteCommand); + command_->on_event(*event_vr); + + EventPtr event_ui = PrepareUiCommandResponseEvent(kCorrelationId + 1, kCmdId); + SetUpUiCommandSubsequentResponseExpectations( + event_ui, hmi_apis::FunctionID::UI_DeleteSubMenu); + command_->on_event(*event_ui); + + EventPtr event_submenu = + PrepareSubMenuResponseEvent(kCorrelationId + 2, kMenuIdChild); + SetUpSubMenuSubsequentResponseExpectations( + event_submenu, hmi_apis::FunctionID::UI_DeleteSubMenu); + command_->on_event(*event_submenu); + + EventPtr event_final = + PrepareSubMenuResponseEvent(kCorrelationId + 3, kMenuId); + SetUpSubMenuFinalResponseExpectations(event_final); + command_->on_event(*event_final); } TEST_F(DeleteSubMenuRequestTest, - DeleteSubmenu_NotAChildOfMenupartam_DontSendHMIRequest) { - Event event(hmi_apis::FunctionID::UI_DeleteSubMenu); - (*message_)[am::strings::msg_params][am::strings::menu_id] = kMenuId; - (*message_)[am::strings::msg_params][am::strings::menu_params] - [am::hmi_request::parent_id] = kMenuId + 1; - (*message_)[am::strings::params][am::strings::connection_key] = - kConnectionKey; - (*message_)[am::strings::params][am::hmi_response::code] = - am::mobile_api::Result::SUCCESS; - event.set_smart_object(*message_); + OnEvent_DeleteSubmenuVrAndUiWithChild_SUCCESS) { + auto sub_menu_ptr = GenerateSubMenuMap(kMenuId, 0); + sub_menu_map_.insert(std::pair( + kMenuId, sub_menu_ptr.get())); - commands_map_.insert( - std::make_pair(0, &((*message_)[am::strings::msg_params]))); + auto command_ptr = GenerateUiVrCommandMapChild(kCmdId, kMenuId); + commands_map_.insert(std::pair( + kCmdId, command_ptr.get())); - EXPECT_CALL(app_mngr_, application(_)).WillRepeatedly(Return(app_)); - EXPECT_CALL(*app_, sub_menu_map()).WillRepeatedly(Return(sub_menu_accessor_)); - EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_, _)).Times(0); - EXPECT_CALL(*app_, commands_map()).Times(2).WillRepeatedly(Return(accessor_)); - EXPECT_CALL(*app_, RemoveCommand(_)).Times(0); + auto sub_menu_child_ptr = GenerateSubMenuMap(kMenuIdChild, kMenuId); + sub_menu_map_.insert(std::pair( + kMenuIdChild, sub_menu_child_ptr.get())); + + SetUpSubMenuRequestExpectations(hmi_apis::FunctionID::UI_DeleteSubMenu); + command_->Run(); + + EventPtr event_submenu = + PrepareSubMenuResponseEvent(kCorrelationId, kMenuIdChild); + SetUpSubMenuSubsequentResponseExpectations( + event_submenu, hmi_apis::FunctionID::VR_DeleteCommand); + command_->on_event(*event_submenu); + + EventPtr event_vr = PrepareVrCommandResponseEvent(kCorrelationId + 1); + SetUpVrCommandSubsequentResponseExpectations( + event_vr, hmi_apis::FunctionID::UI_DeleteCommand); + command_->on_event(*event_vr); + + EventPtr event_ui = PrepareUiCommandResponseEvent(kCorrelationId + 2, kCmdId); + SetUpUiCommandSubsequentResponseExpectations( + event_ui, hmi_apis::FunctionID::UI_DeleteSubMenu); + command_->on_event(*event_ui); + + EventPtr event_final = + PrepareSubMenuResponseEvent(kCorrelationId + 3, kMenuId); + SetUpSubMenuFinalResponseExpectations(event_final); + command_->on_event(*event_final); +} + +TEST_F(DeleteSubMenuResponseTest, Run_SUCCESS) { + MessageSharedPtr message(CreateMessage()); + (*message)[am::strings::msg_params][am::strings::connection_key] = + kConnectionKey; + DeleteSubMenuResponsePtr command( + CreateCommand(message)); EXPECT_CALL( mock_rpc_service_, - ManageMobileCommand(MobileResultCodeIs(mobile_apis::Result::SUCCESS), - am::commands::Command::SOURCE_SDL)); - command_->on_event(event); + SendMessageToMobile(CheckMessageConnectionKey(kConnectionKey), _)); + command->Run(); } } // namespace delete_sub_menu_request diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/dummy_mobile_commands_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/dummy_mobile_commands_test.cc index 8f83a2dd10e..201118eec09 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/dummy_mobile_commands_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/dummy_mobile_commands_test.cc @@ -165,12 +165,8 @@ class MobileCommandsTest : public components::commands_test::CommandRequestTest< typedef Command CommandType; void InitCommand(const uint32_t& timeout) OVERRIDE { - EXPECT_CALL(app_mngr_settings_, default_timeout()) - .WillOnce(ReturnRef(timeout)); - ON_CALL(app_mngr_, event_dispatcher()) - .WillByDefault(ReturnRef(event_dispatcher_)); - ON_CALL(app_mngr_, get_settings()) - .WillByDefault(ReturnRef(app_mngr_settings_)); + CommandRequestTest::InitCommand(timeout); + ON_CALL(app_mngr_settings_, app_icons_folder()) .WillByDefault(ReturnRef(kEmptyString_)); } diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/get_way_points_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/get_way_points_request_test.cc index 7f7a8b55bdf..fd2bc2e51a5 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/get_way_points_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/get_way_points_request_test.cc @@ -202,7 +202,7 @@ TEST_F(GetWayPointsRequestTest, OnEvent_DefaultCase) { event.set_smart_object(*message_); - EXPECT_CALL(app_mngr_, updateRequestTimeout(_, _, _)).Times(0); + EXPECT_CALL(app_mngr_, UpdateRequestTimeout(_, _, _)).Times(0); EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_, _)).Times(0); diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/perform_audio_pass_thru_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/perform_audio_pass_thru_test.cc index 2915418d438..c7627b7e55c 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/perform_audio_pass_thru_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/perform_audio_pass_thru_test.cc @@ -626,7 +626,7 @@ TEST_F(PerformAudioPassThruRequestTest, EXPECT_CALL(app_mngr_, BeginAudioPassThru(app_id)); EXPECT_CALL(app_mngr_, StartAudioPassThruThread(_, _, _, _, _, _)); - EXPECT_CALL(app_mngr_, updateRequestTimeout(_, _, _)); + EXPECT_CALL(app_mngr_, UpdateRequestTimeout(_, _, _)); ON_CALL(mock_hmi_interfaces_, GetInterfaceState(_)) .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE)); @@ -654,7 +654,7 @@ TEST_F(PerformAudioPassThruRequestTest, ON_CALL(mock_hmi_interfaces_, GetInterfaceState(_)) .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE)); // First call on_event for setting result_tts_speak_ to UNSUPPORTED_RESOURCE - EXPECT_CALL(app_mngr_, updateRequestTimeout(_, _, _)); + EXPECT_CALL(app_mngr_, UpdateRequestTimeout(_, _, _)); CallOnEvent caller_speak(*command_sptr_, event_speak); caller_speak(); @@ -691,31 +691,7 @@ TEST_F(PerformAudioPassThruRequestTest, app_mngr_, StartAudioPassThruThread(kConnectionKey, kCorrelationId, _, _, _, _)); - EXPECT_CALL(app_mngr_, updateRequestTimeout(_, _, _)); - ON_CALL(mock_hmi_interfaces_, GetInterfaceState(_)) - .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE)); - CallOnEvent caller(*command_sptr_, event); - caller(); - - EXPECT_EQ(kConnectionKey, msg_params_[am::strings::connection_key].asUInt()); - EXPECT_EQ(kFunctionId, msg_params_[am::strings::function_id].asString()); -} - -TEST_F(PerformAudioPassThruRequestTest, - DISABLED_OnEvent_TTSOnResetTimeout_UpdateTimeout) { - am::event_engine::Event event(hmi_apis::FunctionID::TTS_OnResetTimeout); - - msg_params_[am::strings::connection_key] = kConnectionKey; - msg_params_[am::strings::function_id] = kFunctionId; - - uint32_t app_id = kConnectionKey; - EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_, _)).WillOnce(Return(true)); - EXPECT_CALL(app_mngr_, BeginAudioPassThru(app_id)).WillOnce(Return(true)); - - EXPECT_CALL( - app_mngr_, - StartAudioPassThruThread(kConnectionKey, kCorrelationId, _, _, _, _)); - EXPECT_CALL(app_mngr_, updateRequestTimeout(_, _, _)); + EXPECT_CALL(app_mngr_, UpdateRequestTimeout(_, _, _)); ON_CALL(mock_hmi_interfaces_, GetInterfaceState(_)) .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE)); CallOnEvent caller(*command_sptr_, event); @@ -729,7 +705,7 @@ TEST_F(PerformAudioPassThruRequestTest, OnEvent_DefaultCase) { am::event_engine::Event event(hmi_apis::FunctionID::INVALID_ENUM); uint32_t app_id = kConnectionKey; - EXPECT_CALL(app_mngr_, updateRequestTimeout(_, _, _)).Times(0); + EXPECT_CALL(app_mngr_, UpdateRequestTimeout(_, _, _)).Times(0); EXPECT_CALL(app_mngr_, EndAudioPassThru(app_id)).Times(0); CallOnEvent caller(*command_sptr_, event); diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/register_app_interface_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/register_app_interface_request_test.cc index 29f9b25e8d3..d376c3f021d 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/register_app_interface_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/register_app_interface_request_test.cc @@ -409,6 +409,7 @@ TEST_F(RegisterAppInterfaceRequestTest, DefaultTimeout_CheckIfZero_SUCCESS) { TEST_F(RegisterAppInterfaceRequestTest, Run_MinimalData_SUCCESS) { InitBasicMessage(); (*msg_)[am::strings::msg_params][am::strings::hash_id] = kAppId1; + EXPECT_CALL(app_mngr_, WaitForHmiIsReady()).WillOnce(Return(true)); EXPECT_CALL(app_mngr_, IsApplicationForbidden(_, _)).WillOnce(Return(false)); @@ -460,22 +461,6 @@ TEST_F(RegisterAppInterfaceRequestTest, Run_MinimalData_SUCCESS) { .WillByDefault( Return(application_manager::HmiInterfaces::HMI_INTERFACE_Buttons)); - EXPECT_CALL(mock_hmi_capabilities_, is_ui_cooperating()) - .WillRepeatedly(Return(true)); - - MessageSharedPtr button_caps_ptr(CreateMessage(smart_objects::SmartType_Map)); - (*button_caps_ptr)[0][am::hmi_response::button_name] = - mobile_apis::ButtonName::CUSTOM_BUTTON; - - EXPECT_CALL(mock_hmi_capabilities_, button_capabilities()) - .WillRepeatedly(Return(button_caps_ptr)); - - EXPECT_CALL( - mock_rpc_service_, - ManageHMICommand( - HMIResultCodeIs(hmi_apis::FunctionID::Buttons_SubscribeButton), _)) - .WillOnce(Return(true)); - application_manager::DisplayCapabilitiesBuilder builder(*mock_app); ON_CALL(*mock_app, display_capabilities_builder()) .WillByDefault(ReturnRef(builder)); @@ -515,6 +500,7 @@ TEST_F(RegisterAppInterfaceRequestTest, InitBasicMessage(); ON_CALL(app_mngr_, WaitForHmiIsReady()).WillByDefault(Return(true)); + EXPECT_CALL(app_mngr_, IsApplicationForbidden(_, _)).WillOnce(Return(false)); ON_CALL(mock_connection_handler_, @@ -592,7 +578,6 @@ TEST_F(RegisterAppInterfaceRequestTest, hmi_apis::FunctionID::BasicCommunication_OnAppRegistered), _)) .WillOnce(Return(true)); - EXPECT_CALL( mock_rpc_service_, ManageHMICommand( @@ -811,6 +796,7 @@ TEST_F(RegisterAppInterfaceRequestTest, (*msg_)[am::strings::params][am::strings::connection_key] = kConnectionKey2; ON_CALL(app_mngr_, WaitForHmiIsReady()).WillByDefault(Return(true)); + EXPECT_CALL(app_mngr_, IsApplicationForbidden(kConnectionKey2, kAppId1)) .WillOnce(Return(false)); @@ -851,7 +837,6 @@ TEST_F(RegisterAppInterfaceRequestTest, hmi_apis::FunctionID::BasicCommunication_OnAppRegistered), _)) .WillOnce(Return(true)); - EXPECT_CALL( mock_rpc_service_, ManageHMICommand( diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/reset_global_properties_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/reset_global_properties_test.cc index 8ca15f39fe0..f62f6b4682b 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/reset_global_properties_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/reset_global_properties_test.cc @@ -282,6 +282,42 @@ TEST_F(ResetGlobalPropertiesRequestTest, command_->on_event(event); } +TEST_F(ResetGlobalPropertiesRequestTest, + OnEvent_RC_SetGlobalProperties_SUCCESS) { + am::ResetGlobalPropertiesResult result; + result.user_location = true; + + EXPECT_CALL(app_mngr_, ResetGlobalProperties(_, _)).WillOnce(Return(result)); + + smart_objects::SmartObjectSPtr msg_params = + std::make_shared( + smart_objects::SmartType_Map); + + EXPECT_CALL(mock_message_helper_, CreateRCResetGlobalPropertiesRequest(_, _)) + .WillOnce(Return(msg_params)); + + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand( + HMIResultCodeIs(hmi_apis::FunctionID::RC_SetGlobalProperties), _)) + .WillOnce(Return(true)); + + command_->Run(); + + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand( + MobileResultCodeIs(mobile_apis::Result::eType::SUCCESS), + am::commands::Command::SOURCE_SDL)); + + (*msg_)[am::strings::params][am::hmi_response::code] = + hmi_apis::Common_Result::SUCCESS; + + Event event(hmi_apis::FunctionID::RC_SetGlobalProperties); + event.set_smart_object(*msg_); + + command_->on_event(event); +} + TEST_F(ResetGlobalPropertiesResponseTest, Run_Sendmsg_SUCCESS) { MessageSharedPtr message(CreateMessage()); ResetGlobalPropertiesResponsePtr command( diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/scrollable_message_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/scrollable_message_test.cc index 6b17aa238d6..443868168d3 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/scrollable_message_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/scrollable_message_test.cc @@ -173,17 +173,21 @@ TEST_F(ScrollableMessageRequestTest, Init_CorrectTimeout_SUCCESS) { (*msg_)[msg_params][timeout] = kTimeOut; (*msg_)[msg_params][interaction_mode] = mobile_apis::InteractionMode::MANUAL_ONLY; - EXPECT_EQ(kDefaultTimeout_, command_->default_timeout()); + const uint32_t initial_timeout = + kDefaultTimeout_ + kDefaultTimeoutCompensation_; + EXPECT_EQ(initial_timeout, command_->default_timeout()); command_->Init(); - EXPECT_EQ(kTimeOut + kDefaultTimeout_, command_->default_timeout()); + EXPECT_EQ(kTimeOut + initial_timeout, command_->default_timeout()); } TEST_F(ScrollableMessageRequestTest, Init_CorrectTimeout_UNSUCCESS) { (*msg_)[msg_params][interaction_mode] = mobile_apis::InteractionMode::MANUAL_ONLY; - EXPECT_EQ(kDefaultTimeout_, command_->default_timeout()); + const uint32_t initial_timeout = + kDefaultTimeout_ + kDefaultTimeoutCompensation_; + EXPECT_EQ(initial_timeout, command_->default_timeout()); command_->Init(); - EXPECT_EQ(kDefaultTimeout_, command_->default_timeout()); + EXPECT_EQ(initial_timeout, command_->default_timeout()); } TEST_F(ScrollableMessageRequestTest, Run_ApplicationIsNotRegistered_UNSUCCESS) { @@ -240,18 +244,6 @@ TEST_F(ScrollableMessageRequestTest, OnEvent_ReceivedUnknownEvent_UNSUCCESS) { command_->on_event(event); } -TEST_F(ScrollableMessageRequestTest, - OnEvent_ReceivedUIOnResetTimeoutEvent_SUCCESS) { - (*msg_)[params][connection_key] = kConnectionKey; - (*msg_)[params][correlation_id] = kCorrelationId; - EXPECT_CALL( - app_mngr_, - updateRequestTimeout(kConnectionKey, kCorrelationId, kDefaultTimeout_)); - Event event(hmi_apis::FunctionID::UI_OnResetTimeout); - event.set_smart_object(*msg_); - command_->on_event(event); -} - TEST_F(ScrollableMessageRequestTest, DISABLED_OnEvent_ReceivedUIScrollableMessage_SUCCESS) { (*msg_)[params][hmi_response::code] = hmi_apis::Common_Result::SUCCESS; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/slider_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/slider_test.cc index 0450f06ee18..d9bffc6b4ae 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/slider_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/slider_test.cc @@ -274,22 +274,6 @@ TEST_F(SliderRequestTest, Run_SUCCESS) { command->Run(); } -TEST_F(SliderRequestTest, OnEvent_UI_OnResetTimeout_UNSUCCESS) { - PreConditions(); - (*msg_)[am::strings::msg_params][am::strings::timeout] = kDefaultTimeout; - (*msg_)[am::strings::params][am::strings::correlation_id] = kCorrelationId; - - CommandPtr command(CreateCommand(msg_)); - EXPECT_TRUE(command->Init()); - - EXPECT_CALL(app_mngr_, - updateRequestTimeout(kConnectionKey, kCorrelationId, _)); - - Event event(hmi_apis::FunctionID::UI_OnResetTimeout); - event.set_smart_object(*msg_); - command->on_event(event); -} - TEST_F(SliderRequestTest, OnEvent_UI_UnknownEventId_UNSUCCESS) { PreConditions(); EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)).Times(0); diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/speak_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/speak_request_test.cc index 87320d3a7a5..dd082a52a76 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/speak_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/speak_request_test.cc @@ -366,18 +366,6 @@ TEST_F(SpeakRequestTest, OnEvent_TTS_SpeakWithWarning_WarningWithSuccess) { command->on_event(event); } -TEST_F(SpeakRequestTest, OnEvent_TTS_OnResetTimeout_UpdateTimeout) { - Event event(Event::EventID::TTS_OnResetTimeout); - (*request_)[am::strings::params][am::strings::connection_key] = - kConnectionKey; - (*request_)[am::strings::params][am::strings::correlation_id] = kAppId; - CommandPtr command(CreateCommand(request_)); - - EXPECT_CALL(app_mngr_, updateRequestTimeout(kConnectionKey, kAppId, _)); - - command->on_event(event); -} - TEST_F(SpeakRequestTest, OnEvent_ApplicationIsNotRegistered_UNSUCCESS) { const hmi_apis::Common_Result::eType hmi_result = hmi_apis::Common_Result::SUCCESS; diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/CMakeLists.txt b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/CMakeLists.txt index a741c32129c..e858967619a 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/CMakeLists.txt +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/CMakeLists.txt @@ -45,7 +45,6 @@ collect_sources(VEHICLE_INFO_PLUGIN_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/src") set(LIBRARIES HMI_API MOBILE_API - MessageHelper ApplicationManager v4_protocol_v1_2_no_extra SmartObjects @@ -63,6 +62,7 @@ target_link_libraries("vehicle_info_plugin_static" ${LIBRARIES}) add_library(vehicle_info_plugin SHARED "src/vehicle_info_plugin.cc" ) target_link_libraries(vehicle_info_plugin vehicle_info_plugin_static) +target_link_libraries(vehicle_info_plugin MessageHelper) set(INSTALL_DESTINATION bin) diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/vehicle_info_plugin.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/vehicle_info_plugin.h index 1910a9efdf0..8c67bc1d101 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/vehicle_info_plugin.h +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/vehicle_info_plugin.h @@ -55,13 +55,6 @@ class VehicleInfoPlugin : public plugins::RPCPlugin { policy::PolicyHandlerInterface& policy_handler, resumption::LastStateWrapperPtr last_state) OVERRIDE; - DEPRECATED - bool Init(app_mngr::ApplicationManager& application_manager, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler, - resumption::LastState& last_state) OVERRIDE; - bool IsAbleToProcess( const int32_t function_id, const app_mngr::commands::Command::CommandSource source) OVERRIDE; diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/get_vehicle_data_request.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/get_vehicle_data_request.cc index 17a450ca897..18149fbe02a 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/get_vehicle_data_request.cc +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/get_vehicle_data_request.cc @@ -126,6 +126,12 @@ void GetVehicleDataRequest::on_event(const event_engine::Event& event) { std::string response_info; GetInfo(message, response_info); + if (message[strings::msg_params].keyExists(strings::tire_pressure)) { + ApplicationSharedPtr app = + application_manager_.application(connection_key()); + MessageHelper::AddDefaultParamsToTireStatus(app, message); + } + auto data_not_available_with_params = [this, &result_code, &message]() { if (hmi_apis::Common_Result::DATA_NOT_AVAILABLE != result_code) { return false; diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/on_vehicle_data_notification.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/on_vehicle_data_notification.cc index e0627282176..0ae38a93982 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/on_vehicle_data_notification.cc +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/on_vehicle_data_notification.cc @@ -89,16 +89,22 @@ void OnVehicleDataNotification::Run() { SDL_LOG_ERROR("NULL pointer"); continue; } + + smart_objects::SmartObject output_message = *message_; + if (strings::tire_pressure == name) { + MessageHelper::AddDefaultParamsToTireStatus(app, output_message); + } + notified_app_it = find(notify_apps.begin(), notify_apps.end(), app); if (notified_app_it == notify_apps.end()) { notify_apps.push_back(app); smart_objects::SmartObject msg_param = smart_objects::SmartObject(smart_objects::SmartType_Map); - msg_param[name] = (*message_)[strings::msg_params][name]; + msg_param[name] = output_message[strings::msg_params][name]; appSO.push_back(msg_param); } else { size_t idx = std::distance(notify_apps.begin(), notified_app_it); - appSO[idx][name] = (*message_)[strings::msg_params][name]; + appSO[idx][name] = output_message[strings::msg_params][name]; } } } diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_plugin.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_plugin.cc index 1a357a86ee7..b20e52636c6 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_plugin.cc +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_plugin.cc @@ -88,25 +88,6 @@ bool VehicleInfoPlugin::Init( return true; } -bool VehicleInfoPlugin::Init( - application_manager::ApplicationManager& application_manager, - application_manager::rpc_service::RPCService& rpc_service, - application_manager::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler, - resumption::LastState& last_state) { - UNUSED(last_state); - application_manager_ = &application_manager; - custom_vehicle_data_manager_.reset( - new CustomVehicleDataManagerImpl(policy_handler, rpc_service)); - command_factory_.reset(new vehicle_info_plugin::VehicleInfoCommandFactory( - application_manager, - rpc_service, - hmi_capabilities, - policy_handler, - *(custom_vehicle_data_manager_.get()))); - return true; -} - bool VehicleInfoPlugin::IsAbleToProcess( const int32_t function_id, const commands::Command::CommandSource source) { return command_factory_->IsAbleToProcess(function_id, source); diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/CMakeLists.txt b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/CMakeLists.txt index c9697d71f2e..10739743245 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/CMakeLists.txt +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/CMakeLists.txt @@ -64,7 +64,7 @@ set(LIBRARIES HMI_API MOBILE_API connectionHandler - vehicle_info_plugin + vehicle_info_plugin_static SmartObjects formatters jsoncpp diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/include/vehicle_info_plugin/commands/vi_commands_test.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/include/vehicle_info_plugin/commands/vi_commands_test.h index ae25acea87c..e7d73fc4f05 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/include/vehicle_info_plugin/commands/vi_commands_test.h +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/include/vehicle_info_plugin/commands/vi_commands_test.h @@ -66,7 +66,7 @@ using ::smart_objects::SmartObject; template class VICommandsTest : public CommandsTest { public: - enum { kDefaultTimeout_ = 100 }; + enum { kDefaultTimeout_ = 100, kDefaultTimeoutCompensation_ = 10 }; template std::shared_ptr CreateCommandVI() { @@ -76,7 +76,7 @@ class VICommandsTest : public CommandsTest { template std::shared_ptr CreateCommandVI(MessageSharedPtr& msg) { - InitCommandVI(kDefaultTimeout_); + InitCommandVI(kDefaultTimeout_, kDefaultTimeoutCompensation_); vehicle_info_plugin::VehicleInfoCommandParams params = { CommandsTest::app_mngr_, CommandsTest::mock_rpc_service_, @@ -90,11 +90,14 @@ class VICommandsTest : public CommandsTest { mock_custom_vehicle_data_manager_; protected: - void InitCommandVI(const uint32_t& timeout) { + void InitCommandVI(const uint32_t timeout, const uint32_t compensation) { ON_CALL(CommandsTest::app_mngr_, get_settings()) .WillByDefault(ReturnRef(CommandsTest::app_mngr_settings_)); ON_CALL(CommandsTest::app_mngr_settings_, default_timeout()) .WillByDefault(ReturnRef(timeout)); + ON_CALL(CommandsTest::app_mngr_settings_, + default_timeout_compensation()) + .WillByDefault(ReturnRef(compensation)); } }; } // namespace commands_test diff --git a/src/components/application_manager/src/application_data_impl.cc b/src/components/application_manager/src/application_data_impl.cc index e190025addf..1d6ea8afe84 100644 --- a/src/components/application_manager/src/application_data_impl.cc +++ b/src/components/application_manager/src/application_data_impl.cc @@ -201,6 +201,7 @@ DynamicApplicationDataImpl::DynamicApplicationDataImpl() , keyboard_props_(nullptr) , menu_title_(nullptr) , menu_icon_(nullptr) + , menu_layout_(nullptr) , tbt_show_command_(nullptr) , commands_() , commands_lock_ptr_(std::make_shared()) @@ -349,6 +350,11 @@ const smart_objects::SmartObject* DynamicApplicationDataImpl::menu_icon() return menu_icon_; } +const smart_objects::SmartObject* DynamicApplicationDataImpl::menu_layout() + const { + return menu_layout_; +} + smart_objects::SmartObject DynamicApplicationDataImpl::day_color_scheme() const { using namespace mobile_apis::PredefinedWindows; @@ -467,6 +473,8 @@ void DynamicApplicationDataImpl::load_global_properties( SetGlobalProperties(properties_so.getElement(strings::menu_icon), &DynamicApplicationData::set_menu_icon); + SetGlobalProperties(properties_so.getElement(strings::menu_layout), + &DynamicApplicationData::set_menu_layout); } void DynamicApplicationDataImpl::set_help_prompt( @@ -560,6 +568,14 @@ void DynamicApplicationDataImpl::set_menu_icon( menu_icon_ = new smart_objects::SmartObject(menu_icon); } +void DynamicApplicationDataImpl::set_menu_layout( + const smart_objects::SmartObject& menu_layout) { + if (menu_layout_) { + delete menu_layout_; + } + menu_layout_ = new smart_objects::SmartObject(menu_layout); +} + void DynamicApplicationDataImpl::set_day_color_scheme( const smart_objects::SmartObject& color_scheme) { using namespace mobile_apis::PredefinedWindows; diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index c3a1e9d327c..c3f3ef4bb36 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -51,6 +51,8 @@ #include "application_manager/mobile_message_handler.h" #include "application_manager/plugin_manager/rpc_plugin_manager_impl.h" #include "application_manager/policies/policy_handler.h" +#include "application_manager/request_controller_impl.h" +#include "application_manager/request_timeout_handler_impl.h" #include "application_manager/resumption/resume_ctrl_impl.h" #include "application_manager/rpc_handler_impl.h" #include "application_manager/rpc_protection_manager_impl.h" @@ -170,7 +172,10 @@ ApplicationManagerImpl::ApplicationManagerImpl( , connection_handler_(NULL) , policy_handler_(new policy::PolicyHandler(policy_settings, *this)) , protocol_handler_(NULL) - , request_ctrl_(am_settings) + , request_timeout_handler_( + new request_controller::RequestTimeoutHandlerImpl(*this)) + , request_ctrl_(new request_controller::RequestControllerImpl( + am_settings, *request_timeout_handler_)) , mobile_correlation_id_(0) , correlation_id_(0) , max_correlation_id_(UINT_MAX) @@ -215,7 +220,7 @@ ApplicationManagerImpl::ApplicationManagerImpl( std::make_shared(*policy_handler_); policy_handler_->add_listener(rpc_protection_manager.get()); rpc_service_.reset(new rpc_service::RPCServiceImpl(*this, - request_ctrl_, + *request_ctrl_, protocol_handler_, hmi_handler_, *commands_holder_, @@ -304,13 +309,6 @@ ApplicationSharedPtr ApplicationManagerImpl::pending_application_by_policy_id( return FindPendingApp(accessor, finder); } -ApplicationSharedPtr ApplicationManagerImpl::application_by_name( - const std::string& app_name) const { - AppNamePredicate finder(app_name); - DataAccessor accessor = applications(); - return FindApp(accessor, finder); -} - ApplicationSharedPtr ApplicationManagerImpl::reregister_application_by_policy_id( const std::string& policy_app_id) const { @@ -458,6 +456,7 @@ void ApplicationManagerImpl::OnApplicationRegistered(ApplicationSharedPtr app) { sync_primitives::AutoLock lock(applications_list_lock_ptr_); const mobile_apis::HMILevel::eType default_level = GetDefaultHmiLevel(app); state_ctrl_.OnApplicationRegistered(app, default_level); + commands_holder_->Resume(app, CommandHolder::CommandType::kMobileCommand); } void ApplicationManagerImpl::OnApplicationSwitched(ApplicationSharedPtr app) { @@ -1720,7 +1719,7 @@ void ApplicationManagerImpl::OnDeviceSwitchingStart( } for (const auto& app : wait_list) { - request_ctrl_.terminateAppRequests(app->app_id()); + request_ctrl_->TerminateAppRequests(app->app_id()); resume_ctrl_->SaveApplication(app); } @@ -2482,7 +2481,7 @@ void ApplicationManagerImpl::StartDevicesDiscovery() { void ApplicationManagerImpl::TerminateRequest(const uint32_t connection_key, const uint32_t corr_id, const int32_t function_id) { - request_ctrl_.TerminateRequest(corr_id, connection_key, function_id, true); + request_ctrl_->TerminateRequest(corr_id, connection_key, function_id, true); } void ApplicationManagerImpl::RemoveHMIFakeParameters( @@ -2502,11 +2501,6 @@ void ApplicationManagerImpl::RemoveHMIFakeParameters( (*message)[jhs::S_PARAMS][jhs::S_FUNCTION_ID] = mobile_function_id; } -bool ApplicationManagerImpl::Init(resumption::LastState&, - media_manager::MediaManager*) { - return false; -} - bool ApplicationManagerImpl::Init( resumption::LastStateWrapperPtr last_state_wrapper, media_manager::MediaManager* media_manager) { @@ -2601,7 +2595,7 @@ bool ApplicationManagerImpl::Stop() { } catch (...) { SDL_LOG_ERROR("An error occurred during unregistering applications."); } - request_ctrl_.DestroyThreadpool(); + request_ctrl_->Stop(); // for PASA customer policy backup should happen :AllApp(SUSPEND) SDL_LOG_DEBUG("Unloading policy library."); @@ -2941,21 +2935,21 @@ void ApplicationManagerImpl::SetTelemetryObserver( } #endif // TELEMETRY_MONITOR -void ApplicationManagerImpl::addNotification(const CommandSharedPtr ptr) { - request_ctrl_.addNotification(ptr); +void ApplicationManagerImpl::AddNotification(const CommandSharedPtr ptr) { + request_ctrl_->AddNotification(ptr); } -void ApplicationManagerImpl::removeNotification( +void ApplicationManagerImpl::RemoveNotification( const commands::Command* notification) { - request_ctrl_.removeNotification(notification); + request_ctrl_->RemoveNotification(notification); } -void ApplicationManagerImpl::updateRequestTimeout( +void ApplicationManagerImpl::UpdateRequestTimeout( uint32_t connection_key, uint32_t mobile_correlation_id, uint32_t new_timeout_value) { SDL_LOG_AUTO_TRACE(); - request_ctrl_.updateRequestTimeout( + request_ctrl_->UpdateRequestTimeout( connection_key, mobile_correlation_id, new_timeout_value); } @@ -2965,7 +2959,7 @@ void ApplicationManagerImpl::IncreaseForwardedRequestTimeout( << get_settings().rpc_pass_through_timeout()); uint32_t new_timeout_value = get_settings().default_timeout() + get_settings().rpc_pass_through_timeout(); - request_ctrl_.updateRequestTimeout( + request_ctrl_->UpdateRequestTimeout( connection_key, mobile_correlation_id, new_timeout_value); } @@ -3187,7 +3181,7 @@ void ApplicationManagerImpl::UnregisterAllApplications() { if (is_ignition_off) { resume_controller().OnIgnitionOff(); } - request_ctrl_.terminateAllHMIRequests(); + request_ctrl_->TerminateAllHMIRequests(); { sync_primitives::AutoLock lock(expired_button_requests_lock_); @@ -3292,11 +3286,10 @@ void ApplicationManagerImpl::UnregisterApplication( } if (!app_to_remove) { SDL_LOG_ERROR("Cant find application with app_id = " << app_id); - // Just to terminate RAI in case of connection is dropped (rare case) // App won't be unregistered since RAI has not been started yet SDL_LOG_DEBUG("Trying to terminate possible RAI request."); - request_ctrl_.terminateAppRequests(app_id); + request_ctrl_->TerminateAppRequests(app_id); return; } @@ -3360,7 +3353,8 @@ void ApplicationManagerImpl::UnregisterApplication( }; plugin_manager_->ForEachPlugin(on_app_unregistered); - request_ctrl_.terminateAppRequests(app_id); + + request_ctrl_->TerminateAppRequests(app_id); const bool is_applications_list_empty = applications().GetData().empty(); if (is_applications_list_empty) { @@ -3445,7 +3439,7 @@ void ApplicationManagerImpl::OnLowVoltage() { is_low_voltage_ = true; resume_ctrl_->SaveLowVoltageTime(); resume_ctrl_->StopSavePersistentDataTimer(); - request_ctrl_.OnLowVoltage(); + request_ctrl_->OnLowVoltage(); } bool ApplicationManagerImpl::IsLowVoltage() const { @@ -3457,7 +3451,7 @@ void ApplicationManagerImpl::OnWakeUp() { SDL_LOG_AUTO_TRACE(); resume_ctrl_->SaveWakeUpTime(); resume_ctrl_->StartSavePersistentDataTimer(); - request_ctrl_.OnWakeUp(); + request_ctrl_->OnWakeUp(); is_low_voltage_ = false; } @@ -3520,53 +3514,6 @@ bool ApplicationManagerImpl::CanAppStream( return HMIStateAllowsStreaming(app_id, service_type) && is_allowed; } -void ApplicationManagerImpl::ForbidStreaming(uint32_t app_id) { - using namespace mobile_apis::AppInterfaceUnregisteredReason; - using namespace mobile_apis::Result; - - SDL_LOG_AUTO_TRACE(); - - ApplicationSharedPtr app = application(app_id); - if (!app || (!app->is_navi() && !app->mobile_projection_enabled())) { - SDL_LOG_DEBUG( - "There is no navi or projection application with id: " << app_id); - return; - } - - { - sync_primitives::AutoLock lock(navi_app_to_stop_lock_); - if (navi_app_to_stop_.end() != std::find(navi_app_to_stop_.begin(), - navi_app_to_stop_.end(), - app_id) || - navi_app_to_end_stream_.end() != - std::find(navi_app_to_end_stream_.begin(), - navi_app_to_end_stream_.end(), - app_id)) { - return; - } - } - - bool unregister = false; - { - sync_primitives::AutoLock lock(navi_service_status_lock_); - - NaviServiceStatusMap::iterator it = navi_service_status_.find(app_id); - if (navi_service_status_.end() == it || - (!it->second.first && !it->second.second)) { - unregister = true; - } - } - if (unregister) { - rpc_service_->ManageMobileCommand( - MessageHelper::GetOnAppInterfaceUnregisteredNotificationToMobile( - app_id, PROTOCOL_VIOLATION), - commands::Command::SOURCE_SDL); - UnregisterApplication(app_id, ABORTED); - return; - } - EndNaviServices(app_id); -} - void ApplicationManagerImpl::ForbidStreaming( uint32_t app_id, protocol_handler::ServiceType service_type) { using namespace mobile_apis::AppInterfaceUnregisteredReason; @@ -3650,48 +3597,6 @@ void ApplicationManagerImpl::OnAppStreaming( } } -void ApplicationManagerImpl::OnAppStreaming( - uint32_t app_id, - protocol_handler::ServiceType service_type, - const Application::StreamingState new_state) { - SDL_LOG_AUTO_TRACE(); - - ApplicationSharedPtr app = application(app_id); - if (!app || (!app->is_navi() && !app->mobile_projection_enabled())) { - SDL_LOG_DEBUG( - " There is no navi or projection application with id: " << app_id); - return; - } - DCHECK_OR_RETURN_VOID(media_manager_); - - SDL_LOG_DEBUG("New state for service " << static_cast(service_type) - << " is " - << static_cast(new_state)); - switch (new_state) { - case Application::StreamingState::kStopped: { - // Stop activity in media_manager_ when service is stopped - // State controller has been already notified by kSuspended event - // received before - media_manager_->StopStreaming(app_id, service_type); - break; - } - - case Application::StreamingState::kStarted: { - // Apply temporary streaming state and start activity in media_manager_ - state_ctrl_.OnVideoStreamingStarted(app); - media_manager_->StartStreaming(app_id, service_type); - break; - } - - case Application::StreamingState::kSuspended: { - // Don't stop activity in media_manager_ in that case - // Just cancel the temporary streaming state - state_ctrl_.OnVideoStreamingStopped(app); - break; - } - } -} - void ApplicationManagerImpl::EndNaviServices(uint32_t app_id) { using namespace protocol_handler; SDL_LOG_AUTO_TRACE(); diff --git a/src/components/application_manager/src/commands/command_impl.cc b/src/components/application_manager/src/commands/command_impl.cc index 8a3d8bc9ffb..8751823e859 100644 --- a/src/components/application_manager/src/commands/command_impl.cc +++ b/src/components/application_manager/src/commands/command_impl.cc @@ -105,7 +105,9 @@ CommandImpl::CommandImpl(const MessageSharedPtr& message, HMICapabilities& hmi_capabilities, policy::PolicyHandlerInterface& policy_handler) : message_(message) - , default_timeout_(application_manager.get_settings().default_timeout()) + , default_timeout_( + application_manager.get_settings().default_timeout() + + application_manager.get_settings().default_timeout_compensation()) , allowed_to_terminate_(true) , application_manager_(application_manager) , rpc_service_(rpc_service) diff --git a/src/components/application_manager/src/commands/command_request_impl.cc b/src/components/application_manager/src/commands/command_request_impl.cc index 86eccc38b34..65fbf7e66f4 100644 --- a/src/components/application_manager/src/commands/command_request_impl.cc +++ b/src/components/application_manager/src/commands/command_request_impl.cc @@ -44,6 +44,7 @@ #include "smart_objects/smart_object.h" #include "smart_objects/enum_schema_item.h" +#include "utils/helpers.h" namespace application_manager { @@ -468,6 +469,7 @@ uint32_t CommandRequestImpl::SendHMIRequest( const hmi_apis::FunctionID::eType& function_id, const smart_objects::SmartObject* msg_params, bool use_events) { + SDL_LOG_AUTO_TRACE(); smart_objects::SmartObjectSPtr result = std::make_shared(); @@ -493,7 +495,9 @@ uint32_t CommandRequestImpl::SendHMIRequest( subscribe_on_event(function_id, hmi_correlation_id); } if (ProcessHMIInterfacesAvailability(hmi_correlation_id, function_id)) { - if (!rpc_service_.ManageHMICommand(result, SOURCE_SDL_TO_HMI)) { + if (rpc_service_.ManageHMICommand(result, SOURCE_SDL_TO_HMI)) { + AddRequestToTimeoutHandler(request); + } else { SDL_LOG_ERROR("Unable to send request"); SendResponse(false, mobile_apis::Result::OUT_OF_MEMORY); } @@ -710,6 +714,17 @@ bool CommandRequestImpl::PrepareResultForMobileResponse( return result; } +bool CommandRequestImpl::PrepareResultForMobileResponse( + ResponseInfo& out_first, + ResponseInfo& out_second, + ResponseInfo& out_third) const { + SDL_LOG_AUTO_TRACE(); + bool result = (PrepareResultForMobileResponse(out_first, out_second) || + PrepareResultForMobileResponse(out_second, out_third)) && + PrepareResultForMobileResponse(out_first, out_third); + return result; +} + void CommandRequestImpl::GetInfo( const smart_objects::SmartObject& response_from_hmi, std::string& out_info) { @@ -749,6 +764,19 @@ mobile_apis::Result::eType CommandRequestImpl::PrepareResultCodeForResponse( return result_code; } +mobile_apis::Result::eType CommandRequestImpl::PrepareResultCodeForResponse( + const ResponseInfo& first, + const ResponseInfo& second, + const ResponseInfo& third) { + SDL_LOG_AUTO_TRACE(); + + const auto first_comparison = PrepareResultCodeForResponse(first, second); + const auto second_comparison = PrepareResultCodeForResponse(second, third); + const auto third_comparison = PrepareResultCodeForResponse(first, third); + + return std::max({first_comparison, second_comparison, third_comparison}); +} + const CommandParametersPermissions& CommandRequestImpl::parameters_permissions() const { return parameters_permissions_; @@ -851,6 +879,51 @@ void CommandRequestImpl::AddTimeOutComponentInfoToMessage( } } +void CommandRequestImpl::AddRequestToTimeoutHandler( + const smart_objects::SmartObject& request_to_hmi) const { + auto function_id = static_cast( + request_to_hmi[strings::params][strings::function_id].asUInt()); + // SDL must not apply "default timeout for RPCs processing" for + // BasicCommunication.DialNumber RPC (that is, SDL must always wait for HMI + // response to BC.DialNumber as long as it takes and not return GENERIC_ERROR + // to mobile app), so the OnResetTimeout logic is not applicable for + // DialNumber RPC + if (helpers::Compare( + function_id, + hmi_apis::FunctionID::BasicCommunication_DialNumber, + hmi_apis::FunctionID::INVALID_ENUM)) { + SDL_LOG_DEBUG( + "Current RPC is DialNumber or Invalid, OnResetTimeout " + "logic is not applicable in this case"); + return; + } + + // If soft buttons are present in Alert or SubtleAlert RPC, SDL will not use + // timeout tracking for response, so the OnResetTimeout logic is not + // applicable in this case + if (helpers::Compare( + function_id, + hmi_apis::FunctionID::UI_Alert, + hmi_apis::FunctionID::UI_SubtleAlert)) { + if (request_to_hmi.keyExists(strings::msg_params)) { + if (request_to_hmi[strings::msg_params].keyExists( + strings::soft_buttons)) { + SDL_LOG_DEBUG("Soft buttons are present in " + << EnumToString(function_id) + << " RPC, OnResetTimeout " + "logic is not applicable in this case"); + return; + } + } + } + + const application_manager::request_controller::Request request{ + correlation_id(), connection_key(), static_cast(function_id)}; + application_manager_.get_request_timeout_handler().AddRequest( + request_to_hmi[strings::params][strings::correlation_id].asUInt(), + request); +} + } // namespace commands } // namespace application_manager diff --git a/src/components/application_manager/src/commands/request_from_hmi.cc b/src/components/application_manager/src/commands/request_from_hmi.cc index db6b3f78b18..fca48854e23 100644 --- a/src/components/application_manager/src/commands/request_from_hmi.cc +++ b/src/components/application_manager/src/commands/request_from_hmi.cc @@ -177,7 +177,7 @@ void RequestFromHMI::SendProviderRequest( if (hmi_destination) { SDL_LOG_DEBUG("Sending Request to HMI Provider"); application_manager_.IncreaseForwardedRequestTimeout( - application_manager::request_controller::RequestInfo::HmiConnectionKey, + application_manager::request_controller::RequestInfo::kHmiConnectionKey, correlation_id()); SendHMIRequest(hmi_function_id, &(*msg)[strings::msg_params], use_events); return; @@ -195,7 +195,7 @@ void RequestFromHMI::SendProviderRequest( SDL_LOG_DEBUG("Sending Request to Mobile Provider"); application_manager_.IncreaseForwardedRequestTimeout( - application_manager::request_controller::RequestInfo::HmiConnectionKey, + application_manager::request_controller::RequestInfo::kHmiConnectionKey, correlation_id()); SendMobileRequest( mobile_function_id, app, &(*msg)[strings::msg_params], use_events); diff --git a/src/components/application_manager/src/helpers/application_helper.cc b/src/components/application_manager/src/helpers/application_helper.cc index d104b41ec93..09b8eed6fe7 100644 --- a/src/components/application_manager/src/helpers/application_helper.cc +++ b/src/components/application_manager/src/helpers/application_helper.cc @@ -87,6 +87,7 @@ void DeleteGlobalProperties(ApplicationSharedPtr app, app->set_keyboard_props(empty_so); app->set_menu_icon(empty_so); app->set_menu_title(empty_so); + app->set_menu_layout(empty_so); MessageHelper::SendResetPropertiesRequest(app, app_manager); } diff --git a/src/components/application_manager/src/hmi_capabilities_impl.cc b/src/components/application_manager/src/hmi_capabilities_impl.cc index f313e0c0a52..a8001eba91b 100644 --- a/src/components/application_manager/src/hmi_capabilities_impl.cc +++ b/src/components/application_manager/src/hmi_capabilities_impl.cc @@ -431,8 +431,6 @@ void HMICapabilitiesImpl::Init( ui_language_, vr_language_, tts_language_); } -void HMICapabilitiesImpl::Init(resumption::LastState*) {} - bool HMICapabilitiesImpl::is_ui_cooperating() const { return is_ui_cooperating_; } diff --git a/src/components/application_manager/src/hmi_interfaces_impl.cc b/src/components/application_manager/src/hmi_interfaces_impl.cc index 488b0a4b15c..205585959ba 100644 --- a/src/components/application_manager/src/hmi_interfaces_impl.cc +++ b/src/components/application_manager/src/hmi_interfaces_impl.cc @@ -132,7 +132,8 @@ generate_function_to_interface_convert_map() { convert_map[TTS_GetSupportedLanguages] = HmiInterfaces::HMI_INTERFACE_TTS; convert_map[TTS_GetLanguage] = HmiInterfaces::HMI_INTERFACE_TTS; convert_map[TTS_SetGlobalProperties] = HmiInterfaces::HMI_INTERFACE_TTS; - convert_map[TTS_OnResetTimeout] = HmiInterfaces::HMI_INTERFACE_TTS; + convert_map[BasicCommunication_OnResetTimeout] = + HmiInterfaces::HMI_INTERFACE_BasicCommunication; convert_map[UI_Alert] = HmiInterfaces::HMI_INTERFACE_UI; convert_map[UI_SubtleAlert] = HmiInterfaces::HMI_INTERFACE_UI; convert_map[UI_Show] = HmiInterfaces::HMI_INTERFACE_UI; @@ -165,7 +166,6 @@ generate_function_to_interface_convert_map() { convert_map[UI_EndAudioPassThru] = HmiInterfaces::HMI_INTERFACE_UI; convert_map[UI_IsReady] = HmiInterfaces::HMI_INTERFACE_UI; convert_map[UI_ClosePopUp] = HmiInterfaces::HMI_INTERFACE_UI; - convert_map[UI_OnResetTimeout] = HmiInterfaces::HMI_INTERFACE_UI; convert_map[UI_SendHapticData] = HmiInterfaces::HMI_INTERFACE_UI; convert_map[Navigation_IsReady] = HmiInterfaces::HMI_INTERFACE_Navigation; convert_map[Navigation_SendLocation] = diff --git a/src/components/application_manager/src/message_helper/message_helper.cc b/src/components/application_manager/src/message_helper/message_helper.cc index b8d1d72e3c4..decdabb55c9 100644 --- a/src/components/application_manager/src/message_helper/message_helper.cc +++ b/src/components/application_manager/src/message_helper/message_helper.cc @@ -62,6 +62,7 @@ #include "utils/file_system.h" #include "utils/logger.h" #include "utils/macro.h" +#include "utils/semantic_version.h" #include "formatters/CFormatterJsonBase.h" #include "formatters/CFormatterJsonSDLRPCv1.h" @@ -1280,7 +1281,7 @@ MessageHelper::CreateGlobalPropertiesRequestsToHMI( if (can_send_ui && (app->vr_help_title() || app->vr_help() || app->keyboard_props() || - app->menu_title() || app->menu_icon())) { + app->menu_title() || app->menu_icon() || app->menu_layout())) { smart_objects::SmartObjectSPtr ui_global_properties = CreateMessageForHMI( hmi_apis::messageType::request, app_mngr.GetNextHMICorrelationID()); if (ui_global_properties) { @@ -1304,6 +1305,9 @@ MessageHelper::CreateGlobalPropertiesRequestsToHMI( if (app->menu_icon()) { ui_msg_params[strings::menu_icon] = (*app->menu_icon()); } + if (app->menu_layout()) { + ui_msg_params[strings::menu_layout] = (*app->menu_layout()); + } ui_msg_params[strings::app_id] = app->app_id(); (*ui_global_properties)[strings::msg_params] = ui_msg_params; @@ -1986,6 +1990,9 @@ smart_objects::SmartObjectList MessageHelper::CreateAddSubMenuRequestsToHMI( msg_params[strings::menu_params][strings::parent_id] = (*i->second)[strings::parent_id]; } + if ((*i->second).keyExists(strings::menu_layout)) { + msg_params[strings::menu_layout] = (*i->second)[strings::menu_layout]; + } msg_params[strings::app_id] = app->app_id(); (*ui_sub_menu)[strings::msg_params] = msg_params; if (((*i->second).keyExists(strings::menu_icon)) && @@ -3468,4 +3475,42 @@ WindowID MessageHelper::ExtractWindowIdFromSmartObject( return mobile_apis::PredefinedWindows::DEFAULT_WINDOW; } +void MessageHelper::AddDefaultParamsToTireStatus( + ApplicationSharedPtr app, smart_objects::SmartObject& response_from_hmi) { + const utils::SemanticVersion max_version_with_mandatory_params(8, 0, 0); + + if (!app) { + SDL_LOG_ERROR("Application not found"); + return; + } + + if (app->msg_version() >= max_version_with_mandatory_params) { + SDL_LOG_DEBUG( + "Tire status parameters are " + "non-mandatory for this app version, no need in default values"); + return; + } + + smart_objects::SmartObject& tire_status = + response_from_hmi[strings::msg_params][strings::tire_pressure]; + + if (!tire_status.keyExists(strings::pressure_telltale)) { + tire_status[strings::pressure_telltale] = + mobile_apis::WarningLightStatus::WLS_NOT_USED; + } + + const std::vector tires{strings::left_front, + strings::right_front, + strings::left_rear, + strings::right_rear, + strings::inner_left_rear, + strings::inner_right_rear}; + for (const std::string& tire : tires) { + if (!tire_status.keyExists(tire)) { + tire_status[tire][strings::status] = + mobile_apis::ComponentVolumeStatus::CVS_UNKNOWN; + } + } +} + } // namespace application_manager diff --git a/src/components/application_manager/src/policies/policy_handler.cc b/src/components/application_manager/src/policies/policy_handler.cc index c0d61bdd4eb..c8c2a25a6dc 100644 --- a/src/components/application_manager/src/policies/policy_handler.cc +++ b/src/components/application_manager/src/policies/policy_handler.cc @@ -1236,12 +1236,6 @@ void PolicyHandler::OnPendingPermissionChange( policy_manager->RemovePendingPermissionChanges(policy_app_id); } -bool PolicyHandler::SendMessageToSDK(const BinaryMessage& pt_string, - const std::string& url) { - const uint32_t app_id = GetAppIdForSending(); - return SendMessageToSDK(pt_string, url, app_id); -} - bool PolicyHandler::SendMessageToSDK(const BinaryMessage& pt_string, const std::string& url, const uint32_t app_id) { diff --git a/src/components/application_manager/src/request_controller.cc b/src/components/application_manager/src/request_controller_impl.cc similarity index 77% rename from src/components/application_manager/src/request_controller.cc rename to src/components/application_manager/src/request_controller_impl.cc index d94bb0e4df9..10f0f64b4ea 100644 --- a/src/components/application_manager/src/request_controller.cc +++ b/src/components/application_manager/src/request_controller_impl.cc @@ -34,7 +34,7 @@ #include "application_manager/commands/command_request_impl.h" #include "application_manager/commands/request_to_hmi.h" -#include "application_manager/request_controller.h" +#include "application_manager/request_controller_impl.h" #include "utils/timer_task_impl.h" @@ -46,37 +46,50 @@ using namespace sync_primitives; SDL_CREATE_LOG_VARIABLE("RequestController") -RequestController::RequestController(const RequestControlerSettings& settings) - : pool_state_(UNDEFINED) +RequestControllerImpl::RequestControllerImpl( + const RequestControlerSettings& settings, + RequestTimeoutHandler& request_timeout_handler) + : pool_state_(TPoolState::UNDEFINED) , pool_size_(settings.thread_pool_size()) , request_tracker_(settings) , duplicate_message_count_() , timer_("AM RequestCtrlTimer", - new timer::TimerTaskImpl( - this, &RequestController::TimeoutThread)) + new timer::TimerTaskImpl( + this, &RequestControllerImpl::TimeoutThread)) , timer_stop_flag_(false) , is_low_voltage_(false) - , settings_(settings) { + , settings_(settings) + , request_timeout_handler_(request_timeout_handler) { SDL_LOG_AUTO_TRACE(); InitializeThreadpool(); timer_.Start(0, timer::kSingleShot); } -RequestController::~RequestController() { +RequestControllerImpl::~RequestControllerImpl() { SDL_LOG_AUTO_TRACE(); + Stop(); +} + +void RequestControllerImpl::Stop() { + SDL_LOG_AUTO_TRACE(); + { sync_primitives::AutoLock auto_lock(timer_lock); timer_stop_flag_ = true; timer_condition_.Broadcast(); } - timer_.Stop(); + if (pool_state_ != TPoolState::STOPPED) { DestroyThreadpool(); } + + SDL_LOG_DEBUG("Stopping timeout tracker"); + timer_.Stop(); } -void RequestController::InitializeThreadpool() { +void RequestControllerImpl::InitializeThreadpool() { SDL_LOG_AUTO_TRACE(); + // TODO(DK): Consider lazy loading threads instead of creating all at once pool_state_ = TPoolState::STARTED; char name[50]; @@ -88,7 +101,7 @@ void RequestController::InitializeThreadpool() { } } -void RequestController::DestroyThreadpool() { +void RequestControllerImpl::DestroyThreadpool() { SDL_LOG_AUTO_TRACE(); { AutoLock auto_lock(mobile_request_list_lock_); @@ -105,12 +118,12 @@ void RequestController::DestroyThreadpool() { pool_.clear(); } -RequestController::TResult RequestController::CheckPosibilitytoAdd( +RequestControllerImpl::TResult RequestControllerImpl::CheckPosibilitytoAdd( const RequestPtr request, const mobile_apis::HMILevel::eType level) { SDL_LOG_AUTO_TRACE(); if (!CheckPendingRequestsAmount(settings_.pending_requests_amount())) { SDL_LOG_ERROR("Too many pending request"); - return RequestController::TOO_MANY_PENDING_REQUESTS; + return RequestController::TResult::TOO_MANY_PENDING_REQUESTS; } const TrackResult track_result = @@ -118,25 +131,26 @@ RequestController::TResult RequestController::CheckPosibilitytoAdd( if (TrackResult::kNoneLevelMaxRequestsExceeded == track_result) { SDL_LOG_ERROR("Too many application requests in hmi level NONE"); - return RequestController::NONE_HMI_LEVEL_MANY_REQUESTS; + return RequestController::TResult::NONE_HMI_LEVEL_MANY_REQUESTS; } if (TrackResult::kMaxRequestsExceeded == track_result) { SDL_LOG_ERROR("Too many application requests"); - return RequestController::TOO_MANY_REQUESTS; + return RequestController::TResult::TOO_MANY_REQUESTS; } if (IsLowVoltage()) { SDL_LOG_ERROR("Impossible to add request due to Low Voltage is active"); - return RequestController::INVALID_DATA; + return RequestController::TResult::INVALID_DATA; } - return SUCCESS; + return TResult::SUCCESS; } -bool RequestController::CheckPendingRequestsAmount( - const uint32_t& pending_requests_amount) { +bool RequestControllerImpl::CheckPendingRequestsAmount( + const uint32_t pending_requests_amount) { SDL_LOG_AUTO_TRACE(); + if (pending_requests_amount > 0) { const size_t pending_requests_size = mobile_request_list_.size(); const bool available_to_add = @@ -152,19 +166,19 @@ bool RequestController::CheckPendingRequestsAmount( return true; } -RequestController::TResult RequestController::addMobileRequest( +RequestController::TResult RequestControllerImpl::AddMobileRequest( const RequestPtr request, const mobile_apis::HMILevel::eType& hmi_level) { SDL_LOG_AUTO_TRACE(); if (!request) { SDL_LOG_ERROR("Null Pointer request"); cond_var_.NotifyOne(); - return INVALID_DATA; + return TResult::INVALID_DATA; } SDL_LOG_DEBUG("correlation_id : " << request->correlation_id() << "connection_key : " << request->connection_key()); RequestController::TResult result = CheckPosibilitytoAdd(request, hmi_level); - if (SUCCESS == result) { + if (TResult::SUCCESS == result) { AutoLock auto_lock_list(mobile_request_list_lock_); mobile_request_list_.push_back(request); SDL_LOG_DEBUG("Waiting for execution: " << mobile_request_list_.size()); @@ -174,13 +188,13 @@ RequestController::TResult RequestController::addMobileRequest( return result; } -RequestController::TResult RequestController::addHMIRequest( +RequestController::TResult RequestControllerImpl::AddHMIRequest( const RequestPtr request) { SDL_LOG_AUTO_TRACE(); if (request.use_count() == 0) { SDL_LOG_ERROR("HMI request pointer is invalid"); - return RequestController::INVALID_DATA; + return RequestController::TResult::INVALID_DATA; } SDL_LOG_DEBUG(" correlation_id : " << request->correlation_id()); @@ -197,18 +211,19 @@ RequestController::TResult RequestController::addHMIRequest( if (IsLowVoltage()) { SDL_LOG_ERROR("Impossible to add request due to Low Voltage is active"); - return RequestController::INVALID_DATA; + return RequestController::TResult::INVALID_DATA; } waiting_for_response_.Add(request_info_ptr); SDL_LOG_DEBUG("Waiting for response count:" << waiting_for_response_.Size()); NotifyTimer(); - return RequestController::SUCCESS; + return RequestController::TResult::SUCCESS; } -void RequestController::addNotification(const RequestPtr ptr) { +void RequestControllerImpl::AddNotification(const RequestPtr ptr) { SDL_LOG_AUTO_TRACE(); + if (IsLowVoltage()) { SDL_LOG_ERROR( "Impossible to add notification due to Low Voltage is active"); @@ -217,7 +232,7 @@ void RequestController::addNotification(const RequestPtr ptr) { notification_list_.push_back(ptr); } -void RequestController::removeNotification( +void RequestControllerImpl::RemoveNotification( const commands::Command* notification) { SDL_LOG_AUTO_TRACE(); std::list::iterator it = notification_list_.begin(); @@ -233,15 +248,16 @@ void RequestController::removeNotification( SDL_LOG_DEBUG("Cannot find notification"); } -void RequestController::TerminateRequest(const uint32_t correlation_id, - const uint32_t connection_key, - const int32_t function_id, - bool force_terminate) { +void RequestControllerImpl::TerminateRequest(const uint32_t correlation_id, + const uint32_t connection_key, + const int32_t function_id, + bool force_terminate) { SDL_LOG_AUTO_TRACE(); SDL_LOG_DEBUG("correlation_id = " << correlation_id << " connection_key = " << connection_key << " function_id = " << function_id << " force_terminate = " << force_terminate); + { AutoLock auto_lock(duplicate_message_count_lock_); auto dup_it = duplicate_message_count_.find(correlation_id); @@ -269,27 +285,32 @@ void RequestController::TerminateRequest(const uint32_t correlation_id, } if (force_terminate || request->request()->AllowedToTerminate()) { waiting_for_response_.RemoveRequest(request); + if (RequestInfo::HMIRequest == request->request_type()) { + request_timeout_handler_.RemoveRequest(request->requestId()); + } + } else { SDL_LOG_WARN("Request was not terminated"); } NotifyTimer(); } -void RequestController::OnMobileResponse(const uint32_t mobile_correlation_id, - const uint32_t connection_key, - const int32_t function_id) { +void RequestControllerImpl::OnMobileResponse( + const uint32_t mobile_correlation_id, + const uint32_t connection_key, + const int32_t function_id) { SDL_LOG_AUTO_TRACE(); TerminateRequest(mobile_correlation_id, connection_key, function_id); } -void RequestController::OnHMIResponse(const uint32_t correlation_id, - const int32_t function_id) { +void RequestControllerImpl::OnHMIResponse(const uint32_t correlation_id, + const int32_t function_id) { SDL_LOG_AUTO_TRACE(); - TerminateRequest(correlation_id, RequestInfo::HmiConnectionKey, function_id); + TerminateRequest(correlation_id, RequestInfo::kHmiConnectionKey, function_id); } -void RequestController::terminateWaitingForExecutionAppRequests( - const uint32_t& app_id) { +void RequestControllerImpl::TerminateWaitingForExecutionAppRequests( + const uint32_t app_id) { SDL_LOG_AUTO_TRACE(); SDL_LOG_DEBUG("app_id: " << app_id << "Waiting for execution" << mobile_request_list_.size()); @@ -306,15 +327,15 @@ void RequestController::terminateWaitingForExecutionAppRequests( SDL_LOG_DEBUG("Waiting for execution " << mobile_request_list_.size()); } -void RequestController::terminateWaitingForResponseAppRequests( - const uint32_t& app_id) { +void RequestControllerImpl::TerminateWaitingForResponseAppRequests( + const uint32_t app_id) { SDL_LOG_AUTO_TRACE(); waiting_for_response_.RemoveByConnectionKey(app_id); SDL_LOG_DEBUG( "Waiting for response count : " << waiting_for_response_.Size()); } -void RequestController::terminateAppRequests(const uint32_t& app_id) { +void RequestControllerImpl::TerminateAppRequests(const uint32_t app_id) { SDL_LOG_AUTO_TRACE(); SDL_LOG_DEBUG("app_id : " << app_id << "Requests waiting for execution count : " @@ -322,18 +343,19 @@ void RequestController::terminateAppRequests(const uint32_t& app_id) { << "Requests waiting for response count : " << waiting_for_response_.Size()); - terminateWaitingForExecutionAppRequests(app_id); - terminateWaitingForResponseAppRequests(app_id); + TerminateWaitingForExecutionAppRequests(app_id); + TerminateWaitingForResponseAppRequests(app_id); NotifyTimer(); } -void RequestController::terminateAllHMIRequests() { +void RequestControllerImpl::TerminateAllHMIRequests() { SDL_LOG_AUTO_TRACE(); - terminateWaitingForResponseAppRequests(RequestInfo::HmiConnectionKey); + TerminateWaitingForResponseAppRequests(RequestInfo::kHmiConnectionKey); } -void RequestController::terminateAllMobileRequests() { +void RequestControllerImpl::TerminateAllMobileRequests() { SDL_LOG_AUTO_TRACE(); + waiting_for_response_.RemoveMobileRequests(); SDL_LOG_DEBUG("Mobile Requests waiting for response cleared"); AutoLock waiting_execution_auto_lock(mobile_request_list_lock_); @@ -342,21 +364,30 @@ void RequestController::terminateAllMobileRequests() { NotifyTimer(); } -void RequestController::updateRequestTimeout(const uint32_t& app_id, - const uint32_t& correlation_id, - const uint32_t& new_timeout) { +void RequestControllerImpl::UpdateRequestTimeout(const uint32_t app_id, + const uint32_t correlation_id, + const uint32_t new_timeout) { SDL_LOG_AUTO_TRACE(); - SDL_LOG_DEBUG("app_id : " << app_id << " mobile_correlation_id : " << correlation_id << " new_timeout : " << new_timeout); - SDL_LOG_DEBUG( - "New_timeout is NULL. RequestCtrl will " - "not manage this request any more"); + + if (new_timeout == 0) { + SDL_LOG_DEBUG( + "New_timeout is NULL. RequestCtrl will " + "not manage this request any more"); + } RequestInfoPtr request_info = waiting_for_response_.Find(app_id, correlation_id); if (request_info) { + if (0 == request_info->timeout_msec()) { + SDL_LOG_INFO( + "Request with zero timeout is not updating, " + "manual control is assumed"); + return; + } + waiting_for_response_.RemoveRequest(request_info); request_info->updateTimeOut(new_timeout); waiting_for_response_.Add(request_info); @@ -371,26 +402,32 @@ void RequestController::updateRequestTimeout(const uint32_t& app_id, } } -void RequestController::OnLowVoltage() { +void RequestControllerImpl::OnLowVoltage() { SDL_LOG_AUTO_TRACE(); is_low_voltage_ = true; } -void RequestController::OnWakeUp() { +void RequestControllerImpl::OnWakeUp() { SDL_LOG_AUTO_TRACE(); - terminateAllHMIRequests(); - terminateAllMobileRequests(); + TerminateAllHMIRequests(); + TerminateAllMobileRequests(); is_low_voltage_ = false; SDL_LOG_DEBUG("Terminate old requests done"); } -bool RequestController::IsLowVoltage() { +bool RequestControllerImpl::IsLowVoltage() { SDL_LOG_TRACE("result: " << is_low_voltage_); return is_low_voltage_; } -void RequestController::TimeoutThread() { +void RequestControllerImpl::TimeoutThread() { SDL_LOG_AUTO_TRACE(); + + if (TPoolState::STOPPED == pool_state_) { + SDL_LOG_DEBUG("Thread pool has been stopped. Skipping timer restart"); + return; + } + SDL_LOG_DEBUG( "ENTER Waiting fore response count: " << waiting_for_response_.Size()); sync_primitives::AutoLock auto_lock(timer_lock); @@ -427,18 +464,21 @@ void RequestController::TimeoutThread() { << " request id: " << probably_expired->requestId() << " connection_key: " << probably_expired->app_id() << " is expired"); - const uint32_t experied_request_id = probably_expired->requestId(); - const uint32_t experied_app_id = probably_expired->app_id(); + const uint32_t expired_request_id = probably_expired->requestId(); + const uint32_t expired_app_id = probably_expired->app_id(); probably_expired->request()->onTimeOut(); - if (RequestInfo::HmiConnectionKey == probably_expired->app_id()) { + if (RequestInfo::kHmiConnectionKey == probably_expired->app_id()) { SDL_LOG_DEBUG("Erase HMI request: " << probably_expired->requestId()); waiting_for_response_.RemoveRequest(probably_expired); + if (RequestInfo::HMIRequest == probably_expired->request_type()) { + request_timeout_handler_.RemoveRequest(expired_request_id); + } } probably_expired = waiting_for_response_.FrontWithNotNullTimeout(); if (probably_expired) { - if (experied_request_id == probably_expired->requestId() && - experied_app_id == probably_expired->app_id()) { + if (expired_request_id == probably_expired->requestId() && + expired_app_id == probably_expired->app_id()) { SDL_LOG_DEBUG("Expired request wasn't removed"); break; } @@ -448,12 +488,12 @@ void RequestController::TimeoutThread() { "EXIT Waiting for response count : " << waiting_for_response_.Size()); } -RequestController::Worker::Worker(RequestController* requestController) - : request_controller_(requestController), stop_flag_(false) {} +RequestControllerImpl::Worker::Worker(RequestControllerImpl* request_controller) + : request_controller_(request_controller), stop_flag_(false) {} -RequestController::Worker::~Worker() {} +RequestControllerImpl::Worker::~Worker() {} -void RequestController::Worker::threadMain() { +void RequestControllerImpl::Worker::threadMain() { SDL_LOG_AUTO_TRACE(); AutoLock auto_lock(thread_lock_); while (!stop_flag_) { @@ -531,13 +571,13 @@ void RequestController::Worker::threadMain() { } } -void RequestController::Worker::exitThreadMain() { +void RequestControllerImpl::Worker::exitThreadMain() { stop_flag_ = true; // setup stop flag and whit while threadMain will be finished correctly // FIXME (dchmerev@luxoft.com): There is no waiting } -void RequestController::NotifyTimer() { +void RequestControllerImpl::NotifyTimer() { SDL_LOG_AUTO_TRACE(); timer_condition_.NotifyOne(); } diff --git a/src/components/application_manager/src/request_info.cc b/src/components/application_manager/src/request_info.cc index b1c1d68eaac..6770e839b3a 100644 --- a/src/components/application_manager/src/request_info.cc +++ b/src/components/application_manager/src/request_info.cc @@ -42,12 +42,12 @@ namespace request_controller { SDL_CREATE_LOG_VARIABLE("RequestController") -uint32_t RequestInfo::HmiConnectionKey = 0; +constexpr uint32_t RequestInfo::kHmiConnectionKey; HMIRequestInfo::HMIRequestInfo(RequestPtr request, const uint64_t timeout_msec) : RequestInfo(request, HMIRequest, timeout_msec) { correlation_id_ = request_->correlation_id(); - app_id_ = RequestInfo::HmiConnectionKey; + app_id_ = RequestInfo::kHmiConnectionKey; } HMIRequestInfo::HMIRequestInfo(RequestPtr request, @@ -55,7 +55,7 @@ HMIRequestInfo::HMIRequestInfo(RequestPtr request, const uint64_t timeout_msec) : RequestInfo(request, HMIRequest, start_time, timeout_msec) { correlation_id_ = request_->correlation_id(); - app_id_ = RequestInfo::HmiConnectionKey; + app_id_ = RequestInfo::kHmiConnectionKey; } MobileRequestInfo::MobileRequestInfo(RequestPtr request, @@ -132,13 +132,13 @@ bool RequestInfoSet::Add(RequestInfoPtr request_info) { << request_info->requestId()); sync_primitives::AutoLock lock(pending_requests_lock_); CheckSetSizes(); - const std::pair& insert_resilt = + const std::pair& insert_result = hash_sorted_pending_requests_.insert(request_info); - if (insert_resilt.second == true) { - const std::pair& insert_resilt = + if (insert_result.second == true) { + const std::pair& insert_result = time_sorted_pending_requests_.insert(request_info); - DCHECK(insert_resilt.second); - if (!insert_resilt.second) { + DCHECK(insert_result.second); + if (!insert_result.second) { return false; } CheckSetSizes(); @@ -153,7 +153,7 @@ bool RequestInfoSet::Add(RequestInfoPtr request_info) { } RequestInfoPtr RequestInfoSet::Find(const uint32_t connection_key, - const uint32_t correlation_id) { + const uint32_t correlation_id) const { RequestInfoPtr result; // Request info for searching in request info set by log_n time @@ -259,7 +259,7 @@ uint32_t RequestInfoSet::RemoveByConnectionKey(uint32_t connection_key) { uint32_t RequestInfoSet::RemoveMobileRequests() { SDL_LOG_AUTO_TRACE(); return RemoveRequests(AppIdCompararator(AppIdCompararator::NotEqual, - RequestInfo::HmiConnectionKey)); + RequestInfo::kHmiConnectionKey)); } const size_t RequestInfoSet::Size() { diff --git a/src/components/application_manager/src/request_timeout_handler_impl.cc b/src/components/application_manager/src/request_timeout_handler_impl.cc new file mode 100644 index 00000000000..f246693d569 --- /dev/null +++ b/src/components/application_manager/src/request_timeout_handler_impl.cc @@ -0,0 +1,122 @@ +/* + * Copyright (c) 2020, 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/request_timeout_handler_impl.h" +#include "application_manager/message_helper.h" +#include "application_manager/request_info.h" +#include "utils/logger.h" + +SDL_CREATE_LOG_VARIABLE("RequestTimeoutHandler") + +namespace application_manager { +namespace request_controller { + +RequestTimeoutHandlerImpl::RequestTimeoutHandlerImpl( + ApplicationManager& application_manager) + : EventObserver(application_manager.event_dispatcher()) + , application_manager_(application_manager) { + subscribe_on_event(hmi_apis::FunctionID::BasicCommunication_OnResetTimeout); +} + +void RequestTimeoutHandlerImpl::AddRequest(const uint32_t hmi_correlation_id, + const Request& request) { + requests_.insert(std::make_pair(hmi_correlation_id, request)); +} + +void RequestTimeoutHandlerImpl::RemoveRequest( + const uint32_t hmi_correlation_id) { + SDL_LOG_AUTO_TRACE(); + sync_primitives::AutoLock lock(requests_lock_); + auto it = requests_.find(hmi_correlation_id); + if (it != requests_.end()) { + requests_.erase(it); + }; +} + +bool RequestTimeoutHandlerImpl::IsTimeoutUpdateRequired( + const Request& request, + const uint32_t timeout, + const hmi_apis::FunctionID::eType method_name) { + if (0 == timeout) { + SDL_LOG_WARN("Zero timeout ignored"); + return false; + } + + if (static_cast(request.hmi_function_id_) != + method_name) { + SDL_LOG_WARN("Method name does not match the hmi function id"); + return false; + } + + return true; +} + +void RequestTimeoutHandlerImpl::on_event(const event_engine::Event& event) { + SDL_LOG_AUTO_TRACE(); + const auto event_id = event.id(); + if (hmi_apis::FunctionID::BasicCommunication_OnResetTimeout == event_id) { + const smart_objects::SmartObject& message = event.smart_object(); + const auto method_name = StringToEnum( + message[strings::msg_params][strings::method_name].asString()); + + if (hmi_apis::FunctionID::INVALID_ENUM == method_name) { + SDL_LOG_WARN( + "Wrong method name received: " + << message[strings::msg_params][strings::method_name].asString()); + return; + } + uint32_t timeout = application_manager_.get_settings().default_timeout(); + if (message[strings::msg_params].keyExists(strings::reset_period)) { + timeout = message[strings::msg_params][strings::reset_period].asUInt(); + } + const auto hmi_corr_id = + message[strings::msg_params][strings::request_id].asUInt(); + auto it = requests_.find(hmi_corr_id); + if (it != requests_.end()) { + const auto& request = it->second; + if (IsTimeoutUpdateRequired(request, timeout, method_name)) { + // Add compensation time + timeout += + application_manager_.get_settings().default_timeout_compensation(); + application_manager_.UpdateRequestTimeout( + request.connection_key_, request.mob_correlation_id_, timeout); + application_manager_.UpdateRequestTimeout( + RequestInfo::kHmiConnectionKey, hmi_corr_id, timeout); + } + } else { + SDL_LOG_WARN("Timeout reset failed by " << hmi_corr_id + << ", no such mobile command"); + } + } +} +} // namespace request_controller +} // namespace application_manager diff --git a/src/components/application_manager/src/resumption/resume_ctrl_impl.cc b/src/components/application_manager/src/resumption/resume_ctrl_impl.cc index bc373d48c9e..96870c12c1c 100644 --- a/src/components/application_manager/src/resumption/resume_ctrl_impl.cc +++ b/src/components/application_manager/src/resumption/resume_ctrl_impl.cc @@ -283,10 +283,6 @@ void ResumeCtrlImpl::RemoveFromResumption(uint32_t app_id) { queue_lock_.Release(); } -bool ResumeCtrlImpl::Init(LastState&) { - return false; -} - bool ResumeCtrlImpl::SetAppHMIState( ApplicationSharedPtr application, const mobile_apis::HMILevel::eType hmi_level, diff --git a/src/components/application_manager/src/resumption/resumption_data.cc b/src/components/application_manager/src/resumption/resumption_data.cc index 95dd331b884..c72231d334d 100644 --- a/src/components/application_manager/src/resumption/resumption_data.cc +++ b/src/components/application_manager/src/resumption/resumption_data.cc @@ -132,6 +132,8 @@ smart_objects::SmartObject ResumptionData::GetApplicationGlobalProperties( PointerToSmartObj(application->menu_title()); global_properties[strings::menu_icon] = PointerToSmartObj(application->menu_icon()); + global_properties[strings::menu_layout] = + PointerToSmartObj(application->menu_layout()); return global_properties; } diff --git a/src/components/application_manager/src/resumption/resumption_data_json.cc b/src/components/application_manager/src/resumption/resumption_data_json.cc index 1f2d0f116f6..5d6d0089111 100644 --- a/src/components/application_manager/src/resumption/resumption_data_json.cc +++ b/src/components/application_manager/src/resumption/resumption_data_json.cc @@ -573,8 +573,4 @@ void ResumptionDataJson::Persist() { last_state_wrapper_->get_accessor().GetMutableData().SaveToFileSystem(); } -LastState& ResumptionDataJson::last_state() const { - return last_state_wrapper_->get_accessor().GetMutableData(); -} - } // namespace resumption diff --git a/src/components/application_manager/src/rpc_service_impl.cc b/src/components/application_manager/src/rpc_service_impl.cc index f0cd720e30c..67ff7cb6f0d 100644 --- a/src/components/application_manager/src/rpc_service_impl.cc +++ b/src/components/application_manager/src/rpc_service_impl.cc @@ -36,6 +36,7 @@ #include "application_manager/app_service_manager.h" #include "application_manager/command_factory.h" #include "application_manager/commands/command.h" +#include "application_manager/commands/command_impl.h" #include "application_manager/plugin_manager/plugin_keys.h" namespace application_manager { @@ -138,10 +139,18 @@ bool RPCServiceImpl::ManageMobileCommand( const uint32_t connection_key = static_cast( (*message)[strings::params][strings::connection_key].asUInt()); + const WindowID window_id = MessageHelper::ExtractWindowIdFromSmartObject( + (*message)[strings::msg_params]); + int32_t message_type = + (*message)[strings::params][strings::message_type].asInt(); auto app_ptr = app_manager_.application(connection_key); - if (app_ptr && app_manager_.IsAppInReconnectMode(app_ptr->device(), - app_ptr->policy_app_id())) { + if (app_ptr && + (app_manager_.IsAppInReconnectMode(app_ptr->device(), + app_ptr->policy_app_id()) || + (!app_ptr->WindowIdExists(window_id) && + mobile_apis::PredefinedWindows::DEFAULT_WINDOW == window_id && + mobile_apis::messageType::notification == message_type))) { commands_holder_.Suspend( app_ptr, CommandHolder::CommandType::kMobileCommand, source, message); return true; @@ -209,8 +218,6 @@ bool RPCServiceImpl::ManageMobileCommand( return false; } - int32_t message_type = - (*message)[strings::params][strings::message_type].asInt(); if (message_type == mobile_apis::messageType::response) { if (command->Init() && command->CheckPermissions()) { command->Run(); @@ -219,11 +226,11 @@ bool RPCServiceImpl::ManageMobileCommand( return true; } if (message_type == mobile_apis::messageType::notification) { - request_ctrl_.addNotification(command); + request_ctrl_.AddNotification(command); if (command->Init() && command->CheckPermissions()) { command->Run(); if (command->CleanUp()) { - request_ctrl_.removeNotification(command.get()); + request_ctrl_.RemoveNotification(command.get()); } // If CleanUp returned false notification should remove it self. } @@ -254,11 +261,11 @@ bool RPCServiceImpl::ManageMobileCommand( // commands will be launched from request_ctrl const request_controller::RequestController::TResult result = - request_ctrl_.addMobileRequest(command, app_hmi_level); + request_ctrl_.AddMobileRequest(command, app_hmi_level); - if (result == request_controller::RequestController::SUCCESS) { + if (result == request_controller::RequestController::TResult::SUCCESS) { SDL_LOG_DEBUG("Perform request"); - } else if (result == request_controller::RequestController:: + } else if (result == request_controller::RequestController::TResult:: TOO_MANY_PENDING_REQUESTS) { SDL_LOG_ERROR("RET Unable top perform request: " << "TOO_MANY_PENDING_REQUESTS"); @@ -277,8 +284,8 @@ bool RPCServiceImpl::ManageMobileCommand( SendMessageToMobile(response); return false; - } else if (result == - request_controller::RequestController::TOO_MANY_REQUESTS) { + } else if (result == request_controller::RequestController::TResult:: + TOO_MANY_REQUESTS) { SDL_LOG_ERROR("RET Unable to perform request: " << "TOO_MANY_REQUESTS"); @@ -297,7 +304,7 @@ bool RPCServiceImpl::ManageMobileCommand( app_ptr->usage_report().RecordRemovalsForBadBehavior(); } return false; - } else if (result == request_controller::RequestController:: + } else if (result == request_controller::RequestController::TResult:: NONE_HMI_LEVEL_MANY_REQUESTS) { SDL_LOG_ERROR("RET Unable to perform request: " << "REQUEST_WHILE_IN_NONE_HMI_LEVEL"); @@ -385,7 +392,7 @@ bool RPCServiceImpl::ManageHMICommand(const commands::MessageSharedPtr message, if (kRequest == message_type) { SDL_LOG_DEBUG("ManageHMICommand"); command->set_warning_info(warning_info); - request_ctrl_.addHMIRequest(command); + request_ctrl_.AddHMIRequest(command); } if (command->Init()) { diff --git a/src/components/application_manager/src/smart_object_keys.cc b/src/components/application_manager/src/smart_object_keys.cc index a680653d6cd..1490f9f5b1b 100644 --- a/src/components/application_manager/src/smart_object_keys.cc +++ b/src/components/application_manager/src/smart_object_keys.cc @@ -275,6 +275,13 @@ const char* vin = "vin"; const char* gearStatus = "gearStatus"; const char* prndl = "prndl"; const char* tire_pressure = "tirePressure"; +const char* pressure_telltale = "pressureTelltale"; +const char* left_front = "leftFront"; +const char* right_front = "rightFront"; +const char* left_rear = "leftRear"; +const char* right_rear = "rightRear"; +const char* inner_left_rear = "innerLeftRear"; +const char* inner_right_rear = "innerRightRear"; const char* odometer = "odometer"; const char* belt_status = "beltStatus"; const char* electronic_park_brake_status = "electronicParkBrakeStatus"; @@ -454,6 +461,10 @@ const char* const rect = "rect"; const char* const x = "x"; const char* const y = "y"; const char* const preferred_fps = "preferredFPS"; + +// OnResetTimeout +const char* const request_id = "requestID"; +const char* const reset_period = "resetPeriod"; } // namespace strings namespace hmi_interface { diff --git a/src/components/application_manager/test/CMakeLists.txt b/src/components/application_manager/test/CMakeLists.txt index cdaa770155f..596d11cfa98 100755 --- a/src/components/application_manager/test/CMakeLists.txt +++ b/src/components/application_manager/test/CMakeLists.txt @@ -72,6 +72,7 @@ set(testSources ${AM_TEST_DIR}/application_helper_test.cc ${AM_TEST_DIR}/rpc_service_impl_test.cc ${AM_TEST_DIR}/command_holder_test.cc + ${AM_TEST_DIR}/request_timeout_handler_test.cc ) set(testSourcesMockHmi diff --git a/src/components/application_manager/test/application_helper_test.cc b/src/components/application_manager/test/application_helper_test.cc index 0ef6f928f0c..1f1a76298c8 100644 --- a/src/components/application_manager/test/application_helper_test.cc +++ b/src/components/application_manager/test/application_helper_test.cc @@ -173,6 +173,7 @@ TEST_F(ApplicationHelperTest, RecallApplicationData_ExpectAppDataReset) { app_impl_->set_keyboard_props(dummy_data); app_impl_->set_menu_title(dummy_data); app_impl_->set_menu_icon(dummy_data); + app_impl_->set_menu_layout(dummy_data); const bool persistent = false; const bool downloaded = true; @@ -201,6 +202,8 @@ TEST_F(ApplicationHelperTest, RecallApplicationData_ExpectAppDataReset) { EXPECT_TRUE(menu_title->asString() == some_string); auto menu_icon = app_impl_->menu_icon(); EXPECT_TRUE(menu_icon->asString() == some_string); + auto menu_layout = app_impl_->menu_layout(); + EXPECT_TRUE(menu_layout->asString() == some_string); auto file_ptr = app_impl_->GetFile(filename); EXPECT_TRUE(NULL != file_ptr); EXPECT_TRUE(file_ptr->file_name == filename); @@ -234,6 +237,8 @@ TEST_F(ApplicationHelperTest, RecallApplicationData_ExpectAppDataReset) { EXPECT_FALSE(menu_title->asString() == some_string); menu_icon = app_impl_->menu_icon(); EXPECT_FALSE(menu_icon->asString() == some_string); + menu_layout = app_impl_->menu_layout(); + EXPECT_FALSE(menu_layout->asString() == some_string); file_ptr = app_impl_->GetFile(filename); EXPECT_TRUE(NULL == file_ptr); } diff --git a/src/components/application_manager/test/commands/command_impl_test.cc b/src/components/application_manager/test/commands/command_impl_test.cc index 734a7d91b81..b7b0801167f 100644 --- a/src/components/application_manager/test/commands/command_impl_test.cc +++ b/src/components/application_manager/test/commands/command_impl_test.cc @@ -150,7 +150,9 @@ TEST_F(CommandImplTest, GetMethods_SUCCESS) { (*msg)[strings::params][strings::function_id] = kFunctionId; (*msg)[strings::params][strings::connection_key] = kConnectionKey; - EXPECT_EQ(kDefaultTimeout_, command->default_timeout()); + const uint32_t expected_timeout = + kDefaultTimeout_ + kDefaultTimeoutCompensation_; + EXPECT_EQ(expected_timeout, command->default_timeout()); EXPECT_EQ(kCorrelationId, command->correlation_id()); EXPECT_EQ(kConnectionKey, command->connection_key()); EXPECT_EQ(kFunctionId, command->function_id()); diff --git a/src/components/application_manager/test/help_prompt_manager_test.cc b/src/components/application_manager/test/help_prompt_manager_test.cc index caff56f675d..d9fb0b82d95 100644 --- a/src/components/application_manager/test/help_prompt_manager_test.cc +++ b/src/components/application_manager/test/help_prompt_manager_test.cc @@ -57,6 +57,7 @@ const uint32_t kAppId = 10u; const uint32_t kCmdId = 1u; const std::string kPolicyAppId = "fake_app_id"; const uint32_t kTimeout = 10000u; +const uint32_t kTimeoutCompensation = 1000u; const std::string kText = "one"; const uint32_t kPosition = 1u; const std::string kFirstVrCommand = "first"; @@ -168,6 +169,8 @@ void HelpPromptManagerTest::SetUp() { .WillByDefault(ReturnRef(mock_event_dispatcher_)); ON_CALL(app_mngr_settings_, default_timeout()) .WillByDefault(ReturnRef(kTimeout)); + ON_CALL(app_mngr_settings_, default_timeout_compensation()) + .WillByDefault(ReturnRef(kTimeoutCompensation)); ON_CALL(app_mngr_settings_, app_icons_folder()) .WillByDefault(ReturnRef(kDirectoryName)); ON_CALL(app_mngr_settings_, app_storage_folder()) diff --git a/src/components/application_manager/test/include/application_manager/commands/command_request_test.h b/src/components/application_manager/test/include/application_manager/commands/command_request_test.h index 3a44d7b3ff6..b252d37181a 100644 --- a/src/components/application_manager/test/include/application_manager/commands/command_request_test.h +++ b/src/components/application_manager/test/include/application_manager/commands/command_request_test.h @@ -38,6 +38,7 @@ #include "gtest/gtest.h" #include "application_manager/commands/command_request_impl.h" +#include "application_manager/mock_request_timeout_handler.h" #include "application_manager/smart_object_keys.h" #include "application_manager/test/include/application_manager/commands/commands_test.h" #include "application_manager/test/include/application_manager/mock_event_dispatcher.h" @@ -59,6 +60,7 @@ namespace am = ::application_manager; using am::commands::Command; using am::commands::CommandRequestImpl; using am::event_engine::Event; +using test::components::application_manager_test::MockRequestTimeoutHandler; class CallRun { public: @@ -112,14 +114,17 @@ class CommandRequestTest : public CommandsTest { } MockEventDisp event_dispatcher_; + MockRequestTimeoutHandler mock_request_timeout_handler_; protected: CommandRequestTest() : CommandsTest() {} - virtual void InitCommand(const uint32_t& default_timeout) OVERRIDE { + void InitCommand(const uint32_t& default_timeout) OVERRIDE { CommandsTest::InitCommand(default_timeout); ON_CALL(CommandsTest::app_mngr_, event_dispatcher()) .WillByDefault(ReturnRef(event_dispatcher_)); + ON_CALL(CommandsTest::app_mngr_, get_request_timeout_handler()) + .WillByDefault(ReturnRef(mock_request_timeout_handler_)); } }; diff --git a/src/components/application_manager/test/include/application_manager/commands/commands_test.h b/src/components/application_manager/test/include/application_manager/commands/commands_test.h index 18afa01a883..2087ef8f289 100644 --- a/src/components/application_manager/test/include/application_manager/commands/commands_test.h +++ b/src/components/application_manager/test/include/application_manager/commands/commands_test.h @@ -146,7 +146,7 @@ class CommandsTest : public ::testing::Test { mock_policy_handler_); } - enum { kDefaultTimeout_ = 100 }; + enum { kDefaultTimeout_ = 100, kDefaultTimeoutCompensation_ = 10 }; MockAppManager app_mngr_; MockRPCService mock_rpc_service_; @@ -160,16 +160,25 @@ class CommandsTest : public ::testing::Test { protected: virtual void InitCommand(const uint32_t& timeout) { + this->InitCommand(timeout, kDefaultTimeoutCompensation_); + } + + virtual void InitCommand(const uint32_t timeout, + const uint32_t compensation) { timeout_ = timeout; + timeout_compensation_ = compensation; ON_CALL(app_mngr_, get_settings()) .WillByDefault(ReturnRef(app_mngr_settings_)); ON_CALL(app_mngr_settings_, default_timeout()) .WillByDefault(ReturnRef(timeout_)); + ON_CALL(app_mngr_settings_, default_timeout_compensation()) + .WillByDefault(ReturnRef(timeout_compensation_)); } CommandsTest() : mock_message_helper_(*am::MockMessageHelper::message_helper_mock()) - , timeout_(0) { + , timeout_(0) + , timeout_compensation_(0) { ON_CALL(app_mngr_, hmi_interfaces()) .WillByDefault(ReturnRef(mock_hmi_interfaces_)); ON_CALL(mock_hmi_interfaces_, GetInterfaceFromFunction(_)) @@ -254,6 +263,7 @@ class CommandsTest : public ::testing::Test { private: uint32_t timeout_; + uint32_t timeout_compensation_; }; MATCHER_P(MobileResultCodeIs, result_code, "") { diff --git a/src/components/application_manager/test/include/application_manager/mock_application.h b/src/components/application_manager/test/include/application_manager/mock_application.h index 2c9fe688b44..ac2a534929e 100644 --- a/src/components/application_manager/test/include/application_manager/mock_application.h +++ b/src/components/application_manager/test/include/application_manager/mock_application.h @@ -253,6 +253,7 @@ class MockApplication : public ::application_manager::Application { MOCK_CONST_METHOD0(keyboard_props, const smart_objects::SmartObject*()); MOCK_CONST_METHOD0(menu_title, const smart_objects::SmartObject*()); MOCK_CONST_METHOD0(menu_icon, const smart_objects::SmartObject*()); + MOCK_CONST_METHOD0(menu_layout, const smart_objects::SmartObject*()); MOCK_CONST_METHOD0(day_color_scheme, smart_objects::SmartObject()); MOCK_CONST_METHOD0(night_color_scheme, smart_objects::SmartObject()); MOCK_CONST_METHOD0(display_layout, std::string()); @@ -305,6 +306,8 @@ class MockApplication : public ::application_manager::Application { void(const smart_objects::SmartObject& menu_title)); MOCK_METHOD1(set_menu_icon, void(const smart_objects::SmartObject& menu_icon)); + MOCK_METHOD1(set_menu_layout, + void(const smart_objects::SmartObject& menu_layout)); MOCK_METHOD1(set_day_color_scheme, void(const smart_objects::SmartObject& color_scheme)); MOCK_METHOD1(set_night_color_scheme, diff --git a/src/components/application_manager/test/include/application_manager/mock_hmi_capabilities.h b/src/components/application_manager/test/include/application_manager/mock_hmi_capabilities.h index e40197cc13f..f0da952d18d 100644 --- a/src/components/application_manager/test/include/application_manager/mock_hmi_capabilities.h +++ b/src/components/application_manager/test/include/application_manager/mock_hmi_capabilities.h @@ -205,9 +205,6 @@ class MockHMICapabilities : public ::application_manager::HMICapabilities { set_seat_location_capability, void(const smart_objects::SmartObject& seat_location_capability)); - DEPRECATED - MOCK_METHOD1(Init, void(resumption::LastState* last_state)); - MOCK_METHOD1(Init, void(resumption::LastStateWrapperPtr last_state_wrapper)); MOCK_CONST_METHOD0(ccpu_version, const std::string&()); diff --git a/src/components/application_manager/test/include/application_manager/mock_message_helper.h b/src/components/application_manager/test/include/application_manager/mock_message_helper.h index a5365f49499..9e69b0bcd6f 100644 --- a/src/components/application_manager/test/include/application_manager/mock_message_helper.h +++ b/src/components/application_manager/test/include/application_manager/mock_message_helper.h @@ -395,6 +395,10 @@ class MockMessageHelper { application_manager::ApplicationManager& app_mngr, const application_manager::WindowID window_id)); + MOCK_METHOD2(AddDefaultParamsToTireStatus, + void(application_manager::ApplicationSharedPtr application, + smart_objects::SmartObject& response_from_hmi)); + static MockMessageHelper* message_helper_mock(); }; diff --git a/src/components/application_manager/test/include/application_manager/mock_resume_ctrl.h b/src/components/application_manager/test/include/application_manager/mock_resume_ctrl.h index c2c02a1d0c6..ed7d08e850d 100644 --- a/src/components/application_manager/test/include/application_manager/mock_resume_ctrl.h +++ b/src/components/application_manager/test/include/application_manager/mock_resume_ctrl.h @@ -86,8 +86,7 @@ class MockResumeCtrl : public resumption::ResumeCtrl { MOCK_METHOD1(OnAppActivated, void(app_mngr::ApplicationSharedPtr application)); MOCK_METHOD1(RemoveFromResumption, void(uint32_t app_id)); - DEPRECATED - MOCK_METHOD1(Init, bool(resumption::LastState& last_state)); + MOCK_METHOD1(Init, bool(resumption::LastStateWrapperPtr last_state)); MOCK_METHOD2(OnAppRegistrationStart, void(const std::string& policy_app_id, diff --git a/src/components/application_manager/test/message_helper/message_helper_test.cc b/src/components/application_manager/test/message_helper/message_helper_test.cc index d2dc8f3528b..4b36647a112 100644 --- a/src/components/application_manager/test/message_helper/message_helper_test.cc +++ b/src/components/application_manager/test/message_helper/message_helper_test.cc @@ -37,7 +37,6 @@ #include "gmock/gmock.h" #include "utils/macro.h" -#include "application_manager/commands/command_impl.h" #include "application_manager/event_engine/event_dispatcher.h" #include "application_manager/mock_application.h" #include "application_manager/mock_application_manager.h" @@ -53,6 +52,7 @@ #include "utils/custom_string.h" #include "utils/lock.h" +#include "application_manager/commands/command_impl.h" #include "policy/policy_table/types.h" #include "rpc_base/rpc_base_json_inl.h" @@ -650,7 +650,6 @@ class MessageHelperTest : public ::testing::Test { const StringArray function_id_strings; const StringArray events_id_strings; const StringArray hmi_level_strings; - const size_t delta_from_functions_id; }; diff --git a/src/components/application_manager/test/mock_message_helper.cc b/src/components/application_manager/test/mock_message_helper.cc index d32b3d31a96..02cf70e3ba3 100644 --- a/src/components/application_manager/test/mock_message_helper.cc +++ b/src/components/application_manager/test/mock_message_helper.cc @@ -686,4 +686,11 @@ smart_objects::SmartObjectSPtr MessageHelper::CreateResponseMessageFromHmi( return MockMessageHelper::message_helper_mock()->CreateResponseMessageFromHmi( function_id, correlation_id, result_code); } + +void MessageHelper::AddDefaultParamsToTireStatus( + application_manager::ApplicationSharedPtr application, + smart_objects::SmartObject& response_from_hmi) { + return MockMessageHelper::message_helper_mock()->AddDefaultParamsToTireStatus( + application, response_from_hmi); +} } // namespace application_manager diff --git a/src/components/application_manager/test/request_controller/request_controller_test.cc b/src/components/application_manager/test/request_controller/request_controller_test.cc index 992bf8e303e..ccb7788b3d5 100644 --- a/src/components/application_manager/test/request_controller/request_controller_test.cc +++ b/src/components/application_manager/test/request_controller/request_controller_test.cc @@ -33,7 +33,7 @@ #include #include "application_manager/mock_request.h" -#include "application_manager/request_controller.h" +#include "application_manager/request_controller_impl.h" #include "application_manager/request_info.h" #include "gtest/gtest.h" @@ -43,8 +43,11 @@ #include "smart_objects/smart_object.h" #include "application_manager/event_engine/event_dispatcher.h" +#include "application_manager/mock_application_manager.h" + #include "application_manager/mock_application_manager.h" #include "application_manager/mock_request_controller_settings.h" +#include "application_manager/mock_request_timeout_handler.h" #include "application_manager/policies/policy_handler.h" #include "application_manager/resumption/resume_ctrl.h" #include "application_manager/state_controller.h" @@ -56,7 +59,9 @@ namespace components { namespace request_controller_test { using ::application_manager::request_controller::RequestController; +using ::application_manager::request_controller::RequestControllerImpl; using ::application_manager::request_controller::RequestInfo; +using test::components::application_manager_test::MockRequestTimeoutHandler; using ::testing::_; using ::testing::NiceMock; @@ -65,7 +70,7 @@ using ::testing::ReturnRef; typedef NiceMock MRequest; typedef std::shared_ptr RequestPtr; -typedef std::shared_ptr RequestControllerSPtr; +typedef std::shared_ptr RequestControllerSPtr; namespace { const size_t kNumberOfRequests = 10u; @@ -103,8 +108,8 @@ class RequestControllerTestClass : public ::testing::Test { RequestControllerTestClass() { ON_CALL(mock_request_controller_settings_, thread_pool_size()) .WillByDefault(Return(kThreadPoolSize)); - request_ctrl_ = - std::make_shared(mock_request_controller_settings_); + request_ctrl_ = std::make_shared( + mock_request_controller_settings_, mock_request_timeout_handler_); } RequestPtr GetMockRequest( @@ -126,10 +131,10 @@ class RequestControllerTestClass : public ::testing::Test { const mobile_apis::HMILevel::eType& hmi_level = mobile_apis::HMILevel::INVALID_ENUM) { if (RequestInfo::RequestType::HMIRequest == request_type) { - return request_ctrl_->addHMIRequest(request); + return request_ctrl_->AddHMIRequest(request); } CallSettings(settings); - return request_ctrl_->addMobileRequest(request, hmi_level); + return request_ctrl_->AddMobileRequest(request, hmi_level); } void CallSettings(const TestSettings& settings) const { @@ -154,6 +159,7 @@ class RequestControllerTestClass : public ::testing::Test { NiceMock mock_request_controller_settings_; + MockRequestTimeoutHandler mock_request_timeout_handler_; RequestControllerSPtr request_ctrl_; RequestPtr empty_mock_request_; const TestSettings default_settings_; @@ -169,7 +175,7 @@ TEST_F(RequestControllerTestClass, .Times(1) .WillRepeatedly(NotifyTestAsyncWaiter(waiter_valid)); - EXPECT_EQ(RequestController::SUCCESS, + EXPECT_EQ(RequestController::TResult::SUCCESS, AddRequest(default_settings_, request_valid, RequestInfo::RequestType::MobileRequest, @@ -185,7 +191,7 @@ TEST_F(RequestControllerTestClass, ON_CALL(*request_dup_corr_id, Run()) .WillByDefault(NotifyTestAsyncWaiter(waiter_dup)); - EXPECT_EQ(RequestController::SUCCESS, + EXPECT_EQ(RequestController::TResult::SUCCESS, AddRequest(default_settings_, request_dup_corr_id, RequestInfo::RequestType::MobileRequest, @@ -200,7 +206,7 @@ TEST_F(RequestControllerTestClass, // app_hmi_level_none_time_scale_max_requests_ equals 0 // (in the default settings they setted to 0) for (size_t i = 0; i < kMaxRequestAmount; ++i) { - EXPECT_EQ(RequestController::SUCCESS, + EXPECT_EQ(RequestController::TResult::SUCCESS, AddRequest(default_settings_, GetMockRequest(i), RequestInfo::RequestType::MobileRequest, @@ -247,7 +253,7 @@ TEST_F(RequestControllerTestClass, IsLowVoltage_SetOnWakeUp_FALSE) { } TEST_F(RequestControllerTestClass, AddMobileRequest_SetValidData_SUCCESS) { - EXPECT_EQ(RequestController::SUCCESS, + EXPECT_EQ(RequestController::TResult::SUCCESS, AddRequest(default_settings_, GetMockRequest(), RequestInfo::RequestType::MobileRequest, @@ -256,7 +262,7 @@ TEST_F(RequestControllerTestClass, AddMobileRequest_SetValidData_SUCCESS) { TEST_F(RequestControllerTestClass, AddMobileRequest_SetInvalidData_INVALID_DATA) { - EXPECT_EQ(RequestController::INVALID_DATA, + EXPECT_EQ(RequestController::TResult::INVALID_DATA, AddRequest(default_settings_, empty_mock_request_, RequestInfo::RequestType::MobileRequest, @@ -264,14 +270,14 @@ TEST_F(RequestControllerTestClass, } TEST_F(RequestControllerTestClass, AddHMIRequest_AddRequest_SUCCESS) { - EXPECT_EQ(RequestController::SUCCESS, + EXPECT_EQ(RequestController::TResult::SUCCESS, AddRequest(default_settings_, GetMockRequest(), RequestInfo::RequestType::HMIRequest)); } TEST_F(RequestControllerTestClass, AddHMIRequest_AddInvalidData_INVALID_DATA) { - EXPECT_EQ(RequestController::INVALID_DATA, + EXPECT_EQ(RequestController::TResult::INVALID_DATA, AddRequest(default_settings_, empty_mock_request_, RequestInfo::RequestType::HMIRequest)); @@ -283,7 +289,7 @@ TEST_F(RequestControllerTestClass, OnTimer_SUCCESS) { kDefaultCorrelationID, kDefaultConnectionKey, request_timeout); auto waiter = TestAsyncWaiter::createInstance(); - EXPECT_EQ(RequestController::SUCCESS, + EXPECT_EQ(RequestController::TResult::SUCCESS, AddRequest(default_settings_, mock_request, RequestInfo::RequestType::MobileRequest)); diff --git a/src/components/application_manager/test/request_timeout_handler_test.cc b/src/components/application_manager/test/request_timeout_handler_test.cc new file mode 100644 index 00000000000..c045a653aa0 --- /dev/null +++ b/src/components/application_manager/test/request_timeout_handler_test.cc @@ -0,0 +1,306 @@ +/* + * Copyright (c) 2020, 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/request_timeout_handler_impl.h" + +#include +#include + +#include "gtest/gtest.h" + +#include "application_manager/commands/command_request_test.h" +#include "application_manager/mock_application_manager.h" +#include "application_manager/mock_event_dispatcher.h" +#include "application_manager/mock_hmi_capabilities.h" +#include "application_manager/mock_message_helper.h" +#include "application_manager/mock_request_controller.h" +#include "application_manager/policies/mock_policy_handler_interface.h" +#include "application_manager/request_info.h" +#include "sdl_rpc_plugin/commands/hmi/on_reset_timeout_notification.h" +#include "sdl_rpc_plugin/commands/mobile/subscribe_way_points_request.h" +#include "sdl_rpc_plugin/commands/mobile/unsubscribe_way_points_request.h" + +namespace test { +namespace components { +namespace request_timeout_handler_test { + +using application_manager::event_engine::Event; +using ::testing::_; +using ::testing::Mock; +using ::testing::Return; +using ::testing::ReturnRef; +using namespace application_manager::commands; +using namespace application_manager::strings; +using namespace application_manager::request_controller; +using application_manager_test::MockRequestController; +using sdl_rpc_plugin::commands::SubscribeWayPointsRequest; +using sdl_rpc_plugin::commands::UnsubscribeWayPointsRequest; + +namespace { +const uint32_t kDefaultTimeout = 10000u; +const uint32_t kDefaultTimeoutCompensation = 1000u; +const uint32_t kTimeout = 13000u; +const uint32_t kRequestId = 22; +const std::string kMethodNameSubscribeWayPoints = + "Navigation.SubscribeWayPoints"; +const std::string kMethodNameUnsubscribeWayPoints = + "Navigation.UnsubscribeWayPoints"; +const uint32_t kConnectionKey = 3u; +} // namespace + +class RequestTimeoutHandlerTest + : public commands_test::CommandRequestTest< + commands_test::CommandsTestMocks::kIsNice> { + public: + RequestTimeoutHandlerTest() + : mock_message_helper_( + application_manager::MockMessageHelper::message_helper_mock()) {} + + protected: + void SetUp() OVERRIDE { + ON_CALL(app_mngr_, event_dispatcher()) + .WillByDefault(ReturnRef(event_dispatcher_)); + ON_CALL(app_mngr_, get_request_controller()) + .WillByDefault(ReturnRef(mock_request_controller_)); + request_timeout_handler_ = + std::make_shared(app_mngr_); + Mock::VerifyAndClearExpectations(&mock_message_helper_); + } + + void TearDown() OVERRIDE { + Mock::VerifyAndClearExpectations(&mock_message_helper_); + } + + template + std::unique_ptr CreateCommand() { + ON_CALL(app_mngr_, get_settings()) + .WillByDefault(ReturnRef(app_mngr_settings_)); + ON_CALL(app_mngr_settings_, default_timeout()) + .WillByDefault(ReturnRef(kDefaultTimeout)); + ON_CALL(app_mngr_settings_, default_timeout_compensation()) + .WillByDefault(ReturnRef(kDefaultTimeoutCompensation)); + + std::shared_ptr msg = + std::make_shared( + smart_objects::SmartType_Null); + + std::unique_ptr command(new Command(msg, + app_mngr_, + mock_rpc_service_, + mock_hmi_capabilities_, + mock_policy_handler_)); + return command; + } + + application_manager::MockMessageHelper* mock_message_helper_; + MockRequestController mock_request_controller_; + std::shared_ptr request_timeout_handler_; + testing::NiceMock + mock_hmi_capabilities_; + policy_test::MockPolicyHandlerInterface mock_policy_handler_; +}; + +TEST_F(RequestTimeoutHandlerTest, OnEvent_OnResetTimeout_SUCCESS) { + // RequestTimeoutHandler works with all the commands. + // But just for testing, only SubscribeWayPointsRequest was chosen in current + // test. + std::unique_ptr command = + CreateCommand(); + MockAppPtr mock_app = CreateMockApp(); + ON_CALL(app_mngr_, application(_)).WillByDefault(Return(mock_app)); + ON_CALL(app_mngr_, IsAppSubscribedForWayPoints(Ref(*mock_app))) + .WillByDefault(Return(false)); + ON_CALL(app_mngr_, IsAnyAppSubscribedForWayPoints()) + .WillByDefault(Return(false)); + ON_CALL(app_mngr_, GetNextHMICorrelationID()) + .WillByDefault(Return(kRequestId)); + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_, _)).WillOnce(Return(true)); + + Event event(hmi_apis::FunctionID::BasicCommunication_OnResetTimeout); + smart_objects::SmartObject notification_msg; + notification_msg[msg_params][reset_period] = kTimeout; + notification_msg[msg_params][request_id] = kRequestId; + notification_msg[msg_params][method_name] = kMethodNameSubscribeWayPoints; + event.set_smart_object(notification_msg); + + ON_CALL(app_mngr_, get_settings()) + .WillByDefault(ReturnRef(app_mngr_settings_)); + ON_CALL(app_mngr_settings_, default_timeout()) + .WillByDefault(ReturnRef(kDefaultTimeout)); + ON_CALL(app_mngr_settings_, default_timeout_compensation()) + .WillByDefault(ReturnRef(kDefaultTimeoutCompensation)); + + EXPECT_CALL(app_mngr_, get_request_timeout_handler()) + .WillOnce(ReturnRef(*request_timeout_handler_)); + + EXPECT_CALL(app_mngr_, + UpdateRequestTimeout(mock_app->app_id(), + command->correlation_id(), + kTimeout + kDefaultTimeoutCompensation)); + EXPECT_CALL(app_mngr_, + UpdateRequestTimeout(RequestInfo::kHmiConnectionKey, + kRequestId, + kTimeout + kDefaultTimeoutCompensation)); + + ASSERT_TRUE(command->Init()); + command->Run(); + request_timeout_handler_->on_event(event); +} + +TEST_F(RequestTimeoutHandlerTest, OnEvent_OnResetTimeout_MissedResetPeriod) { + // RequestTimeoutHandler works with all the commands. + // But just for testing, only SubscribeWayPointsRequest was chosen in current + // test. + + std::unique_ptr command = + CreateCommand(); + MockAppPtr mock_app = CreateMockApp(); + ON_CALL(app_mngr_, application(_)).WillByDefault(Return(mock_app)); + ON_CALL(app_mngr_, IsAppSubscribedForWayPoints(Ref(*mock_app))) + .WillByDefault(Return(false)); + ON_CALL(app_mngr_, IsAnyAppSubscribedForWayPoints()) + .WillByDefault(Return(false)); + ON_CALL(app_mngr_, GetNextHMICorrelationID()) + .WillByDefault(Return(kRequestId)); + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_, _)).WillOnce(Return(true)); + + Event event(hmi_apis::FunctionID::BasicCommunication_OnResetTimeout); + smart_objects::SmartObject notification_msg; + notification_msg[msg_params][request_id] = kRequestId; + notification_msg[msg_params][method_name] = kMethodNameSubscribeWayPoints; + event.set_smart_object(notification_msg); + + ON_CALL(app_mngr_, get_settings()) + .WillByDefault(ReturnRef(app_mngr_settings_)); + ON_CALL(app_mngr_settings_, default_timeout()) + .WillByDefault(ReturnRef(kDefaultTimeout)); + ON_CALL(app_mngr_settings_, default_timeout_compensation()) + .WillByDefault(ReturnRef(kDefaultTimeoutCompensation)); + + EXPECT_CALL(app_mngr_, get_request_timeout_handler()) + .WillOnce(ReturnRef(*request_timeout_handler_)); + EXPECT_CALL( + app_mngr_, + UpdateRequestTimeout(mock_app->app_id(), + command->correlation_id(), + kDefaultTimeout + kDefaultTimeoutCompensation)); + EXPECT_CALL( + app_mngr_, + UpdateRequestTimeout(RequestInfo::kHmiConnectionKey, + kRequestId, + kDefaultTimeout + kDefaultTimeoutCompensation)); + + ASSERT_TRUE(command->Init()); + command->Run(); + request_timeout_handler_->on_event(event); +} + +TEST_F(RequestTimeoutHandlerTest, OnEvent_OnResetTimeout_InvalidRequestId) { + // RequestTimeoutHandler works with all the commands. + // But just for testing, only SubscribeWayPointsRequest was chosen in + // current test. + std::unique_ptr command = + CreateCommand(); + MockAppPtr mock_app = CreateMockApp(); + ON_CALL(app_mngr_, application(_)).WillByDefault(Return(mock_app)); + ON_CALL(app_mngr_, IsAppSubscribedForWayPoints(Ref(*mock_app))) + .WillByDefault(Return(false)); + ON_CALL(app_mngr_, IsAnyAppSubscribedForWayPoints()) + .WillByDefault(Return(false)); + ON_CALL(app_mngr_, GetNextHMICorrelationID()) + .WillByDefault(Return(kRequestId)); + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_, _)).WillOnce(Return(true)); + + Event event(hmi_apis::FunctionID::BasicCommunication_OnResetTimeout); + smart_objects::SmartObject notification_msg; + notification_msg[msg_params][reset_period] = kTimeout; + notification_msg[msg_params][method_name] = kMethodNameSubscribeWayPoints; + notification_msg[msg_params][request_id] = 0u; + event.set_smart_object(notification_msg); + + ON_CALL(app_mngr_, get_settings()) + .WillByDefault(ReturnRef(app_mngr_settings_)); + ON_CALL(app_mngr_settings_, default_timeout()) + .WillByDefault(ReturnRef(kDefaultTimeout)); + ON_CALL(app_mngr_settings_, default_timeout_compensation()) + .WillByDefault(ReturnRef(kDefaultTimeoutCompensation)); + + EXPECT_CALL(app_mngr_, get_request_timeout_handler()) + .WillOnce(ReturnRef(*request_timeout_handler_)); + EXPECT_CALL(app_mngr_, UpdateRequestTimeout(_, _, _)).Times(0); + + ASSERT_TRUE(command->Init()); + command->Run(); + request_timeout_handler_->on_event(event); +} + +TEST_F(RequestTimeoutHandlerTest, OnEvent_OnResetTimeout_InvalidMethodName) { + // RequestTimeoutHandler works with all the commands. + // But just for testing, only SubscribeWayPointsRequest was chosen in + // current test. + std::unique_ptr command = + CreateCommand(); + MockAppPtr mock_app = CreateMockApp(); + ON_CALL(app_mngr_, application(_)).WillByDefault(Return(mock_app)); + ON_CALL(app_mngr_, IsAppSubscribedForWayPoints(Ref(*mock_app))) + .WillByDefault(Return(false)); + ON_CALL(app_mngr_, IsAnyAppSubscribedForWayPoints()) + .WillByDefault(Return(false)); + ON_CALL(app_mngr_, GetNextHMICorrelationID()) + .WillByDefault(Return(kRequestId)); + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_, _)).WillOnce(Return(true)); + + Event event(hmi_apis::FunctionID::BasicCommunication_OnResetTimeout); + smart_objects::SmartObject notification_msg; + notification_msg[msg_params][reset_period] = kTimeout; + notification_msg[msg_params][method_name] = " "; + notification_msg[msg_params][request_id] = kRequestId; + event.set_smart_object(notification_msg); + + ON_CALL(app_mngr_, get_settings()) + .WillByDefault(ReturnRef(app_mngr_settings_)); + ON_CALL(app_mngr_settings_, default_timeout()) + .WillByDefault(ReturnRef(kDefaultTimeout)); + ON_CALL(app_mngr_settings_, default_timeout_compensation()) + .WillByDefault(ReturnRef(kDefaultTimeoutCompensation)); + + EXPECT_CALL(app_mngr_, get_request_timeout_handler()) + .WillOnce(ReturnRef(*request_timeout_handler_)); + EXPECT_CALL(app_mngr_, UpdateRequestTimeout(_, _, _)).Times(0); + + ASSERT_TRUE(command->Init()); + command->Run(); + request_timeout_handler_->on_event(event); +} +} // namespace request_timeout_handler_test +} // namespace components +} // namespace test diff --git a/src/components/application_manager/test/rpc_service_impl_test.cc b/src/components/application_manager/test/rpc_service_impl_test.cc index 0a7cff031d0..76f1f053420 100644 --- a/src/components/application_manager/test/rpc_service_impl_test.cc +++ b/src/components/application_manager/test/rpc_service_impl_test.cc @@ -46,11 +46,13 @@ #include "application_manager/mock_message_helper.h" #include "application_manager/mock_request.h" #include "application_manager/mock_request_controller_settings.h" +#include "application_manager/mock_request_timeout_handler.h" #include "application_manager/mock_rpc_plugin.h" #include "application_manager/mock_rpc_plugin_manager.h" #include "application_manager/mock_rpc_protection_manager.h" #include "application_manager/plugin_manager/plugin_keys.h" #include "application_manager/policies/mock_policy_handler_interface.h" +#include "application_manager/request_controller_impl.h" #include "connection_handler/mock_connection_handler.h" #include "hmi_message_handler/mock_hmi_message_handler.h" #include "include/test/protocol_handler/mock_protocol_handler.h" @@ -66,6 +68,7 @@ using test::components::protocol_handler_test::MockProtocolHandler; typedef smart_objects::SmartObjectSPtr MessageSharedPtr; typedef utils::Optional PluginOpt; using test::components::application_manager_test::MockAppServiceManager; +using test::components::application_manager_test::MockRequestTimeoutHandler; using ::testing::_; using ::testing::NiceMock; using ::testing::Return; @@ -86,7 +89,8 @@ const int32_t kConnectionSessionsCount = 2; class RPCServiceImplTest : public ::testing::Test { public: RPCServiceImplTest() - : request_controller_(mock_request_controler_) + : request_controller_(mock_request_controler_, + mock_request_timeout_handler_) , mock_rpc_protection_manager_( std::make_shared< testing::NiceMock >()) @@ -145,7 +149,7 @@ class RPCServiceImplTest : public ::testing::Test { testing::NiceMock mock_app_mngr_; testing::NiceMock mock_request_controler_; testing::NiceMock mock_protocol_handler_; - am::request_controller::RequestController request_controller_; + am::request_controller::RequestControllerImpl request_controller_; testing::NiceMock mock_hmi_handler_; testing::NiceMock mock_command_holder_; std::shared_ptr mock_rpc_protection_manager_; @@ -157,6 +161,7 @@ class RPCServiceImplTest : public ::testing::Test { mock_rpc_plugin_manager_; testing::NiceMock mock_rpc_plugin_; testing::NiceMock mock_command_factory_; + MockRequestTimeoutHandler mock_request_timeout_handler_; }; TEST_F(RPCServiceImplTest, ManageMobileCommand_MessageIsNullPtr_False) { diff --git a/src/components/application_manager/test/zero_request_amount_test.cc b/src/components/application_manager/test/zero_request_amount_test.cc index 0166c036c15..4f943176c00 100644 --- a/src/components/application_manager/test/zero_request_amount_test.cc +++ b/src/components/application_manager/test/zero_request_amount_test.cc @@ -99,19 +99,19 @@ TEST(RequestControlTest, ZeroValuePendingRequestsAmount) { RequestController request_ctrl_; commands::Command* reg = RegisterApplication(); - request_ctrl_.addMobileRequest(reg, mobile_apis::HMILevel::HMI_FULL); + request_ctrl_.AddMobileRequest(reg, mobile_apis::HMILevel::HMI_FULL); for (uint32_t i = 0; i < big_count_of_requests_for_test_; ++i) { correlation_id = i; commands::Command* testCommand = PutFileCommand(correlation_id, connection_key); - result = request_ctrl_.addMobileRequest(testCommand, + result = request_ctrl_.AddMobileRequest(testCommand, mobile_apis::HMILevel::HMI_FULL); EXPECT_EQ(RequestController::SUCCESS, result); } commands::Command* unreg = UnregisterApplication(); - request_ctrl_.addMobileRequest(unreg, mobile_apis::HMILevel::HMI_FULL); + request_ctrl_.AddMobileRequest(unreg, mobile_apis::HMILevel::HMI_FULL); } TEST(RequestControlTest, ZeroValueAppRequestsTimeScale) { @@ -124,19 +124,19 @@ TEST(RequestControlTest, ZeroValueAppRequestsTimeScale) { RequestController request_ctrl_; commands::Command* reg = RegisterApplication(); - request_ctrl_.addMobileRequest(reg, mobile_apis::HMILevel::HMI_FULL); + request_ctrl_.AddMobileRequest(reg, mobile_apis::HMILevel::HMI_FULL); for (uint32_t i = 0; i < big_count_of_requests_for_test_; ++i) { correlation_id = i; commands::Command* testCommand = PutFileCommand(correlation_id, connection_key); - result = request_ctrl_.addMobileRequest(testCommand, + result = request_ctrl_.AddMobileRequest(testCommand, mobile_apis::HMILevel::HMI_FULL); EXPECT_EQ(RequestController::SUCCESS, result); } commands::Command* unreg = UnregisterApplication(); - request_ctrl_.addMobileRequest(unreg, mobile_apis::HMILevel::HMI_FULL); + request_ctrl_.AddMobileRequest(unreg, mobile_apis::HMILevel::HMI_FULL); } TEST(RequestControlTest, ZeroValueAppTimeScaleMaxRequests) { @@ -149,19 +149,19 @@ TEST(RequestControlTest, ZeroValueAppTimeScaleMaxRequests) { RequestController request_ctrl_; commands::Command* reg = RegisterApplication(); - request_ctrl_.addMobileRequest(reg, mobile_apis::HMILevel::HMI_FULL); + request_ctrl_.AddMobileRequest(reg, mobile_apis::HMILevel::HMI_FULL); for (uint32_t i = 0; i < big_count_of_requests_for_test_; ++i) { correlation_id = i; commands::Command* testCommand = PutFileCommand(correlation_id, connection_key); - result = request_ctrl_.addMobileRequest(testCommand, + result = request_ctrl_.AddMobileRequest(testCommand, mobile_apis::HMILevel::HMI_FULL); EXPECT_EQ(RequestController::SUCCESS, result); } commands::Command* unreg = UnregisterApplication(); - request_ctrl_.addMobileRequest(unreg, mobile_apis::HMILevel::HMI_FULL); + request_ctrl_.AddMobileRequest(unreg, mobile_apis::HMILevel::HMI_FULL); } } // namespace application_manager_test diff --git a/src/components/config_profile/include/config_profile/profile.h b/src/components/config_profile/include/config_profile/profile.h index 48ffd30ff37..bb7762721fc 100644 --- a/src/components/config_profile/include/config_profile/profile.h +++ b/src/components/config_profile/include/config_profile/profile.h @@ -249,6 +249,12 @@ class Profile : public protocol_handler::ProtocolHandlerSettings, */ const uint32_t& default_timeout() const; + /** + * @brief Default timeout compensation for waiting some extra time for + * response to mobile app + */ + const uint32_t& default_timeout_compensation() const; + /** * @brief Default timeout for waiting for resuming */ @@ -1012,6 +1018,7 @@ class Profile : public protocol_handler::ProtocolHandlerSettings, bool is_redecoding_enabled_; uint32_t max_cmd_id_; uint32_t default_timeout_; + uint32_t default_timeout_compensation_; uint32_t app_resuming_timeout_; uint32_t app_resumption_save_persistent_data_timeout_; std::string vr_help_title_; diff --git a/src/components/config_profile/src/profile.cc b/src/components/config_profile/src/profile.cc index c12deb44c87..ad624a22a9b 100644 --- a/src/components/config_profile/src/profile.cc +++ b/src/components/config_profile/src/profile.cc @@ -181,6 +181,7 @@ const char* kDeleteFileRequestKey = "DeleteFileRequest"; const char* kListFilesRequestKey = "ListFilesRequest"; const char* kListFilesResponseSizeKey = "ListFilesResponseSize"; const char* kDefaultTimeoutKey = "DefaultTimeout"; +const char* kDefaultTimeoutCompensationKey = "DefaultTimeoutCompensation"; const char* kAppResumingTimeoutKey = "ApplicationResumingTimeout"; const char* kAppSavePersistentDataTimeoutKey = "AppSavePersistentDataTimeout"; const char* kResumptionDelayBeforeIgnKey = "ResumptionDelayBeforeIgn"; @@ -359,6 +360,7 @@ const uint32_t kDefaultPutFileRequestInNone = 5; const uint32_t kDefaultDeleteFileRequestInNone = 5; const uint32_t kDefaultListFilesRequestInNone = 5; const uint32_t kDefaultTimeout = 10000; +const uint32_t kDefaultTimeoutCompensation = 1000; const uint32_t kDefaultAppResumingTimeout = 3000; const uint32_t kDefaultAppSavePersistentDataTimeout = 10000; const uint32_t kDefaultResumptionDelayBeforeIgn = 30; @@ -482,6 +484,7 @@ Profile::Profile() , is_redecoding_enabled_(false) , max_cmd_id_(kDefaultMaxCmdId) , default_timeout_(kDefaultTimeout) + , default_timeout_compensation_(kDefaultTimeoutCompensation) , app_resuming_timeout_(kDefaultAppResumingTimeout) , app_resumption_save_persistent_data_timeout_( kDefaultAppSavePersistentDataTimeout) @@ -685,6 +688,10 @@ const uint32_t& Profile::default_timeout() const { return default_timeout_; } +const uint32_t& Profile::default_timeout_compensation() const { + return default_timeout_compensation_; +} + const uint32_t& Profile::app_resuming_timeout() const { return app_resuming_timeout_; } @@ -1725,6 +1732,16 @@ void Profile::UpdateValues() { LOG_UPDATED_VALUE(default_timeout_, kDefaultTimeoutKey, kMainSection); + // Default timeout compensation + ReadUIntValue(&default_timeout_compensation_, + kDefaultTimeoutCompensation, + kMainSection, + kDefaultTimeoutCompensationKey); + + LOG_UPDATED_VALUE(default_timeout_compensation_, + kDefaultTimeoutCompensationKey, + kMainSection); + // Application resuming timeout ReadUIntValue(&app_resuming_timeout_, kDefaultAppResumingTimeout, diff --git a/src/components/include/application_manager/application_manager.h b/src/components/include/application_manager/application_manager.h index 32aaf671a18..72a322f3367 100644 --- a/src/components/include/application_manager/application_manager.h +++ b/src/components/include/application_manager/application_manager.h @@ -48,6 +48,8 @@ #include "application_manager/application_manager_settings.h" #include "application_manager/hmi_interfaces.h" #include "application_manager/plugin_manager/rpc_plugin_manager.h" +#include "application_manager/request_controller.h" +#include "application_manager/request_timeout_handler.h" #include "application_manager/state_controller.h" #include "policy/policy_types.h" @@ -87,7 +89,10 @@ class RPCService; namespace rpc_handler { class RPCHandler; } - +namespace request_controller { +class RequestTimeoutHandler; +class RequestController; +} // namespace request_controller class Application; class AppServiceManager; class StateControllerImpl; @@ -140,10 +145,6 @@ class ApplicationManager { public: virtual ~ApplicationManager() {} - DEPRECATED - virtual bool Init(resumption::LastState&, - media_manager::MediaManager* media_manager) = 0; - /** * Inits application manager */ @@ -215,9 +216,6 @@ class ApplicationManager { virtual ApplicationSharedPtr application_by_policy_id( const std::string& policy_app_id) const = 0; - DEPRECATED virtual ApplicationSharedPtr application_by_name( - const std::string& app_name) const = 0; - virtual ApplicationSharedPtr pending_application_by_policy_id( const std::string& policy_app_id) const = 0; @@ -507,6 +505,10 @@ class ApplicationManager { virtual rpc_service::RPCService& GetRPCService() const = 0; virtual rpc_handler::RPCHandler& GetRPCHandler() const = 0; + virtual request_controller::RequestTimeoutHandler& + get_request_timeout_handler() const = 0; + virtual request_controller::RequestController& get_request_controller() + const = 0; virtual bool is_stopping() const = 0; virtual bool is_audio_pass_thru_active() const = 0; @@ -729,7 +731,7 @@ class ApplicationManager { * @param mobile_correlation_id Correlation ID of the mobile request * @param new_timeout_value New timeout in milliseconds to be set */ - virtual void updateRequestTimeout(uint32_t connection_key, + virtual void UpdateRequestTimeout(uint32_t connection_key, uint32_t mobile_correlation_id, uint32_t new_timeout_value) = 0; @@ -872,11 +874,6 @@ class ApplicationManager { protocol_handler::ServiceType service_type, bool state) = 0; - DEPRECATED - virtual void OnAppStreaming(uint32_t app_id, - protocol_handler::ServiceType service_type, - const Application::StreamingState new_state) = 0; - /** * @brief CreateRegularState create regular HMI state for application * @param app Application @@ -904,9 +901,6 @@ class ApplicationManager { virtual bool CanAppStream( uint32_t app_id, protocol_handler::ServiceType service_type) const = 0; - DEPRECATED - virtual void ForbidStreaming(uint32_t app_id) = 0; - /** * @brief ForbidStreaming forbid the stream over the certain application. * @param app_id the application's id which should stop streaming. diff --git a/src/components/include/application_manager/application_manager_settings.h b/src/components/include/application_manager/application_manager_settings.h index 02cd79aa8ed..c7ab634ad02 100644 --- a/src/components/include/application_manager/application_manager_settings.h +++ b/src/components/include/application_manager/application_manager_settings.h @@ -63,6 +63,7 @@ class ApplicationManagerSettings : public RequestControlerSettings, virtual uint16_t tts_global_properties_timeout() const = 0; virtual uint16_t max_supported_protocol_version() const = 0; virtual const uint32_t& default_timeout() const = 0; + virtual const uint32_t& default_timeout_compensation() const = 0; virtual const uint32_t& max_cmd_id() const = 0; virtual bool launch_hmi() const = 0; virtual const uint32_t& delete_file_in_none() const = 0; diff --git a/src/components/include/application_manager/hmi_capabilities.h b/src/components/include/application_manager/hmi_capabilities.h index 6c593acd3b5..93cb09737d0 100644 --- a/src/components/include/application_manager/hmi_capabilities.h +++ b/src/components/include/application_manager/hmi_capabilities.h @@ -519,9 +519,6 @@ class HMICapabilities { virtual const smart_objects::SmartObjectSPtr seat_location_capability() const = 0; - DEPRECATED - virtual void Init(resumption::LastState* last_state) = 0; - virtual void Init(resumption::LastStateWrapperPtr last_state_wrapper) = 0; /** diff --git a/src/components/include/application_manager/policies/policy_handler_interface.h b/src/components/include/application_manager/policies/policy_handler_interface.h index 7ada7884bf2..d79c059b342 100644 --- a/src/components/include/application_manager/policies/policy_handler_interface.h +++ b/src/components/include/application_manager/policies/policy_handler_interface.h @@ -77,9 +77,7 @@ class PolicyHandlerInterface : public VehicleDataItemProvider { virtual bool InitPolicyTable() = 0; virtual bool ResetPolicyTable() = 0; virtual bool ClearUserConsent() = 0; - // Deprecated in favor of private variant - DEPRECATED virtual bool SendMessageToSDK(const BinaryMessage& pt_string, - const std::string& url) = 0; + virtual bool ReceiveMessageFromSDK(const std::string& file, const BinaryMessage& pt_string) = 0; virtual bool UnloadPolicyLibrary() = 0; diff --git a/src/components/include/application_manager/request_controller.h b/src/components/include/application_manager/request_controller.h new file mode 100644 index 00000000000..287493926b3 --- /dev/null +++ b/src/components/include/application_manager/request_controller.h @@ -0,0 +1,194 @@ +/* + * Copyright (c) 2020, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SRC_COMPONENTS_INCLUDE_APPLICATION_MANAGER_REQUEST_CONTROLLER_H_ +#define SRC_COMPONENTS_INCLUDE_APPLICATION_MANAGER_REQUEST_CONTROLLER_H_ + +#include "application_manager/commands/command.h" + +#include + +namespace application_manager { +namespace request_controller { + +typedef std::shared_ptr RequestPtr; +/** + * @brief RequestController class is used to control currently active mobile + * requests. + */ +class RequestController { + public: + /** + * @brief Result code for addRequest + */ + enum class TResult { + SUCCESS = 0, + TOO_MANY_REQUESTS, + TOO_MANY_PENDING_REQUESTS, + NONE_HMI_LEVEL_MANY_REQUESTS, + INVALID_DATA + }; + + /** + * @brief Thread pool state + */ + enum class TPoolState { + UNDEFINED = 0, + STARTED, + STOPPED, + }; + + /** + * @brief Class destructor + */ + virtual ~RequestController() {} + + /** + * @brief Stop request controller internal activities + */ + virtual void Stop() = 0; + + /** + * @brief Initialize thread pool + */ + virtual void InitializeThreadpool() = 0; + + /** + * @brief Destroy thread pool + */ + virtual void DestroyThreadpool() = 0; + + /** + * @brief Check if max request amount wasn't exceed and adds request to queue. + * @param request Active request to mobile + * @param hmi_level Current application hmi_level + * @return Result code + */ + virtual TResult AddMobileRequest( + const RequestPtr request, + const mobile_apis::HMILevel::eType& hmi_level) = 0; + + /** + * @brief Store HMI request until response or timeout won't remove it + * @param request Active request to hmi + * @return Result code + */ + virtual TResult AddHMIRequest(const RequestPtr request) = 0; + + /** + * @brief Add notification to collection + * @param ptr Reference to shared pointer that point on hmi notification + */ + virtual void AddNotification(const RequestPtr ptr) = 0; + + /** + * @brief Removes request from queue + * @param correlation_id Active request correlation ID, + * @param connection_key Active request connection key (0 for HMI requests) + * @param function_id Active request function id + * @param force_terminate if true, request controller will terminate + * even if not allowed by request + */ + virtual void TerminateRequest(const uint32_t correlation_id, + const uint32_t connection_key, + const int32_t function_id, + const bool force_terminate = false) = 0; + + /** + * @brief Removes request from queue + * @param mobile_correlation_id Active mobile request correlation ID + * @param connection_key Active request connection key (0 for HMI requests) + * @param function_id Active request function ID + */ + virtual void OnMobileResponse(const uint32_t mobile_correlation_id, + const uint32_t connection_key, + const int32_t function_id) = 0; + + /** + * @brief Removes request from queue + * @param mobile_correlation_id Active mobile request correlation ID + * @param function_id Active request function ID + */ + virtual void OnHMIResponse(const uint32_t correlation_id, + const int32_t function_id) = 0; + + /** + * @ Add notification to collection + * @param notification Pointer that points to hmi notification + */ + virtual void RemoveNotification(const commands::Command* notification) = 0; + + /** + * @brief Removes all requests from queue for specified application + * @param app_id Mobile application ID (app_id) + */ + virtual void TerminateAppRequests(const uint32_t app_id) = 0; + + /** + * @brief Terminates all requests from HMI + */ + virtual void TerminateAllHMIRequests() = 0; + + /** + * @brief Terminates all requests from Mobile + */ + virtual void TerminateAllMobileRequests() = 0; + + /** + * @brief Updates request timeout + * @param app_id Connection key of application + * @param mobile_correlation_id Correlation ID of the mobile request + * @param new_timeout_value New timeout to be set in milliseconds + */ + virtual void UpdateRequestTimeout(const uint32_t app_id, + const uint32_t mobile_correlation_id, + const uint32_t new_timeout) = 0; + /** + * @brief Function Should be called when Low Voltage is occured + */ + virtual void OnLowVoltage() = 0; + + /** + * @brief Function Should be called when WakeUp occures after Low Voltage + */ + virtual void OnWakeUp() = 0; + + /** + * @return true if low voltage state is active + */ + virtual bool IsLowVoltage() = 0; +}; + +} // namespace request_controller +} // namespace application_manager + +#endif // SRC_COMPONENTS_INCLUDE_APPLICATION_MANAGER_REQUEST_CONTROLLER_H_ diff --git a/src/components/include/application_manager/request_timeout_handler.h b/src/components/include/application_manager/request_timeout_handler.h new file mode 100644 index 00000000000..ef646d8a941 --- /dev/null +++ b/src/components/include/application_manager/request_timeout_handler.h @@ -0,0 +1,85 @@ +/* + * Copyright (c) 2020, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SRC_COMPONENTS_INCLUDE_APPLICATION_MANAGER_REQUEST_TIMEOUT_HANDLER_H_ +#define SRC_COMPONENTS_INCLUDE_APPLICATION_MANAGER_REQUEST_TIMEOUT_HANDLER_H_ + +#include + +namespace application_manager { +namespace request_controller { + +/* + * @brief Structure for active mobile request + * that is waiting for a response from the HMI. + * Used for OnResetTimeout logic. + */ +struct Request { + Request(const uint32_t mob_correlation_id, + const uint32_t connection_key, + const uint32_t hmi_function_id) + : mob_correlation_id_(mob_correlation_id) + , connection_key_(connection_key) + , hmi_function_id_(hmi_function_id) {} + + uint32_t mob_correlation_id_; + uint32_t connection_key_; + uint32_t hmi_function_id_; +}; + +/** + * @brief The RequestTimeoutHandler class + * handles OnResetTimeout notification from HMI, + * reset timeout for mobile request + */ +class RequestTimeoutHandler { + public: + /** + * @brief AddRequest adds request that waits for response + * @param hmi_correlation_id hmi correlation id + * @param request active mobile request + */ + virtual void AddRequest(const uint32_t hmi_correlation_id, + const Request& request) = 0; + /** + * @brief RemoveRequest removes processed request + * @param hmi_correlation_id hmi correlation id + */ + virtual void RemoveRequest(const uint32_t hmi_correlation_id) = 0; + + virtual ~RequestTimeoutHandler() {} +}; + +} // namespace request_controller +} // namespace application_manager + +#endif // SRC_COMPONENTS_INCLUDE_APPLICATION_MANAGER_REQUEST_TIMEOUT_HANDLER_H_ diff --git a/src/components/include/media_manager/media_manager.h b/src/components/include/media_manager/media_manager.h index 1ecdb122574..60c93843d1a 100644 --- a/src/components/include/media_manager/media_manager.h +++ b/src/components/include/media_manager/media_manager.h @@ -42,13 +42,6 @@ namespace media_manager { class MediaManager { public: - DEPRECATED virtual void PlayA2DPSource(int32_t application_key) = 0; - DEPRECATED virtual void StopA2DPSource(int32_t application_key) = 0; - - DEPRECATED virtual void StartMicrophoneRecording( - int32_t application_key, - const std::string& outputFileName, - int32_t duration) = 0; virtual void StartMicrophoneRecording( int32_t application_key, const std::string& outputFileName, diff --git a/src/components/include/policy/policy_external/policy/policy_manager.h b/src/components/include/policy/policy_external/policy/policy_manager.h index d9844c153bd..5d57d5ca45c 100644 --- a/src/components/include/policy/policy_external/policy/policy_manager.h +++ b/src/components/include/policy/policy_external/policy/policy_manager.h @@ -752,15 +752,6 @@ class PolicyManager : public usage_statistics::StatisticsManager, */ virtual const PolicySettings& get_settings() const = 0; - /** - * @deprecated Unused in EXTERNAL_PROPRIETARY policies - * @brief Finds the next URL that must be sent on OnSystemRequest retry - * @param urls vector of vectors that contain urls for each application - * @return Pair of policy application id and application url id from the - * urls vector - */ - DEPRECATED virtual AppIdURL GetNextUpdateUrl(const EndpointUrls& urls) = 0; - /** * @brief Assigns new HMI types for specified application * @param device_handle device identifier diff --git a/src/components/include/protocol_handler/protocol_handler.h b/src/components/include/protocol_handler/protocol_handler.h index 011592da499..2cea958bae4 100644 --- a/src/components/include/protocol_handler/protocol_handler.h +++ b/src/components/include/protocol_handler/protocol_handler.h @@ -127,22 +127,6 @@ class ProtocolHandler { virtual const ProtocolHandlerSettings& get_settings() const = 0; virtual SessionObserver& get_session_observer() = 0; - /** - * @brief Called by connection handler to notify the context of - * OnSessionStartedCallback(). - * @param context reference to structure with started session data - * @param rejected_params list of parameters name that are rejected. - * Only valid when generated_session_id is 0. Note, even if - * generated_session_id is 0, the list may be empty. - * @param err_reason string with NACK reason. Only valid when - * generated_session_id is 0. - */ - DEPRECATED - virtual void NotifySessionStarted( - const SessionContext& context, - std::vector& rejected_params, - const std::string err_reason = std::string()) = 0; - /** * @brief Called by connection handler to notify the context of * OnSessionStartedCallback(). diff --git a/src/components/include/resumption/last_state.h b/src/components/include/resumption/last_state.h index b28e5611b79..1f54959ffce 100644 --- a/src/components/include/resumption/last_state.h +++ b/src/components/include/resumption/last_state.h @@ -45,12 +45,6 @@ class LastState { */ virtual ~LastState() {} - /** - * @brief Saves dictionary to filesystem - */ - DEPRECATED - virtual void SaveStateToFileSystem() = 0; - /** * @brief SaveToFileSystem * Saving dictionary to filesystem @@ -63,12 +57,6 @@ class LastState { */ virtual void RemoveFromFileSystem() = 0; - /** - * @brief dictionary Gets internal dictionary - * @return Reference to internal dictionary json value - */ - virtual Json::Value& get_dictionary() = 0; - /** * @brief dictionary Gets internal dictionary * @return Copy of internal dictionary json value diff --git a/src/components/include/test/application_manager/mock_application_manager.h b/src/components/include/test/application_manager/mock_application_manager.h index 3b6c4170313..116d758ec40 100644 --- a/src/components/include/test/application_manager/mock_application_manager.h +++ b/src/components/include/test/application_manager/mock_application_manager.h @@ -68,10 +68,6 @@ class MockApplicationManager : public application_manager::ApplicationManager { MOCK_METHOD2(Init, bool(resumption::LastStateWrapperPtr last_state, media_manager::MediaManager* media_manager)); - DEPRECATED - MOCK_METHOD2(Init, - bool(resumption::LastState& last_state, - media_manager::MediaManager* media_manager)); MOCK_METHOD0(Stop, bool()); MOCK_METHOD1(set_hmi_message_handler, void(hmi_message_handler::HMIMessageHandler* handler)); @@ -117,9 +113,6 @@ class MockApplicationManager : public application_manager::ApplicationManager { MOCK_CONST_METHOD1(application_by_policy_id, application_manager::ApplicationSharedPtr( const std::string& policy_app_id)); - MOCK_CONST_METHOD1( - application_by_name, - application_manager::ApplicationSharedPtr(const std::string& app_name)); MOCK_CONST_METHOD1(pending_application_by_policy_id, application_manager::ApplicationSharedPtr( const std::string& policy_app_id)); @@ -195,6 +188,12 @@ class MockApplicationManager : public application_manager::ApplicationManager { application_manager::rpc_service::RPCService&()); MOCK_CONST_METHOD0(GetRPCHandler, application_manager::rpc_handler::RPCHandler&()); + MOCK_CONST_METHOD0( + get_request_timeout_handler, + application_manager::request_controller::RequestTimeoutHandler&()); + MOCK_CONST_METHOD0( + get_request_controller, + application_manager::request_controller::RequestController&()); MOCK_CONST_METHOD0(is_stopping, bool()); MOCK_CONST_METHOD0(is_audio_pass_thru_active, bool()); MOCK_METHOD0(GetNextHMICorrelationID, uint32_t()); @@ -269,7 +268,7 @@ class MockApplicationManager : public application_manager::ApplicationManager { void(const connection_handler::DeviceHandle)); MOCK_METHOD4(UnregisterApplication, void(const uint32_t&, mobile_apis::Result::eType, bool, bool)); - MOCK_METHOD3(updateRequestTimeout, + MOCK_METHOD3(UpdateRequestTimeout, void(uint32_t connection_key, uint32_t mobile_correlation_id, uint32_t new_timeout_value)); @@ -319,12 +318,6 @@ class MockApplicationManager : public application_manager::ApplicationManager { void(uint32_t app_id, protocol_handler::ServiceType service_type, bool state)); - DEPRECATED - MOCK_METHOD3( - OnAppStreaming, - void(uint32_t app_id, - protocol_handler::ServiceType service_type, - const application_manager::Application::StreamingState new_state)); MOCK_CONST_METHOD6(CreateRegularState, application_manager::HmiStatePtr( application_manager::ApplicationSharedPtr app, @@ -339,8 +332,6 @@ class MockApplicationManager : public application_manager::ApplicationManager { MOCK_CONST_METHOD2(CanAppStream, bool(uint32_t app_id, protocol_handler::ServiceType service_type)); - DEPRECATED - MOCK_METHOD1(ForbidStreaming, void(uint32_t app_id)); MOCK_METHOD2(ForbidStreaming, void(uint32_t app_id, protocol_handler::ServiceType service_type)); diff --git a/src/components/include/test/application_manager/mock_application_manager_settings.h b/src/components/include/test/application_manager/mock_application_manager_settings.h index 9a70a374a7c..b30fc098306 100644 --- a/src/components/include/test/application_manager/mock_application_manager_settings.h +++ b/src/components/include/test/application_manager/mock_application_manager_settings.h @@ -70,6 +70,7 @@ class MockApplicationManagerSettings MOCK_CONST_METHOD0(tts_global_properties_timeout, uint16_t()); MOCK_CONST_METHOD0(max_supported_protocol_version, uint16_t()); MOCK_CONST_METHOD0(default_timeout, const uint32_t&()); + MOCK_CONST_METHOD0(default_timeout_compensation, const uint32_t&()); MOCK_CONST_METHOD0(max_cmd_id, const uint32_t&()); MOCK_CONST_METHOD0(launch_hmi, bool()); MOCK_CONST_METHOD0(delete_file_in_none, const uint32_t&()); diff --git a/src/components/include/test/application_manager/mock_request_controller.h b/src/components/include/test/application_manager/mock_request_controller.h new file mode 100644 index 00000000000..5ed726b3010 --- /dev/null +++ b/src/components/include/test/application_manager/mock_request_controller.h @@ -0,0 +1,87 @@ +/* + * Copyright (c) 2020, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SRC_COMPONENTS_INCLUDE_TEST_APPLICATION_MANAGER_MOCK_REQUEST_CONTROLLER_H_ +#define SRC_COMPONENTS_INCLUDE_TEST_APPLICATION_MANAGER_MOCK_REQUEST_CONTROLLER_H_ + +#include "application_manager/request_controller.h" + +namespace test { +namespace components { +namespace application_manager_test { + +class MockRequestController + : public application_manager::request_controller::RequestController { + public: + MOCK_METHOD0(Stop, void()); + MOCK_METHOD0(InitializeThreadpool, void()); + MOCK_METHOD0(DestroyThreadpool, void()); + MOCK_METHOD2( + AddMobileRequest, + TResult(const application_manager::request_controller::RequestPtr request, + const mobile_apis::HMILevel::eType& hmi_level)); + MOCK_METHOD1(AddHMIRequest, + TResult(const application_manager::request_controller::RequestPtr + request)); + MOCK_METHOD1( + AddNotification, + void(const application_manager::request_controller::RequestPtr request)); + MOCK_METHOD4(TerminateRequest, + void(const uint32_t correlation_id, + const uint32_t connection_key, + const int32_t function_id, + bool force_terminate)); + MOCK_METHOD3(OnMobileResponse, + void(const uint32_t mobile_correlation_id, + const uint32_t connection_key, + const int32_t function_id)); + MOCK_METHOD2(OnHMIResponse, + void(const uint32_t correlation_id, const int32_t function_id)); + MOCK_METHOD1( + RemoveNotification, + void(const application_manager::commands::Command* notification)); + MOCK_METHOD1(TerminateAppRequests, void(const uint32_t app_id)); + MOCK_METHOD0(TerminateAllHMIRequests, void()); + MOCK_METHOD0(TerminateAllMobileRequests, void()); + MOCK_METHOD3(UpdateRequestTimeout, + void(const uint32_t app_id, + const uint32_t mobile_correlation_id, + const uint32_t new_timeout)); + MOCK_METHOD0(OnLowVoltage, void()); + MOCK_METHOD0(OnWakeUp, void()); + MOCK_METHOD0(IsLowVoltage, bool()); +}; +} // namespace application_manager_test +} // namespace components +} // namespace test + +#endif // SRC_COMPONENTS_INCLUDE_TEST_APPLICATION_MANAGER_MOCK_REQUEST_CONTROLLER_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_tts_reset_timeout_notification.cc b/src/components/include/test/application_manager/mock_request_timeout_handler.h similarity index 56% rename from src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_tts_reset_timeout_notification.cc rename to src/components/include/test/application_manager/mock_request_timeout_handler.h index 96f6c5cd5b5..b1492a9812d 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_tts_reset_timeout_notification.cc +++ b/src/components/include/test/application_manager/mock_request_timeout_handler.h @@ -29,43 +29,29 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ -#include "sdl_rpc_plugin/commands/hmi/on_tts_reset_timeout_notification.h" -#include "application_manager/event_engine/event.h" -#include "interfaces/HMI_API.h" -namespace sdl_rpc_plugin { -using namespace application_manager; +#ifndef SRC_COMPONENTS_INCLUDE_TEST_APPLICATION_MANAGER_MOCK_REQUEST_TIMEOUT_HANDLER_H_ +#define SRC_COMPONENTS_INCLUDE_TEST_APPLICATION_MANAGER_MOCK_REQUEST_TIMEOUT_HANDLER_H_ -namespace commands { +#include "application_manager/request_timeout_handler.h" +#include "gmock/gmock.h" -namespace hmi { +namespace test { +namespace components { +namespace application_manager_test { -SDL_CREATE_LOG_VARIABLE("Commands") +class MockRequestTimeoutHandler + : public application_manager::request_controller::RequestTimeoutHandler { + public: + MOCK_METHOD2( + AddRequest, + void(const uint32_t hmi_correlation_id, + const application_manager::request_controller::Request& request)); + MOCK_METHOD1(RemoveRequest, void(const uint32_t hmi_correlation_id)); +}; -OnTTSResetTimeoutNotification::OnTTSResetTimeoutNotification( - const application_manager::commands::MessageSharedPtr& message, - ApplicationManager& application_manager, - rpc_service::RPCService& rpc_service, - HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handle) - : NotificationFromHMI(message, - application_manager, - rpc_service, - hmi_capabilities, - policy_handle) {} +} // namespace application_manager_test +} // namespace components +} // namespace test -OnTTSResetTimeoutNotification::~OnTTSResetTimeoutNotification() {} - -void OnTTSResetTimeoutNotification::Run() { - SDL_LOG_AUTO_TRACE(); - - event_engine::Event event(hmi_apis::FunctionID::TTS_OnResetTimeout); - event.set_smart_object(*message_); - event.raise(application_manager_.event_dispatcher()); -} - -} // namespace hmi - -} // namespace commands - -} // namespace sdl_rpc_plugin +#endif // SRC_COMPONENTS_INCLUDE_TEST_APPLICATION_MANAGER_MOCK_REQUEST_TIMEOUT_HANDLER_H_ diff --git a/src/components/include/test/application_manager/mock_rpc_plugin.h b/src/components/include/test/application_manager/mock_rpc_plugin.h index 26338254284..2dba5367c64 100644 --- a/src/components/include/test/application_manager/mock_rpc_plugin.h +++ b/src/components/include/test/application_manager/mock_rpc_plugin.h @@ -16,13 +16,6 @@ class MockRPCPlugin : public RPCPlugin { HMICapabilities& hmi_capabilities, policy::PolicyHandlerInterface& policy_handler, resumption::LastStateWrapperPtr last_state)); - DEPRECATED - MOCK_METHOD5(Init, - bool(ApplicationManager& app_manager, - rpc_service::RPCService& rpc_service, - HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler, - resumption::LastState& last_state)); MOCK_METHOD2(IsAbleToProcess, bool(const int32_t function_id, const commands::Command::CommandSource message_source)); diff --git a/src/components/include/test/application_manager/policies/mock_policy_handler_interface.h b/src/components/include/test/application_manager/policies/mock_policy_handler_interface.h index af4019ce214..ca5d25ed4c3 100644 --- a/src/components/include/test/application_manager/policies/mock_policy_handler_interface.h +++ b/src/components/include/test/application_manager/policies/mock_policy_handler_interface.h @@ -53,9 +53,6 @@ class MockPolicyHandlerInterface : public policy::PolicyHandlerInterface { MOCK_METHOD0(InitPolicyTable, bool()); MOCK_METHOD0(ResetPolicyTable, bool()); MOCK_METHOD0(ClearUserConsent, bool()); - MOCK_METHOD2(SendMessageToSDK, - bool(const policy::BinaryMessage& pt_string, - const std::string& url)); MOCK_METHOD2(ReceiveMessageFromSDK, bool(const std::string& file, const policy::BinaryMessage& pt_string)); diff --git a/src/components/include/test/media_manager/mock_media_manager.h b/src/components/include/test/media_manager/mock_media_manager.h index 364c495236d..cfee287d128 100644 --- a/src/components/include/test/media_manager/mock_media_manager.h +++ b/src/components/include/test/media_manager/mock_media_manager.h @@ -41,12 +41,6 @@ namespace media_manager_test { class MockMediaManager : public media_manager::MediaManager { public: - MOCK_METHOD1(PlayA2DPSource, void(int32_t application_key)); - MOCK_METHOD1(StopA2DPSource, void(int32_t application_key)); - MOCK_METHOD3(StartMicrophoneRecording, - void(int32_t application_key, - const std::string& outputFileName, - int32_t duration)); MOCK_METHOD6(StartMicrophoneRecording, void(int32_t application_key, const std::string& outputFileName, diff --git a/src/components/include/test/resumption/mock_last_state.h b/src/components/include/test/resumption/mock_last_state.h index 99c3799a958..c646dcd2861 100644 --- a/src/components/include/test/resumption/mock_last_state.h +++ b/src/components/include/test/resumption/mock_last_state.h @@ -43,10 +43,6 @@ namespace resumption_test { class MockLastState : public resumption::LastState { public: - DEPRECATED - MOCK_METHOD0(SaveStateToFileSystem, void()); - DEPRECATED - MOCK_METHOD0(get_dictionary, Json::Value&()); MOCK_METHOD0(SaveToFileSystem, void()); MOCK_METHOD0(RemoveFromFileSystem, void()); MOCK_CONST_METHOD0(dictionary, Json::Value()); diff --git a/src/components/include/test/transport_manager/mock_transport_manager.h b/src/components/include/test/transport_manager/mock_transport_manager.h index 1920af18a32..7aa70b80619 100644 --- a/src/components/include/test/transport_manager/mock_transport_manager.h +++ b/src/components/include/test/transport_manager/mock_transport_manager.h @@ -57,8 +57,6 @@ class MockTransportManager : public ::transport_manager::TransportManager, transport_manager::TMTelemetryObserver> { public: MOCK_METHOD1(Init, int(resumption::LastStateWrapperPtr last_state)); - DEPRECATED - MOCK_METHOD1(Init, int(resumption::LastState& last_state)); MOCK_METHOD0(Reinit, int()); MOCK_METHOD0(Deinit, void()); MOCK_METHOD0(StopEventsProcessing, void()); diff --git a/src/components/include/transport_manager/transport_manager.h b/src/components/include/transport_manager/transport_manager.h index 4697bf99822..45bb159aa20 100644 --- a/src/components/include/transport_manager/transport_manager.h +++ b/src/components/include/transport_manager/transport_manager.h @@ -53,9 +53,6 @@ class TransportManager { **/ virtual ~TransportManager() {} - DEPRECATED - virtual int Init(resumption::LastState& last_state) = 0; - /** * @brief Initialize transport manager. * @return Error code. diff --git a/src/components/interfaces/HMI_API.xml b/src/components/interfaces/HMI_API.xml index 212e62c4533..f5a8ce163de 100644 --- a/src/components/interfaces/HMI_API.xml +++ b/src/components/interfaces/HMI_API.xml @@ -1809,10 +1809,10 @@ uuid of a module. "moduleId + moduleType" uniquely identify a module. - + Location of a module. - + Service area of a module. @@ -1832,7 +1832,7 @@ - + Contains a list of SeatLocation in the vehicle @@ -1880,8 +1880,8 @@ Specify the mode of a massage zone. - - + + @@ -1895,7 +1895,7 @@ The intensity or firmness of a cushion. - + @@ -1914,7 +1914,7 @@ - + @@ -1925,7 +1925,7 @@ Seat control data corresponds to "SEAT" ModuleType. - + @@ -1941,9 +1941,9 @@ - - - + + + @@ -1953,7 +1953,7 @@ It should not be used to identify a module by mobile application. - + Information about a RC module, including its id. @@ -2107,13 +2107,13 @@ Identifies the 4-alpha-character station call sign plus an optional (-FM) extension - + Used for network Application. Consists of Country Code and FCC Facility ID. Identifies the station call sign or other identifying information in the long format. - + Provides the 3-dimensional geographic station location. @@ -2157,7 +2157,7 @@ - + Read-only Station Information Service (SIS) data provides basic information about the station such as call sign, as well as information not displayable to the consumer such as the station identification number @@ -2167,7 +2167,7 @@ The short name or a short description of the radio control module. - + Information about a RC module, including its id. @@ -2293,7 +2293,7 @@ - + @@ -2322,7 +2322,7 @@ The short name or a short description of the climate control module. - + Information about a RC module, including its id. @@ -2437,7 +2437,7 @@ - + In a getter response or a notification, it is the current primary audio source of the system. In a setter request, it is the target audio source that the system shall switch to. @@ -2456,7 +2456,7 @@ Reflects the volume of audio, from 0%-100%. - + Defines the list of supported channels (band) and their current/desired settings on HMI @@ -2468,7 +2468,7 @@ It should not be used to identify a module by mobile application. - + Information about a RC module, including its id. @@ -2605,7 +2605,7 @@ - + Indicates if the status (ON/OFF) can be set remotely. App shall not use read-only values (RAMP_UP/RAMP_DOWN/UNKNOWN/INVALID) in a setInteriorVehicleData request. @@ -2630,25 +2630,25 @@ It should not be used to identify a module by mobile application. - + Information about a RC module, including its id. - + An array of available light names that are controllable. - + The name of a light or a group of lights. - + - + - + An array of LightNames and their current or desired status. No change to the status of the LightNames that are not listed in the array. @@ -2665,9 +2665,9 @@ Corresponds to "HMI_SETTINGS" ModuleType - - - + + + @@ -2677,7 +2677,7 @@ It should not be used to identify a module by mobile application. - + Information about a RC module, including its id. @@ -2702,13 +2702,13 @@ - + - + - + - + @@ -2744,7 +2744,7 @@ The name of the Button from the ButtonName enum - + Information about a RC module, including its id. @@ -2886,8 +2886,8 @@ Currently only predefined window template layouts are defined. - - + + @@ -3280,7 +3280,7 @@ The status of component volume. See ComponentVolumeStatus. - + The status of TPMS according to the particular tire. @@ -3638,7 +3638,7 @@ - + Latitude/Longitude of the location. @@ -3653,10 +3653,10 @@ Phone number of location / establishment. - + Image / icon of intended location. - + Address to be used by navigation engines for search @@ -3708,24 +3708,24 @@ The preferred frame rate per second of the head unit. The mobile application / app library may take other factors into account that constrain the frame rate lower than this value, but it should not perform streaming at a higher frame rate than this value. - + - + Used as a descriptor of what data to expect in this struct. The corresponding param to this enum should be included and the only other param included. - + Describes supported capabilities for video streaming - + An array of ImageFieldName values for which the system supports sending OnFileUpdate notifications. If you send an Image struct for that image field with a name without having uploaded the image data using PutFile that matches that name, the system will request that you upload the data with PutFile at a later point when the HMI needs it. The HMI will then display the image in the appropriate field. If not sent, assume false. @@ -3743,7 +3743,7 @@ Describes the capabilities of a single keyboard layout. - + Number of keys available for special characters, App can customize as per their needs. @@ -3753,7 +3753,7 @@ Availability of capability to mask input characters using keyboard. True: Available, False: Not Available - + Capabilities of supported keyboard layouts by HMI. @@ -3765,13 +3765,13 @@ or omitted for the main window on the main display. - + A set of all fields that support text data. See TextField - + A set of all fields that support images. See ImageField - + Provides information about image types supported by the system. @@ -3780,19 +3780,19 @@ The number of on-window custom presets available (if any); otherwise omitted. - + The number of buttons and the capabilities of each on-window button. - + The number of soft buttons available on-window and the capabilities for each button. An array of available menu layouts. If this parameter is not provided, only the `LIST` layout is assumed to be available - + Contains the head unit's capabilities for dynamic updating features declaring if the module will send dynamic update RPCs. - + See KeyboardCapabilities @@ -3800,12 +3800,12 @@ Contains information about the display capabilities. - + Informs the application how many windows the app is allowed to create per type. - + Contains a list of capabilities of all windows related to the app. Once the app has registered the capabilities of all windows are provided. @@ -3830,39 +3830,39 @@ - + - + - + - + Describes capabilities when the driver is distracted - + If included, the platform supports RC climate controls. For this baseline version, maxsize=1. i.e. only one climate control module is supported. - + If included, the platform supports RC radio controls. For this baseline version, maxsize=1. i.e. only one climate control module is supported. - + If included, the platform supports RC button controls with the included button names. - + If included, the platform supports seat controls. - + If included, the platform supports audio controls. - + If included, the platform supports hmi setting controls. - + If included, the platform supports light controls. @@ -4395,10 +4395,10 @@ - + Contains information about the locations of each seat - + Describes capabilities when the driver is distracted @@ -4471,7 +4471,7 @@ The seek next / skip previous subscription buttons' content - + If the type is TIME, this number of seconds may be present alongside the skip indicator. @@ -4789,6 +4789,27 @@ + + + HMI must send this notification to SDL for method instance for which timeout needs to be reset + + + + Id between HMI and SDL which SDL used to send the request for method in question, for which timeout needs to be reset. + + + + + Name of the function for which timeout needs to be reset + + + + + Timeout period in milliseconds, for the method for which timeout needs to be reset. + If omitted, timeout would be reset by defaultTimeout specified in smartDeviceLink.ini + + + @@ -5323,18 +5344,6 @@ - - - Sender: HMI->SDL. HMI must send this notification every 10 sec. in case the 'methodName' - results long processing on HMI - - - Id of application that concerns the 'methodName'. - - - The name of the method, the renew of timeout is required for - - @@ -6034,15 +6043,6 @@ Provides the result of operation. - - HMI must provide SDL with notifications specific to the current Turn-By-Turn client status on the module - - Id of application that invoked notifcation. - - - Currently used method name on which was triggered action - - Issued by SDL to notify HMI about capturing mic data should be started diff --git a/src/components/media_manager/include/media_manager/audio/from_mic_recorder_adapter.h b/src/components/media_manager/include/media_manager/audio/from_mic_recorder_adapter.h index 9e0a8b51231..5ecb1a6b4a2 100644 --- a/src/components/media_manager/include/media_manager/audio/from_mic_recorder_adapter.h +++ b/src/components/media_manager/include/media_manager/audio/from_mic_recorder_adapter.h @@ -53,7 +53,6 @@ class FromMicRecorderAdapter : public MediaAdapterImpl { void StopActivity(int32_t application_key); bool is_app_performing_activity(int32_t application_key) const; void set_output_file(const std::string& output_file); - DEPRECATED void set_duration(int32_t duration); void set_config(mobile_apis::SamplingRate::eType sampling_rate, mobile_apis::BitsPerSample::eType bits_per_sample, mobile_apis::AudioType::eType audio_type, diff --git a/src/components/media_manager/include/media_manager/media_manager_impl.h b/src/components/media_manager/include/media_manager/media_manager_impl.h index f8e94cbbb2e..faa51feec91 100644 --- a/src/components/media_manager/include/media_manager/media_manager_impl.h +++ b/src/components/media_manager/include/media_manager/media_manager_impl.h @@ -60,13 +60,6 @@ class MediaManagerImpl : public MediaManager, const MediaManagerSettings& settings); virtual ~MediaManagerImpl(); - DEPRECATED virtual void PlayA2DPSource(int32_t application_key); - DEPRECATED virtual void StopA2DPSource(int32_t application_key); - - DEPRECATED virtual void StartMicrophoneRecording( - int32_t application_key, - const std::string& outputFileName, - int32_t duration); virtual void StartMicrophoneRecording( int32_t application_key, const std::string& outputFileName, diff --git a/src/components/media_manager/src/media_manager_impl.cc b/src/components/media_manager/src/media_manager_impl.cc index 4fc8b38d87d..8a73101b471 100644 --- a/src/components/media_manager/src/media_manager_impl.cc +++ b/src/components/media_manager/src/media_manager_impl.cc @@ -184,39 +184,6 @@ void MediaManagerImpl::Init() { } } -void MediaManagerImpl::PlayA2DPSource(int32_t application_key) { - SDL_LOG_AUTO_TRACE(); - -#if defined(EXTENDED_MEDIA_MODE) - if (!a2dp_player_ && protocol_handler_) { - a2dp_player_ = - new A2DPSourcePlayerAdapter(protocol_handler_->get_session_observer()); - } -#endif - - if (a2dp_player_) { - a2dp_player_->StartActivity(application_key); - } -} - -void MediaManagerImpl::StopA2DPSource(int32_t application_key) { - SDL_LOG_AUTO_TRACE(); - if (a2dp_player_) { - a2dp_player_->StopActivity(application_key); - } -} - -void MediaManagerImpl::StartMicrophoneRecording(int32_t application_key, - const std::string& output_file, - int32_t duration) { - StartMicrophoneRecording(application_key, - output_file, - duration, - mobile_apis::SamplingRate::INVALID_ENUM, - mobile_apis::BitsPerSample::INVALID_ENUM, - mobile_apis::AudioType::INVALID_ENUM); -} - void MediaManagerImpl::StartMicrophoneRecording( int32_t application_key, const std::string& output_file, diff --git a/src/components/policy/policy_external/CMakeLists.txt b/src/components/policy/policy_external/CMakeLists.txt index 72f7dd7bdb4..0e3735093fd 100644 --- a/src/components/policy/policy_external/CMakeLists.txt +++ b/src/components/policy/policy_external/CMakeLists.txt @@ -132,7 +132,7 @@ if (ENABLE_LOG AND ${LOGGER_NAME} STREQUAL "LOG4CXX") target_link_libraries(Policy log4cxx -L${LOG4CXX_LIBS_DIRECTORY}) endif() -add_custom_target(copy_library_Policy ALL +add_custom_target(copy_policy_library ALL COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_BINARY_DIR}/${library_name} ${copy_destination} diff --git a/src/components/policy/policy_external/include/policy/policy_manager_impl.h b/src/components/policy/policy_external/include/policy/policy_manager_impl.h index 813af17b3f6..2be8183bfa5 100644 --- a/src/components/policy/policy_external/include/policy/policy_manager_impl.h +++ b/src/components/policy/policy_external/include/policy/policy_manager_impl.h @@ -790,14 +790,6 @@ class PolicyManagerImpl : public PolicyManager { */ const PolicySettings& get_settings() const OVERRIDE; - /** - * @brief Finds the next URL that must be sent on OnSystemRequest retry - * @param urls vector of vectors that contain urls for each application - * @return Pair of policy application id and application url id from the - * urls vector - */ - DEPRECATED AppIdURL GetNextUpdateUrl(const EndpointUrls& urls) OVERRIDE; - /** * @brief Checks if there is existing URL in the EndpointUrls vector with * index saved in the policy manager and if not, it moves to the next diff --git a/src/components/policy/policy_external/src/policy_manager_impl.cc b/src/components/policy/policy_external/src/policy_manager_impl.cc index b1e1c85490c..75920be58c0 100644 --- a/src/components/policy/policy_external/src/policy_manager_impl.cc +++ b/src/components/policy/policy_external/src/policy_manager_impl.cc @@ -2143,18 +2143,6 @@ void PolicyManagerImpl::SetDecryptedCertificate( cache_->SetDecryptedCertificate(certificate); } -AppIdURL PolicyManagerImpl::GetNextUpdateUrl(const EndpointUrls& urls) { - SDL_LOG_AUTO_TRACE(); - - const AppIdURL next_app_url = RetrySequenceUrl(retry_sequence_url_, urls); - - retry_sequence_url_.url_idx_ = next_app_url.second + 1; - retry_sequence_url_.app_idx_ = next_app_url.first; - retry_sequence_url_.policy_app_id_ = urls[next_app_url.first].app_id; - - return next_app_url; -} - AppIdURL PolicyManagerImpl::RetrySequenceUrl(const struct RetrySequenceURL& rs, const EndpointUrls& urls) const { uint32_t url_idx = rs.url_idx_; diff --git a/src/components/protocol_handler/include/protocol_handler/protocol_handler_impl.h b/src/components/protocol_handler/include/protocol_handler/protocol_handler_impl.h index 02c96fc3c7b..b036735216d 100644 --- a/src/components/protocol_handler/include/protocol_handler/protocol_handler_impl.h +++ b/src/components/protocol_handler/include/protocol_handler/protocol_handler_impl.h @@ -462,11 +462,6 @@ class ProtocolHandlerImpl * Only valid when generated_session_id is 0. Note, even if * generated_session_id is 0, the list may be empty. */ - DEPRECATED - void NotifySessionStarted(const SessionContext& context, - std::vector& rejected_params, - const std::string err_reason) OVERRIDE; - void NotifySessionStarted(SessionContext& context, std::vector& rejected_params, const std::string err_reason) OVERRIDE; diff --git a/src/components/protocol_handler/src/protocol_handler_impl.cc b/src/components/protocol_handler/src/protocol_handler_impl.cc index 2595b268865..7b5d9901ea6 100644 --- a/src/components/protocol_handler/src/protocol_handler_impl.cc +++ b/src/components/protocol_handler/src/protocol_handler_impl.cc @@ -2128,14 +2128,6 @@ void ProtocolHandlerImpl::NotifySessionStarted( } } -void ProtocolHandlerImpl::NotifySessionStarted( - const SessionContext& context, - std::vector& rejected_params, - const std::string err_reason) { - SessionContext context_copy = context; - NotifySessionStarted(context_copy, rejected_params, err_reason); -} - RESULT_CODE ProtocolHandlerImpl::HandleControlMessageHeartBeat( const ProtocolPacket& packet) { const ConnectionID connection_id = packet.connection_id(); diff --git a/src/components/resumption/include/resumption/last_state_impl.h b/src/components/resumption/include/resumption/last_state_impl.h index 5eb4050d2d8..8495c39d046 100644 --- a/src/components/resumption/include/resumption/last_state_impl.h +++ b/src/components/resumption/include/resumption/last_state_impl.h @@ -57,9 +57,6 @@ class LastStateImpl : public LastState { */ ~LastStateImpl(); - DEPRECATED - void SaveStateToFileSystem(); - /** * @brief Saving dictionary to filesystem */ @@ -76,12 +73,6 @@ class LastStateImpl : public LastState { */ Json::Value dictionary() const OVERRIDE; - /** - * @brief Get the dictionary - * @return Reference to the dictionary - */ - DEPRECATED Json::Value& get_dictionary(); - /** * @brief Resets internal dictionary * @param dictionary New dictionary json value to be set diff --git a/src/components/resumption/src/last_state_impl.cc b/src/components/resumption/src/last_state_impl.cc index 2083369a8e7..9920a1499bb 100644 --- a/src/components/resumption/src/last_state_impl.cc +++ b/src/components/resumption/src/last_state_impl.cc @@ -52,28 +52,6 @@ LastStateImpl::~LastStateImpl() { SaveToFileSystem(); } -void LastStateImpl::SaveStateToFileSystem() { - SDL_LOG_AUTO_TRACE(); - - std::string styled_string; - { - sync_primitives::AutoLock lock(dictionary_lock_); - styled_string = dictionary_.toStyledString(); - } - - const std::string full_path = - !app_storage_folder_.empty() - ? app_storage_folder_ + "/" + app_info_storage_ - : app_info_storage_; - - const std::vector char_vector_pdata(styled_string.begin(), - styled_string.end()); - DCHECK(file_system::CreateDirectoryRecursively(app_storage_folder_)); - SDL_LOG_INFO("LastState::SaveStateToFileSystem[DEPRECATED] " - << full_path << styled_string); - DCHECK(file_system::Write(full_path, char_vector_pdata)); -} - void LastStateImpl::SaveToFileSystem() { SDL_LOG_AUTO_TRACE(); @@ -124,11 +102,6 @@ Json::Value LastStateImpl::dictionary() const { return dictionary_; } -Json::Value& LastStateImpl::get_dictionary() { - sync_primitives::AutoLock lock(dictionary_lock_); - return dictionary_; -} - void LastStateImpl::set_dictionary(const Json::Value& dictionary) { DCHECK(dictionary.type() == Json::objectValue || dictionary.type() == Json::nullValue); diff --git a/src/components/transport_manager/include/transport_manager/bluetooth/bluetooth_transport_adapter.h b/src/components/transport_manager/include/transport_manager/bluetooth/bluetooth_transport_adapter.h index 5429f50f7fe..6e36877e2d4 100644 --- a/src/components/transport_manager/include/transport_manager/bluetooth/bluetooth_transport_adapter.h +++ b/src/components/transport_manager/include/transport_manager/bluetooth/bluetooth_transport_adapter.h @@ -52,10 +52,6 @@ class BluetoothTransportAdapter : public TransportAdapterImpl { BluetoothTransportAdapter(resumption::LastStateWrapperPtr last_state_wrapper, const TransportManagerSettings& settings); - DEPRECATED - BluetoothTransportAdapter(resumption::LastState&, - const TransportManagerSettings& settings); - protected: /** * @brief Return type of device. diff --git a/src/components/transport_manager/include/transport_manager/iap2_emulation/iap2_transport_adapter.h b/src/components/transport_manager/include/transport_manager/iap2_emulation/iap2_transport_adapter.h index 3dabfb39cad..4525f6b5d99 100644 --- a/src/components/transport_manager/include/transport_manager/iap2_emulation/iap2_transport_adapter.h +++ b/src/components/transport_manager/include/transport_manager/iap2_emulation/iap2_transport_adapter.h @@ -63,11 +63,6 @@ class IAP2BluetoothEmulationTransportAdapter : public TcpTransportAdapter { resumption::LastStateWrapperPtr last_state_wrapper, const TransportManagerSettings& settings); - DEPRECATED - IAP2BluetoothEmulationTransportAdapter( - const uint16_t port, - resumption::LastState& last_state_wrapper, - const TransportManagerSettings& settings); /** * @brief DeviceSwitched is called during switching from iAP2 Bluetooth to * iAP2 USB transport. @@ -113,12 +108,6 @@ class IAP2USBEmulationTransportAdapter : public TcpTransportAdapter { resumption::LastStateWrapperPtr last_state_wrapper, const TransportManagerSettings& settings); - DEPRECATED - IAP2USBEmulationTransportAdapter(const uint16_t port, - resumption::LastState&, - const TransportManagerSettings& settings) = - delete; - /** * Destructor */ diff --git a/src/components/transport_manager/include/transport_manager/tcp/tcp_transport_adapter.h b/src/components/transport_manager/include/transport_manager/tcp/tcp_transport_adapter.h index c5948062c90..1cd5c1cb7b0 100644 --- a/src/components/transport_manager/include/transport_manager/tcp/tcp_transport_adapter.h +++ b/src/components/transport_manager/include/transport_manager/tcp/tcp_transport_adapter.h @@ -53,11 +53,6 @@ class TcpTransportAdapter : public TransportAdapterImpl { resumption::LastStateWrapperPtr last_state_wrapper, const TransportManagerSettings& settings); - DEPRECATED - TcpTransportAdapter(uint16_t port, - resumption::LastState&, - const TransportManagerSettings& settings) = delete; - /** * @brief Destructor. */ diff --git a/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_impl.h b/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_impl.h index cfc886cb15a..58dd4b16db2 100644 --- a/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_impl.h +++ b/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_impl.h @@ -85,13 +85,6 @@ class TransportAdapterImpl : public TransportAdapter, resumption::LastStateWrapperPtr last_state_wrapper, const TransportManagerSettings& settings); - DEPRECATED - TransportAdapterImpl(DeviceScanner* device_scanner, - ServerConnectionFactory* server_connection_factory, - ClientConnectionListener* client_connection_listener, - resumption::LastState& last_state, - const TransportManagerSettings& settings) = delete; - /** * @brief Destructor. **/ @@ -677,10 +670,6 @@ class TransportAdapterImpl : public TransportAdapter, TMTelemetryObserver* metric_observer_; #endif // TELEMETRY_MONITOR - resumption::LastState& last_state() const { - return last_state_wrapper_->get_accessor().GetMutableData(); - } - /** * @brief Pointer to the device scanner. */ diff --git a/src/components/transport_manager/include/transport_manager/transport_manager_default.h b/src/components/transport_manager/include/transport_manager/transport_manager_default.h index 81fc92dc38d..d9407276b07 100644 --- a/src/components/transport_manager/include/transport_manager/transport_manager_default.h +++ b/src/components/transport_manager/include/transport_manager/transport_manager_default.h @@ -82,9 +82,6 @@ class TransportManagerDefault : public TransportManagerImpl { */ int Init(resumption::LastStateWrapperPtr last_state_wrapper) OVERRIDE; - DEPRECATED - int Init(resumption::LastState& last_state) OVERRIDE; - /** * @brief Destructor. */ diff --git a/src/components/transport_manager/include/transport_manager/transport_manager_impl.h b/src/components/transport_manager/include/transport_manager/transport_manager_impl.h index 85d96bac55b..b45d7cc3792 100644 --- a/src/components/transport_manager/include/transport_manager/transport_manager_impl.h +++ b/src/components/transport_manager/include/transport_manager/transport_manager_impl.h @@ -126,9 +126,6 @@ class TransportManagerImpl */ int Init(resumption::LastStateWrapperPtr last_state_wrapper) OVERRIDE; - DEPRECATED - int Init(resumption::LastState& last_state) OVERRIDE; - /** * Reinitializes transport manager * @return Error code diff --git a/src/components/transport_manager/include/transport_manager/usb/usb_aoa_adapter.h b/src/components/transport_manager/include/transport_manager/usb/usb_aoa_adapter.h index 45c6d4c0e4f..12516e769e4 100644 --- a/src/components/transport_manager/include/transport_manager/usb/usb_aoa_adapter.h +++ b/src/components/transport_manager/include/transport_manager/usb/usb_aoa_adapter.h @@ -47,10 +47,6 @@ class UsbAoaAdapter : public TransportAdapterImpl { UsbAoaAdapter(resumption::LastStateWrapperPtr last_state_wrapper, const TransportManagerSettings& settings); - DEPRECATED - UsbAoaAdapter(resumption::LastState&, - const TransportManagerSettings& settings) = delete; - virtual ~UsbAoaAdapter(); protected: diff --git a/src/components/transport_manager/src/transport_manager_default.cc b/src/components/transport_manager/src/transport_manager_default.cc index 45d0b045288..0ffb8432ea3 100644 --- a/src/components/transport_manager/src/transport_manager_default.cc +++ b/src/components/transport_manager/src/transport_manager_default.cc @@ -190,10 +190,6 @@ int TransportManagerDefault::Init( return E_SUCCESS; } -int TransportManagerDefault::Init(resumption::LastState&) { - return 1; -} - TransportManagerDefault::~TransportManagerDefault() {} } // namespace transport_manager diff --git a/src/components/transport_manager/src/transport_manager_impl.cc b/src/components/transport_manager/src/transport_manager_impl.cc index bb6f3626e12..5f4ddc9d7e3 100644 --- a/src/components/transport_manager/src/transport_manager_impl.cc +++ b/src/components/transport_manager/src/transport_manager_impl.cc @@ -582,15 +582,6 @@ int TransportManagerImpl::Init( return E_SUCCESS; } -int TransportManagerImpl::Init(resumption::LastState& last_state) { - // Last state required to initialize Transport adapters - UNUSED(last_state); - SDL_LOG_TRACE("enter"); - is_initialized_ = true; - SDL_LOG_TRACE("exit with E_SUCCESS"); - return E_SUCCESS; -} - void TransportManagerImpl::Deinit() { SDL_LOG_AUTO_TRACE(); DisconnectAllDevices(); diff --git a/src/components/transport_manager/src/websocket_server/websocket_server_transport_adapter.cc b/src/components/transport_manager/src/websocket_server/websocket_server_transport_adapter.cc index 68f23a6326b..18c6ad9be19 100644 --- a/src/components/transport_manager/src/websocket_server/websocket_server_transport_adapter.cc +++ b/src/components/transport_manager/src/websocket_server/websocket_server_transport_adapter.cc @@ -100,7 +100,9 @@ TransportAdapter::Error WebSocketServerTransportAdapter::Init() { void WebSocketServerTransportAdapter::Store() const { SDL_LOG_AUTO_TRACE(); if (webengine_device_) { - Json::Value& dictionary = last_state().get_dictionary(); + resumption::LastStateAccessor accessor = + last_state_wrapper_->get_accessor(); + Json::Value dictionary = accessor.GetData().dictionary(); if (dictionary["TransportManager"].isMember("WebsocketServerAdapter")) { SDL_LOG_DEBUG( "WebsocketServerAdapter already exists. Storing is skipped"); @@ -119,7 +121,8 @@ void WebSocketServerTransportAdapter::Store() const { bool WebSocketServerTransportAdapter::Restore() { SDL_LOG_AUTO_TRACE(); - const Json::Value& dictionary = last_state().get_dictionary(); + resumption::LastStateAccessor accessor = last_state_wrapper_->get_accessor(); + Json::Value dictionary = accessor.GetData().dictionary(); const Json::Value ws_adapter_dictionary = dictionary["TransportManager"]["WebsocketServerAdapter"]; webengine_device_id_ = diff --git a/src/components/transport_manager/test/include/transport_manager/raw_message_matcher.h b/src/components/transport_manager/test/include/transport_manager/raw_message_matcher.h index 5aedfd58aaf..4f5cbf71eb7 100644 --- a/src/components/transport_manager/test/include/transport_manager/raw_message_matcher.h +++ b/src/components/transport_manager/test/include/transport_manager/raw_message_matcher.h @@ -54,10 +54,6 @@ using namespace ::protocol_handler; class RawMessageMatcher : public MatcherInterface { public: explicit RawMessageMatcher(RawMessagePtr ptr); - - DEPRECATED - virtual bool MatchAndExplain(const RawMessagePtr msg, - MatchResultListener* listener) const; virtual void DescribeTo(std::ostream* os) const; virtual void DescribeNegationTo(std::ostream* os) const; diff --git a/src/components/transport_manager/test/include/transport_manager/transport_adapter/mock_transport_adapter_impl.h b/src/components/transport_manager/test/include/transport_manager/transport_adapter/mock_transport_adapter_impl.h index 7b1d720ba2d..4be51431d70 100644 --- a/src/components/transport_manager/test/include/transport_manager/transport_adapter/mock_transport_adapter_impl.h +++ b/src/components/transport_manager/test/include/transport_manager/transport_adapter/mock_transport_adapter_impl.h @@ -66,13 +66,6 @@ class MockTransportAdapterImpl : public TransportAdapterImpl { last_state_wrapper, settings) {} - DEPRECATED - MockTransportAdapterImpl(DeviceScanner*, - ServerConnectionFactory*, - ClientConnectionListener*, - resumption::LastState&, - const transport_manager::TransportManagerSettings&); - ConnectionSPtr FindStatedConnection(const DeviceUID& device_handle, const ApplicationHandle& app_handle) { return this->FindEstablishedConnection(device_handle, app_handle); diff --git a/src/components/transport_manager/test/transport_manager_default_test.cc b/src/components/transport_manager/test/transport_manager_default_test.cc index 67b4a0a8ba3..66cfa85ef94 100644 --- a/src/components/transport_manager/test/transport_manager_default_test.cc +++ b/src/components/transport_manager/test/transport_manager_default_test.cc @@ -210,8 +210,6 @@ void TestTransportManagerDefault::ExpectationsSettings_TM( .WillByDefault(ReturnRef(kWSServerCACertPath)); ON_CALL(*mock_last_state_, dictionary()) .WillByDefault(Return(custom_dictionary_)); - ON_CALL(*mock_last_state_, get_dictionary()) - .WillByDefault(ReturnRef(custom_dictionary_)); EXPECT_CALL(transport_manager_settings_, use_last_state()) .WillRepeatedly(Return(use_last_state)); diff --git a/src/components/utils/include/utils/file_system.h b/src/components/utils/include/utils/file_system.h index 232d9583b16..382f38e5201 100644 --- a/src/components/utils/include/utils/file_system.h +++ b/src/components/utils/include/utils/file_system.h @@ -257,9 +257,6 @@ bool ReadBinaryFile(const std::string& name, bool ReadFile(const std::string& name, std::string& result); -DEPRECATED -const std::string ConvertPathForURL(const std::string& path); - /** * @brief Create empty file * diff --git a/src/components/utils/src/file_system.cc b/src/components/utils/src/file_system.cc index f0c838a7f98..b2c1f44c53e 100644 --- a/src/components/utils/src/file_system.cc +++ b/src/components/utils/src/file_system.cc @@ -458,25 +458,6 @@ bool file_system::ReadFile(const std::string& name, std::string& result) { return true; } -const std::string file_system::ConvertPathForURL(const std::string& path) { - SDL_LOG_AUTO_TRACE(); - const std::string reserved_symbols = "!#$&'()*+,:;=?@[] "; - std::string converted_path; - - for (const auto symbol : path) { - size_t pos = reserved_symbols.find_first_of(symbol); - if (pos != std::string::npos) { - const size_t size = 100; - char percent_value[size]; - snprintf(percent_value, size, "%%%x", symbol); - converted_path += percent_value; - } else { - converted_path += symbol; - } - } - return converted_path; -} - bool file_system::CreateFile(const std::string& path) { SDL_LOG_AUTO_TRACE(); diff --git a/tools/rpc_spec b/tools/rpc_spec index 72632f94694..12c2d1dacc4 160000 --- a/tools/rpc_spec +++ b/tools/rpc_spec @@ -1 +1 @@ -Subproject commit 72632f946941d63a57ee5e99896e3eae3627f7dd +Subproject commit 12c2d1dacc4315be22bbc1f5e655f4464d9fae44