summaryrefslogtreecommitdiff
path: root/src/components/application_manager/src
diff options
context:
space:
mode:
authorMasato Ogawa <mogawa@xevo.com>2017-08-04 17:22:13 +0900
committerMasato Ogawa <mogawa@xevo.com>2017-08-22 13:05:15 +0900
commit9b2f37ad1cc2bd7f6e2ed73e9baa5bd9569a2864 (patch)
treec06505cfbe7bfe315c523a96f349c725a1e1daac /src/components/application_manager/src
parent5fcb0ef3bf43370b0d579bf23ef6764af75a97de (diff)
downloadsdl_core-9b2f37ad1cc2bd7f6e2ed73e9baa5bd9569a2864.tar.gz
Implement SendHapticData RPC
HMI does not know the position of widget in Navigation template. In cases HMI manages the Haptic feedback of each widget, the Navi app should notify the HMI which elements can be focused using SendHapticData RPC. This is for discussion on proposal SDL-0075.
Diffstat (limited to 'src/components/application_manager/src')
-rw-r--r--src/components/application_manager/src/commands/hmi/ui_send_haptic_data_request.cc52
-rw-r--r--src/components/application_manager/src/commands/hmi/ui_send_haptic_data_response.cc57
-rw-r--r--src/components/application_manager/src/commands/mobile/send_haptic_data_request.cc116
-rw-r--r--src/components/application_manager/src/commands/mobile/send_haptic_data_response.cc53
-rw-r--r--src/components/application_manager/src/hmi_command_factory.cc12
-rw-r--r--src/components/application_manager/src/hmi_interfaces_impl.cc1
-rw-r--r--src/components/application_manager/src/mobile_command_factory.cc13
-rw-r--r--src/components/application_manager/src/smart_object_keys.cc1
8 files changed, 305 insertions, 0 deletions
diff --git a/src/components/application_manager/src/commands/hmi/ui_send_haptic_data_request.cc b/src/components/application_manager/src/commands/hmi/ui_send_haptic_data_request.cc
new file mode 100644
index 0000000000..9484906a17
--- /dev/null
+++ b/src/components/application_manager/src/commands/hmi/ui_send_haptic_data_request.cc
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2017 Xevo Inc.
+ * 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 Xevo Inc. nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "application_manager/commands/hmi/ui_send_haptic_data_request.h"
+
+namespace application_manager {
+
+namespace commands {
+
+UISendHapticDataRequest::UISendHapticDataRequest(
+ const MessageSharedPtr& message, ApplicationManager& application_manager)
+ : RequestToHMI(message, application_manager) {}
+
+UISendHapticDataRequest::~UISendHapticDataRequest() {}
+
+void UISendHapticDataRequest::Run() {
+ LOG4CXX_AUTO_TRACE(logger_);
+ SendRequest();
+}
+
+} // namespace commands
+
+} // namespace application_manager
diff --git a/src/components/application_manager/src/commands/hmi/ui_send_haptic_data_response.cc b/src/components/application_manager/src/commands/hmi/ui_send_haptic_data_response.cc
new file mode 100644
index 0000000000..03a2ce69e2
--- /dev/null
+++ b/src/components/application_manager/src/commands/hmi/ui_send_haptic_data_response.cc
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2017 Xevo Inc.
+ * 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 Xevo Inc. nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "application_manager/commands/hmi/ui_send_haptic_data_response.h"
+#include "application_manager/event_engine/event.h"
+
+#include "interfaces/HMI_API.h"
+
+namespace application_manager {
+
+namespace commands {
+
+UISendHapticDataResponse::UISendHapticDataResponse(
+ const MessageSharedPtr& message, ApplicationManager& application_manager)
+ : ResponseFromHMI(message, application_manager) {}
+
+UISendHapticDataResponse::~UISendHapticDataResponse() {}
+
+void UISendHapticDataResponse::Run() {
+ LOG4CXX_AUTO_TRACE(logger_);
+ event_engine::Event event(
+ hmi_apis::FunctionID::UI_SendHapticData);
+ event.set_smart_object(*message_);
+ event.raise(application_manager_.event_dispatcher());
+}
+
+} // namespace commands
+
+} // namespace application_manager
diff --git a/src/components/application_manager/src/commands/mobile/send_haptic_data_request.cc b/src/components/application_manager/src/commands/mobile/send_haptic_data_request.cc
new file mode 100644
index 0000000000..891f103315
--- /dev/null
+++ b/src/components/application_manager/src/commands/mobile/send_haptic_data_request.cc
@@ -0,0 +1,116 @@
+/*
+ * Copyright (c) 2017 Xevo Inc.
+ * 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 Xevo Inc. nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "application_manager/commands/mobile/send_haptic_data_request.h"
+
+#include <vector>
+#include <string>
+#include <stdio.h>
+#include <algorithm>
+#include <sstream>
+#include "application_manager/policies/policy_handler_interface.h"
+#include "interfaces/MOBILE_API.h"
+#include "utils/file_system.h"
+#include "formatters/CFormatterJsonBase.h"
+#include "json/json.h"
+#include "utils/helpers.h"
+#include "utils/custom_string.h"
+
+namespace application_manager {
+
+namespace commands {
+
+namespace custom_str = utils::custom_string;
+
+SendHapticDataRequest::SendHapticDataRequest(const MessageSharedPtr& message,
+ ApplicationManager& application_manager)
+ : CommandRequestImpl(message, application_manager) {}
+
+SendHapticDataRequest::~SendHapticDataRequest() {}
+
+void SendHapticDataRequest::Run() {
+ LOG4CXX_AUTO_TRACE(logger_);
+
+ ApplicationSharedPtr application =
+ application_manager_.application(connection_key());
+
+ if (!(application.valid())) {
+ LOG4CXX_ERROR(logger_, "NULL pointer");
+ SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED);
+ return;
+ }
+
+ smart_objects::SmartObject& msg_params = (*message_)[strings::msg_params];
+ msg_params[strings::app_id] = application->hmi_app_id();
+ SendHMIRequest(hmi_apis::FunctionID::UI_SendHapticData,
+ &msg_params,
+ true);
+}
+
+void SendHapticDataRequest::on_event(const event_engine::Event& event) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ using namespace helpers;
+
+ const smart_objects::SmartObject& message = event.smart_object();
+
+ switch (event.id()) {
+ case hmi_apis::FunctionID::UI_SendHapticData: {
+ mobile_apis::Result::eType result_code =
+ GetMobileResultCode(static_cast<hmi_apis::Common_Result::eType>(
+ message[strings::params][hmi_response::code].asUInt()));
+
+ const bool result = Compare<mobile_api::Result::eType, EQ, ONE>(
+ result_code,
+ mobile_api::Result::SUCCESS,
+ mobile_api::Result::WARNINGS);
+
+ ApplicationSharedPtr application =
+ application_manager_.application(connection_key());
+
+ if (!(application.valid())) {
+ LOG4CXX_ERROR(logger_, "NULL pointer");
+ return;
+ }
+
+ SendResponse(result, result_code, NULL, &(message[strings::msg_params]));
+ break;
+ }
+ default: {
+ LOG4CXX_ERROR(logger_, "Received unknown event" << event.id());
+ return;
+ }
+ }
+}
+
+} // namespace commands
+
+} // namespace application_manager
diff --git a/src/components/application_manager/src/commands/mobile/send_haptic_data_response.cc b/src/components/application_manager/src/commands/mobile/send_haptic_data_response.cc
new file mode 100644
index 0000000000..cb7cd9f3ec
--- /dev/null
+++ b/src/components/application_manager/src/commands/mobile/send_haptic_data_response.cc
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2017 Xevo Inc.
+ * 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 Xevo Inc. nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "application_manager/commands/mobile/send_haptic_data_response.h"
+
+namespace application_manager {
+
+namespace commands {
+
+SendHapticDataResponse::SendHapticDataResponse(const MessageSharedPtr& message,
+ ApplicationManager& application_manager)
+ : CommandResponseImpl(message, application_manager) {}
+
+SendHapticDataResponse::~SendHapticDataResponse() {}
+
+void SendHapticDataResponse::Run() {
+ LOG4CXX_AUTO_TRACE(logger_);
+
+ application_manager_.SendMessageToMobile(message_);
+}
+
+} // namespace commands
+
+} // namespace application_manager
diff --git a/src/components/application_manager/src/hmi_command_factory.cc b/src/components/application_manager/src/hmi_command_factory.cc
index d02d9060eb..46dd8dcea1 100644
--- a/src/components/application_manager/src/hmi_command_factory.cc
+++ b/src/components/application_manager/src/hmi_command_factory.cc
@@ -278,6 +278,8 @@
#include "application_manager/commands/hmi/on_tts_reset_timeout_notification.h"
#include "application_manager/commands/hmi/dial_number_request.h"
#include "application_manager/commands/hmi/dial_number_response.h"
+#include "application_manager/commands/hmi/ui_send_haptic_data_request.h"
+#include "application_manager/commands/hmi/ui_send_haptic_data_response.h"
CREATE_LOGGERPTR_GLOBAL(logger_, "ApplicationManager")
namespace application_manager {
@@ -2264,6 +2266,16 @@ CommandSharedPtr HMICommandFactory::CreateCommand(
message, application_manager));
break;
}
+ case hmi_apis::FunctionID::UI_SendHapticData: {
+ if (is_response) {
+ command.reset(new commands::UISendHapticDataResponse(
+ message, application_manager));
+ } else {
+ command.reset(new commands::UISendHapticDataRequest(
+ message, application_manager));
+ }
+ break;
+ }
}
return command;
}
diff --git a/src/components/application_manager/src/hmi_interfaces_impl.cc b/src/components/application_manager/src/hmi_interfaces_impl.cc
index 3f05252b02..d9410e9bd5 100644
--- a/src/components/application_manager/src/hmi_interfaces_impl.cc
+++ b/src/components/application_manager/src/hmi_interfaces_impl.cc
@@ -155,6 +155,7 @@ generate_function_to_interface_convert_map() {
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] =
HmiInterfaces::HMI_INTERFACE_Navigation;
diff --git a/src/components/application_manager/src/mobile_command_factory.cc b/src/components/application_manager/src/mobile_command_factory.cc
index d5db849d96..f925a18217 100644
--- a/src/components/application_manager/src/mobile_command_factory.cc
+++ b/src/components/application_manager/src/mobile_command_factory.cc
@@ -135,6 +135,8 @@
#include "application_manager/commands/mobile/send_location_response.h"
#include "application_manager/commands/mobile/dial_number_request.h"
#include "application_manager/commands/mobile/dial_number_response.h"
+#include "application_manager/commands/mobile/send_haptic_data_request.h"
+#include "application_manager/commands/mobile/send_haptic_data_response.h"
#include "interfaces/MOBILE_API.h"
#include "utils/make_shared.h"
@@ -702,6 +704,17 @@ CommandSharedPtr MobileCommandFactory::CreateCommand(
message, application_manager);
break;
}
+ case mobile_apis::FunctionID::SendHapticDataID: {
+ if ((*message)[strings::params][strings::message_type] ==
+ static_cast<int>(application_manager::MessageType::kResponse)) {
+ command.reset(
+ new commands::SendHapticDataResponse(message, application_manager));
+ } else {
+ command.reset(
+ new commands::SendHapticDataRequest(message, application_manager));
+ }
+ break;
+ }
default: {
(*message)[strings::params][strings::function_id] =
static_cast<int32_t>(mobile_apis::FunctionID::GenericResponseID);
diff --git a/src/components/application_manager/src/smart_object_keys.cc b/src/components/application_manager/src/smart_object_keys.cc
index 75d324699c..355314086f 100644
--- a/src/components/application_manager/src/smart_object_keys.cc
+++ b/src/components/application_manager/src/smart_object_keys.cc
@@ -140,6 +140,7 @@ const char* system_capabilities = "systemCapabilities";
const char* navigation_capability = "navigationCapability";
const char* phone_capability = "phoneCapability";
const char* video_streaming_capability = "videoStreamingCapability";
+const char* haptic_spatial_data = "HapticSpatialData";
// PutFile
const char* sync_file_name = "syncFileName";