summaryrefslogtreecommitdiff
path: root/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src
diff options
context:
space:
mode:
authorDmitriy Boltovskiy <dboltovskyi@luxoft.com>2020-12-16 10:48:33 -0500
committerDmitriy Boltovskiy <dboltovskyi@luxoft.com>2020-12-16 10:48:33 -0500
commit2097cabea6062fd2071b7d0ecd6c5779364be806 (patch)
tree39181d259053c941a1a3ca03a01ca2a886133ad8 /src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src
parent6ef9cfb61065b10785ad4fc37f0b0b0463f86fb7 (diff)
parent04ced64614e550490e1eae4b866d5d70092a5450 (diff)
downloadsdl_core-fix/sdl_does_not_unsubscribe_from_subbuttons_after_receiving_response.tar.gz
Merge remote-tracking branch 'smart/develop' into fix/sdl_does_not_unsubscribe_from_subbuttons_after_receiving_responsefix/sdl_does_not_unsubscribe_from_subbuttons_after_receiving_response
Diffstat (limited to 'src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src')
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_navi_way_point_change_notification.cc8
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_way_point_change_notification.cc1
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_way_point_change_notification_from_mobile.cc90
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/subscribe_way_points_request.cc34
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/unsubscribe_way_points_request.cc35
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/mobile_command_factory.cc5
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/waypoints_pending_resumption_handler.cc6
7 files changed, 164 insertions, 15 deletions
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_navi_way_point_change_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_navi_way_point_change_notification.cc
index 2440e918b7..02c2ccf31b 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_navi_way_point_change_notification.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_navi_way_point_change_notification.cc
@@ -32,6 +32,8 @@
#include "sdl_rpc_plugin/commands/hmi/on_navi_way_point_change_notification.h"
+#include "application_manager/app_service_manager.h"
+
namespace sdl_rpc_plugin {
using namespace application_manager;
@@ -56,8 +58,12 @@ void OnNaviWayPointChangeNotification::Run() {
// prepare SmartObject for mobile factory
(*message_)[strings::params][strings::function_id] =
static_cast<int32_t>(mobile_apis::FunctionID::OnWayPointChangeID);
+ application_manager_.SaveWayPointsMessage(message_, 0);
- SendNotificationToMobile(message_);
+ if (application_manager_.GetAppServiceManager().FindWayPointsHandler() ==
+ nullptr) {
+ SendNotificationToMobile(message_);
+ }
}
} // namespace commands
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_way_point_change_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_way_point_change_notification.cc
index 33413f805d..4aa0d9c630 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_way_point_change_notification.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_way_point_change_notification.cc
@@ -67,7 +67,6 @@ void OnWayPointChangeNotification::Run() {
(*message_)[strings::params][strings::connection_key] = *app_id;
SendNotification();
}
- application_manager_.SaveWayPointsMessage(message_);
}
} // namespace commands
} // namespace sdl_rpc_plugin
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_way_point_change_notification_from_mobile.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_way_point_change_notification_from_mobile.cc
new file mode 100644
index 0000000000..ad1b0c7ef7
--- /dev/null
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_way_point_change_notification_from_mobile.cc
@@ -0,0 +1,90 @@
+/*
+ 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 "sdl_rpc_plugin/commands/mobile/on_way_point_change_notification_from_mobile.h"
+
+#include "application_manager/app_service_manager.h"
+#include "application_manager/message.h"
+#include "application_manager/message_helper.h"
+
+namespace sdl_rpc_plugin {
+using namespace application_manager;
+namespace commands {
+
+SDL_CREATE_LOG_VARIABLE("Commands")
+
+OnWayPointChangeNotificationFromMobile::OnWayPointChangeNotificationFromMobile(
+ const application_manager::commands::MessageSharedPtr& message,
+ ApplicationManager& application_manager,
+ app_mngr::rpc_service::RPCService& rpc_service,
+ app_mngr::HMICapabilities& hmi_capabilities,
+ policy::PolicyHandlerInterface& policy_handler)
+ : CommandNotificationFromMobileImpl(message,
+ application_manager,
+ rpc_service,
+ hmi_capabilities,
+ policy_handler) {}
+
+OnWayPointChangeNotificationFromMobile::
+ ~OnWayPointChangeNotificationFromMobile() {}
+
+void OnWayPointChangeNotificationFromMobile::Run() {
+ SDL_LOG_AUTO_TRACE();
+
+ (*message_)[strings::params][strings::message_type] =
+ static_cast<int32_t>(application_manager::MessageType::kNotification);
+ ApplicationSharedPtr app = application_manager_.application(connection_key());
+
+ if (app.use_count() == 0) {
+ SDL_LOG_ERROR(
+ "OnWayPointChangeNotificationFromMobile application doesn't exist");
+ return;
+ }
+
+ auto service =
+ application_manager_.GetAppServiceManager().FindWayPointsHandler();
+ if (!service || !service->mobile_service ||
+ service->connection_key != connection_key()) {
+ SDL_LOG_ERROR("Application is not active NAVIGATION ASP");
+ return;
+ }
+
+ application_manager_.SaveWayPointsMessage(message_, connection_key());
+
+ (*message_)[strings::params][strings::message_type] =
+ static_cast<int32_t>(application_manager::MessageType::kNotification);
+ rpc_service_.ManageMobileCommand(message_, SOURCE_SDL);
+}
+
+} // namespace commands
+
+} // namespace sdl_rpc_plugin
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/subscribe_way_points_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/subscribe_way_points_request.cc
index 6e8ad05a74..11cbdac14a 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/subscribe_way_points_request.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/subscribe_way_points_request.cc
@@ -31,6 +31,8 @@
*/
#include "sdl_rpc_plugin/commands/mobile/subscribe_way_points_request.h"
+
+#include "application_manager/app_service_manager.h"
#include "application_manager/application_manager.h"
#include "application_manager/message_helper.h"
@@ -72,8 +74,8 @@ void SubscribeWayPointsRequest::Run() {
return;
}
- if (application_manager_.IsAnyAppSubscribedForWayPoints()) {
- application_manager_.SubscribeAppForWayPoints(app);
+ if (application_manager_.IsSubscribedToHMIWayPoints()) {
+ application_manager_.SubscribeAppForWayPoints(app, false);
SendResponse(true, mobile_apis::Result::SUCCESS);
return;
}
@@ -91,15 +93,20 @@ void SubscribeWayPointsRequest::on_event(const event_engine::Event& event) {
case hmi_apis::FunctionID::Navigation_SubscribeWayPoints: {
SDL_LOG_INFO("Received Navigation_SubscribeWayPoints event");
EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_Navigation);
- const hmi_apis::Common_Result::eType result_code =
+ hmi_apis::Common_Result::eType result_code =
static_cast<hmi_apis::Common_Result::eType>(
message[strings::params][hmi_response::code].asInt());
std::string response_info;
GetInfo(message, response_info);
- const bool result = PrepareResultForMobileResponse(
+ bool result = PrepareResultForMobileResponse(
result_code, HmiInterfaces::HMI_INTERFACE_Navigation);
if (result) {
- application_manager_.SubscribeAppForWayPoints(app);
+ application_manager_.SubscribeAppForWayPoints(app, true);
+ } else if (application_manager_.GetAppServiceManager()
+ .FindWayPointsHandler() != nullptr) {
+ application_manager_.SubscribeAppForWayPoints(app, false);
+ result = true;
+ result_code = hmi_apis::Common_Result::WARNINGS;
}
SendResponse(result,
MessageHelper::HMIToMobileResult(result_code),
@@ -114,6 +121,23 @@ void SubscribeWayPointsRequest::on_event(const event_engine::Event& event) {
}
}
+void SubscribeWayPointsRequest::onTimeOut() {
+ SDL_LOG_AUTO_TRACE();
+ if (application_manager_.GetAppServiceManager().FindWayPointsHandler() !=
+ nullptr) {
+ ApplicationSharedPtr app =
+ application_manager_.application(connection_key());
+ application_manager_.SubscribeAppForWayPoints(app, false);
+ SendResponse(true,
+ mobile_apis::Result::WARNINGS,
+ "HMI request timeout expired, waypoints are available through "
+ "NAVIGATION service");
+ } else {
+ SendResponse(
+ false, mobile_apis::Result::GENERIC_ERROR, "Request timeout expired");
+ }
+}
+
bool SubscribeWayPointsRequest::Init() {
hash_update_mode_ = HashUpdateMode::kDoHashUpdate;
return true;
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/unsubscribe_way_points_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/unsubscribe_way_points_request.cc
index 545a36def8..7aa6e2b40a 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/unsubscribe_way_points_request.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/unsubscribe_way_points_request.cc
@@ -31,6 +31,8 @@
*/
#include "sdl_rpc_plugin/commands/mobile/unsubscribe_way_points_request.h"
+
+#include "application_manager/app_service_manager.h"
#include "application_manager/application_manager.h"
#include "application_manager/message_helper.h"
@@ -75,9 +77,10 @@ void UnsubscribeWayPointsRequest::Run() {
std::set<uint32_t> subscribed_apps =
application_manager_.GetAppsSubscribedForWayPoints();
- if (subscribed_apps.size() > 1) {
+ if (subscribed_apps.size() > 1 ||
+ !application_manager_.IsSubscribedToHMIWayPoints()) {
// More than 1 subscribed app, don't send HMI unsubscribe request
- application_manager_.UnsubscribeAppFromWayPoints(app);
+ application_manager_.UnsubscribeAppFromWayPoints(app, false);
SendResponse(true, mobile_apis::Result::SUCCESS, NULL);
return;
} else {
@@ -96,15 +99,20 @@ void UnsubscribeWayPointsRequest::on_event(const event_engine::Event& event) {
case hmi_apis::FunctionID::Navigation_UnsubscribeWayPoints: {
SDL_LOG_INFO("Received Navigation_UnsubscribeWayPoints event");
EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_Navigation);
- const hmi_apis::Common_Result::eType result_code =
+ hmi_apis::Common_Result::eType result_code =
static_cast<hmi_apis::Common_Result::eType>(
message[strings::params][hmi_response::code].asInt());
std::string response_info;
GetInfo(message, response_info);
- const bool result = PrepareResultForMobileResponse(
+ bool result = PrepareResultForMobileResponse(
result_code, HmiInterfaces::HMI_INTERFACE_Navigation);
if (result) {
- application_manager_.UnsubscribeAppFromWayPoints(app);
+ application_manager_.UnsubscribeAppFromWayPoints(app, true);
+ } else if (application_manager_.GetAppServiceManager()
+ .FindWayPointsHandler() != nullptr) {
+ application_manager_.UnsubscribeAppFromWayPoints(app, false);
+ result = true;
+ result_code = hmi_apis::Common_Result::WARNINGS;
}
SendResponse(result,
MessageHelper::HMIToMobileResult(result_code),
@@ -119,6 +127,23 @@ void UnsubscribeWayPointsRequest::on_event(const event_engine::Event& event) {
}
}
+void UnsubscribeWayPointsRequest::onTimeOut() {
+ SDL_LOG_AUTO_TRACE();
+ if (application_manager_.GetAppServiceManager().FindWayPointsHandler() !=
+ nullptr) {
+ ApplicationSharedPtr app =
+ application_manager_.application(connection_key());
+ application_manager_.UnsubscribeAppFromWayPoints(app, false);
+ SendResponse(true,
+ mobile_apis::Result::WARNINGS,
+ "HMI request timeout expired, waypoints are available through "
+ "NAVIGATION service");
+ } else {
+ SendResponse(
+ false, mobile_apis::Result::GENERIC_ERROR, "Request timeout expired");
+ }
+}
+
bool UnsubscribeWayPointsRequest::Init() {
hash_update_mode_ = HashUpdateMode::kDoHashUpdate;
return true;
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/mobile_command_factory.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/mobile_command_factory.cc
index d2f1325c82..9809a11a81 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/mobile_command_factory.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/mobile_command_factory.cc
@@ -96,6 +96,7 @@
#include "sdl_rpc_plugin/commands/mobile/on_update_file_notification.h"
#include "sdl_rpc_plugin/commands/mobile/on_update_sub_menu_notification.h"
#include "sdl_rpc_plugin/commands/mobile/on_way_point_change_notification.h"
+#include "sdl_rpc_plugin/commands/mobile/on_way_point_change_notification_from_mobile.h"
#include "sdl_rpc_plugin/commands/mobile/perform_audio_pass_thru_request.h"
#include "sdl_rpc_plugin/commands/mobile/perform_audio_pass_thru_response.h"
#include "sdl_rpc_plugin/commands/mobile/perform_interaction_request.h"
@@ -491,6 +492,10 @@ CommandCreator& MobileCommandFactory::get_notification_from_mobile_creator(
case mobile_apis::FunctionID::OnHMIStatusID: {
return factory.GetCreator<commands::OnHMIStatusNotificationFromMobile>();
}
+ case mobile_apis::FunctionID::OnWayPointChangeID: {
+ return factory
+ .GetCreator<commands::OnWayPointChangeNotificationFromMobile>();
+ }
default: {}
}
return factory.GetCreator<InvalidCommand>();
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/waypoints_pending_resumption_handler.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/waypoints_pending_resumption_handler.cc
index 7aa6dd5273..5d44fe474e 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/waypoints_pending_resumption_handler.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/waypoints_pending_resumption_handler.cc
@@ -86,7 +86,7 @@ void WayPointsPendingResumptionHandler::HandleResumptionSubscriptionRequest(
SDL_LOG_DEBUG(
"Subscription to waypoint already exist, no need to send "
"request to HMI");
- application_manager_.SubscribeAppForWayPoints(app.app_id());
+ application_manager_.SubscribeAppForWayPoints(app.app_id(), false);
return;
}
@@ -170,7 +170,7 @@ void WayPointsPendingResumptionHandler::on_event(
if (resumption::IsResponseSuccessful(response)) {
SDL_LOG_DEBUG("Resumption of waypoints is successful");
- application_manager_.SubscribeAppForWayPoints(app);
+ application_manager_.SubscribeAppForWayPoints(app, true);
}
ProcessNextPendingResumption();
}
@@ -195,7 +195,7 @@ void WayPointsPendingResumptionHandler::ProcessNextPendingResumption() {
auto pending_copy = pending;
pending_requests_.pop_front();
auto app = application_manager_.application(pending_copy.app_id_);
- application_manager_.SubscribeAppForWayPoints(app);
+ application_manager_.SubscribeAppForWayPoints(app, false);
RaiseFakeSuccessfulResponse(pending_copy.corr_id_);
ProcessNextPendingResumption();
}