summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYana Chernysheva (GitHub) <59469418+ychernysheva@users.noreply.github.com>2021-08-11 19:56:55 +0300
committerGitHub <noreply@github.com>2021-08-11 12:56:55 -0400
commit253280549e45ed726cce9246682fe09263ef5525 (patch)
tree41b7c1b273c78dc4c505b2104cc2b04871d0c682
parent50457915a4081e8c135d6a400eb30330f0d37c9d (diff)
downloadsdl_core-253280549e45ed726cce9246682fe09263ef5525.tar.gz
[SDL-0189] Restructuring OnResetTimeout (#3726)
* Add Reset Timeout Handler, remove deprecated functionality, create Request Controller interface. * fixup! Add Reset Timeout Handler, remove deprecated functionality, create Request Controller interface. * Fix compilation errors after merge of develop branch * Remove deprecated functions from SubtleAlert request and remove redundant UTs * Add changes to HMI API * Increase timeout in case if SIVD need Consent popup * Increase timeout for ButtonPress request * Restrict timeout for Subtle Alert with soft buttons * update timeout for hmi request * careful stopping of the request controller * Fix OnResetTimeout for Alerts with soft buttons (#192) * Do not manage requests with NULL timeout * Revert double timeouts from core * Apply smaller timeout to requests * Address Livio comments * Add timeout compensation parameter Update default timeout logic accordingly for all commands. Added new file to ini file. * Fix affected unit tests * Address Livio comments * Update rpc_spec * Update rpc_spec one more time Co-authored-by: Yevhenii <dem.yevhenii@gmail.com> Co-authored-by: Yevhenii <ydementieiev@luxoft.com> Co-authored-by: Vadym Luchko (gitHub) <vluchko@luxoft.com> Co-authored-by: Vadym Luchko (GitHub) <76956836+VadymLuchko@users.noreply.github.com> Co-authored-by: Dmytro Boltovskyi (GitHub) <dboltovskyi@luxoft.com> Co-authored-by: Andrii Kalinich <AKalinich@luxoft.com>
-rw-r--r--src/appMain/smartDeviceLink.ini2
-rw-r--r--src/components/application_manager/include/application_manager/application_manager_impl.h25
-rw-r--r--src/components/application_manager/include/application_manager/commands/command_request_impl.h7
-rw-r--r--src/components/application_manager/include/application_manager/request_controller_impl.h (renamed from src/components/application_manager/include/application_manager/request_controller.h)179
-rw-r--r--src/components/application_manager/include/application_manager/request_info.h6
-rw-r--r--src/components/application_manager/include/application_manager/request_timeout_handler_impl.h75
-rw-r--r--src/components/application_manager/include/application_manager/smart_object_keys.h4
-rw-r--r--src/components/application_manager/rpc_plugins/app_service_rpc_plugin/test/commands/hmi/dummy_hmi_commands_test.cc8
-rw-r--r--src/components/application_manager/rpc_plugins/app_service_rpc_plugin/test/commands/mobile/dummy_mobile_commands_test.cc8
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/resource_allocation_manager.h13
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/resource_allocation_manager_impl.h4
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/rc_command_request.cc5
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/resource_allocation_manager_impl.cc22
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/button_press_request_test.cc2
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/rc_get_interior_vehicle_data_consent_test.cc15
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/set_interior_vehicle_data_request_test.cc2
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/include/rc_rpc_plugin/mock/mock_resource_allocation_manager.h4
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_reset_timeout_notification.h (renamed from src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_ui_reset_timeout_notification.h)20
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_tts_reset_timeout_notification.h83
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_audio_start_stream_request.cc6
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_start_stream_request.cc6
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_reset_timeout_notification.cc (renamed from src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_ui_reset_timeout_notification.cc)12
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_activate_app_request.cc4
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/alert_maneuver_request.cc10
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/alert_request.cc17
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/create_interaction_choice_set_request.cc2
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_way_points_request.cc10
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/perform_audio_pass_thru_request.cc12
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/perform_interaction_request.cc15
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/scrollable_message_request.cc10
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/slider_request.cc13
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/speak_request.cc10
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/subtle_alert_request.cc17
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/hmi_command_factory.cc10
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/dummy_hmi_commands_test.cc14
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/hmi_notifications_test.cc34
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/sdl_activate_app_request_test.cc5
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/alert_request_test.cc21
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/create_interaction_choice_set_test.cc14
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/dummy_mobile_commands_test.cc8
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/get_way_points_request_test.cc2
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/perform_audio_pass_thru_test.cc32
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/register_app_interface_request_test.cc3
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/scrollable_message_test.cc24
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/slider_test.cc16
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/speak_request_test.cc12
-rw-r--r--src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/include/vehicle_info_plugin/commands/vi_commands_test.h9
-rw-r--r--src/components/application_manager/src/application_manager_impl.cc41
-rw-r--r--src/components/application_manager/src/commands/command_impl.cc4
-rw-r--r--src/components/application_manager/src/commands/command_request_impl.cc51
-rw-r--r--src/components/application_manager/src/commands/request_from_hmi.cc4
-rw-r--r--src/components/application_manager/src/hmi_interfaces_impl.cc4
-rw-r--r--src/components/application_manager/src/request_controller_impl.cc (renamed from src/components/application_manager/src/request_controller.cc)182
-rw-r--r--src/components/application_manager/src/request_info.cc20
-rw-r--r--src/components/application_manager/src/request_timeout_handler_impl.cc122
-rw-r--r--src/components/application_manager/src/rpc_service_impl.cc19
-rw-r--r--src/components/application_manager/src/smart_object_keys.cc4
-rwxr-xr-xsrc/components/application_manager/test/CMakeLists.txt1
-rw-r--r--src/components/application_manager/test/commands/command_impl_test.cc4
-rw-r--r--src/components/application_manager/test/help_prompt_manager_test.cc3
-rw-r--r--src/components/application_manager/test/include/application_manager/commands/command_request_test.h7
-rw-r--r--src/components/application_manager/test/include/application_manager/commands/commands_test.h14
-rw-r--r--src/components/application_manager/test/message_helper/message_helper_test.cc3
-rw-r--r--src/components/application_manager/test/request_controller/request_controller_test.cc34
-rw-r--r--src/components/application_manager/test/request_timeout_handler_test.cc306
-rw-r--r--src/components/application_manager/test/rpc_service_impl_test.cc9
-rw-r--r--src/components/application_manager/test/zero_request_amount_test.cc18
-rw-r--r--src/components/config_profile/include/config_profile/profile.h7
-rw-r--r--src/components/config_profile/src/profile.cc17
-rw-r--r--src/components/include/application_manager/application_manager.h13
-rw-r--r--src/components/include/application_manager/application_manager_settings.h1
-rw-r--r--src/components/include/application_manager/request_controller.h194
-rw-r--r--src/components/include/application_manager/request_timeout_handler.h85
-rw-r--r--src/components/include/test/application_manager/mock_application_manager.h8
-rw-r--r--src/components/include/test/application_manager/mock_application_manager_settings.h1
-rw-r--r--src/components/include/test/application_manager/mock_request_controller.h87
-rw-r--r--src/components/include/test/application_manager/mock_request_timeout_handler.h (renamed from src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_tts_reset_timeout_notification.cc)54
-rw-r--r--src/components/interfaces/HMI_API.xml42
m---------tools/rpc_spec0
79 files changed, 1470 insertions, 721 deletions
diff --git a/src/appMain/smartDeviceLink.ini b/src/appMain/smartDeviceLink.ini
index d19f7ef7a1..56822db0ef 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/application_manager_impl.h b/src/components/application_manager/include/application_manager/application_manager_impl.h
index a8a41bc23a..09f2c7d4df 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"
@@ -781,14 +780,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
@@ -797,7 +796,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;
@@ -986,6 +985,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::RPCService>& rpc_service) {
rpc_service_ = std::move(rpc_service);
}
@@ -1589,8 +1600,10 @@ class ApplicationManagerImpl
connection_handler::ConnectionHandler* connection_handler_;
std::unique_ptr<policy::PolicyHandlerInterface> policy_handler_;
protocol_handler::ProtocolHandler* protocol_handler_;
+ std::unique_ptr<request_controller::RequestTimeoutHandler>
+ request_timeout_handler_;
+ std::unique_ptr<request_controller::RequestController> request_ctrl_;
std::unique_ptr<plugin_manager::RPCPluginManager> plugin_manager_;
- request_controller::RequestController request_ctrl_;
std::unique_ptr<application_manager::AppServiceManager> 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 084340ad08..727863d16d 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
@@ -419,6 +419,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/request_controller.h b/src/components/application_manager/include/application_manager/request_controller_impl.h
index 8a3c90061e..7277cdc3fa 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 <climits>
#include <list>
@@ -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 c6cf00caea..e3d5dfd491 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 0000000000..c58d09598f
--- /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 <map>
+#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<uint32_t, Request> 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/smart_object_keys.h b/src/components/application_manager/include/application_manager/smart_object_keys.h
index 5a79059f1f..b1b3c5f000 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
@@ -501,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/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 4236ac23f9..4e79bad899 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<kIsNice>::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 69bff3ad76..3c70028574 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<kIsNice>::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/resource_allocation_manager.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/resource_allocation_manager.h
index ee0bd11885..623498dac7 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
@@ -130,6 +130,19 @@ class ResourceAllocationManager {
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
* @param module_id uuid of a resource
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 0fd5449912..4361312dde 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/rc_command_request.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/rc_command_request.cc
index 12608d64c1..e179c0c0d7 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/resource_allocation_manager_impl.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/resource_allocation_manager_impl.cc
index a26cf71448..0c513cb01e 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 6c0962a557..3772a25f47 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/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 8fbaeda2f2..15b2148187 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::SmartObject>(
smart_objects::SmartType::SmartType_Array))
- , request_controller(mock_request_controler)
, rpc_protection_manager_(
std::make_shared<application_manager::MockRPCProtectionManager>())
+ , 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<application_manager::MockRPCProtectionManager>
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<RCAppExtension> 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<commands::RCGetInteriorVehicleDataConsentResponse>(
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 9b06ddb137..9ba959de29 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 fca6c9c77e..2f128d64a8 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
index 1c87f82349..57c6f55e03 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 c8bd159064..0000000000
--- 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/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 21d6282436..05d0a4e8f2 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<uint32_t, int32_t> 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 973c323ebe..c671b11282 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<uint32_t, int32_t> 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
index d8de31cfbc..ff5b2709c0 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 66ac9c458b..4de8b17b8d 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/mobile/alert_maneuver_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/alert_maneuver_request.cc
index 8728bb4403..0e0d91f05d 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 5d1a058f16..26c209bf2a 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 f3e0b67921..2f624efe76 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/get_way_points_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_way_points_request.cc
index 54b542d245..9e156bf755 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 0accdd1e76..74b474f76b 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 bb990574bd..da1f744689 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/scrollable_message_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/scrollable_message_request.cc
index 89e77d9d19..7cfe5f5414 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/slider_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/slider_request.cc
index 22935e2136..0fdc412572 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 b8de053853..f8307f8355 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 2a8e267436..8491a859e6 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 642bdc7b11..954ddb4e57 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
@@ -218,6 +218,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"
@@ -225,13 +226,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"
@@ -775,8 +774,8 @@ CommandCreator& HMICommandFactory::get_creator_factory(
case hmi_apis::FunctionID::UI_OnTouchEvent: {
return factory.GetCreator<commands::hmi::OnUITouchEventNotification>();
}
- case hmi_apis::FunctionID::UI_OnResetTimeout: {
- return factory.GetCreator<commands::hmi::OnUIResetTimeoutNotification>();
+ case hmi_apis::FunctionID::BasicCommunication_OnResetTimeout: {
+ return factory.GetCreator<commands::hmi::OnResetTimeoutNotification>();
}
case hmi_apis::FunctionID::Navigation_SetVideoConfig: {
return hmi_apis::messageType::request == message_type
@@ -875,9 +874,6 @@ CommandCreator& HMICommandFactory::get_creator_factory(
case hmi_apis::FunctionID::SDL_OnDeviceStateChanged: {
return factory.GetCreator<commands::OnDeviceStateChangedNotification>();
}
- case hmi_apis::FunctionID::TTS_OnResetTimeout: {
- return factory.GetCreator<commands::hmi::OnTTSResetTimeoutNotification>();
- }
case hmi_apis::FunctionID::BasicCommunication_OnEventChanged: {
return factory.GetCreator<commands::OnEventChangedNotification>();
}
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 5fa910b2d9..5e485adb7f 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
@@ -114,6 +114,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"
@@ -125,13 +126,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"
@@ -258,14 +257,10 @@ class HMICommandsTest : public components::commands_test::CommandRequestTest<
typedef Command CommandType;
void InitCommand(const uint32_t& timeout) OVERRIDE {
+ CommandRequestTest<kIsNice>::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_));
}
@@ -454,7 +449,6 @@ typedef Types<commands::hmi::OnButtonEventNotification,
commands::OnNaviTBTClientStateNotification,
commands::hmi::OnUIKeyBoardInputNotification,
commands::hmi::OnUITouchEventNotification,
- commands::hmi::OnUIResetTimeoutNotification,
commands::NaviStartStreamResponse,
commands::NaviStartStreamRequest,
commands::NaviStopStreamResponse,
@@ -485,7 +479,7 @@ typedef Types<commands::hmi::OnButtonEventNotification,
commands::OnReceivedPolicyUpdate,
commands::OnPolicyUpdate,
commands::OnDeviceStateChangedNotification,
- commands::hmi::OnTTSResetTimeoutNotification,
+ commands::hmi::OnResetTimeoutNotification,
commands::hmi::DialNumberResponse,
commands::hmi::DialNumberRequest,
commands::OnEventChangedNotification,
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/hmi_notifications_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/hmi_notifications_test.cc
index 5487da51a3..bb5008654a 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/hmi_notifications_test.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/hmi_notifications_test.cc
@@ -61,6 +61,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_resume_audio_source_notification.h"
#include "sdl_rpc_plugin/commands/hmi/on_sdl_close_notification.h"
#include "sdl_rpc_plugin/commands/hmi/on_sdl_consent_needed_notification.h"
@@ -72,13 +73,11 @@
#include "sdl_rpc_plugin/commands/hmi/on_system_info_changed_notification.h"
#include "sdl_rpc_plugin/commands/hmi/on_system_request_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_video_data_streaming_notification.h"
@@ -257,13 +256,9 @@ class HMICommandsNotificationsTest
MockAppServiceManager mock_app_service_manager_;
void InitCommand(const uint32_t& default_timeout) OVERRIDE {
+ CommandsTest<kIsNice>::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_));
@@ -362,12 +357,10 @@ typedef Types<
hmi_apis::FunctionID::BasicCommunication_OnAppDeactivated>,
CommandPair<OnEventChangedNotification,
hmi_apis::FunctionID::BasicCommunication_OnEventChanged>,
- CommandPair<hmi::OnTTSResetTimeoutNotification,
- hmi_apis::FunctionID::TTS_OnResetTimeout>,
+ CommandPair<hmi::OnResetTimeoutNotification,
+ hmi_apis::FunctionID::BasicCommunication_OnResetTimeout>,
CommandPair<OnTTSStartedNotification, hmi_apis::FunctionID::TTS_Started>,
CommandPair<OnTTSStoppedNotification, hmi_apis::FunctionID::TTS_Stopped>,
- CommandPair<hmi::OnUIResetTimeoutNotification,
- hmi_apis::FunctionID::UI_OnResetTimeout>,
CommandPair<OnVRStartedNotification, hmi_apis::FunctionID::VR_Started>,
CommandPair<OnVRStoppedNotification, hmi_apis::FunctionID::VR_Stopped> >
HMIOnNotificationsEventDispatcherTypes;
@@ -517,7 +510,8 @@ TEST_F(HMICommandsNotificationsTest,
std::shared_ptr<Command> command =
CreateCommand<OnAppRegisteredNotification>(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();
@@ -539,7 +533,8 @@ TEST_F(HMICommandsNotificationsTest,
std::shared_ptr<Command> command =
CreateCommand<OnAppUnregisteredNotification>(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();
@@ -561,7 +556,8 @@ TEST_F(HMICommandsNotificationsTest, OnButtonPressNotificationEventDispatcher) {
CreateCommand<hmi::OnButtonPressNotification>(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();
@@ -578,7 +574,8 @@ TEST_F(HMICommandsNotificationsTest, OnReadyNotificationEventDispatcher) {
CreateCommand<OnReadyNotification>(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();
@@ -1298,11 +1295,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 31285f5b17..a2dc705f60 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<CommandsTestMocks::kIsNice>::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/mobile/alert_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/alert_request_test.cc
index 5e1f3e4782..9130fa52a0 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<AlertRequest>(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 80abfec61d..d77e0588f8 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/dummy_mobile_commands_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/dummy_mobile_commands_test.cc
index 8f83a2dd10..201118eec0 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<CommandsTestMocks::kIsNice>::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 7f7a8b55bd..fd2bc2e51a 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 2915418d43..c7627b7e55 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 4572a6d907..99491873be 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
@@ -416,6 +416,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));
@@ -501,6 +502,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_,
@@ -802,6 +804,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));
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 6b17aa238d..443868168d 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) {
@@ -241,18 +245,6 @@ TEST_F(ScrollableMessageRequestTest, OnEvent_ReceivedUnknownEvent_UNSUCCESS) {
}
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 0450f06ee1..d9bffc6b4a 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<SliderRequest>(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 87320d3a7a..dd082a52a7 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<SpeakRequest>(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/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 ae25acea87..e7d73fc4f0 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 <const CommandsTestMocks kIsNice = CommandsTestMocks::kNotNice>
class VICommandsTest : public CommandsTest<kIsNice> {
public:
- enum { kDefaultTimeout_ = 100 };
+ enum { kDefaultTimeout_ = 100, kDefaultTimeoutCompensation_ = 10 };
template <class Command>
std::shared_ptr<Command> CreateCommandVI() {
@@ -76,7 +76,7 @@ class VICommandsTest : public CommandsTest<kIsNice> {
template <class Command>
std::shared_ptr<Command> CreateCommandVI(MessageSharedPtr& msg) {
- InitCommandVI(kDefaultTimeout_);
+ InitCommandVI(kDefaultTimeout_, kDefaultTimeoutCompensation_);
vehicle_info_plugin::VehicleInfoCommandParams params = {
CommandsTest<kIsNice>::app_mngr_,
CommandsTest<kIsNice>::mock_rpc_service_,
@@ -90,11 +90,14 @@ class VICommandsTest : public CommandsTest<kIsNice> {
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<kIsNice>::app_mngr_, get_settings())
.WillByDefault(ReturnRef(CommandsTest<kIsNice>::app_mngr_settings_));
ON_CALL(CommandsTest<kIsNice>::app_mngr_settings_, default_timeout())
.WillByDefault(ReturnRef(timeout));
+ ON_CALL(CommandsTest<kIsNice>::app_mngr_settings_,
+ default_timeout_compensation())
+ .WillByDefault(ReturnRef(compensation));
}
};
} // namespace commands_test
diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc
index f5dedc0e35..e78d6ee668 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<RPCProtectionManagerImpl>(*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_,
@@ -1714,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);
}
@@ -2476,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(
@@ -2590,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.");
@@ -2930,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);
}
@@ -2954,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);
}
@@ -3176,7 +3181,7 @@ void ApplicationManagerImpl::UnregisterAllApplications() {
if (is_ignition_off) {
resume_controller().OnIgnitionOff();
}
- request_ctrl_.terminateAllHMIRequests();
+ request_ctrl_->TerminateAllHMIRequests();
}
void ApplicationManagerImpl::RemoveAppsWaitingForRegistration(
@@ -3276,11 +3281,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;
}
@@ -3344,7 +3348,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) {
@@ -3429,7 +3434,7 @@ void ApplicationManagerImpl::OnLowVoltage() {
is_low_voltage_ = true;
resume_ctrl_->SaveLowVoltageTime();
resume_ctrl_->StopSavePersistentDataTimer();
- request_ctrl_.OnLowVoltage();
+ request_ctrl_->OnLowVoltage();
}
bool ApplicationManagerImpl::IsLowVoltage() const {
@@ -3441,7 +3446,7 @@ void ApplicationManagerImpl::OnWakeUp() {
SDL_LOG_AUTO_TRACE();
resume_ctrl_->SaveWakeUpTime();
resume_ctrl_->StartSavePersistentDataTimer();
- request_ctrl_.OnWakeUp();
+ request_ctrl_->OnWakeUp();
is_low_voltage_ = false;
}
diff --git a/src/components/application_manager/src/commands/command_impl.cc b/src/components/application_manager/src/commands/command_impl.cc
index c7b01efb7f..c6ad7b79c1 100644
--- a/src/components/application_manager/src/commands/command_impl.cc
+++ b/src/components/application_manager/src/commands/command_impl.cc
@@ -81,7 +81,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 dad2689f29..3b0c6bf98c 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<smart_objects::SmartObject>();
@@ -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);
}
@@ -913,6 +917,51 @@ void CommandRequestImpl::AddTimeOutComponentInfoToMessage(
}
}
+void CommandRequestImpl::AddRequestToTimeoutHandler(
+ const smart_objects::SmartObject& request_to_hmi) const {
+ auto function_id = static_cast<hmi_apis::FunctionID::eType>(
+ 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<hmi_apis::FunctionID::eType, helpers::EQ, helpers::ONE>(
+ 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<hmi_apis::FunctionID::eType, helpers::EQ, helpers::ONE>(
+ 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<uint32_t>(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 835df70202..467001d8db 100644
--- a/src/components/application_manager/src/commands/request_from_hmi.cc
+++ b/src/components/application_manager/src/commands/request_from_hmi.cc
@@ -214,7 +214,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;
@@ -232,7 +232,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/hmi_interfaces_impl.cc b/src/components/application_manager/src/hmi_interfaces_impl.cc
index e4fa4c936c..7365e5e081 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/request_controller.cc b/src/components/application_manager/src/request_controller_impl.cc
index d94bb0e4df..10f0f64b4e 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<RequestController>(
- this, &RequestController::TimeoutThread))
+ new timer::TimerTaskImpl<RequestControllerImpl>(
+ 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<RequestPtr>::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 b1c1d68eaa..6770e839b3 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<HashSortedRequestInfoSet::iterator, bool>& insert_resilt =
+ const std::pair<HashSortedRequestInfoSet::iterator, bool>& insert_result =
hash_sorted_pending_requests_.insert(request_info);
- if (insert_resilt.second == true) {
- const std::pair<TimeSortedRequestInfoSet::iterator, bool>& insert_resilt =
+ if (insert_result.second == true) {
+ const std::pair<TimeSortedRequestInfoSet::iterator, bool>& 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 0000000000..f246693d56
--- /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<hmi_apis::FunctionID::eType>(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<hmi_apis::FunctionID::eType>(
+ 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/rpc_service_impl.cc b/src/components/application_manager/src/rpc_service_impl.cc
index 6cb03705ab..67ff7cb6f0 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 {
@@ -225,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.
}
@@ -260,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");
@@ -283,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");
@@ -303,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");
@@ -391,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 b7c40987ad..1490f9f5b1 100644
--- a/src/components/application_manager/src/smart_object_keys.cc
+++ b/src/components/application_manager/src/smart_object_keys.cc
@@ -461,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 cdaa770155..596d11cfa9 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/commands/command_impl_test.cc b/src/components/application_manager/test/commands/command_impl_test.cc
index 734a7d91b8..b7b0801167 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 caff56f675..d9fb0b82d9 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 3a44d7b3ff..b252d37181 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<kIsNice> {
}
MockEventDisp event_dispatcher_;
+ MockRequestTimeoutHandler mock_request_timeout_handler_;
protected:
CommandRequestTest() : CommandsTest<kIsNice>() {}
- virtual void InitCommand(const uint32_t& default_timeout) OVERRIDE {
+ void InitCommand(const uint32_t& default_timeout) OVERRIDE {
CommandsTest<kIsNice>::InitCommand(default_timeout);
ON_CALL(CommandsTest<kIsNice>::app_mngr_, event_dispatcher())
.WillByDefault(ReturnRef(event_dispatcher_));
+ ON_CALL(CommandsTest<kIsNice>::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 18afa01a88..2087ef8f28 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/message_helper/message_helper_test.cc b/src/components/application_manager/test/message_helper/message_helper_test.cc
index d2dc8f3528..4b36647a11 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/request_controller/request_controller_test.cc b/src/components/application_manager/test/request_controller/request_controller_test.cc
index 992bf8e303..ccb7788b3d 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 <stdint.h>
#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"
@@ -44,7 +44,10 @@
#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<application_manager_test::MockRequest> MRequest;
typedef std::shared_ptr<MRequest> RequestPtr;
-typedef std::shared_ptr<RequestController> RequestControllerSPtr;
+typedef std::shared_ptr<RequestControllerImpl> 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<RequestController>(mock_request_controller_settings_);
+ request_ctrl_ = std::make_shared<RequestControllerImpl>(
+ 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<application_manager_test::MockRequestControlerSettings>
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 0000000000..c045a653aa
--- /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 <memory>
+#include <string>
+
+#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<RequestTimeoutHandlerImpl>(app_mngr_);
+ Mock::VerifyAndClearExpectations(&mock_message_helper_);
+ }
+
+ void TearDown() OVERRIDE {
+ Mock::VerifyAndClearExpectations(&mock_message_helper_);
+ }
+
+ template <typename Command>
+ std::unique_ptr<Command> 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<smart_objects::SmartObject> msg =
+ std::make_shared<smart_objects::SmartObject>(
+ smart_objects::SmartType_Null);
+
+ std::unique_ptr<Command> 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<RequestTimeoutHandlerImpl> request_timeout_handler_;
+ testing::NiceMock<application_manager_test::MockHMICapabilities>
+ 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<SubscribeWayPointsRequest> command =
+ CreateCommand<SubscribeWayPointsRequest>();
+ 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<SubscribeWayPointsRequest> command =
+ CreateCommand<SubscribeWayPointsRequest>();
+ 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<SubscribeWayPointsRequest> command =
+ CreateCommand<SubscribeWayPointsRequest>();
+ 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<SubscribeWayPointsRequest> command =
+ CreateCommand<SubscribeWayPointsRequest>();
+ 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 0a7cff031d..76f1f05342 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<am::plugin_manager::RPCPlugin> 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<am::MockRPCProtectionManager> >())
@@ -145,7 +149,7 @@ class RPCServiceImplTest : public ::testing::Test {
testing::NiceMock<MockApplicationManager> mock_app_mngr_;
testing::NiceMock<MockRequestControlerSettings> mock_request_controler_;
testing::NiceMock<MockProtocolHandler> mock_protocol_handler_;
- am::request_controller::RequestController request_controller_;
+ am::request_controller::RequestControllerImpl request_controller_;
testing::NiceMock<MockHMIMessageHandler> mock_hmi_handler_;
testing::NiceMock<MockCommandHolder> mock_command_holder_;
std::shared_ptr<am::MockRPCProtectionManager> mock_rpc_protection_manager_;
@@ -157,6 +161,7 @@ class RPCServiceImplTest : public ::testing::Test {
mock_rpc_plugin_manager_;
testing::NiceMock<am::plugin_manager::MockRPCPlugin> mock_rpc_plugin_;
testing::NiceMock<MockCommandFactory> 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 0166c036c1..4f943176c0 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 48ffd30ff3..bb7762721f 100644
--- a/src/components/config_profile/include/config_profile/profile.h
+++ b/src/components/config_profile/include/config_profile/profile.h
@@ -250,6 +250,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
*/
const uint32_t& app_resuming_timeout() const;
@@ -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 c12deb44c8..ad624a22a9 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 ef4da3e2d8..708bf8b048 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;
@@ -495,6 +500,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;
@@ -717,7 +726,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;
diff --git a/src/components/include/application_manager/application_manager_settings.h b/src/components/include/application_manager/application_manager_settings.h
index 02cd79aa8e..c7ab634ad0 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/request_controller.h b/src/components/include/application_manager/request_controller.h
new file mode 100644
index 0000000000..287493926b
--- /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 <memory>
+
+namespace application_manager {
+namespace request_controller {
+
+typedef std::shared_ptr<commands::Command> 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 0000000000..ef646d8a94
--- /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 <cstdint>
+
+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/test/application_manager/mock_application_manager.h b/src/components/include/test/application_manager/mock_application_manager.h
index 50fb168411..525197cb49 100644
--- a/src/components/include/test/application_manager/mock_application_manager.h
+++ b/src/components/include/test/application_manager/mock_application_manager.h
@@ -188,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());
@@ -262,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));
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 9a70a374a7..b30fc09830 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 0000000000..5ed726b301
--- /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
index 96f6c5cd5b..b1492a9812 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/interfaces/HMI_API.xml b/src/components/interfaces/HMI_API.xml
index b185b88ada..9b09f239fe 100644
--- a/src/components/interfaces/HMI_API.xml
+++ b/src/components/interfaces/HMI_API.xml
@@ -4783,6 +4783,27 @@
</function>
<function name="DialNumber" messagetype="response">
</function>
+ <function name="OnResetTimeout" messagetype="notification">
+ <description>
+ HMI must send this notification to SDL for method instance for which timeout needs to be reset
+ </description>
+ <param name="requestID" type="Integer" minvalue="0" maxvalue="65535" mandatory="true">
+ <description>
+ Id between HMI and SDL which SDL used to send the request for method in question, for which timeout needs to be reset.
+ </description>
+ </param>
+ <param name="methodName" type="String" mandatory="true">
+ <description>
+ Name of the function for which timeout needs to be reset
+ </description>
+ </param>
+ <param name="resetPeriod" type="Integer" minvalue="0" maxvalue="1000000" mandatory="false">
+ <description>
+ 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
+ </description>
+ </param>
+ </function>
<!-- Policies -->
<!-- SyncP RPC-->
@@ -5317,18 +5338,6 @@
</function>
<function name="SetGlobalProperties" messagetype="response">
</function>
- <function name="OnResetTimeout" messagetype="notification">
- <description>
- Sender: HMI->SDL. HMI must send this notification every 10 sec. in case the 'methodName'
- results long processing on HMI
- </description>
- <param name="appID" type="Integer" mandatory="true">
- <description>Id of application that concerns the 'methodName'.</description>
- </param>
- <param name="methodName" type="String" mandatory="true">
- <description>The name of the method, the renew of timeout is required for</description>
- </param>
- </function>
</interface>
<interface name="UI" version="1.5.0" date="2021-04-14">
@@ -6028,15 +6037,6 @@
<function name="ClosePopUp" messagetype="response">
<description>Provides the result of operation.</description>
</function>
- <function name="OnResetTimeout" messagetype="notification">
- <description>HMI must provide SDL with notifications specific to the current Turn-By-Turn client status on the module</description>
- <param name="appID" type="Integer" mandatory="true">
- <description>Id of application that invoked notifcation.</description>
- </param>
- <param name="methodName" type="String" mandatory="true">
- <description>Currently used method name on which was triggered action</description>
- </param>
- </function>
<function name="OnRecordStart" messagetype="notification">
<description>Issued by SDL to notify HMI about capturing mic data should be started</description>
<param name="appID" type="Integer" mandatory="true">
diff --git a/tools/rpc_spec b/tools/rpc_spec
-Subproject 44f0a419c6a43815bc095134712eab4fef352ad
+Subproject 12c2d1dacc4315be22bbc1f5e655f4464d9fae4