summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShobhit Adlakha <ShobhitAd@users.noreply.github.com>2019-03-06 13:36:58 -0500
committerGitHub <noreply@github.com>2019-03-06 13:36:58 -0500
commit222ec0566594288744d73ef30174e714bd6f29ce (patch)
treed92070464b2cb41f989ddb32595ceedc06674cff
parent2e433d4810c1a9a4a78550b6caa0a27ff03259ef (diff)
downloadsdl_core-222ec0566594288744d73ef30174e714bd6f29ce.tar.gz
GetFile RPC (#2811)
* Implemented GetFile rpc in MOBILE API * Initial implementation of GetFile rpc * Implemented GetFile RPC * Fixed binary data param in GetFile response * Added case for handling SmartType UInteger in SmartObject::duplicate function * Implemented offset and length params * Implemented GetFile for services published by the HMI * Switched to events to handle forwarding GetFile request to HMI * Addressed review comments * Addressed review comments * Addressed review comments * Implemented length parameter * Changed RPC name from GetFileFromHMI to GetFilePath * Fix MOBILE_API formatting * Fix HMI_API formatting * Addressed review comments * Checking success rather than result code for hmi response
-rw-r--r--src/appMain/sdl_preloaded_pt.json6
-rw-r--r--src/components/application_manager/include/application_manager/commands/command_request_impl.h10
-rw-r--r--src/components/application_manager/include/application_manager/smart_object_keys.h2
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/bc_get_file_path_request.h77
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/bc_get_file_path_response.h77
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/get_file_request.h87
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/get_file_response.h77
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/bc_get_file_path_request.cc62
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/bc_get_file_path_response.cc66
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_file_request.cc353
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_file_response.cc63
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/hmi_command_factory.cc7
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/mobile_command_factory.cc7
-rw-r--r--src/components/application_manager/src/commands/command_request_impl.cc7
-rw-r--r--src/components/application_manager/src/hmi_interfaces_impl.cc2
-rw-r--r--src/components/application_manager/src/smart_object_keys.cc2
-rw-r--r--src/components/interfaces/HMI_API.xml23
-rw-r--r--src/components/interfaces/MOBILE_API.xml59
-rw-r--r--src/components/policy/policy_external/include/policy/policy_table/enums.h5
-rw-r--r--src/components/policy/policy_external/src/policy_table/enums.cc5
-rw-r--r--src/components/policy/policy_regular/include/policy/policy_table/enums.h5
-rw-r--r--src/components/policy/policy_regular/src/policy_table/enums.cc9
-rw-r--r--src/components/smart_objects/src/smart_object.cc3
-rw-r--r--src/components/utils/include/utils/file_system.h13
-rw-r--r--src/components/utils/src/file_system.cc20
25 files changed, 1041 insertions, 6 deletions
diff --git a/src/appMain/sdl_preloaded_pt.json b/src/appMain/sdl_preloaded_pt.json
index 8041a0d4e9..fcd92e6df5 100644
--- a/src/appMain/sdl_preloaded_pt.json
+++ b/src/appMain/sdl_preloaded_pt.json
@@ -200,6 +200,12 @@
"LIMITED",
"NONE"]
},
+ "GetFile": {
+ "hmi_levels": ["BACKGROUND",
+ "FULL",
+ "LIMITED",
+ "NONE"]
+ },
"RegisterAppInterface": {
"hmi_levels": ["BACKGROUND",
"FULL",
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 a5ecd7274b..e12c6de3ab 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
@@ -159,10 +159,12 @@ class CommandRequestImpl : public CommandImpl,
* @param info Provides additional human readable info regarding the result
* @param response_params Additional params in response
*/
- void SendResponse(const bool success,
- const mobile_apis::Result::eType& result_code,
- const char* info = NULL,
- const smart_objects::SmartObject* response_params = NULL);
+ void SendResponse(
+ const bool success,
+ const mobile_apis::Result::eType& result_code,
+ const char* info = NULL,
+ const smart_objects::SmartObject* response_params = NULL,
+ const std::vector<uint8_t> binary_data = std::vector<uint8_t>());
/**
* @brief Check syntax of string from mobile
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 5054536883..5d030dace6 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
@@ -200,6 +200,7 @@ extern const char* cloud_connection_status;
// PutFile
extern const char* sync_file_name;
extern const char* file_name;
+extern const char* file_path;
extern const char* file_type;
extern const char* file_size;
extern const char* crc32_check_sum;
@@ -316,6 +317,7 @@ extern const char* service_id;
extern const char* service_manifest;
extern const char* service_published;
extern const char* service_active;
+extern const char* app_service_id;
extern const char* service_data;
extern const char* request_service_active;
extern const char* app_services;
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/bc_get_file_path_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/bc_get_file_path_request.h
new file mode 100644
index 0000000000..fd241da3c4
--- /dev/null
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/bc_get_file_path_request.h
@@ -0,0 +1,77 @@
+/*
+ Copyright (c) 2019, Ford Motor Company, Livio
+ 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 the copyright holders nor the names of their
+ 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_BC_GET_FILE_PATH_REQUEST_H_
+#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_BC_GET_FILE_PATH_REQUEST_H_
+
+#include "application_manager/commands/request_to_hmi.h"
+
+namespace sdl_rpc_plugin {
+namespace app_mngr = application_manager;
+
+namespace commands {
+
+/**
+ * @brief BCGetFilePathRequest command class
+ **/
+class BCGetFilePathRequest : public app_mngr::commands::RequestToHMI {
+ public:
+ /**
+ * @brief BCGetFilePathRequest class constructor
+ *
+ * @param message Incoming SmartObject message
+ **/
+ BCGetFilePathRequest(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_handler);
+
+ /**
+ * @brief BCGetFilePathRequest class destructor
+ **/
+ virtual ~BCGetFilePathRequest();
+
+ /**
+ * @brief Execute command
+ **/
+ virtual void Run();
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(BCGetFilePathRequest);
+};
+
+} // namespace commands
+
+} // namespace sdl_rpc_plugin
+
+#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_sdl_RPC_PLUGIN_INCLUDE_sdl_RPC_PLUGIN_COMMANDS_HMI_BC_GET_FILE_PATH_REQUEST_H_
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/bc_get_file_path_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/bc_get_file_path_response.h
new file mode 100644
index 0000000000..2a6025cbdf
--- /dev/null
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/bc_get_file_path_response.h
@@ -0,0 +1,77 @@
+/*
+ Copyright (c) 2019, Ford Motor Company, Livio
+ 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 the copyright holders nor the names of their
+ 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_BC_GET_FILE_PATH_RESPONSE_H_
+#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_BC_GET_FILE_PATH_RESPONSE_H_
+
+#include "application_manager/commands/response_from_hmi.h"
+
+namespace sdl_rpc_plugin {
+namespace app_mngr = application_manager;
+
+namespace commands {
+
+/**
+ * @brief BCGetFilePathResponse command class
+ **/
+class BCGetFilePathResponse : public app_mngr::commands::ResponseFromHMI {
+ public:
+ /**
+ * @brief BCGetFilePathResponse class constructor
+ *
+ * @param message Incoming SmartObject message
+ **/
+ BCGetFilePathResponse(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_handler);
+
+ /**
+ * @brief BCGetFilePathResponse class destructor
+ **/
+ virtual ~BCGetFilePathResponse();
+
+ /**
+ * @brief Execute command
+ **/
+ virtual void Run();
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(BCGetFilePathResponse);
+};
+
+} // namespace commands
+
+} // namespace sdl_rpc_plugin
+
+#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_BC_GET_FILE_PATH_RESPONSE_H_
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/get_file_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/get_file_request.h
new file mode 100644
index 0000000000..d4182ea004
--- /dev/null
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/get_file_request.h
@@ -0,0 +1,87 @@
+/*
+ Copyright (c) 2019, Ford Motor Company, Livio
+ 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 the copyright holders nor the names of their
+ 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_MOBILE_GET_FILE_REQUEST_H_
+#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_GET_FILE_REQUEST_H_
+
+#include "application_manager/commands/command_request_impl.h"
+#include "application_manager/event_engine/event.h"
+
+namespace sdl_rpc_plugin {
+namespace app_mngr = application_manager;
+
+namespace commands {
+
+/**
+ * @brief GetFileRequest command class
+ **/
+class GetFileRequest : public app_mngr::commands::CommandRequestImpl {
+ public:
+ /**
+ * @brief GetFileRequest class constructor
+ *
+ * @param message Incoming SmartObject message
+ **/
+ GetFileRequest(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 GetFileRequest class destructor
+ **/
+ virtual ~GetFileRequest();
+
+ /**
+ * @brief Execute command
+ **/
+ virtual void Run();
+
+ bool GetFilePath(std::string& file_path, bool& forward_to_hmi);
+
+ void on_event(const app_mngr::event_engine::Event& event) FINAL;
+
+ private:
+ std::string file_name_;
+ mobile_apis::FileType::eType file_type_;
+ uint32_t length_;
+ uint32_t offset_;
+
+ DISALLOW_COPY_AND_ASSIGN(GetFileRequest);
+};
+
+} // namespace commands
+
+} // namespace sdl_rpc_plugin
+
+#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_GET_FILE_REQUEST_H_
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/get_file_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/get_file_response.h
new file mode 100644
index 0000000000..bc191d224c
--- /dev/null
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/get_file_response.h
@@ -0,0 +1,77 @@
+/*
+ Copyright (c) 2019, Ford Motor Company, Livio
+ 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 the copyright holders nor the names of their
+ 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_MOBILE_GET_FILE_RESPONSE_H_
+#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_GET_FILE_RESPONSE_H_
+
+#include "application_manager/commands/command_response_impl.h"
+
+namespace sdl_rpc_plugin {
+namespace app_mngr = application_manager;
+
+namespace commands {
+
+/**
+ * @brief GetFileResponse command class
+ **/
+class GetFileResponse : public app_mngr::commands::CommandResponseImpl {
+ public:
+ /**
+ * @brief GetFileResponse class constructor
+ *
+ * @param message Incoming SmartObject message
+ **/
+ GetFileResponse(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 GetFileResponse class destructor
+ **/
+ virtual ~GetFileResponse();
+
+ /**
+ * @brief Execute command
+ **/
+ virtual void Run();
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(GetFileResponse);
+};
+
+} // namespace commands
+
+} // namespace sdl_rpc_plugin
+
+#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_GET_FILE_RESPONSE_H_
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/bc_get_file_path_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/bc_get_file_path_request.cc
new file mode 100644
index 0000000000..b735cd9bdf
--- /dev/null
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/bc_get_file_path_request.cc
@@ -0,0 +1,62 @@
+/*
+ Copyright (c) 2019, Ford Motor Company, Livio
+ 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 the copyright holders nor the names of their
+ 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/hmi/bc_get_file_path_request.h"
+#include "application_manager/application_impl.h"
+#include "application_manager/rpc_service.h"
+#include "interfaces/MOBILE_API.h"
+
+namespace sdl_rpc_plugin {
+using namespace application_manager;
+namespace commands {
+
+BCGetFilePathRequest::BCGetFilePathRequest(
+ 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)
+ : RequestToHMI(message,
+ application_manager,
+ rpc_service,
+ hmi_capabilities,
+ policy_handler) {}
+
+BCGetFilePathRequest::~BCGetFilePathRequest() {}
+
+void BCGetFilePathRequest::Run() {
+ LOG4CXX_AUTO_TRACE(logger_);
+ SendRequest();
+}
+
+} // namespace commands
+} // namespace sdl_rpc_plugin
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/bc_get_file_path_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/bc_get_file_path_response.cc
new file mode 100644
index 0000000000..b86ab6a2b8
--- /dev/null
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/bc_get_file_path_response.cc
@@ -0,0 +1,66 @@
+/*
+ Copyright (c) 2019, Ford Motor Company, Livio
+ 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 the copyright holders nor the names of their
+ 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/hmi/bc_get_file_path_response.h"
+#include "application_manager/application_impl.h"
+#include "application_manager/rpc_service.h"
+#include "interfaces/MOBILE_API.h"
+#include "application_manager/event_engine/event.h"
+
+namespace sdl_rpc_plugin {
+using namespace application_manager;
+namespace commands {
+
+BCGetFilePathResponse::BCGetFilePathResponse(
+ 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)
+ : ResponseFromHMI(message,
+ application_manager,
+ rpc_service,
+ hmi_capabilities,
+ policy_handler) {}
+
+BCGetFilePathResponse::~BCGetFilePathResponse() {}
+
+void BCGetFilePathResponse::Run() {
+ LOG4CXX_AUTO_TRACE(logger_);
+ application_manager::event_engine::Event event(
+ hmi_apis::FunctionID::BasicCommunication_GetFilePath);
+ event.set_smart_object(*message_);
+ event.raise(application_manager_.event_dispatcher());
+}
+
+} // namespace commands
+} // namespace sdl_rpc_plugin
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_file_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_file_request.cc
new file mode 100644
index 0000000000..c0fbcee146
--- /dev/null
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_file_request.cc
@@ -0,0 +1,353 @@
+/*
+ Copyright (c) 2019, Ford Motor Company, Livio
+ 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 the copyright holders nor the names of their
+ 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/get_file_request.h"
+#include "application_manager/application_impl.h"
+#include "application_manager/rpc_service.h"
+#include "interfaces/MOBILE_API.h"
+#include "application_manager/message_helper.h"
+#include "application_manager/app_service_manager.h"
+#include "utils/file_system.h"
+#include <boost/crc.hpp>
+
+namespace {
+/**
+* Calculates CRC32 checksum
+* @param binary_data - input data for which CRC32 should be calculated
+* @return calculated CRC32 checksum
+*/
+uint32_t GetCrc32CheckSum(const std::vector<uint8_t>& binary_data) {
+ const std::size_t file_size = binary_data.size();
+ boost::crc_32_type result;
+ result.process_bytes(&binary_data[0], file_size);
+ return result.checksum();
+}
+
+} // namespace
+
+namespace sdl_rpc_plugin {
+using namespace application_manager;
+namespace commands {
+
+GetFileRequest::GetFileRequest(
+ 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)
+ : CommandRequestImpl(message,
+ application_manager,
+ rpc_service,
+ hmi_capabilities,
+ policy_handler)
+ , file_name_("")
+ , file_type_(mobile_apis::FileType::INVALID_ENUM)
+ , length_(0)
+ , offset_(0) {}
+
+GetFileRequest::~GetFileRequest() {}
+
+bool GetFileRequest::GetFilePath(std::string& file_path, bool& forward_to_hmi) {
+ std::string path = application_manager_.get_settings().app_storage_folder();
+ auto connect_key = connection_key();
+ forward_to_hmi = false;
+
+ if ((*message_)[strings::msg_params].keyExists(strings::app_service_id)) {
+ std::string service_id =
+ (*message_)[strings::msg_params][strings::app_service_id].asString();
+ LOG4CXX_DEBUG(logger_,
+ "Finding storage directory for service id: " << service_id);
+
+ AppService* app_service_info =
+ application_manager_.GetAppServiceManager().FindServiceByID(service_id);
+ if (app_service_info) {
+ if (app_service_info->mobile_service) {
+ connect_key = app_service_info->connection_key;
+ } else {
+ forward_to_hmi = true;
+ return true;
+ }
+ } else {
+ return false;
+ }
+ } else {
+ LOG4CXX_DEBUG(logger_, "Using current storage directory");
+ }
+
+ ApplicationSharedPtr app = application_manager_.application(connect_key);
+ file_path = path + "/" + app->folder_name();
+ return true;
+}
+
+void GetFileRequest::Run() {
+ LOG4CXX_AUTO_TRACE(logger_);
+ LOG4CXX_INFO(logger_, "Received GetFile request");
+
+ ApplicationSharedPtr app = application_manager_.application(connection_key());
+ smart_objects::SmartObject response_params =
+ smart_objects::SmartObject(smart_objects::SmartType_Map);
+
+ if (!app) {
+ LOG4CXX_ERROR(logger_, "Application is not registered");
+ SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED);
+ return;
+ }
+
+ file_name_ = (*message_)[strings::msg_params][strings::file_name].asString();
+
+ if (!file_system::IsFileNameValid(file_name_)) {
+ LOG4CXX_ERROR(logger_,
+ "File name " << file_name_ << " contains forbidden symbols.");
+ SendResponse(false,
+ mobile_apis::Result::INVALID_DATA,
+ "File name contains forbidden symbols",
+ &response_params);
+ return;
+ }
+
+ // Initialize other params with default values. If exists overwrite the values
+ LOG4CXX_DEBUG(logger_, "Intialize non manadatory params with default values");
+
+ if ((*message_)[strings::msg_params].keyExists(strings::file_type)) {
+ file_type_ = static_cast<mobile_apis::FileType::eType>(
+ (*message_)[strings::msg_params][strings::file_type].asInt());
+ }
+
+ // Check if file exists on system (may have to use app service id to get the
+ // correct app folder)
+ LOG4CXX_DEBUG(logger_, "Check if file exists on system");
+ std::string file_path;
+ bool forward_to_hmi;
+
+ if (GetFilePath(file_path, forward_to_hmi)) {
+ if (forward_to_hmi) {
+ LOG4CXX_DEBUG(logger_, "Forwarding GetFile request to HMI");
+ SendHMIRequest(hmi_apis::FunctionID::BasicCommunication_GetFilePath,
+ &(*message_)[strings::msg_params],
+ true);
+ return;
+ }
+ } else {
+ LOG4CXX_ERROR(logger_, "Could not get file path");
+ SendResponse(false,
+ mobile_apis::Result::INVALID_DATA,
+ "Could not get file path",
+ &response_params);
+ return;
+ }
+
+ const std::string full_path = file_path + "/" + file_name_;
+ if (!file_system::FileExists(full_path)) {
+ LOG4CXX_ERROR(logger_, "File " << full_path << " does not exist");
+ SendResponse(false,
+ mobile_apis::Result::FILE_NOT_FOUND,
+ "File does not exist",
+ &response_params);
+ return;
+ }
+
+ // Handle offset
+ LOG4CXX_DEBUG(logger_, "Handle offset and length parameters");
+ const uint64_t file_size = file_system::FileSize(full_path);
+
+ if ((*message_)[strings::msg_params].keyExists(strings::offset)) {
+ offset_ = (*message_)[strings::msg_params][strings::offset].asUInt();
+ }
+
+ length_ = file_size - offset_;
+ if ((*message_)[strings::msg_params].keyExists(strings::length)) {
+ length_ = std::min(
+ static_cast<uint32_t>(
+ (*message_)[strings::msg_params][strings::length].asUInt()),
+ length_);
+ }
+
+ if (offset_ > file_size) {
+ LOG4CXX_ERROR(logger_,
+ "Offset " << offset_ << " greater than file size "
+ << file_size);
+ SendResponse(false,
+ mobile_apis::Result::INVALID_DATA,
+ "Offset greater than file size",
+ &response_params);
+ return;
+ }
+ if (length_ > file_size - offset_) {
+ LOG4CXX_ERROR(logger_,
+ "Length " << length_ << " greater than file size - offset"
+ << file_size);
+ SendResponse(false,
+ mobile_apis::Result::INVALID_DATA,
+ "Length greater than file size - offset",
+ &response_params);
+ return;
+ }
+
+ // Load data from file as binary data
+ LOG4CXX_DEBUG(logger_, "Load binary data from file");
+ std::vector<uint8_t> bin_data;
+ if (!file_system::ReadBinaryFile(full_path, bin_data, offset_, length_)) {
+ LOG4CXX_ERROR(logger_, "Failed to read from file: " << full_path);
+ SendResponse(false,
+ mobile_apis::Result::GENERIC_ERROR,
+ "Unable to read from file",
+ &response_params);
+ return;
+ }
+
+ // Construct response message
+ if ((*message_)[strings::msg_params].keyExists(strings::offset)) {
+ response_params[strings::offset] = offset_;
+ }
+ if ((*message_)[strings::msg_params].keyExists(strings::length)) {
+ response_params[strings::length] = length_;
+ }
+ if ((*message_)[strings::msg_params].keyExists(strings::file_type)) {
+ response_params[strings::file_type] = file_type_;
+ }
+ const uint32_t crc_calculated = GetCrc32CheckSum(bin_data);
+ response_params[strings::crc32_check_sum] = crc_calculated;
+
+ SendResponse(true,
+ mobile_apis::Result::SUCCESS,
+ "File uploaded",
+ &response_params,
+ bin_data);
+}
+
+void GetFileRequest::on_event(const app_mngr::event_engine::Event& event) {
+ LOG4CXX_AUTO_TRACE(logger_);
+
+ if (hmi_apis::FunctionID::BasicCommunication_GetFilePath != event.id()) {
+ return;
+ }
+ const smart_objects::SmartObject& event_message = event.smart_object();
+
+ hmi_apis::Common_Result::eType hmi_result =
+ static_cast<hmi_apis::Common_Result::eType>(
+ event_message[strings::params][hmi_response::code].asInt());
+
+ mobile_apis::Result::eType result =
+ MessageHelper::HMIToMobileResult(hmi_result);
+ bool success = PrepareResultForMobileResponse(
+ hmi_result, HmiInterfaces::HMI_INTERFACE_AppService);
+
+ if (!success) {
+ auto msg_params = event_message[strings::msg_params];
+ const char* info = msg_params.keyExists(strings::info)
+ ? msg_params[strings::info].asCharArray()
+ : NULL;
+
+ SendResponse(false, result, info, &msg_params);
+ return;
+ }
+ smart_objects::SmartObject response_params =
+ smart_objects::SmartObject(smart_objects::SmartType_Map);
+ std::vector<uint8_t> bin_data;
+
+ if (event_message[strings::msg_params].keyExists(strings::file_type)) {
+ response_params[strings::file_type] =
+ event_message[strings::msg_params][strings::file_type];
+ }
+
+ if (event_message[strings::msg_params].keyExists(strings::file_path)) {
+ std::string full_path =
+ event_message[strings::msg_params][strings::file_path].asString();
+
+ if (!file_system::FileExists(full_path)) {
+ LOG4CXX_ERROR(logger_, "File " << full_path << " does not exist");
+ SendResponse(false,
+ mobile_apis::Result::FILE_NOT_FOUND,
+ "File does not exist",
+ &response_params);
+ return;
+ }
+
+ const uint64_t file_size = file_system::FileSize(full_path);
+ if ((*message_)[strings::msg_params].keyExists(strings::offset)) {
+ offset_ = (*message_)[strings::msg_params][strings::offset].asUInt();
+ }
+
+ length_ = file_size - offset_;
+ if ((*message_)[strings::msg_params].keyExists(strings::length)) {
+ length_ = std::min(
+ static_cast<uint32_t>(
+ (*message_)[strings::msg_params][strings::length].asUInt()),
+ length_);
+ }
+
+ if (offset_ > file_size) {
+ LOG4CXX_ERROR(logger_,
+ "Offset " << offset_ << " greater than file size "
+ << file_size);
+ SendResponse(false,
+ mobile_apis::Result::INVALID_DATA,
+ "Offset greater than file size",
+ &response_params);
+ return;
+ }
+ if (length_ > file_size - offset_) {
+ LOG4CXX_ERROR(logger_,
+ "Length " << length_ << " greater than file size - offset"
+ << file_size);
+ SendResponse(false,
+ mobile_apis::Result::INVALID_DATA,
+ "Length greater than file size - offset",
+ &response_params);
+ return;
+ }
+ if (!file_system::ReadBinaryFile(full_path, bin_data, offset_, length_)) {
+ LOG4CXX_ERROR(logger_, "Failed to read from file: " << full_path);
+ SendResponse(false,
+ mobile_apis::Result::GENERIC_ERROR,
+ "Failed to read from file",
+ &response_params);
+ return;
+ }
+
+ const uint32_t crc_calculated = GetCrc32CheckSum(bin_data);
+ response_params[strings::crc32_check_sum] = crc_calculated;
+
+ } else {
+ LOG4CXX_ERROR(logger_, "HMI did not return a file path: ");
+ SendResponse(false,
+ mobile_apis::Result::INVALID_DATA,
+ "HMI did not return a file path",
+ &response_params);
+ return;
+ }
+
+ SendResponse(true, result, "File uploaded", &response_params, bin_data);
+}
+
+} // namespace commands
+} // namespace sdl_rpc_plugin
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_file_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_file_response.cc
new file mode 100644
index 0000000000..2ea8dde02a
--- /dev/null
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_file_response.cc
@@ -0,0 +1,63 @@
+/*
+ Copyright (c) 2019, Ford Motor Company, Livio
+ 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 the copyright holders nor the names of their
+ 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/get_file_response.h"
+#include "application_manager/application_impl.h"
+#include "application_manager/rpc_service.h"
+#include "interfaces/MOBILE_API.h"
+
+namespace sdl_rpc_plugin {
+using namespace application_manager;
+namespace commands {
+
+GetFileResponse::GetFileResponse(
+ 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)
+ : CommandResponseImpl(message,
+ application_manager,
+ rpc_service,
+ hmi_capabilities,
+ policy_handler) {}
+
+GetFileResponse::~GetFileResponse() {}
+
+void GetFileResponse::Run() {
+ LOG4CXX_AUTO_TRACE(logger_);
+ LOG4CXX_INFO(logger_, "Sending GetFile response");
+ rpc_service_.SendMessageToMobile(message_);
+}
+
+} // namespace commands
+} // namespace sdl_rpc_plugin
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 dc94474b9d..3cfe4d7118 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
@@ -240,6 +240,8 @@
#include "sdl_rpc_plugin/commands/hmi/rc_is_ready_response.h"
#include "sdl_rpc_plugin/commands/hmi/rc_get_capabilities_request.h"
#include "sdl_rpc_plugin/commands/hmi/rc_get_capabilities_response.h"
+#include "sdl_rpc_plugin/commands/hmi/bc_get_file_path_request.h"
+#include "sdl_rpc_plugin/commands/hmi/bc_get_file_path_response.h"
#include "sdl_rpc_plugin/commands/hmi/on_bc_system_capability_updated_notification.h"
@@ -842,6 +844,11 @@ CommandCreator& HMICommandFactory::get_creator_factory(
? factory.GetCreator<commands::UISendHapticDataRequest>()
: factory.GetCreator<commands::UISendHapticDataResponse>();
}
+ case hmi_apis::FunctionID::BasicCommunication_GetFilePath: {
+ return hmi_apis::messageType::request == message_type
+ ? factory.GetCreator<commands::BCGetFilePathRequest>()
+ : factory.GetCreator<commands::BCGetFilePathResponse>();
+ }
case hmi_apis::FunctionID::BasicCommunication_OnSystemCapabilityUpdated: {
return factory
.GetCreator<commands::OnBCSystemCapabilityUpdatedNotification>();
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 77be545e0b..f12dcbb485 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
@@ -127,6 +127,8 @@
#include "sdl_rpc_plugin/commands/mobile/send_haptic_data_response.h"
#include "sdl_rpc_plugin/commands/mobile/set_cloud_app_properties_request.h"
#include "sdl_rpc_plugin/commands/mobile/set_cloud_app_properties_response.h"
+#include "sdl_rpc_plugin/commands/mobile/get_file_request.h"
+#include "sdl_rpc_plugin/commands/mobile/get_file_response.h"
#include "interfaces/MOBILE_API.h"
CREATE_LOGGERPTR_GLOBAL(logger_, "ApplicationManager")
@@ -234,6 +236,11 @@ CommandCreator& MobileCommandFactory::get_creator_factory(
? factory.GetCreator<commands::PutFileRequest>()
: factory.GetCreator<commands::PutFileResponse>();
}
+ case mobile_apis::FunctionID::GetFileID: {
+ return mobile_api::messageType::request == message_type
+ ? factory.GetCreator<commands::GetFileRequest>()
+ : factory.GetCreator<commands::GetFileResponse>();
+ }
case mobile_apis::FunctionID::DeleteFileID: {
return mobile_api::messageType::request == message_type
? factory.GetCreator<commands::DeleteFileRequest>()
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 8d339d4d14..970f8802c0 100644
--- a/src/components/application_manager/src/commands/command_request_impl.cc
+++ b/src/components/application_manager/src/commands/command_request_impl.cc
@@ -266,7 +266,8 @@ void CommandRequestImpl::SendResponse(
const bool success,
const mobile_apis::Result::eType& result_code,
const char* info,
- const smart_objects::SmartObject* response_params) {
+ const smart_objects::SmartObject* response_params,
+ const std::vector<uint8_t> binary_data) {
LOG4CXX_AUTO_TRACE(logger_);
{
sync_primitives::AutoLock auto_lock(state_lock_);
@@ -291,7 +292,9 @@ void CommandRequestImpl::SendResponse(
CommandImpl::protocol_version_;
response[strings::params][strings::connection_key] = connection_key();
response[strings::params][strings::function_id] = function_id();
-
+ if (!binary_data.empty()) {
+ response[strings::params][strings::binary_data] = binary_data;
+ }
if (response_params) {
response[strings::msg_params] = *response_params;
}
diff --git a/src/components/application_manager/src/hmi_interfaces_impl.cc b/src/components/application_manager/src/hmi_interfaces_impl.cc
index 1d1dbe6996..9aff403e09 100644
--- a/src/components/application_manager/src/hmi_interfaces_impl.cc
+++ b/src/components/application_manager/src/hmi_interfaces_impl.cc
@@ -103,6 +103,8 @@ generate_function_to_interface_convert_map() {
HmiInterfaces::HMI_INTERFACE_BasicCommunication;
convert_map[BasicCommunication_OnEventChanged] =
HmiInterfaces::HMI_INTERFACE_BasicCommunication;
+ convert_map[BasicCommunication_GetFilePath] =
+ HmiInterfaces::HMI_INTERFACE_BasicCommunication;
convert_map[VR_IsReady] = HmiInterfaces::HMI_INTERFACE_VR;
convert_map[VR_Started] = HmiInterfaces::HMI_INTERFACE_VR;
convert_map[VR_Stopped] = HmiInterfaces::HMI_INTERFACE_VR;
diff --git a/src/components/application_manager/src/smart_object_keys.cc b/src/components/application_manager/src/smart_object_keys.cc
index 09e0ccf38b..402a15ae60 100644
--- a/src/components/application_manager/src/smart_object_keys.cc
+++ b/src/components/application_manager/src/smart_object_keys.cc
@@ -167,6 +167,7 @@ const char* cloud_connection_status = "cloudConnectionStatus";
// PutFile
const char* sync_file_name = "syncFileName";
const char* file_name = "fileName";
+const char* file_path = "filePath";
const char* file_type = "fileType";
const char* file_size = "fileSize";
const char* crc32_check_sum = "crc";
@@ -283,6 +284,7 @@ const char* service_id = "serviceID";
const char* service_manifest = "serviceManifest";
const char* service_published = "servicePublished";
const char* service_active = "serviceActive";
+const char* app_service_id = "appServiceId";
const char* service_data = "serviceData";
const char* request_service_active = "requestServiceActive";
const char* app_services = "appServices";
diff --git a/src/components/interfaces/HMI_API.xml b/src/components/interfaces/HMI_API.xml
index 3968ef20fb..e927280718 100644
--- a/src/components/interfaces/HMI_API.xml
+++ b/src/components/interfaces/HMI_API.xml
@@ -4179,6 +4179,29 @@
</param>
</function>
+ <function name="GetFilePath" messagetype="request">
+ <description>This request is sent to retrieve a file path from the HMI.</description>
+ <param name="fileName" type="String" maxlength="255" mandatory="true">
+ <description>File name that should be retrieved.</description>
+ </param>
+ <param name="fileType" type="Common.FileType" mandatory="false">
+ <description>Selected file type.</description>
+ </param>
+ <param name="appServiceId" type="String" mandatory="false">
+ <description> ID of the service that should have uploaded the requested file.</description>
+ </param>
+ </function>
+
+ <function name="GetFilePath" messagetype="response">
+ <description> HMI handles the request internally and returns the file path with the response.</description>
+ <param name="filePath" type="String" mandatory="false">
+ <description>Path to file in hmi</description>
+ </param>
+ <param name="fileType" type="Common.FileType" mandatory="false">
+ <description>Selected file type.</description>
+ </param>
+ </function>
+
<!-- Policies -->
<function name="GetSystemInfo" messagetype="request">
<description>Request from SDL to HMI to obtain information about head unit system.</description>
diff --git a/src/components/interfaces/MOBILE_API.xml b/src/components/interfaces/MOBILE_API.xml
index 5a4b8c5482..f1ec069882 100644
--- a/src/components/interfaces/MOBILE_API.xml
+++ b/src/components/interfaces/MOBILE_API.xml
@@ -2620,6 +2620,7 @@
<element name="PublishAppServiceID" value="52" hexvalue="34" since="5.1" />
<element name="GetAppServiceDataID" value="53" hexvalue="35" since="5.1" />
<element name="PerformAppServiceInteractionID" value="55" hexvalue="37" since="5.1" />
+ <element name="GetFileID" value="54" hexvalue="36" since="5.1" />
<!--
Base Notifications
@@ -6448,6 +6449,64 @@
</param>
</function>
+ <function name ="GetFile" functionID="GetFileID" messagetype="request">
+ <description>This request is sent to the module to retrieve a file</description>
+ <param name="fileName" type="String" maxlength="255" mandatory="true">
+ <description>File name that should be retrieved</description>
+ </param>
+ <param name="appServiceId" type="String" mandatory="false">
+ <description>ID of the service that should have uploaded the requested file.</description>
+ </param>
+ <param name="fileType" type="FileType" mandatory="false">
+ <description>Selected file type.</description>
+ </param>
+ <param name="offset" type="Integer" minvalue="0" maxvalue="2000000000" mandatory="false">
+ <description>Optional offset in bytes for resuming partial data chunks</description>
+ </param>
+ <param name="length" type="Integer" minvalue="0" maxvalue="2000000000" mandatory="false">
+ <description>Optional length in bytes for resuming partial data chunks if offset is set to 0, then length is the total length of the file to be downloaded</description>
+ </param>
+ </function>
+
+ <function name="GetFile" functionID="GetFileID" messagetype="response">
+ <description>This response includes the data that is requested from the specific service</description>
+ <param name="success" type="Boolean" platform="documentation" mandatory="true">
+ <description> true, if successful; false, if failed </description>
+ </param>
+ <param name="resultCode" type="Result" platform="documentation" mandatory="true">
+ <description>See Result</description>
+ <element name="SUCCESS"/>
+ <element name="REJECTED"/>
+ <element name="DISALLOWED"/>
+ <element name="INVALID_DATA"/>
+ <element name="OUT_OF_MEMORY"/>
+ <element name="TOO_MANY_PENDING_REQUESTS"/>
+ <element name="APPLICATION_NOT_REGISTERED"/>
+ <element name="GENERIC_ERROR"/>
+ <element name="FILE_NOT_FOUND"/>
+ </param>
+ <param name="info" type="String" maxlength="1000" mandatory="false" platform="documentation">
+ <description>Provides additional human readable info regarding the result.</description>
+ </param>
+
+ <!-- Specific response data -->
+ <param name="offset" type="Integer" minvalue="0" maxvalue="2000000000" mandatory="false">
+ <description>Optional offset in bytes for resuming partial data chunks</description>
+ </param>
+
+ <param name="length" type="Integer" minvalue="0" maxvalue="2000000000" mandatory="false">
+ <description>Optional length in bytes for resuming partial data chunks if offset is set to 0, then length is the total length of the file to be downloaded</description>
+ </param>
+
+ <param name="fileType" type="FileType" mandatory="false">
+ <description>File type that is being sent in response.</description>
+ </param>
+
+ <param name="crc" type="Integer" minvalue="0" maxvalue="4294967295" mandatory="false">
+ <description>Additional CRC32 checksum to protect data integrity up to 512 Mbits</description>
+ </param>
+ </function>
+
<function name="DeleteFile" functionID="DeleteFileID" messagetype="request" since="3.0">
<description>
Used to delete a file resident on the module in the app's local cache.
diff --git a/src/components/policy/policy_external/include/policy/policy_table/enums.h b/src/components/policy/policy_external/include/policy/policy_table/enums.h
index d795721863..d2cf995e95 100644
--- a/src/components/policy/policy_external/include/policy/policy_table/enums.h
+++ b/src/components/policy/policy_external/include/policy/policy_table/enums.h
@@ -456,6 +456,11 @@ enum FunctionID {
GetAppServiceDataID = 53,
/**
+ * @brief GetFileID
+ */
+ GetFileID = 54,
+
+ /**
* @brief PerformAppServiceInteractionID.
*/
PerformAppServiceInteractionID = 55,
diff --git a/src/components/policy/policy_external/src/policy_table/enums.cc b/src/components/policy/policy_external/src/policy_table/enums.cc
index 718bafa905..2a3d944f33 100644
--- a/src/components/policy/policy_external/src/policy_table/enums.cc
+++ b/src/components/policy/policy_external/src/policy_table/enums.cc
@@ -1131,6 +1131,11 @@ bool EnumFromJsonString(const std::string& literal, FunctionID* result) {
return true;
}
+ if ("GetFile" == literal) {
+ *result = GetFileID;
+ return true;
+ }
+
if ("GetAppServiceData" == literal) {
*result = GetAppServiceDataID;
return true;
diff --git a/src/components/policy/policy_regular/include/policy/policy_table/enums.h b/src/components/policy/policy_regular/include/policy/policy_table/enums.h
index 16f0ef3d67..5b496a4fbd 100644
--- a/src/components/policy/policy_regular/include/policy/policy_table/enums.h
+++ b/src/components/policy/policy_regular/include/policy/policy_table/enums.h
@@ -442,6 +442,11 @@ enum FunctionID {
GetAppServiceDataID = 53,
/**
+ * @brief GetFileID
+ */
+ GetFileID = 54,
+
+ /**
* @brief PerformAppServiceInteractionID.
*/
PerformAppServiceInteractionID = 55,
diff --git a/src/components/policy/policy_regular/src/policy_table/enums.cc b/src/components/policy/policy_regular/src/policy_table/enums.cc
index 25f6d778fc..113ba8c527 100644
--- a/src/components/policy/policy_regular/src/policy_table/enums.cc
+++ b/src/components/policy/policy_regular/src/policy_table/enums.cc
@@ -851,6 +851,8 @@ bool IsValidEnum(FunctionID val) {
return true;
case PublishAppServiceID:
return true;
+ case GetFileID:
+ return true;
case GetAppServiceDataID:
return true;
case PerformAppServiceInteractionID:
@@ -1010,6 +1012,8 @@ const char* EnumToJsonString(FunctionID val) {
return "SetCloudAppProperties";
case PublishAppServiceID:
return "PublishAppService";
+ case GetFileID:
+ return "GetFile";
case GetAppServiceDataID:
return "GetAppServiceData";
case PerformAppServiceInteractionID:
@@ -1318,6 +1322,11 @@ bool EnumFromJsonString(const std::string& literal, FunctionID* result) {
return true;
}
+ if ("GetFile" == literal) {
+ *result = GetFileID;
+ return true;
+ }
+
if ("GetAppServiceData" == literal) {
*result = GetAppServiceDataID;
return true;
diff --git a/src/components/smart_objects/src/smart_object.cc b/src/components/smart_objects/src/smart_object.cc
index 1322757ab1..3235dd619e 100644
--- a/src/components/smart_objects/src/smart_object.cc
+++ b/src/components/smart_objects/src/smart_object.cc
@@ -701,6 +701,9 @@ void SmartObject::duplicate(const SmartObject& OtherObject) {
case SmartType_Integer:
newData.int_value = OtherObject.m_data.int_value;
break;
+ case SmartType_UInteger:
+ newData.int_value = OtherObject.m_data.int_value;
+ break;
case SmartType_Double:
newData.double_value = OtherObject.m_data.double_value;
break;
diff --git a/src/components/utils/include/utils/file_system.h b/src/components/utils/include/utils/file_system.h
index e26fef34bb..e6e5fdc0d4 100644
--- a/src/components/utils/include/utils/file_system.h
+++ b/src/components/utils/include/utils/file_system.h
@@ -241,6 +241,19 @@ bool WriteBinaryFile(const std::string& name,
*/
bool ReadBinaryFile(const std::string& name, std::vector<uint8_t>& result);
+/**
+ * @brief Reads from file
+ *
+ * @param name path to file
+ * @param result read data
+ * @param offset number of bytes to be ignored from begining of file
+ * @return returns true if the operation is successfully.
+ */
+bool ReadBinaryFile(const std::string& name,
+ std::vector<uint8_t>& result,
+ uint32_t offset,
+ uint32_t length);
+
bool ReadFile(const std::string& name, std::string& result);
/**
diff --git a/src/components/utils/src/file_system.cc b/src/components/utils/src/file_system.cc
index f98aeda056..430cf40da0 100644
--- a/src/components/utils/src/file_system.cc
+++ b/src/components/utils/src/file_system.cc
@@ -316,6 +316,26 @@ bool file_system::ReadBinaryFile(const std::string& name,
return true;
}
+bool file_system::ReadBinaryFile(const std::string& name,
+ std::vector<uint8_t>& result,
+ uint32_t offset,
+ uint32_t length) {
+ if (!FileExists(name) || !IsAccessible(name, R_OK)) {
+ return false;
+ }
+
+ std::ifstream file(name.c_str(), std::ios_base::binary);
+ file.ignore(offset);
+ std::ostringstream ss;
+ std::string s;
+ s.resize(length);
+ file.read(&s[0], length);
+
+ result.resize(s.length());
+ std::copy(s.begin(), s.end(), result.begin());
+ return true;
+}
+
bool file_system::ReadFile(const std::string& name, std::string& result) {
if (!FileExists(name) || !IsAccessible(name, R_OK)) {
return false;